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; 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
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
Am 13.05.2013 16:16, schrieb Tom Stellard:> 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?LLVMGetFirstTarget returns a pointer at a quite high address. Subsequent calls to LLVMGetNextTarget all return the very same pointer (much lower). If I query LLVMGetTargetName and LLVMGetTargetDescription I got an empty string and a null pointer.> 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.I've done it exactly like in this example (except the fact that I'm using pascal as language and x86 as main target). So if the sequence of calls seems to be right, I'll be investigating whether I've done something wrong compiling the DLL. Thanks for the information, Christian -- Christian-W. Budde Eleonorenstr. 17 30449 Hannover Tel.: +49 511 31048857 E-Mail: Christian at savioursofsoul.de WWW: http://www.savioursofsoul.de/Christian
Possibly Parallel Threads
- [LLVMdev] [llvm-c]
- [LLVMdev] [llvm-c]
- [LLVMdev] Shared library support of llvm
- [LLVMdev] RFC: llvm-shlib-test (Was: [llvm] r191029 - llvm-c: Make LLVMGetFirstTarget a proper prototype)
- [LLVMdev] RFC: llvm-shlib-test (Was: [llvm] r191029 - llvm-c: Make LLVMGetFirstTarget a proper prototype)