[ARM] Rework selection of feature bits to base build attributes on
=== Context === This patch is part of a patch series to add support for ARMv8-R architecture. Its purpose is to set the feature bits on which to decide what the build attributes should be according to the mode (autodetection, user specified architecture or CPU, or -march/-mcpu=all). === Motivation === Currently, the flags variable which is used to determine the build attribute is constructed from the instruction used (arm_arch_used and thumb_arch_used) as well as the user specified architecture or CPU (selected_cpu). This means when several .arch are specified the resulting feature bits can be such that no architecture provide them all and can thus result in incorrect Tag_CPU_arch. See for instance what having both .arch armv8-a and .arch armv8-m.base would result in. This is not caught by the testsuite because of further bugs in the Tag_CPU_arch build attribute value selection logic (see next patch in the series). === Patch description === As one would expect, this patch solves the problem by setting flags from feature bits used if in autodetection mode [1] and from selected_cpu otherwise. The logic to set arm_ext_v1, arm_ext_v4t and arm_ext_os feature bits is also moved to only run in autodetection mode since otherwise the architecture or CPU would have a consistent set of feature bits already. [1] No architecture or CPU was specified by the user 2017-06-21 Thomas Preud'homme <thomas.preudhomme@arm.com> gas/ * config/tc-arm.c (aeabi_set_public_attributes): Populate flags from feature bits used or selected_cpu depending on whether a CPU was selected by the user.
This commit is contained in:
parent
bdab445c82
commit
54bab2816d
|
@ -1,3 +1,9 @@
|
||||||
|
2017-06-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||||
|
|
||||||
|
* config/tc-arm.c (aeabi_set_public_attributes): Populate flags from
|
||||||
|
feature bits used or selected_cpu depending on whether a CPU was
|
||||||
|
selected by the user.
|
||||||
|
|
||||||
2017-06-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
2017-06-21 Thomas Preud'homme <thomas.preudhomme@arm.com>
|
||||||
|
|
||||||
* config/tc-arm.c (aeabi_set_public_attributes): Test *mcpu_ext_opt to
|
* config/tc-arm.c (aeabi_set_public_attributes): Test *mcpu_ext_opt to
|
||||||
|
|
|
@ -26605,11 +26605,11 @@ aeabi_set_public_attributes (void)
|
||||||
arm_feature_set arm_arch_v8m_base = ARM_ARCH_V8M_BASE;
|
arm_feature_set arm_arch_v8m_base = ARM_ARCH_V8M_BASE;
|
||||||
const cpu_arch_ver_table *p;
|
const cpu_arch_ver_table *p;
|
||||||
|
|
||||||
/* Choose the architecture based on the capabilities of the requested cpu
|
/* Autodetection mode, choose the architecture based the instructions
|
||||||
(if any) and/or the instructions actually used. */
|
actually used. */
|
||||||
|
if (no_cpu_selected ())
|
||||||
|
{
|
||||||
ARM_MERGE_FEATURE_SETS (flags, arm_arch_used, thumb_arch_used);
|
ARM_MERGE_FEATURE_SETS (flags, arm_arch_used, thumb_arch_used);
|
||||||
ARM_MERGE_FEATURE_SETS (flags, flags, *mfpu_opt);
|
|
||||||
ARM_MERGE_FEATURE_SETS (flags, flags, selected_cpu);
|
|
||||||
|
|
||||||
if (ARM_CPU_HAS_FEATURE (arm_arch_used, arm_arch_any))
|
if (ARM_CPU_HAS_FEATURE (arm_arch_used, arm_arch_any))
|
||||||
ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v1);
|
ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v1);
|
||||||
|
@ -26617,7 +26617,21 @@ aeabi_set_public_attributes (void)
|
||||||
if (ARM_CPU_HAS_FEATURE (thumb_arch_used, arm_arch_any))
|
if (ARM_CPU_HAS_FEATURE (thumb_arch_used, arm_arch_any))
|
||||||
ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v4t);
|
ARM_MERGE_FEATURE_SETS (flags, flags, arm_ext_v4t);
|
||||||
|
|
||||||
|
/* We need to make sure that the attributes do not identify us as v6S-M
|
||||||
|
when the only v6S-M feature in use is the Operating System
|
||||||
|
Extensions. */
|
||||||
|
if (ARM_CPU_HAS_FEATURE (flags, arm_ext_os))
|
||||||
|
if (!ARM_CPU_HAS_FEATURE (flags, arm_arch_v6m_only))
|
||||||
|
ARM_CLEAR_FEATURE (flags, flags, arm_ext_os);
|
||||||
|
|
||||||
|
/* Code run during relaxation relies on selected_cpu being set. */
|
||||||
selected_cpu = flags;
|
selected_cpu = flags;
|
||||||
|
}
|
||||||
|
/* Otherwise, choose the architecture based on the capabilities of the
|
||||||
|
requested cpu. */
|
||||||
|
else
|
||||||
|
flags = selected_cpu;
|
||||||
|
ARM_MERGE_FEATURE_SETS (flags, flags, *mfpu_opt);
|
||||||
|
|
||||||
/* Allow the user to override the reported architecture. */
|
/* Allow the user to override the reported architecture. */
|
||||||
if (object_arch)
|
if (object_arch)
|
||||||
|
@ -26626,12 +26640,6 @@ aeabi_set_public_attributes (void)
|
||||||
ARM_MERGE_FEATURE_SETS (flags, flags, *object_arch);
|
ARM_MERGE_FEATURE_SETS (flags, flags, *object_arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We need to make sure that the attributes do not identify us as v6S-M
|
|
||||||
when the only v6S-M feature in use is the Operating System Extensions. */
|
|
||||||
if (ARM_CPU_HAS_FEATURE (flags, arm_ext_os))
|
|
||||||
if (!ARM_CPU_HAS_FEATURE (flags, arm_arch_v6m_only))
|
|
||||||
ARM_CLEAR_FEATURE (flags, flags, arm_ext_os);
|
|
||||||
|
|
||||||
tmp = flags;
|
tmp = flags;
|
||||||
arch = 0;
|
arch = 0;
|
||||||
for (p = cpu_arch_ver; p->val; p++)
|
for (p = cpu_arch_ver; p->val; p++)
|
||||||
|
|
Loading…
Reference in New Issue