diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-27 16:58:39 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-27 16:58:39 -0800 |
commit | eae4e43241c5b7f1e99fef89227c3f18400bfcfe (patch) | |
tree | 315d5ec885ac1946d9e6fe869dd491416d97ab21 /lib/Target/CppBackend/CPPBackend.cpp | |
parent | 8b932cee863cd1af0bac22dd4feb7e722333d5b9 (diff) |
index functions from getPtr as well
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 ef1cd5c0ad..1c896bd7f0 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -203,10 +203,13 @@ namespace { Address a = GlobalAddresses[s]; return a.first; } + unsigned getFunctionIndex(const Function *F) { + dump("TODO: function indexing"); + return 0; + } unsigned getConstAsOffset(const Value *V) { - if (isa<Function>(V)) { - dump("TODO: function indexing"); - return 0; + if (const Function *F = dyn_cast<const Function>(V)) { + return getFunctionIndex(F); } else { return getGlobalAddress(V->getName().str()); } @@ -1217,7 +1220,9 @@ std::string CppWriter::getPtrUse(const Value* Ptr) { } std::string CppWriter::getPtr(const Value* Ptr) { - if (const Constant *CV = dyn_cast<Constant>(Ptr)) { + if (const Function *F = dyn_cast<Function>(Ptr)) { + return utostr(getFunctionIndex(F)); + } else if (const Constant *CV = dyn_cast<Constant>(Ptr)) { if (const GlobalValue *GV = dyn_cast<GlobalValue>(Ptr)) { if (GV->hasExternalLinkage()) { std::string Name = getOpName(Ptr); |