[REVIEW ONLY 4/4] RISC-V: Tentative ".bfloat16" assembly support
Tsukasa OI
research_trasio@irq.a4lg.com
Thu Aug 3 00:04:56 GMT 2023
From: Tsukasa OI <research_trasio@irq.a4lg.com>
This commit adds an assembler directive ".bfloat16" to help BFloat16
extensions ('Zfbfmin', 'Zvfbfmin' and 'Zvfbfwma') users.
gas/ChangeLog:
* config/tc-riscv.c (FLT_CHARS): Add BFloat16 'b' to supported
floating point formats.
(riscv_pseudo_table) Add ".bfloat16" directive.
* testsuite/gas/riscv/bfloat16.s: Copied from
testsuite/gas/aarch64/bfloat16-directive.s.
* testsuite/gas/riscv/bfloat16-be.d: New test ported from
testsuite/gas/aarch64/bfloat16-directive-be.d and float16-be.d.
* testsuite/gas/riscv/bfloat16-le.d: New test ported from
testsuite/gas/aarch64/bfloat16-directive-le.d and float16-le.d.
---
gas/config/tc-riscv.c | 3 ++-
gas/testsuite/gas/riscv/bfloat16-be.d | 10 ++++++++++
gas/testsuite/gas/riscv/bfloat16-le.d | 10 ++++++++++
gas/testsuite/gas/riscv/bfloat16.s | 19 +++++++++++++++++++
4 files changed, 41 insertions(+), 1 deletion(-)
create mode 100644 gas/testsuite/gas/riscv/bfloat16-be.d
create mode 100644 gas/testsuite/gas/riscv/bfloat16-le.d
create mode 100644 gas/testsuite/gas/riscv/bfloat16.s
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index aaf8b9be64fd..9f15233c7b99 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -437,7 +437,7 @@ const char EXP_CHARS[] = "eE";
/* Chars that mean this number is a floating point constant.
As in 0f12.456 or 0d1.2345e12. */
-const char FLT_CHARS[] = "rRsSfFdDxXpPhH";
+const char FLT_CHARS[] = "rRsSfFdDxXpPhHb";
/* Indicate we are already assemble any instructions or not. */
static bool start_assemble = false;
@@ -5178,6 +5178,7 @@ static const pseudo_typeS riscv_pseudo_table[] =
{"attribute", s_riscv_attribute, 0},
{"variant_cc", s_variant_cc, 0},
{"float16", float_cons, 'h'},
+ {"bfloat16", float_cons, 'b'},
{ NULL, NULL, 0 },
};
diff --git a/gas/testsuite/gas/riscv/bfloat16-be.d b/gas/testsuite/gas/riscv/bfloat16-be.d
new file mode 100644
index 000000000000..8775ab035f6c
--- /dev/null
+++ b/gas/testsuite/gas/riscv/bfloat16-be.d
@@ -0,0 +1,10 @@
+# source: bfloat16.s
+# objdump: -sj .data
+# as: -mbig-endian
+
+.*: +file format .*
+
+Contents of section \.data:
+ 0000 41403dfc 000042f7 8000c2f7 7fff7f80 .*
+ 0010 ff807f7f ff7f0080 80800001 8001007f .*
+ 0020 807f3f80 bf804000 c000.*
diff --git a/gas/testsuite/gas/riscv/bfloat16-le.d b/gas/testsuite/gas/riscv/bfloat16-le.d
new file mode 100644
index 000000000000..4de8b2fed68b
--- /dev/null
+++ b/gas/testsuite/gas/riscv/bfloat16-le.d
@@ -0,0 +1,10 @@
+# source: bfloat16.s
+# objdump: -sj .data
+# as: -mlittle-endian
+
+.*: +file format .*
+
+Contents of section \.data:
+ 0000 4041fc3d 0000f742 0080f7c2 ff7f807f .*
+ 0010 80ff7f7f 7fff8000 80800100 01807f00 .*
+ 0020 7f80803f 80bf0040 00c0.*
diff --git a/gas/testsuite/gas/riscv/bfloat16.s b/gas/testsuite/gas/riscv/bfloat16.s
new file mode 100644
index 000000000000..66e17e4fc7da
--- /dev/null
+++ b/gas/testsuite/gas/riscv/bfloat16.s
@@ -0,0 +1,19 @@
+.data
+ .bfloat16 12.0
+ .bfloat16 0.123
+ .bfloat16 +0.0
+ .bfloat16 123.4
+ .bfloat16 -0.0
+ .bfloat16 -123.4
+ .bfloat16 NaN
+ .bfloat16 Inf
+ .bfloat16 -Inf
+ .bfloat16 3.390e+38
+ .bfloat16 -3.390e+38
+ .bfloat16 1.175e-38
+ .bfloat16 -1.175e-38
+ .bfloat16 9.194e-41
+ .bfloat16 -9.194e-41
+ .bfloat16 1.167e-38
+ .bfloat16 -1.167e-38
+ .bfloat16 1.0, -1, 2.0, -2
--
2.41.0
More information about the Binutils
mailing list