[pypy-dev] RE: LLVM backend
Carl Friedrich Bolz
cfbolz at gmx.de
Sun Feb 20 23:01:22 CET 2005
On Thu, 17 Feb 2005 10:50:12 -0600 (CST), Chris Lattner wrote:
> So let me see if I understand correctly: you're writing the code you want
> in C, compiling it with the LLVM C compiler, and using void*'s. This
> means you get things like "[100 x sbyte*]" instead of "[100 x
> dictionary*]" as you would like. To get back the correct type, you're
> having the compiler "copy and paste" this code, inserting the correct
> types as appropriate.
> To me, I don't think it's worth doing this. Instead, why not just
> compile these function to LLVM bytecode and link them into the program as
> you need them, inserting cases to/from sbyte* as appropriate? Sure, some
> amount of type-safety will be "lost" at the LLVM level, but I don't think
> that will significantly impeed the optimizers. The other nice thing
> about this approach is that you can modify the runtime library more
> easily, and performance won't be bad from the result: the LLVM inliner
> can inline these methods where it makes sense. Am I missing something?
Well, it was extremely easy to implement which justifies the approach a bit
;-). Since it works quite well I think I'll stick with it a bit and change
it if problems come up (for example if there are lists of so many different
types that the code bloat gets unbearable).
>> I will probably run into limitations whith this later. For example if I
>> implement exceptions (which should not be too complicated using invoke
>> and unwind) I can't raise them from within the C code that produces the
>> list implementation.
> Yeah, that is annoying. One trick that works well for doing the 'unwind'
> is to just write a simple llvm function that unwinds, and call it from C.
> Invoke is a bit more tricky unfortunately.
Ok, maybe it is enough to unwind from within those functions. I can't think
of any string, list, dict... method that actually catches an exception. So
it seems best to set some global variables that indicate the error and then
call a function written in llvm that unwinds. Does this sound ok?
Thanks for your help!
More information about the Pypy-dev