summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm2cpp/CppWriter.cpp
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
commit595cef1650441de5ff28469f504fc28dcf281d5d (patch)
tree9a6f7a35c1cf6748c4eca52912d69201eba72084 /llvm/tools/llvm2cpp/CppWriter.cpp
parent3c49edcaa11f056c58f70e7374932625a4019f3a (diff)
downloadbcm5719-llvm-595cef1650441de5ff28469f504fc28dcf281d5d.tar.gz
bcm5719-llvm-595cef1650441de5ff28469f504fc28dcf281d5d.zip
Generate the correct cast opcode for constant expressions.
llvm-svn: 32461
Diffstat (limited to 'llvm/tools/llvm2cpp/CppWriter.cpp')
-rw-r--r--llvm/tools/llvm2cpp/CppWriter.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/llvm/tools/llvm2cpp/CppWriter.cpp b/llvm/tools/llvm2cpp/CppWriter.cpp
index ef07d46137c..2d0a3be0df2 100644
--- a/llvm/tools/llvm2cpp/CppWriter.cpp
+++ b/llvm/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 ) {
OpenPOWER on IntegriCloud