aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-12-03 20:48:27 -0500
committerAlon Zakai <alonzakai@gmail.com>2013-12-03 20:48:27 -0500
commit30ffd65550ba806a6ac1e66767e58bc565004c67 (patch)
treeeaee3523b3d0a258cdf9fda0ab2ab5d413f5419c
parent2f30cc800b06f8ef17b3e7cfec7b53bb56b4710d (diff)
emit function table calls including masks
-rw-r--r--lib/Target/CppBackend/CallHandlers.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Target/CppBackend/CallHandlers.h b/lib/Target/CppBackend/CallHandlers.h
index 0b16f5b653..927d60a01f 100644
--- a/lib/Target/CppBackend/CallHandlers.h
+++ b/lib/Target/CppBackend/CallHandlers.h
@@ -12,6 +12,13 @@ CallHandlerMap *CallHandlers;
std::string CH_##Ident(const CallInst *CI, std::string Name, int NumArgs=-1) { Code }
DEF_CALL_HANDLER(__default__, {
+ const Value *CV = CI->getCalledValue();
+ if (!isa<Function>(CV)) {
+ // function pointer call
+ FunctionType *FT = dyn_cast<FunctionType>(dyn_cast<PointerType>(CV->getType())->getElementType());
+ std::string Sig = getFunctionSignature(FT);
+ Name = std::string("FUNCTION_TABLE_") + Sig + "[" + Name + " & #FM_" + Sig + "#]";
+ }
Type *RT = CI->getType();
std::string text = Name + "(";
if (NumArgs == -1) NumArgs = CI->getNumOperands()-1; // last operand is the function itself