diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 15:48:27 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-22 15:48:27 -0800 |
commit | 52d85bf3381566f834cd0c81b003c5743f1bb652 (patch) | |
tree | 3cbee79ac8f931d1e4bf981fe474831f43754a00 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 84f3860a63f5460a43f853c5cd68b5cdbbc8d16c (diff) |
native phi pushing
Diffstat (limited to 'lib/Target/CppBackend/CPPBackend.cpp')
-rw-r--r-- | lib/Target/CppBackend/CPPBackend.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 77e4ad214f..06ab671cee 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -470,7 +470,20 @@ void CppWriter::printCppName(Type* Ty) { } std::string CppWriter::getPhiCode(const BasicBlock *From, const BasicBlock *To) { - return std::string("//phi yo"); + // XXX ignore dependencies and cycles for now + // FIXME this is all quite inefficient, and also done once per incoming to each phi + std::string ret = ""; + for (BasicBlock::const_iterator I = To->begin(), E = To->end(); + I != E; ++I) { + const PHINode* P = dyn_cast<PHINode>(I); + if (!P) break; + int index = P->getBasicBlockIndex(From); + if (index < 0) continue; + // we found it + Value *V = P->getIncomingValue(index); + ret += getAssign(getCppName(P), P->getType()) + getValueAsStr(V) + ";"; + } + return ret; } std::string CppWriter::getCppName(const Value* val) { |