diff mbox

[committed] Change "Q" and "T" constraints to memory constraints

Message ID BLU436-SMTP2591A0601E9336930A88684972D0@phx.gbl
State New
Headers show

Commit Message

John David Anglin Feb. 19, 2015, 11:56 p.m. UTC
On 2015-02-16, at 1:47 PM, John David Anglin wrote:

> On 2015-02-16, at 11:38 AM, Richard Henderson wrote:
> 
>>> 
>>> Possibly the constant can somehow be forced into the data section where the relocations
>>> aren't a problem?
>> 
>> Hmm.  It looks like we might already do that.  See default_select_rtx_section.
> 
> Thanks, I see the problem.  default_reloc_rw_mask returns 0 when not generating PIC
> code, so rtx went to readonly_data_section.  I was thinking that pa_select_section was
> somehow broken.


The attached change fixes the problem with the HP SOM linker and as a result we no longer
need to reject (const (plus (symbol) (const_int))) in pa_cannot_force_const_mem.

I looked at trying to prevent (const (plus (symbol) (const_int))) from being forced to const mem
but I think we are stuck with handling it in certain situations.

Tested on hppa-unknown-linux-gnu, hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.
Committed to trunk and 4.9.

Dave
--
John David Anglin	dave.anglin@bell.net
2015-02-19  John David Anglin  <danglin@gcc.gnu.org>

	* config/pa/pa.c (pa_reloc_rw_mask): New function.
	(TARGET_ASM_RELOC_RW_MASK): Define.
	(pa_cannot_force_const_mem): Revert previous change.
diff mbox

Patch

Index: config/pa/pa.c
===================================================================
--- config/pa/pa.c	(revision 220778)
+++ config/pa/pa.c	(working copy)
@@ -149,6 +149,7 @@ 
 static int pa_adjust_cost (rtx_insn *, rtx, rtx_insn *, int);
 static int pa_adjust_priority (rtx_insn *, int);
 static int pa_issue_rate (void);
+static int pa_reloc_rw_mask (void);
 static void pa_som_asm_init_sections (void) ATTRIBUTE_UNUSED;
 static section *pa_som_tm_clone_table_section (void) ATTRIBUTE_UNUSED;
 static section *pa_select_section (tree, int, unsigned HOST_WIDE_INT)
@@ -324,6 +325,9 @@ 
 #define TARGET_ASM_FILE_END output_deferred_plabels
 #endif
 
+#undef TARGET_ASM_RELOC_RW_MASK
+#define TARGET_ASM_RELOC_RW_MASK pa_reloc_rw_mask
+
 #undef TARGET_PRINT_OPERAND_PUNCT_VALID_P
 #define TARGET_PRINT_OPERAND_PUNCT_VALID_P pa_print_operand_punct_valid_p
 
@@ -1569,14 +1582,6 @@ 
 static bool
 pa_cannot_force_const_mem (machine_mode mode ATTRIBUTE_UNUSED, rtx x)
 {
-  /* Reload sometimes tries to put const data symbolic operands in
-     readonly memory.  The HP SOM linker doesn't allow symbolic data
-     in readonly memory.  */
-  if (TARGET_SOM
-      && !function_label_operand (x, VOIDmode)
-      && symbolic_operand (x, VOIDmode))
-    return true;
-
   return tls_referenced_p (x);
 }
 
@@ -9707,6 +9715,19 @@ 
     return data_section;
 }
 
+/* Implement pa_reloc_rw_mask.  */
+
+static int
+pa_reloc_rw_mask (void)
+{
+  /* We force (const (plus (symbol) (const_int))) to memory when the
+     const_int doesn't fit in a 14-bit integer.  The SOM linker can't
+     handle this construct in read-only memory and we want to avoid
+     this for ELF.  So, we always force an RTX needing relocation to
+     the data section.  */
+  return 3;
+}
+
 static void
 pa_globalize_label (FILE *stream, const char *name)
 {