nios2-protos.h (nios2_symbol_ref_in_small_data_p): Delete extern declaration.
authorChung-Lin Tang <cltang@codesourcery.com>
Sun, 5 Jul 2015 21:49:08 +0000 (21:49 +0000)
committerSandra Loosemore <sandra@gcc.gnu.org>
Sun, 5 Jul 2015 21:49:08 +0000 (17:49 -0400)
2015-07-05  Chung-Lin Tang  <cltang@codesourcery.com>
    Sandra Loosemore <sandra@codesourcery.com>

gcc/
* config/nios2/nios2-protos.h (nios2_symbol_ref_in_small_data_p):
Delete extern declaration.
(gprel_constant_p): Add extern declaration.
* config/nios2/constraints.md ("S"): Use gprel_constant_p
instead of nios2_symbol_ref_in_small_data_p.
* config/nios2/nios2.c (nios2_legitimate_address_p): Likewise.
(nios2_symbol_ref_in_small_data_p): Make static.
(gprel_constant_p): Make non-static.

gcc/testsuite/
* gcc.target/nios2/gprel-offset.c: New test.

Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>
From-SVN: r225437

gcc/ChangeLog
gcc/config/nios2/constraints.md
gcc/config/nios2/nios2-protos.h
gcc/config/nios2/nios2.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/nios2/gprel-offset.c [new file with mode: 0644]

index 6ef5ef1d4452d9ea449332bb19d487e6e3a10c96..0d6337c2a23bc294d20e0557ec817764713a5f72 100644 (file)
@@ -1,3 +1,15 @@
+2015-07-05  Chung-Lin Tang  <cltang@codesourcery.com>
+           Sandra Loosemore <sandra@codesourcery.com>
+
+       * config/nios2/nios2-protos.h (nios2_symbol_ref_in_small_data_p):
+       Delete extern declaration.
+       (gprel_constant_p): Add extern declaration.
+       * config/nios2/constraints.md ("S"): Use gprel_constant_p
+       instead of nios2_symbol_ref_in_small_data_p.
+       * config/nios2/nios2.c (nios2_legitimate_address_p): Likewise.
+       (nios2_symbol_ref_in_small_data_p): Make static.
+       (gprel_constant_p): Make non-static.
+
 2015-07-05  Gerald Pfeifer  <gerald@pfeifer.com>
 
        * doc/fragments.texi (Target Fragment): Convert debian.org
index 735f892d5240841003269009eac04855c5df7c37..b67e87d3b3c85af7285ba6dcc416ea16a0e580e0 100644 (file)
@@ -84,8 +84,7 @@
 
 (define_constraint "S"
   "An immediate stored in small data, accessible by GP."
-  (and (match_code "symbol_ref")
-       (match_test "nios2_symbol_ref_in_small_data_p (op)")))
+  (match_test "gprel_constant_p (op)"))
 
 (define_constraint "T"
   "A constant unspec offset representing a relocation."
index 2855c92b2f65acff3a3e7e0a92319f368138b31a..52985a9d06cc8e1e96081053146620605cc71871 100644 (file)
@@ -44,7 +44,7 @@ extern bool nios2_fpu_insn_enabled (enum n2fpu_code);
 extern const char * nios2_fpu_insn_asm (enum n2fpu_code);
 
 extern bool nios2_legitimate_pic_operand_p (rtx);
-extern bool nios2_symbol_ref_in_small_data_p (rtx);
+extern bool gprel_constant_p (rtx);
 extern bool nios2_regno_ok_for_base_p (int, bool);
 extern bool nios2_unspec_reloc_p (rtx);
 
index fd035fb59aa37fa3561a0294f8bd4712dd5c8e25..51f7aa2defb044b96411d1541bf4abe31dd508f9 100644 (file)
@@ -1614,14 +1614,15 @@ nios2_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED,
     case SYMBOL_REF:
       if (SYMBOL_REF_TLS_MODEL (operand))
        return false;
-      
-      if (nios2_symbol_ref_in_small_data_p (operand))
+
+      /* Else, fall through.  */
+    case CONST:
+      if (gprel_constant_p (operand))
        return true;
 
       /* Else, fall through.  */
     case LABEL_REF:
     case CONST_INT:
-    case CONST:
     case CONST_DOUBLE:
       return false;
 
@@ -1688,7 +1689,7 @@ nios2_in_small_data_p (const_tree exp)
 
 /* Return true if symbol is in small data section.  */
 
-bool
+static bool
 nios2_symbol_ref_in_small_data_p (rtx sym)
 {
   tree decl;
@@ -2110,7 +2111,7 @@ nios2_print_operand (FILE *file, rtx op, int letter)
 }
 
 /* Return true if this is a GP-relative accessible reference.  */
-static bool
+bool
 gprel_constant_p (rtx op)
 {
   if (GET_CODE (op) == SYMBOL_REF
index 2b29e1a6759d03759a48e909bd97b7d4250d6305..2eb4fdc22a48268f2c6499bff8d59dcd52061e3b 100644 (file)
@@ -1,3 +1,8 @@
+2015-07-05  Chung-Lin Tang  <cltang@codesourcery.com>
+           Sandra Loosemore <sandra@codesourcery.com>
+
+       * gcc.target/nios2/gprel-offset.c: New test.
+
 2015-07-04  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/66725
diff --git a/gcc/testsuite/gcc.target/nios2/gprel-offset.c b/gcc/testsuite/gcc.target/nios2/gprel-offset.c
new file mode 100644 (file)
index 0000000..05186c6
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+static struct s {
+  int x;
+  char y;
+} s;
+
+void set (char c)
+{
+  s.y = c;
+}
+
+
+char get (void)
+{
+  return s.y;
+}
+
+/* { dg-final { scan-assembler-times "%gprel\\(s\\+4\\)\\(gp\\)" 2 } } */