[LLVMdev] Using LLVM for a dynamically typed language
sabre at nondot.org
Thu Apr 21 09:10:42 PDT 2005
On Thu, 21 Apr 2005, Evan Jones wrote:
> On Thu, 2005-21-04 at 11:34 -0400, Vyacheslav Akhmechet wrote:
>> I disagree. If I could push a bunch of arguments on a stack (or
>> specify a list of arguments, etc.) and just use a "call" instruction
>> with a pointer to a memory address I wouldn't run into this problem.
>> This is a specific challenge with LLVM because it is strictly typed.
> Ah! Right. You can't manually construct a function call on the stack
> with LLVM. However, an alternative worth considering would be to use
> varargs functions. This would basically compile to native code that just
> stuffs a bunch of things on the stack.
I strongly recommend avoiding varargs functions if possible. It would be
better to pass an explicit list/array of parameters instead. The
optimizer is severely hobbled for varargs functions, but it does a good
job of ripping appart simple arrays and structures.
> As in your example, the function itself knows the number and type of
> parameters that are expected. Before executing the "body" of the
> function, it can verify that things are being passed as expected and
> raise an exception if the are not.
I agree. The structure/array passed in should indicate how many params
there are and the callee should verify things are happy before continuing.
Alternatively, instead of putting the # args in the array, you could pass
it in as an explicit extra argument, which would help out the optimizer
More information about the llvm-dev