On Saturday, 23 March 2013 at 09:30:07 UTC, Jens Mueller wrote:
Moritz Maxeiner wrote:
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.

Do you happen to know why these functions are not declared in the header files. I mean when using the C interface in C I wouldn't even know that
these functions exist.

I suspect it is because of LLVM's internal structure. Each supported target is presented by its own directory and they are afaict mutually independent from one another, "so their initialiation routines should be part of them themselves" I would guess, but I don't know, sorry. Also, when using the C interface in C there is little need to know them because they get encapsulated in LLVMInitializeAllTargets and LLVMInitializeNativeTarget.


I think I leave this up to a higher layer API.
Deimos should provide an API that resembles the C api whenever possible.

Okay, I'll put one into llvm-d one then.

-- Moritz

Reply via email to