diff --git a/gas/config/tc-arm.h b/gas/config/tc-arm.h index 39cc9680b96524c730c15fff1af22b180b9c70d1..8a73bebe6c5b5a027242d02f18b6d51273abcacb 100644 --- a/gas/config/tc-arm.h +++ b/gas/config/tc-arm.h @@ -385,3 +385,7 @@ extern char arm_line_separator_chars[]; #define TC_EQUAL_IN_INSN(c, s) arm_tc_equal_in_insn ((c), (s)) extern bfd_boolean arm_tc_equal_in_insn (int, char *); + +#define TC_LARGEST_EXPONENT_IS_NORMAL(PRECISION) \ + arm_is_largest_exponent_ok ((PRECISION)) +int arm_is_largest_exponent_ok (int precision); diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index b70028f7c2e31c179196b3c9ea9665fbf4b0159f..6176fea2bb523990d660fbcc39bc12007a459809 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -1037,7 +1037,7 @@ const char EXP_CHARS[] = "eE"; /* As in 0f12.456 */ /* or 0d1.2345e12 */ -const char FLT_CHARS[] = "rRsSfFdDxXeEpP"; +const char FLT_CHARS[] = "rRsSfFdDxXeEpPHh"; /* Prefix characters that indicate the start of an immediate value. */ @@ -1188,6 +1188,11 @@ md_atof (int type, char * litP, int * sizeP) switch (type) { + case 'H': + case 'h': + prec = 1; + break; + case 'f': case 'F': case 's': @@ -4925,6 +4930,21 @@ pe_directive_secrel (int dummy ATTRIBUTE_UNUSED) } #endif /* TE_PE */ +enum fp_16bit_format +{ + ARM_FP16_FORMAT_IEEE = 0x1, + ARM_FP16_FORMAT_ALTERNATIVE = 0x2 +}; + +int arm_is_largest_exponent_ok (int precision) +{ + const int fp16_format = bfd_elf_get_obj_attr_int (stdoutput, OBJ_ATTR_PROC, + Tag_ABI_FP_16bit_format); + + /* precision == 1 ensures that this will only return true for 16 bit floats. */ + return (precision == 1) && (fp16_format == ARM_FP16_FORMAT_ALTERNATIVE); +} + /* This table describes all the machine specific pseudo-ops the assembler has to support. The fields are: pseudo-op name without dot @@ -5002,9 +5022,11 @@ const pseudo_typeS md_pseudo_table[] = {"asmfunc", s_ccs_asmfunc, 0}, {"endasmfunc", s_ccs_endasmfunc, 0}, + {"float16", float_cons, 'h'}, + { 0, 0, 0 } }; - + /* Parser functions used exclusively in instruction operands. */ /* Generic immediate-value read function for use in insn parsing. diff --git a/gas/testsuite/gas/arm/float16-bad.d b/gas/testsuite/gas/arm/float16-bad.d new file mode 100644 index 0000000000000000000000000000000000000000..8eac0af5cbb8671e61f18939d723599db4f948a6 --- /dev/null +++ b/gas/testsuite/gas/arm/float16-bad.d @@ -0,0 +1,3 @@ +# name: Invalid float16 literals (IEEE 754 & Alternative) +# source: float16-bad.s +# error_output: float16-bad.l diff --git a/gas/testsuite/gas/arm/float16-bad.l b/gas/testsuite/gas/arm/float16-bad.l new file mode 100644 index 0000000000000000000000000000000000000000..83978b7571cac2644379d3ca1896f609ba87ce30 --- /dev/null +++ b/gas/testsuite/gas/arm/float16-bad.l @@ -0,0 +1,10 @@ +[^:]*: Assembler messages: +[^:]*:2: Error: cannot create floating-point number +[^:]*:3: Error: cannot create floating-point number +[^:]*:4: Error: cannot create floating-point number +[^:]*:7: Warning: NaNs are not supported by this target +[^:]*:8: Warning: NaNs are not supported by this target +[^:]*:9: Warning: NaNs are not supported by this target +[^:]*:11: Warning: Infinities are not supported by this target +[^:]*:12: Warning: Infinities are not supported by this target +[^:]*:13: Warning: Infinities are not supported by this target diff --git a/gas/testsuite/gas/arm/float16-bad.s b/gas/testsuite/gas/arm/float16-bad.s new file mode 100644 index 0000000000000000000000000000000000000000..cb97c605b8c7dd5bffbf4d13ced71d22124202ed --- /dev/null +++ b/gas/testsuite/gas/arm/float16-bad.s @@ -0,0 +1,13 @@ +.data + .float16 9999999999999.0 + .float16 -999999999999.0 + .float16 131008.0 + +.eabi_attribute Tag_ABI_FP_16bit_format, 2 + .float16 NaN + .float16 -NaN + .float16 +NaN + + .float16 Inf + .float16 -Inf + .float16 +Inf diff --git a/gas/testsuite/gas/arm/float16-be.d b/gas/testsuite/gas/arm/float16-be.d new file mode 100644 index 0000000000000000000000000000000000000000..214c7f7a6ceee423ee505ac38eada9f6c9cf0fbf --- /dev/null +++ b/gas/testsuite/gas/arm/float16-be.d @@ -0,0 +1,12 @@ +# name: Big endian float16 literals (IEEE 754 & Alternative) +# source: float16-be.s +# objdump: -s --section=.data +# as: -mbig-endian + +.*: +file format .*arm.* + +Contents of section \.data: + 0000 4a002fdf 1c197bff 000103ff 04003c00.* + 0010 3c017fff 7c00fc00 00008000 bc00bbe7.* + 0020 fbff4200 4a00603e 38567fff ffff7204.* + 0030 7fff7c00.* diff --git a/gas/testsuite/gas/arm/float16-be.s b/gas/testsuite/gas/arm/float16-be.s new file mode 100644 index 0000000000000000000000000000000000000000..0cdecbd7c971313e5963a6e158041400a899da8a --- /dev/null +++ b/gas/testsuite/gas/arm/float16-be.s @@ -0,0 +1,29 @@ +.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 + +.eabi_attribute Tag_ABI_FP_16bit_format, 2 + .float16 0.542 + .float16 131008.0 + .float16 -131008.0 + .float16 12323.1234 + +.eabi_attribute Tag_ABI_FP_16bit_format, 1 + .float16 NaN + .float16 Inf diff --git a/gas/testsuite/gas/arm/float16-le.d b/gas/testsuite/gas/arm/float16-le.d new file mode 100644 index 0000000000000000000000000000000000000000..0efb068c5b3a4f5deed3b5ecc9b9aceb08561163 --- /dev/null +++ b/gas/testsuite/gas/arm/float16-le.d @@ -0,0 +1,12 @@ +# name: Little endian float16 literals (IEEE 754 & Alternative) +# source: float16-le.s +# objdump: -s --section=.data +# as: -mlittle-endian + +.*: +file format .*arm.* + +Contents of section \.data: + 0000 004adf2f 191cff7b 0100ff03 0004003c.* + 0010 013cff7f 007c00fc 00000080 00bce7bb.* + 0020 fffb0042 004a3e60 5638ff7f ffff0472.* + 0030 ff7f007c.* diff --git a/gas/testsuite/gas/arm/float16-le.s b/gas/testsuite/gas/arm/float16-le.s new file mode 100644 index 0000000000000000000000000000000000000000..0cdecbd7c971313e5963a6e158041400a899da8a --- /dev/null +++ b/gas/testsuite/gas/arm/float16-le.s @@ -0,0 +1,29 @@ +.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 + +.eabi_attribute Tag_ABI_FP_16bit_format, 2 + .float16 0.542 + .float16 131008.0 + .float16 -131008.0 + .float16 12323.1234 + +.eabi_attribute Tag_ABI_FP_16bit_format, 1 + .float16 NaN + .float16 Inf