0029-RISC-V-Support-.float16-directive-for-assembler.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. From d1f2bc0a3f745ba7f49d2576300c7c000c5728ef Mon Sep 17 00:00:00 2001
  2. From: Nelson Chu <nelson.chu@sifive.com>
  3. Date: Tue, 21 Apr 2020 14:42:20 +0800
  4. Subject: [PATCH 29/48] RISC-V: Support .float16 directive for assembler.
  5. ---
  6. gas/config/tc-riscv.c | 3 ++-
  7. gas/read.c | 5 +++++
  8. gas/testsuite/gas/riscv/float16.d | 10 ++++++++++
  9. gas/testsuite/gas/riscv/float16.s | 21 +++++++++++++++++++++
  10. 4 files changed, 38 insertions(+), 1 deletion(-)
  11. create mode 100644 gas/testsuite/gas/riscv/float16.d
  12. create mode 100644 gas/testsuite/gas/riscv/float16.s
  13. diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
  14. index bb2819db4a..57d2908fcd 100644
  15. --- a/gas/config/tc-riscv.c
  16. +++ b/gas/config/tc-riscv.c
  17. @@ -362,7 +362,7 @@ const char EXP_CHARS[] = "eE";
  18. /* Chars that mean this number is a floating point constant */
  19. /* As in 0f12.456 */
  20. /* or 0d1.2345e12 */
  21. -const char FLT_CHARS[] = "rRsSfFdDxXpP";
  22. +const char FLT_CHARS[] = "rRsSfFdDxXpPhH";
  23. /* Indicate we are already assemble any instructions or not. */
  24. static bfd_boolean start_assemble = FALSE;
  25. @@ -4182,6 +4182,7 @@ static const pseudo_typeS riscv_pseudo_table[] =
  26. {"sleb128", s_riscv_leb128, 1},
  27. {"insn", s_riscv_insn, 0},
  28. {"attribute", s_riscv_attribute, 0},
  29. + {"float16", float_cons, 'h'},
  30. { NULL, NULL, 0 },
  31. };
  32. diff --git a/gas/read.c b/gas/read.c
  33. index cd06ea51d9..c549629268 100644
  34. --- a/gas/read.c
  35. +++ b/gas/read.c
  36. @@ -4763,6 +4763,11 @@ hex_float (int float_type, char *bytes)
  37. switch (float_type)
  38. {
  39. + case 'h':
  40. + case 'H':
  41. + length = 2;
  42. + break;
  43. +
  44. case 'f':
  45. case 'F':
  46. case 's':
  47. diff --git a/gas/testsuite/gas/riscv/float16.d b/gas/testsuite/gas/riscv/float16.d
  48. new file mode 100644
  49. index 0000000000..e75971d941
  50. --- /dev/null
  51. +++ b/gas/testsuite/gas/riscv/float16.d
  52. @@ -0,0 +1,10 @@
  53. +# source: float16.s
  54. +# objdump: -sj .data
  55. +# as:
  56. +
  57. +.*:[ ]+file format .*
  58. +
  59. +Contents of section \.data:
  60. + 0000 004adf2f 191cff7b 0100ff03 0004003c.*
  61. + 0010 013cff7f 007c00fc 00000080 00bce7bb.*
  62. + 0020 fffb0042 004a3e60 007e017e.*
  63. diff --git a/gas/testsuite/gas/riscv/float16.s b/gas/testsuite/gas/riscv/float16.s
  64. new file mode 100644
  65. index 0000000000..709ea0af7c
  66. --- /dev/null
  67. +++ b/gas/testsuite/gas/riscv/float16.s
  68. @@ -0,0 +1,21 @@
  69. +.data
  70. + .float16 12.0
  71. + .float16 0.123
  72. + .float16 0.004
  73. + .float16 65504
  74. + .float16 5.9605e-8
  75. + .float16 6.0976e-5
  76. + .float16 6.1035e-5
  77. + .float16 1
  78. + .float16 1.001
  79. + .float16 NaN
  80. + .float16 +Inf
  81. + .float16 -Inf
  82. + .float16 +0
  83. + .float16 -0
  84. + .float16 -1
  85. + .float16 -0.98765
  86. + .float16 -65504
  87. + .float16 3.0, 12.0, 543.123
  88. + .float16 0h:7e00 # qNaNh
  89. + .float16 0h:7e01 # sNaNh
  90. --
  91. 2.33.0