[LLVMdev] code generation order revisited.

Hendrik Boom hendrik at topoi.pooq.com
Thu Jun 12 08:38:56 PDT 2008

On Tue, 06 May 2008 16:06:35 -0400, Gordon Henriksen wrote:

> On 2008-05-06, at 13:42, Hendrik Boom wrote:
>> One more question. I hope you're not getting tired of me already. Does
>> generating LLVM code have to proceed in any particular order?
>> Of course, if I am writing LLVM assembler by appending characters to
>> the
>> end of a sequential file, I'd have to write everything in the order
>> prescribed by the assembler syntax.
>> But if I'm using the C interface to build an LLVM parse tree, does that
>> have to be in any particular time-order?  Can I, for example, define a
>> few functions, start scattering code into them, decide I' like to
>> declare
>> some more local variables in one of them, generate code for another,
>> return to the first one and stick in a new basic block at its start,
>> discover I should have declared some more global variables, and so
>> forth?
>> That could be very convenient.
> Yes, you can absolutely do this.
> — Gordon

I think I may have found an exception to this -- the API seems to require 
me to have all the fields for a struct ready before I construct the 
struct.  I don't have the ability to make a struct type, use it to 
declare some variables, and still contribute fields to it during the rest 
of the compilation.

Is there a reason for this limitation other than no one thinking of it?  
Does it need to have all the type information early in building the 
parser tree?  I can't really imagine that.  I for one could do without 
this limitation.

I won't even ask to be able to contribute more fields at link time, 
though that would be useful, too.  Such link-time-assembled structures 
ould resemble the DXD dummy control sections sections that PL/1 used on 

-- hendrik

More information about the llvm-dev mailing list