diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 15:16:18 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 15:16:18 -0800 |
commit | 84f3860a63f5460a43f853c5cd68b5cdbbc8d16c (patch) | |
tree | 9fc689d815285552a154d94f8c826c04e71dfcd1 /lib/Target/CppBackend | |
parent | 4da54cecab3a48a463c4a7ad47522d02b542e4ca (diff) |
preparation for phi pushing
Diffstat (limited to 'lib/Target/CppBackend')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 0267a88171..77e4ad214f 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -38,6 +38,8 @@ #include <set> using namespace llvm; +#include <Relooper.h> + #if 0 #define dump(x) fprintf(stderr, x "\n") #define dumpv(x, ...) fprintf(stderr, x "\n", __VA_ARGS__) @@ -49,8 +51,6 @@ using namespace llvm; #define dumpfail(x) { fprintf(stderr, x "\n"); report_fatal_error("fail"); } #define dumpfailv(x, ...) { fprintf(stderr, x "\n", __VA_ARGS__); report_fatal_error("fail"); } -#include <Relooper.h> - static cl::opt<std::string> FuncName("cppfname", cl::desc("Specify the name of the generated function"), cl::value_desc("function name")); @@ -184,6 +184,8 @@ namespace { std::string getCppName(const Value* val); inline void printCppName(const Value* val); + std::string getPhiCode(const BasicBlock *From, const BasicBlock *To); + void printAttributes(const AttributeSet &PAL, const std::string &name); void printType(Type* Ty); void printTypes(const Module* M); @@ -208,7 +210,7 @@ namespace { void printModuleBody(); - unsigned stackAlign(unsigned x) { + unsigned stackAlign(unsigned x) { // XXX need 8-byte, for doubles return x + (x%4 != 0 ? 4 - x%4 : 0); } }; @@ -467,6 +469,10 @@ void CppWriter::printCppName(Type* Ty) { printEscapedString(getCppName(Ty)); } +std::string CppWriter::getPhiCode(const BasicBlock *From, const BasicBlock *To) { + return std::string("//phi yo"); +} + std::string CppWriter::getCppName(const Value* val) { std::string name; ValueMap::iterator I = ValueNames.find(val); @@ -1156,7 +1162,7 @@ std::string CppWriter::getValueAsParenStr(const Value* V) { // generateInstruction - This member is called for each Instruction in a function. std::string CppWriter::generateInstruction(const Instruction *I) { - std::string text = "NYI: " + std::string(I->getOpcodeName()); + std::string text = ""; std::string bbname = "NO_BBNAME"; std::string iName(getCppName(I)); @@ -1769,12 +1775,14 @@ void CppWriter::printFunctionBody(const Function *F) { if (br->getNumOperands() == 3) { BasicBlock *S0 = br->getSuccessor(0); BasicBlock *S1 = br->getSuccessor(1); - LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S0], NULL); - LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S1], - getOpName(TI->getOperand(0)).c_str()); + std::string P0 = getPhiCode(&*BI, S0); + std::string P1 = getPhiCode(&*BI, S1); + LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S0], NULL, P0.size() > 0 ? P0.c_str() : NULL); + LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S1], getOpName(TI->getOperand(0)).c_str(), P1.size() > 0 ? P1.c_str() : NULL); } else if (br->getNumOperands() == 1) { BasicBlock *S = br->getSuccessor(0); - LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S], NULL); + std::string P = getPhiCode(&*BI, S); + LLVMToRelooper[&*BI]->AddBranchTo(LLVMToRelooper[&*S], NULL, P.size() > 0 ? P.c_str() : NULL); } else { error("Branch with 2 operands?"); } |