summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CWriter/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-14 19:19:53 +0000
committerChris Lattner <sabre@nondot.org>2003-08-14 19:19:53 +0000
commit47be951787629113b21aae2d3265caf754d92893 (patch)
treee7868b2f784a9c5caf4a6c2e03d7574f0e5b4f8a /llvm/lib/CWriter/Writer.cpp
parent00645506365a7efd829bee4c9197a6e1846c7e77 (diff)
downloadbcm5719-llvm-47be951787629113b21aae2d3265caf754d92893.tar.gz
bcm5719-llvm-47be951787629113b21aae2d3265caf754d92893.zip
Stop annoying warnings about mismatched types with the argument of a free
implement more constant expressions so that 176.gcc compiles with the CBE llvm-svn: 7847
Diffstat (limited to 'llvm/lib/CWriter/Writer.cpp')
-rw-r--r--llvm/lib/CWriter/Writer.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/llvm/lib/CWriter/Writer.cpp b/llvm/lib/CWriter/Writer.cpp
index 5cccc37a3c2..6a800190913 100644
--- a/llvm/lib/CWriter/Writer.cpp
+++ b/llvm/lib/CWriter/Writer.cpp
@@ -369,16 +369,32 @@ void CWriter::printConstant(Constant *CPV) {
Out << "))";
return;
case Instruction::Add:
- Out << "(";
- printConstant(CE->getOperand(0));
- Out << " + ";
- printConstant(CE->getOperand(1));
- Out << ")";
- return;
case Instruction::Sub:
+ case Instruction::Mul:
+ case Instruction::Div:
+ case Instruction::Rem:
+ case Instruction::SetEQ:
+ case Instruction::SetNE:
+ case Instruction::SetLT:
+ case Instruction::SetLE:
+ case Instruction::SetGT:
+ case Instruction::SetGE:
Out << "(";
printConstant(CE->getOperand(0));
- Out << " - ";
+ switch (CE->getOpcode()) {
+ case Instruction::Add: Out << " + "; break;
+ case Instruction::Sub: Out << " - "; break;
+ case Instruction::Mul: Out << " * "; break;
+ case Instruction::Div: Out << " / "; break;
+ case Instruction::Rem: Out << " % "; break;
+ case Instruction::SetEQ: Out << " == "; break;
+ case Instruction::SetNE: Out << " != "; break;
+ case Instruction::SetLT: Out << " < "; break;
+ case Instruction::SetLE: Out << " <= "; break;
+ case Instruction::SetGT: Out << " > "; break;
+ case Instruction::SetGE: Out << " >= "; break;
+ default: assert(0 && "Illegal opcode here!");
+ }
printConstant(CE->getOperand(1));
Out << ")";
return;
@@ -1186,7 +1202,7 @@ void CWriter::visitAllocaInst(AllocaInst &I) {
}
void CWriter::visitFreeInst(FreeInst &I) {
- Out << "free(";
+ Out << "free((char*)";
writeOperand(I.getOperand(0));
Out << ")";
}
OpenPOWER on IntegriCloud