[LLVMdev] Tool for run-time code generation?

Samuel Crow samuraileumas at yahoo.com
Fri Jul 16 12:57:50 PDT 2010

----- Original Message ----
> From: David Piepgrass <dpiepgrass at mentoreng.com>
> To: Samuel Crow <samuraileumas at yahoo.com>
> Sent: Fri, July 16, 2010 2:48:10 PM
> Subject: RE: [LLVMdev] Tool for run-time code generation?
> 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.

There's one very big one named ReadArrayElement() right in the middle of what 
you just typed.  You'd have to assume the calling conventions of the ARM code 
are the same as the x86 code (which is impossible because of the different 
architectures), or that the calling convention is the same as ARM Linux.  You'd 
need to implement the Windows CE ABIs into the backend to be able to define the 
C calling convention to call that code.  I think you're trivializing something 
that is more complicated than you are giving it credit for.


More information about the llvm-dev mailing list