The RTL frontend parses the output of print_rtx_function's "compact" mode.
Currently non-virtual pseudo regs in such dumps have a '%' prefix, based on the discussion here (me): * " Re: [PATCH] Tweaks to print_rtx_function" * https://gcc.gnu.org/ml/gcc-patches/2016-10/msg01033.html and here (Bernd): * https://gcc.gnu.org/ml/gcc-patches/2016-10/msg01035.html where Bernd's choice was: >> (reg:SI %3) > Avoids the confusion issue and shouldn't overlap with > hard register names. I think this is the one I prefer, followed > by plain (reg:SI 3). Unfortunately this *does* clash with hard register names on iq2000, which has: #define REGISTER_NAMES \ { \ "%0", "%1", "%2", "%3", "%4", "%5", "%6", "%7", \ etc, leading to ambiguities in the RTL frontend when parsing such dumps. I took a look at prefixes used in register names; grep -nH -e REGISTER_NAMES gcc/config/*/* shows that: alpha, ft32, microblaze, mips, mmix, nds32, spu: these use '$' prefix. In particular, alpha has hard reg names of the form $0, $1, etc iq2000, nvptx, pa, s390, sparc, vax/elf.h: use '%' prefix, and m68k can use it via REGISTER_PREFIX (in m68k/linux.h, m68k/m68kelf.h, and m68k/netbsd-elf.h) Of these only iq2000 has regs with just pure numeric suffixes e.g. %0, %1, etc... (and most of its hard regs are of this form). moxie uses both '$' prefix and '?' prefix (but all hard regs have a letter between the symbol and any numbers) tilegx and tilepro use '?' prefix for some v850 uses '.' prefix for some. The second choice in Bernd's email above was "plain (reg:SI 3)", so I tried implementing that as a fix (looking for pure digits when parsing). Unfortunately, rs6000 aka ppc has plain numbers (no prefixes) for its hard registers: char rs6000_reg_names[][8] = { "0", "1", "2", "3", "4", "5", "6", "7", [etc] #define REGISTER_NAMES \ { \ &rs6000_reg_names[ 0][0], /* r0 */ \ [etc] (gdb) p default_target_hard_regs->x_reg_names $11 = {0x1b0e7c0 <rs6000_reg_names> "0", 0x1b0e7c8 <rs6000_reg_names+8> "1", 0x1b0e7d0 <rs6000_reg_names+16> "2", (gdb) call lookup_reg_by_dump_name ("0") Value returned is $12 = 0 ...so we can't just use plain numbers for pseudo regs. Recalling my brainstorm email: > Our goals for printing regnos 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 The idea list from that email: > * Offset by LAST_VIRTUAL_REGISTER + 1 (as in the patch), and printed > just as a number, giving: > > (reg:SI 3) [clashes with hard regs on rs6000 aka ppc] > * Prefixed by a "sigil" character: > > (reg:SI $3) [clashes with hard regs on alpha] > (reg:SI %3) [the current implementation; clashes with hard regs on iq2000] > (reg:SI #3) > (reg:SI +3) > (reg:SI @3) [I don't *think* any of these clash with any hard regs on any supported target] > (reg:SI &3) > (reg:SI ?3) > (reg:SI P3) [P3 probably clashes. I *think* "&3" is OK. ? is used by moxie and tilegc/tilepro, but I think always with a letter between the ? and any number, so "?3" is probably OK] > * Prefixed so it looks like a register name: > (reg:SI pseudo-3) > (reg:SI pseudo_3) > (reg:SI pseudo+3) [probably too verbose] > * Other syntax ideas: > (reg:SI (3)) > (reg:SI {3}) [I like both of these] > (reg:SI (87+3)) > (reg:SI (LAST_VIRTUAL_REGISTER + 4)) [I think these are too clunky] Any preferences? (or other syntax ideas?). My preference is one of the currently-unused sigils e.g. "@3", or to wrap them in braces "{3}". Dave