[tree-ssa] Computed gotos
Paul Brook
paul@nowt.org
Tue Jun 17 02:36:00 GMT 2003
On Monday 16 June 2003 6:18 pm, law@redhat.com wrote:
> In message <200306151759.45301.paul@nowt.org>, Paul Brook writes:
> Well, what do the tree nodes which use these addresses look like?
We have a static array of structures which contain pointer to the labels.
We declare it something like
DECL_INITIAL(<staticvar>) =
CONSTRUCTOR<array>(TREE_LIST(
CONSTRUCTOR<record>(TREE_LIST (
FIELD_DECL, ADDR_EXPR(LABEL_DECL)))))
Hopefully this makes some kind of sense. More detailed dumps follow.
I've tried to cut the following down as much as possible without loosing
anything that might be important.
The dump of the GENERIC tree for the function before gimplification looks
like this:
MAIN__ ()
{
static int1 c[11] = "Hello World";
_gfor_push_context ();
{
static struct _jump_struct jumptable.1[1] = {{.string1=0B,
.string1_len=0, .string2=0B, .string2_len=0, .target=&L.1}};
goto _gfor_select_string (&jumptable.1, 1, &L.2, (int1 *)&c, 11);;
L.1:;;
abort ();
goto L.2;;
L.2:;
};
_gfor_pop_context ()
}
After gimplification it looks pretty much the same except for the addition
of a few temporaries. One thing I did nothice is that when I compile an
equivalent program in C, I get declarations for the labels appearing in the
GIMPLE dumps. Something like "void L1 = <<< error >>>;"
I also did some digging with gdb and debug_tree. The inner scope (after
_gfor_push_context) looks something like this:
<bind_expr 0x4001e23c type <void_type 0x4001fd90 void>
side-effects vars <var_decl 0x403bb1c0 jumptable.1>
body <compound_expr 0x403ba220 type <void_type 0x4001fd90 void>
<...nodes for body of code follow...>
The decl for jumptable.1:
<var_decl 0x403bb1c0 jumptable.1
type <array_type 0x403bb150
type <record_type 0x403b9af0 _jump_struct BLK
size <integer_cst 0x403b2e00 constant 160>
unit size <integer_cst 0x403b801c constant 20>
align 32 symtab 0 alias set -1 fields <field_decl 0x403b9b60
string1>
pointer_to_this <pointer_type 0x403bb0e0> chain <type_decl
0x403b9d90>>
BLK size <integer_cst 0x403b2e00 160> unit size <integer_cst
0x403b801c 20>
align 32 symtab 0 alias set -1
domain <integer_type 0x40027770 type <integer_type 0x4001faf0>
SI
size <integer_cst 0x4001c594 constant 32>
unit size <integer_cst 0x4001c658 constant 4>
align 32 symtab 0 alias set -1 precision 32 min <integer_cst
0x4001cd20 0> max <integer_cst 0x4001cd20 0>>>
constant addressable used static BLK file test.f90 line 5 size
<integer_cst 0x403b2e00 160> unit size <integer_cst 0x403b801c 20>
align 32 context <function_decl 0x403b9770 MAIN__> initial <constructor
0x403b8ce8>
And the constructor (the initial value of jumptable.1):
<constructor 0x403b8ce8
type <record_type 0x403b9af0 _jump_struct>
constant static
arg 0 <tree_list 0x403b8c78
value <constructor 0x403b8c5c type <record_type 0x403b9af0
_jump_struct>
arg 0 <tree_list 0x403b8bb4 purpose <field_decl 0x403b9b60
string1>
value <integer_cst 0x4001ce54 constant 0>
chain <tree_list 0x403b8bd0 purpose <field_decl 0x403b9bd0
string1_len>
value <integer_cst 0x4001cdac constant 0>
<...SNIPPED, tree_list chains for string2 and string2_len fields...>
chain <tree_list 0x403b8c40 purpose <field_decl 0x403b9d20 target>
value <addr_expr 0x403b8c24 type <pointer_type 0x4001fe00>
arg 0 <label_decl 0x403b9e00 L.1>>>>>>>>>>>>
And finally the label itself
<label_decl 0x403b9e00 L.1
type <void_type 0x4001fd90 void>
used VOID file test.f90 line 3
align 1 context <function_decl 0x403b9770 MAIN__>
test.f90:3>
Hope this helps. My appologies if I've included too much information, I
wasn't sure what you'd want.
Paul
More information about the Gcc
mailing list