public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Krzysztof Matula" <K.Matula@adb.pl>
To: <Richard.Earnshaw@arm.com>
Cc: <gcc@gcc.gnu.org>
Subject: Re: porting GCC
Date: Fri, 02 Feb 2001 06:07:00 -0000	[thread overview]
Message-ID: <00b001c08d21$48f99fd0$3704a4c3@adb.pl> (raw)
In-Reply-To: <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



  reply	other threads:[~2001-02-02  6:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-02-01  2:37 Krzysztof Matula
2001-02-01  3:10 ` Richard Earnshaw
2001-02-02  3:43   ` Krzysztof Matula
2001-02-02  4:00     ` Richard Earnshaw
2001-02-02  6:07       ` Krzysztof Matula [this message]
2001-02-02  7:08         ` Richard Earnshaw
2001-02-15  8:41 porting gcc Filippo Basso
2001-02-15  9:50 ` Fergus Henderson
2002-10-22  9:53 Grégoire Dooms
2002-10-22  9:56 ` Grégoire Dooms
2002-10-22 14:40 ` Mike Stump
2002-10-22 14:43 ` Andrew Haley
2002-10-22 15:16   ` Michael Matz
2002-10-22 15:27   ` Svein E. Seldal
2002-10-22 18:02   ` Mike Stump
2002-10-23 10:05     ` Andrew Haley
2002-10-22 15:50 ` Denis Chertykov
2003-08-13 11:15 Porting gcc Petar Penchev
2003-08-13 16:07 ` Ben Elliston
2004-05-21 13:09 Mile Davidovic
2004-05-21 13:43 ` Dave Korn
2004-06-02 16:49 Porting GCC Gyle Yearsley
2004-06-03 15:38 ` Richard Sandiford
2004-06-04 15:24 Gyle Yearsley
2008-03-12  6:11 Porting gcc Schmave
2008-03-12  6:15 ` Ben Elliston
2008-10-20 10:20 porting gcc Aurélien Buhrig
2008-10-20 19:34 ` Ian Lance Taylor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='00b001c08d21$48f99fd0$3704a4c3@adb.pl' \
    --to=k.matula@adb.pl \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).