1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Fix 2003-06-23-PromotedExprs.llx -- if we are adding two bytes we better

explicitly cast the result to be a byte, or C will gleefully promote it
to int.

llvm-svn: 6869
This commit is contained in:
Brian Gaeke 2003-06-23 20:00:51 +00:00
parent 03d0b3ab98
commit 62947dbf9e

View File

@ -1029,6 +1029,16 @@ void CWriter::visitPHINode(PHINode &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));
@ -1053,6 +1063,10 @@ void CWriter::visitBinaryOperator(Instruction &I) {
}
writeOperand(I.getOperand(1));
if (needsCast) {
Out << "))";
}
}
void CWriter::visitCastInst(CastInst &I) {