+2017-11-17 Tamar Christina <tamar.christina@arm.com>
+
+ PR target/82641
+ * config/arm/arm.c (arm_valid_target_attribute_rec):
+ Parse "arch=" and "+<ext>".
+ (arm_valid_target_attribute_tree): Re-init global options.
+ (arm_option_override): Make non-static.
+ (arm_options_perform_arch_sanity_checks): Make errors fatal.
+ * gcc/config/arm/arm-c.c (__ARM_FEATURE_CMSE): Support undef.
+ (__ARM_FEATURE_CRC32): Support undef.
+ * config/arm/arm_acle.h (__ARM_FEATURE_CRC32): Replace with pragma.
+ * doc/extend.texi (ARM Function Attributes): Add pragma and target.
+
2017-11-17 David Malcolm <dmalcolm@redhat.com>
* gdbinit.in (break-on-diagnostic): New command.
target->tune_flags = tune_data->tune_flags;
target->tune = tune_data->tune;
target->tune_core = tune_data->scheduler;
+ arm_option_reconfigure_globals ();
}
/* Fix up any incompatible options that the user has specified. */
if (! opt_enum_arg_to_value (OPT_mfpu_, q+4,
&fpu_index, CL_TARGET))
{
- error ("invalid fpu for attribute(target(\"%s\"))", q);
+ error ("invalid fpu for target attribute or pragma %qs", q);
return false;
}
if (fpu_index == TARGET_FPU_auto)
}
opts->x_arm_fpu_index = (enum fpu_type) fpu_index;
}
+ else if (!strncmp (q, "arch=", 5))
+ {
+ char* arch = q+5;
+ const arch_option *arm_selected_arch
+ = arm_parse_arch_option_name (all_architectures, "arch", arch);
+
+ if (!arm_selected_arch)
+ {
+ error ("invalid architecture for target attribute or pragma %qs",
+ q);
+ return false;
+ }
+
+ opts->x_arm_arch_string = xstrndup (arch, strlen (arch));
+ }
+ else if (q[0] == '+')
+ {
+ opts->x_arm_arch_string
+ = xasprintf ("%s%s", opts->x_arm_arch_string, q);
+ }
else
{
- error ("attribute(target(\"%s\")) is unknown", q);
+ error ("unknown target attribute or pragma %qs", q);
return false;
}
}
cl_target_option_save (&cl_opts, opts);
arm_configure_build_target (&arm_active_target, &cl_opts, opts_set, false);
arm_option_check_internal (opts);
- /* Do any overrides, such as global options arch=xxx. */
+ /* Do any overrides, such as global options arch=xxx.
+ We do this since arm_active_target was overridden. */
+ arm_option_reconfigure_globals ();
+ arm_options_perform_arch_sanity_checks ();
arm_option_override_internal (opts, opts_set);
return build_target_option_node (opts);
#endif /* __ARM_ARCH >= 5. */
#endif /* (!__thumb__ || __thumb2__) && __ARM_ARCH >= 4. */
-#ifdef __ARM_FEATURE_CRC32
+#pragma GCC push_options
+#if __ARM_ARCH >= 8
+#pragma GCC target ("arch=armv8-a+crc")
+
__extension__ static __inline uint32_t __attribute__ ((__always_inline__))
__crc32b (uint32_t __a, uint8_t __b)
{
}
#endif
-#endif
+#endif /* __ARM_ARCH >= 8. */
+#pragma GCC pop_options
#ifdef __cplusplus
}
The behavior and permissible arguments are the same as for the @option{-mfpu=}
command-line option.
+@item arch=
+@cindex @code{arch=} function attribute, ARM
+Specifies the architecture version and architectural extensions to use
+for this function. The behavior and permissible arguments are the same as
+for the @option{-march=} command-line option.
+
+The above target attributes can be specified as follows:
+
+@smallexample
+__attribute__((target("arch=armv8-a+crc")))
+int
+f (int a)
+@{
+ return a + 5;
+@}
+@end smallexample
+
+Additionally, the architectural extension string may be specified on its
+own. This can be used to turn on and off particular architectural extensions
+without having to specify a particular architecture version or core. Example:
+
+@smallexample
+__attribute__((target("+crc+nocrypto")))
+int
+foo (int a)
+@{
+ return a + 5;
+@}
+@end smallexample
+
+In this example @code{target("+crc+nocrypto")} enables the @code{crc}
+extension and disables the @code{crypto} extension for the function @code{foo}
+without modifying an existing @option{-march=} or @option{-mcpu} option.
+
@end table
@end table
+2017-11-17 Tamar Christina <tamar.christina@arm.com>
+
+ PR target/82641
+ * gcc.target/arm/pragma_arch_attribute.c: New.
+
2017-11-17 Segher Boessenkool <segher@kernel.crashing.org>
* gcc.target/powerpc/altivec-macros.c: Include "-:" in the messages
--- /dev/null
+/* Test for #pragma target macros. */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
+/* { dg-add-options arm_arch_v8a } */
+
+#include <arm_acle.h>
+
+#ifdef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is already defined."
+#endif
+
+#pragma GCC push_options
+#pragma GCC target ("arch=armv8-a+crc")
+#ifndef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is not defined in push 1."
+#endif
+#pragma GCC pop_options
+
+#ifdef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is defined after pop 1."
+#endif
+
+#pragma GCC push_options
+#pragma GCC target ("+crc")
+#ifndef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is not defined in push 2."
+#endif
+#pragma GCC pop_options
+
+#ifdef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is defined after pop 2."
+#endif
+
+__attribute__((target("+crc")))
+void test_crc_unknown_ok_attr_1 ()
+{
+ __crc32b (0, 0);
+}
+
+#ifdef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is defined after attribute set 1."
+#endif
+
+__attribute__((target("arch=armv8-a+crc")))
+void test_crc_unknown_ok_attr_2 ()
+{
+ __crc32b (0, 0);
+}
+
+#ifdef __ARM_FEATURE_CRC32
+# error "__ARM_FEATURE_CRC32 is defined after attribute set 2."
+#endif
+
+#pragma GCC reset_options
\ No newline at end of file