[LLVMdev] ConstantPointerRef and void*'s to functions

Joel Stanley jstanley at cs.uiuc.edu
Fri May 9 21:24:01 PDT 2003


I have a Function* to a function that has a signature like:

void foo(double*, double*);

I need to write the address of this function into a global variable initializer (really, into the initializer of a particular structure field).  The structure field type is void*, and must be.

Because of type constraints, doing something like:

Function* foo = ...;
std::vector<const Type*> fields;
...
fields.push_back(ConstantPointerRef::get(foo));

will yield a type error because the type of the function foo ("void (*) (double*, double*)") does not match the structure field type.

How might I go about making the necessary cast-like step at the GlobalValue/Function level? I want to do something like:

Function* quasiCastThinger = foo->getAsType(myDesiredFunctionType);

TIA.

-j
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20030509/c00d4acb/attachment.html>


More information about the llvm-dev mailing list