@@ -804,8 +804,14 @@ const char *host_detect_local_cpu (int argc, const char **argv)
if (isa_names_table[i].option)
{
if (has_feature (isa_names_table[i].feature))
- options = concat (options, " ",
- isa_names_table[i].option, NULL);
+ {
+ const char *option;
+ if (isa_names_table[i].feature == FEATURE_UINTR)
+ option = "-muintr-native";
+ else
+ option = isa_names_table[i].option;
+ options = concat (options, " ", option, NULL);
+ }
else
options = concat (options, neg_option,
isa_names_table[i].option + 2, NULL);
@@ -1920,9 +1920,6 @@ ix86_option_override_internal (bool main_args_p,
opts->x_ix86_stringop_alg = no_stringop;
}
- if (TARGET_UINTR && !TARGET_64BIT)
- error ("%<-muintr%> not supported for 32-bit code");
-
if (!opts->x_ix86_arch_string)
opts->x_ix86_arch_string
= TARGET_64BIT_P (opts->x_ix86_isa_flags)
@@ -2109,6 +2106,7 @@ ix86_option_override_internal (bool main_args_p,
#define DEF_PTA(NAME) \
if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
&& PTA_ ## NAME != PTA_64BIT \
+ && (TARGET_64BIT || PTA_ ## NAME != PTA_UINTR) \
&& !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
SET_TARGET_ ## NAME (opts);
#include "i386-isa.def"
@@ -2184,6 +2182,16 @@ ix86_option_override_internal (bool main_args_p,
XDELETEVEC (s);
}
+ if (TARGET_64BIT)
+ {
+ /* Turn on UINTR in 64-bit mode for -muintr-native if it has not
+ been set explicitly. */
+ if (ix86_uintr_native && !TARGET_EXPLICIT_UINTR_P (opts))
+ SET_TARGET_UINTR (opts);
+ }
+ else if (TARGET_UINTR)
+ error ("%<-muintr%> not supported for 32-bit code");
+
ix86_arch_mask = HOST_WIDE_INT_1U << ix86_arch;
for (i = 0; i < X86_ARCH_LAST; ++i)
ix86_arch_features[i] = !!(initial_ix86_arch_features[i] & ix86_arch_mask);
@@ -802,6 +802,10 @@ muintr
Target Mask(ISA2_UINTR) Var(ix86_isa_flags2) Save
Support UINTR built-in functions and code generation.
+; Used to enable -muintr only in 64-bit mode with -march=native.
+muintr-native
+Target Undocumented RejectNegative Var(ix86_uintr_native)
+
msgx
Target Mask(ISA2_SGX) Var(ix86_isa_flags2) Save
Support SGX built-in functions and code generation.
new file mode 100644
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=sapphirerapids" } */
+
+#ifdef __x86_64__
+# ifndef __UINTR__
+# error UINTR is not enabled for Sapphirerapids
+# endif
+#else
+# ifdef __UINTR__
+# error UINTR is not usable in 32-bit mode
+# endif
+#endif
new file mode 100644
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -march=native" } */
+
+int
+main ()
+{
+ if (__builtin_cpu_supports ("uintr"))
+ {
+#ifdef __x86_64__
+# ifndef __UINTR__
+ __builtin_abort ();
+# endif
+#else
+# ifdef __UINTR__
+ __builtin_abort ();
+# endif
+#endif
+ return 0;
+ }
+
+ return 0;
+}
new file mode 100644
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=native -mno-uintr" } */
+
+#ifdef __UINTR__
+# error UINTR should be disabled
+#endif