aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm2cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-12 01:31:37 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-12 01:31:37 +0000
commitb0e9f722daf3a896aa1f7bbf1d1ab4cabf2c2d5b (patch)
treeca8d62dbdde2e2fe2010deefda07c0488181981e /tools/llvm2cpp
parent15f46d6c280cc91be70c60ed181931fbe0088652 (diff)
downloadexternal_llvm-b0e9f722daf3a896aa1f7bbf1d1ab4cabf2c2d5b.zip
external_llvm-b0e9f722daf3a896aa1f7bbf1d1ab4cabf2c2d5b.tar.gz
external_llvm-b0e9f722daf3a896aa1f7bbf1d1ab4cabf2c2d5b.tar.bz2
Generate the correct cast opcode for constant expressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32461 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm2cpp')
-rw-r--r--tools/llvm2cpp/CppWriter.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/tools/llvm2cpp/CppWriter.cpp b/tools/llvm2cpp/CppWriter.cpp
index ef07d46..2d0a3be 100644
--- a/tools/llvm2cpp/CppWriter.cpp
+++ b/tools/llvm2cpp/CppWriter.cpp
@@ -761,8 +761,23 @@ void CppWriter::printConstant(const Constant *CV) {
} else if (CE->isCast()) {
printConstant(CE->getOperand(0));
Out << "Constant* " << constName << " = ConstantExpr::getCast(";
- Out << getCppName(CE->getOperand(0)) << ", " << getCppName(CE->getType())
- << ");";
+ switch (CE->getOpcode()) {
+ default: assert(0 && "Invalid cast opcode");
+ case Instruction::Trunc: Out << "Instruction::Trunc"; break;
+ case Instruction::ZExt: Out << "Instruction::ZExt"; break;
+ case Instruction::SExt: Out << "Instruction::SExt"; break;
+ case Instruction::FPTrunc: Out << "Instruction::FPTrunc"; break;
+ case Instruction::FPExt: Out << "Instruction::FPExt"; break;
+ case Instruction::FPToUI: Out << "Instruction::FPToUI"; break;
+ case Instruction::FPToSI: Out << "Instruction::FPToSI"; break;
+ case Instruction::UIToFP: Out << "Instruction::UIToFP"; break;
+ case Instruction::SIToFP: Out << "Instruction::SIToFP"; break;
+ case Instruction::PtrToInt: Out << "Instruction::PtrToInt"; break;
+ case Instruction::IntToPtr: Out << "Instruction::IntToPtr"; break;
+ case Instruction::BitCast: Out << "Instruction::BitCast"; break;
+ }
+ Out << ", " << getCppName(CE->getOperand(0)) << ", "
+ << getCppName(CE->getType()) << ");";
} else {
unsigned N = CE->getNumOperands();
for (unsigned i = 0; i < N; ++i ) {