types allowed for intrinsics?

I was looking at the LLVM IR documentation and was wondering if it is possible to define LLVM intrinsics which might be a pointer to some pre-defined struct or opaque types?
If that is possible how would one go about doing that ?

Thanks
Vinod

You mean something like FILE*? It's not possible to do that, but you can just define it as i8* and use a bitcast at the call site.

-Chris

Unfortunately that does not work, since the bitcast will generate a convert and the argument of the intrinsic will be a value type i8* and the intrinsics is intended to map to an instruction that accepts only a symbolic. The convert gets hoisted, possibly to a different block, and we would like the symbolic variable to stay as an operand of the intrinsic making it possible to write the correct instruction selection rule, or so I think.

An alternative might be to not use intrinsic for this purpose and use the proper signature for this function whose definition (to the right instruction) is supplied by custom lowering of a predefined external function. Can this work?

Thanks
Vinod

A value in LLVM normally doesn't have that sort of identity... what
exactly are you doing?

For a normal intrinsic, if you're using LLVM CodeGen, it shouldn't be
possible to distinguish normally, and otherwise, you should be able to
look through the bitcast.

-Eli

If the bitcast is connected to the intrinsic in the SelectionDAG then yes we can see through it and get to the symbolic variable; but if it is hoisted to another basic block then we have to somehow “chase it up”

Vinod