[LLVMdev] how to get TargetData?

John Criswell criswell at illinois.edu
Fri May 28 09:35:56 PDT 2010


Victor Zverovich wrote:
> Dear all
>
> I am trying to get the size of an LLVM pointer type.
> getPrimitiveSizeInBits() returns 0 for it and the documentation for 
> isSized() suggest to use TargetData.
> I figured out from Kaleidoscope example that one can get a pointer to 
> TagetData object through the execution engine but it seems to be an 
> overkill.
> What is the right way to do it?
TargetData is an LLVM pass.  If you're writing an LLVM pass, just make 
TargetData one of its prerequisite analysis passes in the 
getAnalysisUsage() method and use the getAnalysis<TargetData>() function 
to get a reference to the TargetData pass within your pass.

-- John T.

>
> Best regards,
> Victor
>




More information about the llvm-dev mailing list