]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V/zfh: Support .float16 directive for assembler.
authorNelson Chu <nelson.chu@sifive.com>
Tue, 21 Apr 2020 06:42:20 +0000 (14:42 +0800)
committerNelson Chu <nelson.chu@sifive.com>
Thu, 22 Jul 2021 09:24:52 +0000 (17:24 +0800)
This probably need to be sent to mainline rather than here.

gas/
    * config/tc-riscv.c (FLT_CHARS): Added h and H.
    (riscv_pseudo_table): Added .float16.
    * read.c (hex_float): Handle case 'h' and 'H'.
    * testsuite/gas/riscv/extended/extended.exp: Updated.
    * testsuite/gas/riscv/extended/float16.d: New testcase.
    * testsuite/gas/riscv/extended/float16.s: Likewise.

gas/config/tc-riscv.c
gas/read.c
gas/testsuite/gas/riscv/extended/extended.exp
gas/testsuite/gas/riscv/extended/float16.d [new file with mode: 0644]
gas/testsuite/gas/riscv/extended/float16.s [new file with mode: 0644]

index 2ec97b83cffbf19204e212bb5b25b9a70861509d..1661397c6ecfdcb7d0302f856fccfb9c40eeaea3 100644 (file)
@@ -597,7 +597,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[] = "rRsSfFdDxXpP";
+const char FLT_CHARS[] = "rRsSfFdDxXpPhH";
 
 /* Indicate we are already assemble any instructions or not.  */
 static bool start_assemble = false;
@@ -4571,6 +4571,7 @@ static const pseudo_typeS riscv_pseudo_table[] =
   {"sleb128", s_riscv_leb128, 1},
   {"insn", s_riscv_insn, 0},
   {"attribute", s_riscv_attribute, 0},
+  {"float16", float_cons, 'h'},
 
   { NULL, NULL, 0 },
 };
index 935b1fa7bde655542a64f1646f951d315c236c59..5c7c7399caa866117152c29cc291133ee7e6027a 100644 (file)
@@ -4824,6 +4824,11 @@ hex_float (int float_type, char *bytes)
 
   switch (float_type)
     {
+    case 'h':
+    case 'H':
+      length = 2;
+      break;
+
     case 'f':
     case 'F':
     case 's':
index 3ad8833ea84e5eff00e1317f376be4e1849a8ae6..2b36cc548cc3fcc5a155203128b98e52cb94e172 100644 (file)
@@ -32,6 +32,7 @@ if [istarget riscv*-*-*] {
     run_dump_tests "vector-insns-fail-permutation"
     run_dump_tests "vector-insns-fail-zvamo"
     run_dump_tests "fp-zfh-insns"
+    run_dump_tests "float16"
 
     run_dump_tests "extended-csr"
 }
diff --git a/gas/testsuite/gas/riscv/extended/float16.d b/gas/testsuite/gas/riscv/extended/float16.d
new file mode 100644 (file)
index 0000000..e75971d
--- /dev/null
@@ -0,0 +1,10 @@
+# source: float16.s
+# objdump: -sj .data
+# as:
+
+.*:[   ]+file format .*
+
+Contents of section \.data:
+ 0000 004adf2f 191cff7b 0100ff03 0004003c.*
+ 0010 013cff7f 007c00fc 00000080 00bce7bb.*
+ 0020 fffb0042 004a3e60 007e017e.*
diff --git a/gas/testsuite/gas/riscv/extended/float16.s b/gas/testsuite/gas/riscv/extended/float16.s
new file mode 100644 (file)
index 0000000..709ea0a
--- /dev/null
@@ -0,0 +1,21 @@
+.data
+       .float16 12.0
+       .float16 0.123
+       .float16 0.004
+       .float16 65504
+       .float16 5.9605e-8
+       .float16 6.0976e-5
+       .float16 6.1035e-5
+       .float16 1
+       .float16 1.001
+       .float16 NaN
+       .float16 +Inf
+       .float16 -Inf
+       .float16 +0
+       .float16 -0
+       .float16 -1
+       .float16 -0.98765
+       .float16 -65504
+       .float16 3.0, 12.0, 543.123
+       .float16 0h:7e00        # qNaNh
+       .float16 0h:7e01        # sNaNh