aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-11-22 16:09:55 +0100
committerMartin Liska <marxin@gcc.gnu.org>2018-11-22 15:09:55 +0000
commit2559ef9fc6efff7f977e886cdf6673a8f44ddc56 (patch)
tree2faf9b59a56259f0d19224177134b95e47bdf459 /gcc
parent89d7557202d25a393666ac4c0f7dbdab31e452a2 (diff)
downloadgcc-2559ef9fc6efff7f977e886cdf6673a8f44ddc56.zip
gcc-2559ef9fc6efff7f977e886cdf6673a8f44ddc56.tar.gz
gcc-2559ef9fc6efff7f977e886cdf6673a8f44ddc56.tar.bz2
Fix option values for -march.
2018-11-22 Martin Liska <mliska@suse.cz> * common/config/i386/i386-common.c (processor_names): Add static assert and add missing "znver2". (ix86_get_valid_option_values): Add checking assert for null values and add "native" value if feasible. * config/i386/i386.h: Do not declare size of processor_names. * common/config/i386/i386-common.c: * config/i386/i386.c: Add static assert for size of processor_cost_table. From-SVN: r266381
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog11
-rw-r--r--gcc/common/config/i386/i386-common.c25
-rw-r--r--gcc/config/i386/i386.c5
-rw-r--r--gcc/config/i386/i386.h2
4 files changed, 37 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fa41e71..5796246 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2018-11-22 Martin Liska <mliska@suse.cz>
+
+ * common/config/i386/i386-common.c (processor_names): Add
+ static assert and add missing "znver2".
+ (ix86_get_valid_option_values): Add checking assert for null
+ values and add "native" value if feasible.
+ * config/i386/i386.h: Do not declare size of processor_names.
+ * common/config/i386/i386-common.c:
+ * config/i386/i386.c: Add static assert for size
+ of processor_cost_table.
+
2018-11-22 Thomas Preud'homme <thomas.preudhomme@linaro.org>
* target-insns.def (stack_protect_combined_set): Define new standard
diff --git a/gcc/common/config/i386/i386-common.c b/gcc/common/config/i386/i386-common.c
index 1017147..4238b43 100644
--- a/gcc/common/config/i386/i386-common.c
+++ b/gcc/common/config/i386/i386-common.c
@@ -1478,7 +1478,7 @@ i386_except_unwind_info (struct gcc_options *opts)
#define TARGET_SUPPORTS_SPLIT_STACK ix86_supports_split_stack
/* This table must be in sync with enum processor_type in i386.h. */
-const char *const processor_names[PROCESSOR_max] =
+const char *const processor_names[] =
{
"generic",
"i386",
@@ -1516,9 +1516,13 @@ const char *const processor_names[PROCESSOR_max] =
"bdver4",
"btver1",
"btver2",
- "znver1"
+ "znver1",
+ "znver2"
};
+/* Guarantee that the array is aligned with enum processor_type. */
+STATIC_ASSERT (ARRAY_SIZE (processor_names) == PROCESSOR_max);
+
const pta processor_alias_table[] =
{
{"i386", PROCESSOR_I386, CPU_NONE, 0},
@@ -1734,11 +1738,24 @@ ix86_get_valid_option_values (int option_code,
{
case OPT_march_:
for (unsigned i = 0; i < pta_size; i++)
- v.safe_push (processor_alias_table[i].name);
+ {
+ const char *name = processor_alias_table[i].name;
+ gcc_checking_assert (name != NULL);
+ v.safe_push (name);
+ }
+#ifdef HAVE_LOCAL_CPU_DETECT
+ /* Add also "native" as possible value. */
+ v.safe_push ("native");
+#endif
+
break;
case OPT_mtune_:
for (unsigned i = 0; i < PROCESSOR_max; i++)
- v.safe_push (processor_names[i]);
+ {
+ const char *name = processor_names[i];
+ gcc_checking_assert (name != NULL);
+ v.safe_push (name);
+ }
break;
default:
break;
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 21eb6a2..2f0d531 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -831,7 +831,7 @@ static tree ix86_veclibabi_svml (combined_fn, tree, tree);
static tree ix86_veclibabi_acml (combined_fn, tree, tree);
/* This table must be in sync with enum processor_type in i386.h. */
-static const struct processor_costs *processor_cost_table[PROCESSOR_max] =
+static const struct processor_costs *processor_cost_table[] =
{
&generic_cost,
&i386_cost,
@@ -872,6 +872,9 @@ static const struct processor_costs *processor_cost_table[PROCESSOR_max] =
&znver1_cost,
&znver2_cost
};
+
+/* Guarantee that the array is aligned with enum processor_type. */
+STATIC_ASSERT (ARRAY_SIZE (processor_cost_table) == PROCESSOR_max);
static unsigned int
rest_of_handle_insert_vzeroupper (void)
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 813c86d..b9e726e 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2279,7 +2279,7 @@ enum processor_type
};
#if !defined(IN_LIBGCC2) && !defined(IN_TARGET_LIBS) && !defined(IN_RTS)
-extern const char *const processor_names[PROCESSOR_max];
+extern const char *const processor_names[];
#include "wide-int-bitmask.h"