llvm-d

Moritz Maxeiner moritz at ucworks.org
Fri Mar 22 12:16:30 PDT 2013


A couple of more things I forgot to mention:

- You will need to additionally add bindings for all the 
LLVMInitialize"TARGET_NAME"{TargetInfo,Target,TargetMC,AsmParser,AsmPrinter,Disassembler} 
functions. They reside inside the target libraries and not inside 
llvm-c, which is why only translating the C API won't get you 
them. The LLVMInitializeNativeTarget function , which is 
necessary to use LLVM for jitting - otherwise you'll only have 
access to interpreting, which is horribly slow - uses them, but 
it is a static inline function and as such does not get exposed 
because LLVM builds with the option to hide all inline functions. 
That is not a problem for C, as this function gets defined in the 
header, but for D it is a big problem, because you cannot access 
LLVMInitializeNativeTarget. You need to recreate it in D by using 
all the functions it references. Of course, you'll also have to 
accomodate the fact that these referenced functions may or may 
not be compiled in depending on which target where selected when 
compiling LLVM.
I have done so in llvm.c.functions of llvm-d so if you want you 
could use that as a reference.
- When supporting multiple LLVM versions, we need to use the same 
method. I currently use a version flag, specifically 
"-version=LLVM_X_Y" for LLVM X.Y release (including the trunk) 
and set two variables, a string "LLVM_VersionString" (for some C 
bindings internal stuff) and a float "LLVM_Version" (for static 
ifs). The relevant module is llvm.c.versions.
- It would be nice if deimos-llvm had a module that publically 
imports all other modules, e.g. "all" or "llvm".


More information about the Digitalmars-d-announce mailing list