This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

constant pool issues


Hi, 

I am a bit confused about how the constant pool works. 
So far I understood that there's one per function, and it holds anything 
that can not be an immediate value (i.e., on an IA32 arch, anything above 
4 bytes, including strings of probably any length). 

Q1: where are global consts held ? is there a "global" constant pool, or 
is that just the pool for the "main" function ?

What I would need to do is insert some constants into the constant pool, 
both for local variables, and for global variables (I am working on the 
RTL, not on the tree); i.e., some constants that I would later on like to 
assign to local vars, and others that I would like to assign to global 
vars.

This is mainly for vars of type "double".

Q2: Is there any way to assign some double constant value to a variable 
other than using the constant pool ?

Since this is the only way I've sen so far by looking through the RTL 
dumps, I am assuming the answer to the previous question is "No".
In that case, 

Q3: How do I assign the values to the variables ?
So far, after looking through varasm.c, my feeling is that I should use 
force_const_mem() to insert the variable in the constant pool, and then 
generate insns for extracting it from there and putting it into a 
register.

The equivalent of this source code line:

void myfunc () {
...
param = 1.0;
...
}

in RTL is this:

(insn 10 7 11 (nil) (set (reg:DF 61)
        (float_extend:DF (mem/u/f:SF (symbol_ref/u:SI ("*.LC0")) [3 S4 
A32]))) -1 (nil)
    (expr_list:REG_EQUAL (const_double:DF -2147483648 [0x80000000] 1.0e+0 
[0x0.8p+1])
        (nil)))

Now my question is: why do I need to generate the REG_EQUAL expr_list ? 
Do I need to generate it myself, or can I just stick with the first part 
of the insn, and count on the fact that some subsequent pass will add it ?
(I'm generating my insns real early, right after sibling optimization).

Q4: Is it possible to tell, from within RTL, what variable an "*.LCx" 
(where x is 0, 1, etc) is associated with ?

thank you
mihai





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]