[LLVMdev] Problem with missing support for non-zero contant initializers.

Holger Schurig hs4233 at mail.mn-solutions.de
Mon Aug 20 03:56:25 PDT 2007


> D does have static constructors. I just hoped I could avoid
> it, as something like what I proposed above would be much
> cleaner in my code.

First: a 'D' frontend to LLVM would be *AWESOME* !  :-)


I think you should consider doing both. If the 'D' source
code just makes

   float[4] table;

when your LLVM should be

   @_D9arrayinit5tableG32f = global [4 x float] [
      float 0x7FF8000000000000, float 0x7FF8000000000000,
      float 0x7FF8000000000000, float 0x7FF8000000000000
   ]              ; <[4 x float]*> [#uses=0]

because this is usually the fastest. And then you'll find
out at which "n" a construction code would be faster.





Finally, if you're still bored, you can group all similar
array types together and then initialize them in one go:

   float[4] table1;
   int num;
   float[3] table2;

could then be re-arranged (it's not in a struct, so easy:)

   int num;
   float[4] table1;
   float[3] table2;

and your construction code could then initialize 7 elements
at table1.



More information about the llvm-dev mailing list