On Fri, Dec 2, 2011 at 3:38 PM, Matt Davis <mattdav...@gmail.com> wrote: > I am working on a gcc-plugin where I need to create a structure at compile > time. > I have gleaned over one of the front ends to learn more about creating > structures at compile time. What I have thus far is a type node for my > struct. > > I now need to create an instance of this struct. For exemplary purposes we > will > call this type 'struct T' and we will call the instance of T, 'my_T' By using > the build_constructor() routine in GCC I create an instance, my_T, which I > need > to pass the address of to a function. So, I take this decl, my_T, and pass > it to > build_fold_addr_expr(). The result of the latter is what I pass to the > function 'fn()'. > > Yes, the function I am passing the reference to is expecting the proper type, > that of address-to-T. Running this presents me with an error in > expand_expr_real_1() where "Variables inherited from containing functions > should > have been lowered by this point." > > So, I figure, if I create a temp variable, 'V', of type pointer-to-T, and run > make_ssa_name() on that temp. And then insert an assignment before the call > to > fn, so I get: 'V = &my_T;' After looking at the GIMPLE dump, I see, 'V = > &my_T; > fn(V);' Which is correct, however, in the type list of the caller, I only > see: > 'struct * V;' Now, this concerns me, I would expect to see "struct T *V;" As > above, this case also fails. > > I am baffled, do I need to even be creating the ssa_name instance to pass to > 'fn()', which is 'V' in the case above? Or, will the build_constructor() > produce a tree node that I can treat as a variable, that I can pass to 'fn()' > ? > > -Matt
Well, I have successfully created and used an initialized structure. Note that I do not need to run the make_ssa_name. I can declare the struct as TREE_STATIC and work from there. Now, my problem with the expand_expr_real_1 check failing is because some of the values I initialize in my compile-time created struct can be different at runtime. Is there a way I can take this constructor tree node, and have all of the values in it set in the middle of my function, where those values are defined? I do not need the structure initialized upon function entry. What I need is to have all of the values, which I already setup when I am in the middle of the function being processed. I need these values actually filled-out in the middle of function instead at function entry. I am unsure how to do this. The constructor node exists, and I'm in the middle of an IPA pass. I assume I can call gimplify_expr() but I am thinking I need to pass it something different than just a constructor tree node. Thanks for any help -Matt