Skip to content

Commit 8e671c4

Browse files
committed
RISC-V: Tentative ".bfloat16" assembly support
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.
1 parent d977fb3 commit 8e671c4

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

gas/config/tc-riscv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ const char EXP_CHARS[] = "eE";
437437

438438
/* Chars that mean this number is a floating point constant.
439439
As in 0f12.456 or 0d1.2345e12. */
440-
const char FLT_CHARS[] = "rRsSfFdDxXpPhH";
440+
const char FLT_CHARS[] = "rRsSfFdDxXpPhHb";
441441

442442
/* Indicate we are already assemble any instructions or not. */
443443
static bool start_assemble = false;
@@ -5178,6 +5178,7 @@ static const pseudo_typeS riscv_pseudo_table[] =
51785178
{"attribute", s_riscv_attribute, 0},
51795179
{"variant_cc", s_variant_cc, 0},
51805180
{"float16", float_cons, 'h'},
5181+
{"bfloat16", float_cons, 'b'},
51815182

51825183
{ NULL, NULL, 0 },
51835184
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# source: bfloat16.s
2+
# objdump: -sj .data
3+
# as: -mbig-endian
4+
5+
.*: +file format .*
6+
7+
Contents of section \.data:
8+
0000 41403dfc 000042f7 8000c2f7 7fff7f80 .*
9+
0010 ff807f7f ff7f0080 80800001 8001007f .*
10+
0020 807f3f80 bf804000 c000.*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# source: bfloat16.s
2+
# objdump: -sj .data
3+
# as: -mlittle-endian
4+
5+
.*: +file format .*
6+
7+
Contents of section \.data:
8+
0000 4041fc3d 0000f742 0080f7c2 ff7f807f .*
9+
0010 80ff7f7f 7fff8000 80800100 01807f00 .*
10+
0020 7f80803f 80bf0040 00c0.*

gas/testsuite/gas/riscv/bfloat16.s

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.data
2+
.bfloat16 12.0
3+
.bfloat16 0.123
4+
.bfloat16 +0.0
5+
.bfloat16 123.4
6+
.bfloat16 -0.0
7+
.bfloat16 -123.4
8+
.bfloat16 NaN
9+
.bfloat16 Inf
10+
.bfloat16 -Inf
11+
.bfloat16 3.390e+38
12+
.bfloat16 -3.390e+38
13+
.bfloat16 1.175e-38
14+
.bfloat16 -1.175e-38
15+
.bfloat16 9.194e-41
16+
.bfloat16 -9.194e-41
17+
.bfloat16 1.167e-38
18+
.bfloat16 -1.167e-38
19+
.bfloat16 1.0, -1, 2.0, -2

0 commit comments

Comments
 (0)