[PATCH] Tweaks to print_rtx_function

David Malcolm dmalcolm@redhat.com
Thu Oct 13 14:08:00 GMT 2016

On Thu, 2016-10-13 at 12:24 +0200, Bernd Schmidt wrote:
> On 10/12/2016 11:04 PM, David Malcolm wrote:
> > 
> > This patch implements:
> > * the renumbering of non-virtual pseudos, using
> >   LAST_VIRTUAL_REGISTER + 1 as a base.
> > * omitting the edge "(flags)" directive if there aren't any
> > 
> > Bootstrap & regrtest in progress.
> > 
> > OK for trunk if they pass?

(they did)

> I tend to think probably yes. Let's say ok if I don't object by
> tomorrow 
> :) I'm still wondering whether we want to use some sort of prefix
> like 
> $p or %p which is distinct from any hard register name for clarity.

I'll attempt to sum up the discussion on this so far...

We're already printing names for hard regs and for virtual regs, so
it's non-virtual pseudos that need figuring out.

Consider regno == 90 for target x86_64, where LAST_VIRTUAL_REGISTER is
86 and hence this is a non-virtual pseudo.  The first non-virtual
pseudo has regno 87.

Currently this is printed in non-compact form as:

  (reg:SI 90)

Our goals for printing it in "compact" form (and hence parsed by the
RTL frontend) are (in no particular order):

* readability for humans
* lack of ambiguity for parsers
* "hackability" for humans editing the file
* future-proof against changes to the machine description
* make it reasonably target-independent

I thought it might be useful to brainstorm [1] some ideas on this, so here are various possible ways it could be printed for this use-case:

* Offset by LAST_VIRTUAL_REGISTER + 1 (as in the patch), and printed
just as a number, giving:

  (reg:SI 3) 

* Prefixed by a "sigil" character:

  (reg:SI $3) 
  (reg:SI %3) 
  (reg:SI #3) 
  (reg:SI +3)
  (reg:SI @3)
(reg:SI &3)
  (reg:SI ?3)
  (reg:SI P3)

* Prefixed so it looks like a register name:

  (reg:SI pseudo-3)
  (reg:SI pseudo_3)
  (reg:SI pseudo+3)

* Other syntax ideas:

  (reg:SI (3))

  (reg:SI {3})

  (reg:SI (87+3))

Looking at print_rtx_operand_code_r there are also things like ORIGINAL_REGNO, REG_EXPR and REG_OFFSET which get printed after the main regno, e.g.:

  (reg:SI 1 [ <retval> ])

My thought was to use whatever we come up with for REGNO for ORIGINAL_REGNO (after the "orig:").	

Hope this is constructive

[1] i.e. this is my list before applying any "is this idea a good one" filtering/self-censorship...

More information about the Gcc-patches mailing list