diff options
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) { |