aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorSandra Loosemore <sandra@codesourcery.com>2017-10-26 16:49:48 -0400
committerSandra Loosemore <sandra@gcc.gnu.org>2017-10-26 16:49:48 -0400
commitde10fca02a806c8c323041c5e904abaaef510fc0 (patch)
treef40537de19218fb2bcb55461d96038ae8d100d5d /gcc/config
parent31498bee1acc00d89ea82c9c8614aa65f1eff2e8 (diff)
downloadgcc-de10fca02a806c8c323041c5e904abaaef510fc0.zip
gcc-de10fca02a806c8c323041c5e904abaaef510fc0.tar.gz
gcc-de10fca02a806c8c323041c5e904abaaef510fc0.tar.bz2
nios2.c: Include xregex.h.
2017-10-26 Sandra Loosemore <sandra@codesourcery.com> gcc/ * config/nios2/nios2.c: Include xregex.h. (nios2_gprel_sec_regex): New. (nios2_option_overide): Initialize it. Don't allow GP-relative addressing with PIC. (nios2_small_section_name_p): Check for regex match. * config/nios2/nios2.opt (mgprel-sec=): New option. * doc/invoke.texi (Option Summary): Add -mgprel-sec. (Nios II Options): Document -mgprel-sec. gcc/testsuite/ * gcc.target/nios2/gpopt-gprel-sec.c: New. From-SVN: r254123
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/nios2/nios2.c25
-rw-r--r--gcc/config/nios2/nios2.opt4
2 files changed, 28 insertions, 1 deletions
diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c
index f5963d4..3aade7b 100644
--- a/gcc/config/nios2/nios2.c
+++ b/gcc/config/nios2/nios2.c
@@ -49,6 +49,7 @@
#include "stor-layout.h"
#include "builtins.h"
#include "tree-pass.h"
+#include "xregex.h"
/* This file should be included last. */
#include "target-def.h"
@@ -103,6 +104,9 @@ static int custom_code_index[256];
/* Set to true if any conflicts (re-use of a code between 0-255) are found. */
static bool custom_code_conflict = false;
+/* State for command-line options. */
+regex_t nios2_gprel_sec_regex;
+
/* Definition of builtin function types for nios2. */
@@ -1371,6 +1375,23 @@ nios2_option_override (void)
nios2_gpopt_option = gpopt_local;
}
+ /* GP-relative addressing doesn't make sense for PIC. */
+ if (flag_pic)
+ {
+ if (nios2_gpopt_option != gpopt_none)
+ error ("-mgpopt not supported with PIC.");
+ if (nios2_gprel_sec)
+ error ("-mgprel-sec= not supported with PIC.");
+ }
+
+ /* Process -mgprel-sec=. */
+ if (nios2_gprel_sec)
+ {
+ if (regcomp (&nios2_gprel_sec_regex, nios2_gprel_sec,
+ REG_EXTENDED | REG_NOSUB))
+ error ("-mgprel-sec= argument is not a valid regular expression.");
+ }
+
/* If we don't have mul, we don't have mulx either! */
if (!TARGET_HAS_MUL && TARGET_HAS_MULX)
target_flags &= ~MASK_HAS_MULX;
@@ -2268,7 +2289,9 @@ nios2_small_section_name_p (const char *section)
return (strcmp (section, ".sbss") == 0
|| strncmp (section, ".sbss.", 6) == 0
|| strcmp (section, ".sdata") == 0
- || strncmp (section, ".sdata.", 7) == 0);
+ || strncmp (section, ".sdata.", 7) == 0
+ || (nios2_gprel_sec
+ && regexec (&nios2_gprel_sec_regex, section, 0, NULL, 0) == 0));
}
/* Return true if EXP should be placed in the small data section. */
diff --git a/gcc/config/nios2/nios2.opt b/gcc/config/nios2/nios2.opt
index 08cb935..d08405e 100644
--- a/gcc/config/nios2/nios2.opt
+++ b/gcc/config/nios2/nios2.opt
@@ -586,3 +586,7 @@ Enable generation of R2 BMX instructions.
mcdx
Target Report Mask(HAS_CDX)
Enable generation of R2 CDX instructions.
+
+mgprel-sec=
+Target RejectNegative Joined Var(nios2_gprel_sec) Init(NULL)
+Regular expression matching additional GP-addressible small-data section names.