[LLVMdev] [llvm-c]

Tom Stellard tom at stellard.net
Mon May 13 07:16:29 PDT 2013


On Sat, May 11, 2013 at 01:48:44PM +0200, Christian Budde wrote:
> Hello,
> 
> a few days ago, I was trying to access the LLVM target registry via the
> LLVM-C interface. Unfortunately I can't seem to get some useful
> information out of it.
> 
> Despite the fact that the following code is written in Pascal, can you
> please tell me if I have done something wrong here?
> 
> // initialize all targets / target information
> LLVMInitializeAllTargets;
> LLVMInitializeAllTargetInfos;
> 
> // initialize native target in particular
> LLVMInitializeNativeTarget;
> 
> // get first target
> Target := LLVMGetFirstTarget;
> 
> // loop until the target is NULL
> while (Target <> nil) do
> begin
>   // get target name & description
>   TargetName := LLVMGetTargetName(Target);
>   TargetDescription := LLVMGetTargetDescription(Target);
> 
>   // do something with these information
> 
>   Target := LLVMGetNextTarget(Target);
> end;
> 

I don't see any obvious problems here, though someone else might.
What exactly is the problem you are seeing?  Is LLVMGetFirstTarget
returning NULL?

You may want to take a look at this code:
http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/drivers/radeon/radeon_llvm_emit.c
It is a pretty good example of using the C API for accessing the target
registry.  However, if you want to test this code directly, I would
recommend replacing the r600 target triple with your native
architecture, because the R600 backend is not built by default.

-Tom


> By debugging the LLVM library (a custom DLL, which works fine
> otherwise), I can see that there is no information, but I'm not that
> deep into C and the LLVM structure to identify what went wrong. Also I
> did a lot of tests the other day, trying several things without luck.
> 
> However, since I do not need this code at the moment, it's not urgent,
> just felt to let you know about my problems.
> 
> Kind regards,
> 
>     Christian
> 
> -- 
> Christian-W. Budde
> Eleonorenstr. 17
> 30449 Hannover
> Tel.: +49 511 31048857
> E-Mail: Christian at savioursofsoul.de
> WWW: http://www.savioursofsoul.de/Christian
> 
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev



More information about the llvm-dev mailing list