PRU: Fix HW register numbering for DWARF2 output

Message ID 20180728065628.30999-1-dimitar@dinux.eu
State New
Headers show
Series
  • PRU: Fix HW register numbering for DWARF2 output
Related show

Commit Message

Dimitar Dimitrov July 28, 2018, 6:56 a.m.
A small rework of the PRU GCC port exposed that CIE data alignment is
erroneously set to 4 for PRU in GAS. In fact PRU stack must be aligned to 1.
Set the macro to -1, to allow output from GCC to be assembled without errors.

Also, while at it, set DWARF2 HW register numbering to follow latest GCC port.

gas/ChangeLog:

2018-07-27  Dimitar Dimitrov  <dimitar@dinux.eu>

	* config/tc-pru.c (pru_regname_to_dw2regnum): Return the starting HW
	byte-register number.
	(pru_frame_initial_instructions): Use byte-numbering for FP index.
	* config/tc-pru.h (DWARF2_DEFAULT_RETURN_COLUMN): Use number from
	latest GCC.
	(DWARF2_CIE_DATA_ALIGNMENT): Set to -1.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>

---
 gas/config/tc-pru.c | 17 ++++++++++++++---
 gas/config/tc-pru.h | 10 ++++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)

-- 
2.11.0

Comments

Nick Clifton July 31, 2018, 4:16 p.m. | #1
Hi Dimitar,

> 2018-07-27  Dimitar Dimitrov  <dimitar@dinux.eu>

> 

> 	* config/tc-pru.c (pru_regname_to_dw2regnum): Return the starting HW

> 	byte-register number.

> 	(pru_frame_initial_instructions): Use byte-numbering for FP index.

> 	* config/tc-pru.h (DWARF2_DEFAULT_RETURN_COLUMN): Use number from

> 	latest GCC.

> 	(DWARF2_CIE_DATA_ALIGNMENT): Set to -1.


Approved - please apply.

Cheers
  Nick
Dimitar Dimitrov Aug. 3, 2018, 5:57 a.m. | #2
Quoting Nick Clifton <nickc@redhat.com>:

> Hi Dimitar,

>

>> 2018-07-27  Dimitar Dimitrov  <dimitar@dinux.eu>

>>

>> 	* config/tc-pru.c (pru_regname_to_dw2regnum): Return the starting HW

>> 	byte-register number.

>> 	(pru_frame_initial_instructions): Use byte-numbering for FP index.

>> 	* config/tc-pru.h (DWARF2_DEFAULT_RETURN_COLUMN): Use number from

>> 	latest GCC.

>> 	(DWARF2_CIE_DATA_ALIGNMENT): Set to -1.

>

> Approved - please apply.

Could someone commit it? I do not have write access.

Thanks,
Dimitar
Nick Clifton Aug. 3, 2018, 9:04 a.m. | #3
Hi Dimitar,

>>>     * config/tc-pru.c (pru_regname_to_dw2regnum): Return the starting HW

>>>     byte-register number.

>>>     (pru_frame_initial_instructions): Use byte-numbering for FP index.

>>>     * config/tc-pru.h (DWARF2_DEFAULT_RETURN_COLUMN): Use number from

>>>     latest GCC.

>>>     (DWARF2_CIE_DATA_ALIGNMENT): Set to -1.

>>

>> Approved - please apply.

> Could someone commit it? I do not have write access.


Done.

Cheers
  Nick

Patch

diff --git a/gas/config/tc-pru.c b/gas/config/tc-pru.c
index 5121b1f8a4..d32f793548 100644
--- a/gas/config/tc-pru.c
+++ b/gas/config/tc-pru.c
@@ -1920,14 +1920,25 @@  pru_cons_fix_new (fragS *frag, int where, unsigned int nbytes,
 }
 
 /* Implement tc_regname_to_dw2regnum, to convert REGNAME to a DWARF-2
-   register number.  */
+   register number.  Return the starting HW byte-register number.  */
 int
 pru_regname_to_dw2regnum (char *regname)
 {
+  static const unsigned int regstart[RSEL_NUM_ITEMS] = {
+	  [RSEL_7_0]	= 0,
+	  [RSEL_15_8]	= 1,
+	  [RSEL_23_16]	= 2,
+	  [RSEL_31_24]	= 3,
+	  [RSEL_15_0]	= 0,
+	  [RSEL_23_8]	= 1,
+	  [RSEL_31_16]	= 2,
+	  [RSEL_31_0]	= 0,
+  };
+
   struct pru_reg *r = pru_reg_lookup (regname);
   if (r == NULL)
     return -1;
-  return r->index;
+  return r->index * 4 + regstart[r->regsel];
 }
 
 /* Implement tc_cfi_frame_initial_instructions, to initialize the DWARF-2
@@ -1935,7 +1946,7 @@  pru_regname_to_dw2regnum (char *regname)
 void
 pru_frame_initial_instructions (void)
 {
-  const unsigned fp_regno = 4;
+  const unsigned fp_regno = 4 * 4;
   cfi_add_CFA_def_cfa (fp_regno, 0);
 }
 
diff --git a/gas/config/tc-pru.h b/gas/config/tc-pru.h
index bc4785154b..c0239b5f9a 100644
--- a/gas/config/tc-pru.h
+++ b/gas/config/tc-pru.h
@@ -138,8 +138,14 @@  extern int pru_validate_fix_sub (struct fix *);
 
 /* We want .cfi_* pseudo-ops for generating unwind info.  */
 #define TARGET_USE_CFIPOP 1
-#define DWARF2_DEFAULT_RETURN_COLUMN 31
-#define DWARF2_CIE_DATA_ALIGNMENT (-4)
+
+/* Program Counter register number is not defined by TI documents.  Pick the
+   virtual number used by GCC.  */
+#define DWARF2_DEFAULT_RETURN_COLUMN 132
+
+/* The stack grows down, and is only byte aligned.  */
+#define DWARF2_CIE_DATA_ALIGNMENT -1
+
 #define tc_regname_to_dw2regnum pru_regname_to_dw2regnum
 extern int pru_regname_to_dw2regnum (char *regname);
 #define tc_cfi_frame_initial_instructions  pru_frame_initial_instructions