diff mbox series

[2/2] rs6000: Make debug regnums independent of internal ones

Message ID 41bc1f64ea282719313370cb9106bf288dcba055.1556818314.git.segher@kernel.crashing.org
State New
Headers show
Series [1/2] rs6000: Debug regnums for TM registers | expand

Commit Message

Segher Boessenkool May 2, 2019, 6:24 p.m. UTC
Where we use "internal GCC register numbers" in debug info, that
defines an ABI, so we cannot change those numbers.  But we want to
change the internal numbers, and sometimes we do that without
remembering this gotcha anyway; so let's make everything independent
of the internal numbers.

For those registers that are not recognised here (we still have MQ for
example, but also the GCC-internal frame pointer and arg pointer
registers), this just returns the internal register number.  This is a
bit worrying: that number could be the same as that for a register we
validly want to have in debug info.  I first had a gcc_unreachable ()
for that, but this does now work because dwarf2cfi calls
rs6000_dbx_register_number for every internal register.  Then I just
returned 0 for the internal regs, but that causes various regression
tests to fail.  So now I return the internal register number again,
as it was before; but this needs to be fixed.

Tested on Linux, as the previous patch.  Committing to trunk.


Segher


2019-05-02  Segher Boessenkool  <segher@kernel.crashing.org>

	* config/rs6000/rs6000.c (rs6000_dbx_register_number): Do not use
	the internal register number, for any "real" register.

---
 gcc/config/rs6000/rs6000.c | 107 +++++++++++++++++++++++++++------------------
 1 file changed, 64 insertions(+), 43 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index f8e9fd2..c75fd86 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -36269,53 +36269,74 @@  rs6000_init_dwarf_reg_sizes_extra (tree address)
 unsigned int
 rs6000_dbx_register_number (unsigned int regno, unsigned int format)
 {
-  /* We use the GCC 7 (and before) internal number for non-DWARF debug
-     information, and also for .eh_frame.  */
-  if ((format == 0 && write_symbols != DWARF2_DEBUG) || format == 2)
-    {
-      /* Translate the regnos to their numbers in GCC 7 (and before).  */
-      if (regno == TFHAR_REGNO)
-	regno = 114;
-      else if (regno == TFIAR_REGNO)
-	regno = 115;
-      else if (regno == TEXASR_REGNO)
-	regno = 116;
-
-      return regno;
-    }
-
   /* On some platforms, we use the standard DWARF register
      numbering for .debug_info and .debug_frame.  */
+  if ((format == 0 && write_symbols == DWARF2_DEBUG) || format == 1)
+    {
 #ifdef RS6000_USE_DWARF_NUMBERING
-  if (regno <= 63)
-    return regno;
-  if (regno == LR_REGNO)
-    return 108;
-  if (regno == CTR_REGNO)
-    return 109;
-  /* Special handling for CR for .debug_frame: rs6000_emit_prologue has
-     translated any combination of CR2, CR3, CR4 saves to a save of CR2.
-     The actual code emitted saves the whole of CR, so we map CR2_REGNO
-     to the DWARF reg for CR.  */
-  if (format == 1 && regno == CR2_REGNO)
-    return 64;
-  if (CR_REGNO_P (regno))
-    return regno - CR0_REGNO + 86;
-  if (regno == CA_REGNO)
-    return 101;  /* XER */
-  if (ALTIVEC_REGNO_P (regno))
-    return regno - FIRST_ALTIVEC_REGNO + 1124;
-  if (regno == VRSAVE_REGNO)
-    return 356;
-  if (regno == VSCR_REGNO)
-    return 67;
-  if (regno == TFHAR_REGNO)
-    return 228;
-  if (regno == TFIAR_REGNO)
-    return 229;
-  if (regno == TEXASR_REGNO)
-    return 230;
+      if (regno <= 31)
+	return regno;
+      if (FP_REGNO_P (regno))
+	return regno - FIRST_FPR_REGNO + 32;
+      if (ALTIVEC_REGNO_P (regno))
+	return regno - FIRST_ALTIVEC_REGNO + 1124;
+      if (regno == LR_REGNO)
+	return 108;
+      if (regno == CTR_REGNO)
+	return 109;
+      if (regno == CA_REGNO)
+	return 101;  /* XER */
+      /* Special handling for CR for .debug_frame: rs6000_emit_prologue has
+	 translated any combination of CR2, CR3, CR4 saves to a save of CR2.
+	 The actual code emitted saves the whole of CR, so we map CR2_REGNO
+	 to the DWARF reg for CR.  */
+      if (format == 1 && regno == CR2_REGNO)
+	return 64;
+      if (CR_REGNO_P (regno))
+	return regno - CR0_REGNO + 86;
+      if (regno == VRSAVE_REGNO)
+	return 356;
+      if (regno == VSCR_REGNO)
+	return 67;
+      if (regno == TFHAR_REGNO)
+	return 228;
+      if (regno == TFIAR_REGNO)
+	return 229;
+      if (regno == TEXASR_REGNO)
+	return 230;
+
+      return regno;
 #endif
+    }
+
+  /* We use the GCC 7 (and before) internal number for non-DWARF debug
+     information, and also for .eh_frame.  */
+  /* Translate the regnos to their numbers in GCC 7 (and before).  */
+  if (regno <= 31)
+    return regno;
+  if (FP_REGNO_P (regno))
+    return regno - FIRST_FPR_REGNO + 32;
+  if (ALTIVEC_REGNO_P (regno))
+    return regno - FIRST_ALTIVEC_REGNO + 77;
+  if (regno == LR_REGNO)
+    return 65;
+  if (regno == CTR_REGNO)
+    return 66;
+  if (regno == CA_REGNO)
+    return 76;  /* XER */
+  if (CR_REGNO_P (regno))
+    return regno - CR0_REGNO + 68;
+  if (regno == VRSAVE_REGNO)
+    return 109;
+  if (regno == VSCR_REGNO)
+    return 110;
+  if (regno == TFHAR_REGNO)
+    return 114;
+  if (regno == TFIAR_REGNO)
+    return 115;
+  if (regno == TEXASR_REGNO)
+    return 116;
+
   return regno;
 }