diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-14 19:19:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-14 19:19:53 +0000 |
commit | 29255922300049cb8fd448ccae4edd0ec45eeacf (patch) | |
tree | d50c35beb2bde9ae4b1c28b0c81de9e82ca85a96 /lib/Target | |
parent | 1b9ddd545cd0a10355aedd46ae557fe6aa42918c (diff) | |
download | external_llvm-29255922300049cb8fd448ccae4edd0ec45eeacf.zip external_llvm-29255922300049cb8fd448ccae4edd0ec45eeacf.tar.gz external_llvm-29255922300049cb8fd448ccae4edd0ec45eeacf.tar.bz2 |
Stop annoying warnings about mismatched types with the argument of a free
implement more constant expressions so that 176.gcc compiles with the CBE
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7847 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 32 | ||||
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 32 |
2 files changed, 48 insertions, 16 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 5cccc37..6a80019 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.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 << ")"; } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 5cccc37..6a80019 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/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 << ")"; } |