[gas,arm] Make .fpu reset the FPU/Coprocessor feature bits

Message ID 5dc944c8.1c69fb81.726a8.eb21SMTPIN_ADDED_MISSING@mx.google.com
State New
Headers show
Series
  • [gas,arm] Make .fpu reset the FPU/Coprocessor feature bits
Related show

Commit Message

Mihail Ionescu Nov. 8, 2019, 4:51 p.m.
Hi,

This patch is fixes the '.fpu' behaviour.
Currently, using '.fpu' resets the previously selected '.fpu' options (by overwriting them),
but does not reset previous FPU options selected by other means (ie. when using
'.arch_extension fp' in conjunction with '.fpu <x>', the FPU is not reset).

Example:
.arch armv8-a         @ SET BASE
.arch_extension fp    @ ADD FP-ARMV8
.fpu vfpv2            @ ADD (already existing bits, does not reset)
vfms.f32 s0, s1, s2   @ OK

.arch armv8-a         @ RESET
.fpu fp-armv8         @ ADD FP-ARMV8
vfms.f32 s0, s1, s2   @ OK
.fpu vfpv2            @ RESET to VFPV2
vfms.f32 s0, s1, s2   @ ERROR

After the patch this becomes:
.arch armv8-a         @ SET BASE
.arch_extension fp    @ ADD FP-ARMV8
.fpu vfpv2            @ RESET TO VFPV2
vfms.f32 s0, s1, s2   @ ERROR

.arch armv8-a         @ RESET
.fpu fp-armv8         @ ADD FP-ARMV8
vfms.f32 s0, s1, s2   @ OK
.fpu vfpv2            @ RESET to VFPV2
vfms.f32 s0, s1, s2   @ ERROR



gas/ChangeLog:

2019-11-11  Mihail Ionescu  <mihail.ionescu@arm.com>

	* config/tc-arm.c (s_arm_fpu): Clear selected_cpu fpu bits.
	(fpu_any): Remove OBJ_ELF guards.
	* gas/testsuite/gas/arm/fpu-rst.s: New.
	* gas/testsuite/gas/arm/fpu-rst.d: New.
	* gas/testsuite/gas/arm/fpu-rst.l: New.

Regression tested on arm-none-elf.

Is it ok for trunk?

Regards,
Mihail


###############     Attachment also inlined for ease of reply    ###############
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index edb559b19f91db9f11ce2a4f59bf779b3e7b14b7..76098e6b1b5cf8c5a7f3a2383dfbe4658cc7b6be 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -277,9 +277,7 @@ static const arm_feature_set arm_ext_predres =
   ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES);
 
 static const arm_feature_set arm_arch_any = ARM_ANY;
-#ifdef OBJ_ELF
 static const arm_feature_set fpu_any = FPU_ANY;
-#endif
 static const arm_feature_set arm_arch_full ATTRIBUTE_UNUSED = ARM_FEATURE (-1, -1, -1);
 static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2;
 static const arm_feature_set arm_arch_none = ARM_ARCH_NONE;
@@ -32474,6 +32472,7 @@ s_arm_fpu (int ignored ATTRIBUTE_UNUSED)
     if (streq (opt->name, name))
       {
 	selected_fpu = opt->value;
+	ARM_CLEAR_FEATURE (selected_cpu, selected_cpu, fpu_any);
 #ifndef CPU_DEFAULT
 	if (no_cpu_selected ())
 	  ARM_MERGE_FEATURE_SETS (cpu_variant, arm_arch_any, selected_fpu);
diff --git a/gas/testsuite/gas/arm/fpu-rst.d b/gas/testsuite/gas/arm/fpu-rst.d
new file mode 100644
index 0000000000000000000000000000000000000000..9b5451b042b8c930c710bfd42773f2e5081dade9
--- /dev/null
+++ b/gas/testsuite/gas/arm/fpu-rst.d
@@ -0,0 +1,2 @@
+#name: arm FPU reset test
+#error_output: fpu-rst.l
diff --git a/gas/testsuite/gas/arm/fpu-rst.l b/gas/testsuite/gas/arm/fpu-rst.l
new file mode 100644
index 0000000000000000000000000000000000000000..c3cb2433d531cc2d4956ff3f88c636b82c976ced
--- /dev/null
+++ b/gas/testsuite/gas/arm/fpu-rst.l
@@ -0,0 +1,4 @@
+[^:]*: Assembler messages:
+[^:]*:8: Error: selected processor does not support `vfms.f32 s0,s1,s2' in ARM mode
+[^:]*:11: Error: selected processor does not support `vfms.f32 s0,s1,s2' in ARM mode
+[^:]*:17: Error: selected processor does not support `vfms.f32 s0,s1,s2' in ARM mode
diff --git a/gas/testsuite/gas/arm/fpu-rst.s b/gas/testsuite/gas/arm/fpu-rst.s
new file mode 100644
index 0000000000000000000000000000000000000000..26ae832dd22eb9711e871a6d50b9848c7421f60b
--- /dev/null
+++ b/gas/testsuite/gas/arm/fpu-rst.s
@@ -0,0 +1,17 @@
+.syntax unified
+.text
+.arch armv8-a         @ SET BASE
+.arch_extension fp    @ ADD FP-ARMV8
+vfms.f32 s0, s1, s2   @ OK
+
+.arch armv8-a         @ RESET
+vfms.f32 s0, s1, s2   @ ERROR
+
+.fpu vfpv2            @ SET VFPV2
+vfms.f32 s0, s1, s2   @ ERROR
+
+.arch armv8-a         @ RESET
+.fpu fp-armv8         @ ADD FP-ARMV8
+vfms.f32 s0, s1, s2   @ OK
+.fpu vfpv2            @ RESET to VFPV2
+vfms.f32 s0, s1, s2   @ ERROR

Patch

diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index edb559b19f91db9f11ce2a4f59bf779b3e7b14b7..76098e6b1b5cf8c5a7f3a2383dfbe4658cc7b6be 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -277,9 +277,7 @@  static const arm_feature_set arm_ext_predres =
   ARM_FEATURE_CORE_HIGH (ARM_EXT2_PREDRES);
 
 static const arm_feature_set arm_arch_any = ARM_ANY;
-#ifdef OBJ_ELF
 static const arm_feature_set fpu_any = FPU_ANY;
-#endif
 static const arm_feature_set arm_arch_full ATTRIBUTE_UNUSED = ARM_FEATURE (-1, -1, -1);
 static const arm_feature_set arm_arch_t2 = ARM_ARCH_THUMB2;
 static const arm_feature_set arm_arch_none = ARM_ARCH_NONE;
@@ -32474,6 +32472,7 @@  s_arm_fpu (int ignored ATTRIBUTE_UNUSED)
     if (streq (opt->name, name))
       {
 	selected_fpu = opt->value;
+	ARM_CLEAR_FEATURE (selected_cpu, selected_cpu, fpu_any);
 #ifndef CPU_DEFAULT
 	if (no_cpu_selected ())
 	  ARM_MERGE_FEATURE_SETS (cpu_variant, arm_arch_any, selected_fpu);
diff --git a/gas/testsuite/gas/arm/fpu-rst.d b/gas/testsuite/gas/arm/fpu-rst.d
new file mode 100644
index 0000000000000000000000000000000000000000..9b5451b042b8c930c710bfd42773f2e5081dade9
--- /dev/null
+++ b/gas/testsuite/gas/arm/fpu-rst.d
@@ -0,0 +1,2 @@ 
+#name: arm FPU reset test
+#error_output: fpu-rst.l
diff --git a/gas/testsuite/gas/arm/fpu-rst.l b/gas/testsuite/gas/arm/fpu-rst.l
new file mode 100644
index 0000000000000000000000000000000000000000..c3cb2433d531cc2d4956ff3f88c636b82c976ced
--- /dev/null
+++ b/gas/testsuite/gas/arm/fpu-rst.l
@@ -0,0 +1,4 @@ 
+[^:]*: Assembler messages:
+[^:]*:8: Error: selected processor does not support `vfms.f32 s0,s1,s2' in ARM mode
+[^:]*:11: Error: selected processor does not support `vfms.f32 s0,s1,s2' in ARM mode
+[^:]*:17: Error: selected processor does not support `vfms.f32 s0,s1,s2' in ARM mode
diff --git a/gas/testsuite/gas/arm/fpu-rst.s b/gas/testsuite/gas/arm/fpu-rst.s
new file mode 100644
index 0000000000000000000000000000000000000000..26ae832dd22eb9711e871a6d50b9848c7421f60b
--- /dev/null
+++ b/gas/testsuite/gas/arm/fpu-rst.s
@@ -0,0 +1,17 @@ 
+.syntax unified
+.text
+.arch armv8-a         @ SET BASE
+.arch_extension fp    @ ADD FP-ARMV8
+vfms.f32 s0, s1, s2   @ OK
+
+.arch armv8-a         @ RESET
+vfms.f32 s0, s1, s2   @ ERROR
+
+.fpu vfpv2            @ SET VFPV2
+vfms.f32 s0, s1, s2   @ ERROR
+
+.arch armv8-a         @ RESET
+.fpu fp-armv8         @ ADD FP-ARMV8
+vfms.f32 s0, s1, s2   @ OK
+.fpu vfpv2            @ RESET to VFPV2
+vfms.f32 s0, s1, s2   @ ERROR