[llvm-dev] C++ CreateConstGEP questions
Larry Gritz via llvm-dev
llvm-dev at lists.llvm.org
Mon May 9 13:11:33 PDT 2016
There are two C++ signatures for CreateConstGEP1_32:
Value * CreateConstGEP1_32 (Value *Ptr, unsigned Idx0, const Twine &Name="")
Value * CreateConstGEP1_32 (Type *Ty, Value *Ptr, unsigned Idx0, const Twine &Name="")
I'm assuming that this means that the caller can supply the expected type, and get error checking or casting? Or choose to not supply the type and get whatever they get?
But for CreateConstGEP2_32, there is only the variety with the type supplied:
Value * CreateConstGEP2_32 (Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1, const Twine &Name="")
For CreateConstGEP2_64, there is only the version with no Type supplied:
Value * CreateConstGEP2_64 (Value *Ptr, uint64_t Idx0, uint64_t Idx1, const Twine &Name="")
Same for CreateConstGEP1_64 -- no Type* parameter.
Can anybody offer insight into the strange lack of symmetry here? Why does GEP2_32 require the type, but GEP1_64 and GEP2_64 doesn't allow it all, but GEP1_32 has both varieties?
Is it always safe to pass nullptr as the type?
Also, if you know your constant indices fit into 32 bits, is there any advantage to calling the _32 versions over the _64?
--
Larry Gritz
lg at larrygritz.com
More information about the llvm-dev
mailing list