This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: porting GCC
- To: <Richard dot Earnshaw at arm dot com>
- Subject: Re: porting GCC
- From: "Krzysztof Matula" <K dot Matula at adb dot pl>
- Date: Fri, 2 Feb 2001 15:06:04 +0100
- Cc: <gcc at gcc dot gnu dot org>
- References: <200102021200.MAA10437@cam-mail2.cambridge.arm.com>
----- Original Message -----
From: "Richard Earnshaw" <rearnsha@arm.com>
Sent: Friday, February 02, 2001 13:00
> > I am generating several insn-s inside define_expand. The meaning of the
code
> > is not exactly the same, as the rtl matched. The problem is that GCC
always
> > notes the last insn I generate with REG_EQUAL expression, corresponding
to
> > the ORIGINAL code... I don't know how to avoid this...
>
> Why is this a problem? Gcc annotates the end of the sequence with a note
> of the equivalent it collapses to. If you think of (symbol_ref
> ("__clz_tab")) as the final address that will be dereferenced then the
> expression
>
> (unspec [(symbol_ref ("__clz_tab"))] 3)
> should be thought of as being equivalent to
>
> (minus (symbol_ref ("__clz_tab")) (reg:SI base_reg))
I'm not sure if I understand this... Maybe there's something wrong that GCC
thinks of (symbol_ref ("__clz_tab")) as absolute address and the assembly
instructions not:
(expr_list:REG_EQUAL (plus:SI (mem:SI (reg:SI 9))
(symbol_ref/v:SI ("__clz_tab")))
(reg:SI 9) here represents the index to the __clz_tab, not the segment
base...
Referencing an element requires addition of segment base ((reg:SI 14) in the
example below), the index (reg:SI 9) and the relative starting offset of the
array: (symbol_ref/v:SI ("__clz_tab")). When I write the __clz_tab reference
into otput file I get the offset only...
The segment base is not a single register. It is always accessible as first
hidden argument to every function. It always needs to execute code to get it
into register... I don't think I can do this inside define_insn...
When I compile my example with -O2 GCC makes use of the REG_EQUAL and
produces rlt that doesn't match any insn (and in fact is incorrect):
(insn 10 8 11 (set (reg:SI 15)
(plus:SI (reg/v:SI 13)
(symbol_ref/v:SI ("__clz_tab")))) -1 (nil)
(nil))
(reg/v:SI 13) stands here for the index to the array. No segment base
addition takes place.
> [we don't express it this way since then the compiler might try to
> simplify the expression in a way that would be incorrect, but
> mathematically when the base_reg value is added back on we end up with the
> address we really want.]
If only the value is added...
> >
> > (insn 9 8 11 (set (reg:SI 15) ;;real array address
> > (plus:SI (reg:SI 14) ;;segment base
> >
pec:SI[
> > (symbol_ref/v:SI ("__clz_tab"))
> > ] 3))) -1 (nil)
> > (nil))
> >
> > (insn 11 9 12 (set (reg:SI 16) ;;index to the array
> > (mem:SI (reg:SI 9))) -1 (nil)
> > (nil))
> >
> > (insn 12 11 14 (set (reg:SI 13)
> > (plus:SI (reg:SI 16)
> > (reg:SI 15))) -1 (nil)
> > (nil))
> >
> > (insn 14 12 16 (set (reg:SI 13)
> > (reg:SI 13)) -1 (nil)
> > (expr_list:REG_EQUAL (plus:SI (mem:SI (reg:SI 9))
> > (symbol_ref/v:SI ("__clz_tab")))
> > (nil)))
> >
KM