[LLVMdev] Tool for run-time code generation?

David Piepgrass dpiepgrass at mentoreng.com
Fri Jul 16 12:48:44 PDT 2010

> Have you ever tried running a dynamically allocated code that cannot 
> execute
> malloc() or any runtime libraries or library-based functions because 
> they haven't been ported to your architecture?  That's what it would 
> be like trying to run ARM Linux code on your WinCE target.  Windows CE 
> requires an LLVM port before it will be useful to you.  Put simply, 
> the core architecture of the LLVM ARM backend requires porting to 
> work.
WinCE offers most of the standard C APIs (such as malloc), as well as most standard C++ libraries including, I think, the same STL that is available under Win32. There could be some gaps, but I hope, given that I only need part of LLVM, that any "porting" I have to do will involve only small tweaks.

If you mean that dynamically generated code cannot call malloc (why not? Couldn't I provide a table that tells LLVM the address of malloc and any other methods I want to call?), even then it is not a problem, since the code I want to generate will simply access records and do some arithmetic. For example, I might generate a function that does this:

int ReadArrayElement(byte* record, int index, int defValue) {
    unsigned arraySize = (*(unsigned*)(record + 4) & 0x7F);
    if (index > arraySize)
        return defValue;
    return *(int*)(record + 8 + index * 4); }

No method calls there. 

More information about the llvm-dev mailing list