]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
arm: redirect fp constant data directives through a wrapper
authorRichard Earnshaw <rearnsha@arm.com>
Tue, 4 Jun 2024 11:56:22 +0000 (12:56 +0100)
committerRichard Earnshaw <rearnsha@arm.com>
Wed, 5 Jun 2024 16:45:45 +0000 (17:45 +0100)
Assembler directives such as .float, or .double are handled by generic
code, but on Arm, their output can vary depeding on the type of FPU
begin targetted.  When we remove FPA support we don't want to silently
generate different code for processors that previously defaulted to
the FPA, so redirect these directives through a wrapper function that
checks the FPU is enabled; we use the legacy -mno-fpu in the test to
catch this.

Also fix a few tests so that they won't start to fail on targets (eg
arm-wince-pe) where there is no default format for the FPU and we pick
this from the default processor type.

12 files changed:
gas/config/tc-arm.c
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/arm/bfloat16-directive-be.d
gas/testsuite/gas/arm/bfloat16-directive-le.d
gas/testsuite/gas/arm/float16-bad.d
gas/testsuite/gas/arm/float16-be.d
gas/testsuite/gas/arm/float16-format-opt-bad.d
gas/testsuite/gas/arm/float16-le.d
gas/testsuite/gas/arm/fp-directive-bad.d [new file with mode: 0644]
gas/testsuite/gas/arm/fp-directive-bad.l [new file with mode: 0644]
gas/testsuite/gas/arm/fp-directive.d [new file with mode: 0644]
gas/testsuite/gas/arm/fp-directive.s [new file with mode: 0644]

index 9294619e1a44c295d1d268458f0a6214319f1534..1ba7bb31ac519d92ea31eb6236b8fb3cdd530415 100644 (file)
@@ -5148,6 +5148,14 @@ set_fp16_format (int dummy ATTRIBUTE_UNUSED)
   ignore_rest_of_line ();
 }
 
+static void s_arm_float_cons (int float_type)
+{
+  /* We still parse the directive on error, so that any syntactic issues
+     are picked up.  */
+  if (ARM_FEATURE_ZERO (selected_fpu))
+    as_bad (_("the floating-point format has not been set (or has been disabled)"));
+  float_cons (float_type);
+}
 /* This table describes all the machine specific pseudo-ops the assembler
    has to support.  The fields are:
      pseudo-op name without dot
@@ -5212,10 +5220,17 @@ const pseudo_typeS md_pseudo_table[] =
   { "loc",  dwarf2_directive_loc,  0 },
   { "loc_mark_labels", dwarf2_directive_loc_mark_labels, 0 },
 #endif
-  { "extend",     float_cons, 'x' },
-  { "ldouble",    float_cons, 'x' },
-  { "packed",     float_cons, 'p' },
-  { "bfloat16",           float_cons, 'b' },
+  /* Override the default float_cons handling so that we can validate
+     the FPU setting.  */
+  { "float",      s_arm_float_cons, 'f' },
+  { "single",     s_arm_float_cons, 'f' },
+  { "double",     s_arm_float_cons, 'd' },
+  { "dc.s",       s_arm_float_cons, 'f' },
+  { "dc.d",       s_arm_float_cons, 'd' },
+  { "extend",     s_arm_float_cons, 'x' },
+  { "ldouble",    s_arm_float_cons, 'x' },
+  { "packed",     s_arm_float_cons, 'p' },
+  { "bfloat16",           s_arm_float_cons, 'b' },
 #ifdef TE_PE
   {"secrel32", pe_directive_secrel, 0},
 #endif
@@ -5226,7 +5241,7 @@ const pseudo_typeS md_pseudo_table[] =
   {"asmfunc",      s_ccs_asmfunc,    0},
   {"endasmfunc",   s_ccs_endasmfunc, 0},
 
-  {"float16", float_cons, 'h' },
+  {"float16", s_arm_float_cons, 'h' },
   {"float16_format", set_fp16_format, 0 },
 
   { 0, 0, 0 }
index b9ff43997cbe0a6cd6dbc35145c7a7e6f6cf3fef..af461b1988d5e415a5860e0cb192f1a72ff67603 100644 (file)
@@ -47,6 +47,8 @@ if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
      && ![istarget z80-*-*] } then {
     if { [istarget tic4x-*-*] } then {
        set as_opt ""
+    } elseif { [istarget arm*-*-pe ] } then {
+       set as_opt "--defsym hasnan=1 -mfpu=softvfp"
     } else {
        set as_opt "--defsym hasnan=1"
     }
index 8862f8302f7f101715a032614c1a6d2c4e3cf5a9..44eadb33194a297d81c023d8ef6adf5d2fdb6326 100644 (file)
@@ -1,7 +1,7 @@
 # name: Big endian bfloat16 literal directives
 # source: bfloat16-directive.s
 # objdump: -s --section=.data
-# as: -mbig-endian
+# as: -mbig-endian -mfpu=softvfp
 
 .*: +file format .*
 
index da94b6b254c5b7889b0690535bea464e8c83bbf9..c595d8b065af045949f0014250c06ce9b45550e6 100644 (file)
@@ -1,7 +1,7 @@
 # name: Little endian bfloat16 literal directives
 # source: bfloat16-directive.s
 # objdump: -s --section=.data
-# as: -mlittle-endian
+# as: -mlittle-endian -mfpu=softvfp
 
 .*: +file format .*
 
index 8eac0af5cbb8671e61f18939d723599db4f948a6..604bb20adaffb97e741603dd76b96e8ce339b8b3 100644 (file)
@@ -1,3 +1,4 @@
 # name: Invalid float16 literals (IEEE 754 & Alternative)
 # source: float16-bad.s
 # error_output: float16-bad.l
+# as: -mfpu=softvfp
index e31d9fbf432ca7e8f30896acb90184e4ebe949cd..b63d6cd49d51c89963b7c64b1131db22d324ca00 100644 (file)
@@ -1,7 +1,7 @@
 # name: Big endian float16 literals (IEEE 754 & Alternative)
 # source: float16.s
 # objdump: -s --section=.data
-# as: -mbig-endian
+# as: -mbig-endian -mfpu=softvfp
 
 .*: +file format .*arm.*
 
index 861125800da501da31681b5fd4621a76eca1585f..af8cca48956eaceaad0524dff369b7aa56b01271 100644 (file)
@@ -1,4 +1,4 @@
 # name: Invalid combination of command line arguments and directives
 # source: float16.s
 # error_output: float16-format-opt-bad.l
-# as: -mfp16-format=ieee
+# as: -mfpu=softvfp -mfp16-format=ieee
index c1fe7c20dc6dfe1dd6f4e27d9fa2186676488c59..abbf09202be7461305fc780c4ddd23d9136ea10f 100644 (file)
@@ -1,7 +1,7 @@
 # name: Little endian float16 literals (IEEE 754 & Alternative)
 # source: float16.s
 # objdump: -s --section=.data
-# as: -mlittle-endian
+# as: -mlittle-endian -mfpu=softvfp
 
 .*: +file format .*arm.*
 
diff --git a/gas/testsuite/gas/arm/fp-directive-bad.d b/gas/testsuite/gas/arm/fp-directive-bad.d
new file mode 100644 (file)
index 0000000..dfa01e6
--- /dev/null
@@ -0,0 +1,4 @@
+#name: floating-point directives disabled
+#source: fp-directive.s
+#as: -mno-warn-deprecated -mno-fpu
+#error_output: fp-directive-bad.l
\ No newline at end of file
diff --git a/gas/testsuite/gas/arm/fp-directive-bad.l b/gas/testsuite/gas/arm/fp-directive-bad.l
new file mode 100644 (file)
index 0000000..263cc9e
--- /dev/null
@@ -0,0 +1,7 @@
+[^:]*: Assembler messages:
+[^:]*:2: Error: the floating-point format has not been set \(or has been disabled\)
+[^:]*:3: Error: the floating-point format has not been set \(or has been disabled\)
+[^:]*:4: Error: the floating-point format has not been set \(or has been disabled\)
+[^:]*:5: Error: the floating-point format has not been set \(or has been disabled\)
+[^:]*:6: Error: the floating-point format has not been set \(or has been disabled\)
+[^:]*:7: Error: the floating-point format has not been set \(or has been disabled\)
diff --git a/gas/testsuite/gas/arm/fp-directive.d b/gas/testsuite/gas/arm/fp-directive.d
new file mode 100644 (file)
index 0000000..46ff9e9
--- /dev/null
@@ -0,0 +1,9 @@
+#name: floating-point directives
+#objdump: -s --section=.data
+#as: -mfpu=softvfp
+
+.*: +file format .*arm.*
+
+Contents of section \.data:
+ 0000 .*
+ 0010 .*
diff --git a/gas/testsuite/gas/arm/fp-directive.s b/gas/testsuite/gas/arm/fp-directive.s
new file mode 100644 (file)
index 0000000..c6fc227
--- /dev/null
@@ -0,0 +1,7 @@
+       .data
+       .float 1.0
+       .double 2.0
+       .single 3.0
+       .dc.s 5.3
+       .dc.d 6
+       .float16 4.0