[llvm-dev] How to use single interface for multiple types
sangeeta chowdhary via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 16 21:08:19 PDT 2018
Hi,
I have to pass different values to my instrumented function based on types. Right now this is what I am doing -
if (fpConstant_op0->getTypeID() == Type::FloatTyID && fpConstant_op1->getTypeID() == Type::DoubleTyID)
HandleOp = M->getOrInsertFunction("handleOp_fd", void_ptr_ty, int_ty, float_ty, double_ty);
else if (fpConstant_op0->getTypeID() == Type::DoubleTyID && fpConstant_op1->getTypeID() == Type::FloatTyID)
HandleOp = M->getOrInsertFunction("handleOp_df", void_ptr_ty, int_ty, double_ty, float_ty);
else if (fpConstant_op0->getTypeID() == Type::DoubleTyID && fpConstant_op1->getTypeID() == Type::DoubleTyID)
HandleOp = M->getOrInsertFunction("handleOp_dd", void_ptr_ty, int_ty, double_ty, double_ty);
I am having different functions based on types. My handles look like this
extern "C" void* handleOp_fd(size_t opCode, float op1, double op2)
extern "C" void* handleOp_df(size_t opCode, double op1, float op2)
extern "C" void* handleOp_dd(size_t opCode, double op1, double op2)
How can I unify this?. Instead of having many functions based on types, I want to have only one function and pass different values with their types.
Any help would be much appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180716/7ae2ce63/attachment.html>
More information about the llvm-dev
mailing list