void CWriter::visitBinaryOperator(Instruction &I) {
// binary instructions, shift instructions, setCond instructions.
assert(!isa<PointerType>(I.getType()));
+
+ // We must cast the results of binary operations which might be promoted.
+ bool needsCast = false;
+ if ((I.getType() == Type::UByteTy) || (I.getType() == Type::SByteTy)
+ || (I.getType() == Type::UShortTy) || (I.getType() == Type::ShortTy)) {
+ needsCast = true;
+ Out << "((";
+ printType(Out, I.getType(), "", false, false);
+ Out << ")(";
+ }
writeOperand(I.getOperand(0));
}
writeOperand(I.getOperand(1));
+
+ if (needsCast) {
+ Out << "))";
+ }
}
void CWriter::visitCastInst(CastInst &I) {
void CWriter::visitBinaryOperator(Instruction &I) {
// binary instructions, shift instructions, setCond instructions.
assert(!isa<PointerType>(I.getType()));
+
+ // We must cast the results of binary operations which might be promoted.
+ bool needsCast = false;
+ if ((I.getType() == Type::UByteTy) || (I.getType() == Type::SByteTy)
+ || (I.getType() == Type::UShortTy) || (I.getType() == Type::ShortTy)) {
+ needsCast = true;
+ Out << "((";
+ printType(Out, I.getType(), "", false, false);
+ Out << ")(";
+ }
writeOperand(I.getOperand(0));
}
writeOperand(I.getOperand(1));
+
+ if (needsCast) {
+ Out << "))";
+ }
}
void CWriter::visitCastInst(CastInst &I) {