diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 17:36:39 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 17:36:39 -0800 |
commit | d9c6a850f0c8566221a5e4e3c1cfa6fdfd4baab4 (patch) | |
tree | 5a4c7159a3f5c8e46fcdb79e0bb8563f3cd80da7 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 63ff173e336810695416993cf6c2ee331026f068 (diff) |
trunc
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 05609f3f1b..202158fa23 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -40,7 +40,7 @@ using namespace llvm; #include <Relooper.h> -#if 0 +#if 1 #define dump(x) fprintf(stderr, x "\n") #define dumpv(x, ...) fprintf(stderr, x "\n", __VA_ARGS__) #else @@ -54,8 +54,8 @@ using namespace llvm; #define dumpIR(value) { \ std::string temp; \ raw_string_ostream stream(temp); \ - stream << *value; \ - std::cout << temp << "\n"; \ + stream << *(value); \ + fprintf(stderr, "%s\n", temp.c_str()); \ } #undef assert @@ -1447,7 +1447,12 @@ std::string CppWriter::generateInstruction(const Instruction *I) { case Instruction::SIToFP: case Instruction::BitCast: { switch (I->getOpcode()) { - case Instruction::Trunc: Out << "TruncInst"; break; + case Instruction::Trunc: { + Value *V = I->getOperand(0); + //unsigned inBits = V->getType()->getIntegerBitWidth(); + unsigned outBits = I->getType()->getIntegerBitWidth(); + text = getAssign(iName, I->getType()) + getCppName(I->getOperand(0)) + "&" + utostr(pow(2, outBits)-1) + ";"; break; + } case Instruction::ZExt: Out << "ZExtInst"; break; case Instruction::SExt: Out << "SExtInst"; break; case Instruction::FPTrunc: Out << "FPTruncInst"; break; |