diff options
author | Matthew Malcomson <matthew.malcomson@arm.com> | 2019-11-07 17:07:32 +0000 |
---|---|---|
committer | Matthew Malcomson <matthew.malcomson@arm.com> | 2019-11-07 17:07:32 +0000 |
commit | eb5bbc482128b08d2ee8a2470951a74d8351146f (patch) | |
tree | b528a83fba70f26f1c1669cbb3c6a1a107006622 /gas/config | |
parent | 27cce8667f5c897751bb10d7c859b02b0bb26291 (diff) | |
download | gdb-eb5bbc482128b08d2ee8a2470951a74d8351146f.zip gdb-eb5bbc482128b08d2ee8a2470951a74d8351146f.tar.gz gdb-eb5bbc482128b08d2ee8a2470951a74d8351146f.tar.bz2 |
[Patch][binutils][aarch64] .bfloat16 directive for AArch64 [7/10]
Hi,
This patch is part of a series that adds support for Armv8.6-A
(Matrix Multiply and BFloat16 extensions) to binutils.
This patch implements the '.bfloat' directive for the AArch64 backend.
The syntax for the directive is:
.bfloat16 <0-n numbers>
e.g.
.bfloat16 12.0
.bfloat16 0.123, 1.0, NaN, 5
This is implemented by utilizing the ieee_atof_detail function in order
to encode the slightly
different bfloat16 format.
Added testcases to verify the correct encoding for various bfloat16
values (NaN, Infinity (+ & -), normals, subnormals etc...).
Cross compiled and tested on aarch64-none-elf and aarch64-none-linux-gnu
with no issues.
Committed on behalf of Mihail Ionescu.
gas/ChangeLog:
2019-10-29 Mihail Ionescu <mihail.ionescu@arm.com>
2019-10-29 Barnaby Wilks <barnaby.wilks@arm.com>
* config/tc-aarch64.c (md_atof): Add encoding for the bfloat16 format.
* testsuite/gas/aarch64/bfloat16-directive-le.d: New test.
* testsuite/gas/aarch64/bfloat16-directive-be.d: New test.
* testsuite/gas/aarch64/bfloat16-directive.s: New test.
Is it ok for trunk?
Regards,
Mihail
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-aarch64.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 527d859..eea863b 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -635,6 +635,54 @@ my_get_expression (expressionS * ep, char **str, int prefix_mode, const char * md_atof (int type, char *litP, int *sizeP) { + /* If this is a bfloat16 type, then parse it slightly differently - + as it does not follow the IEEE standard exactly. */ + if (type == 'b') + { + char * t; + LITTLENUM_TYPE words[MAX_LITTLENUMS]; + FLONUM_TYPE generic_float; + + t = atof_ieee_detail (input_line_pointer, 1, 8, words, &generic_float); + + if (t) + input_line_pointer = t; + else + return _("invalid floating point number"); + + switch (generic_float.sign) + { + /* Is +Inf. */ + case 'P': + words[0] = 0x7f80; + break; + + /* Is -Inf. */ + case 'N': + words[0] = 0xff80; + break; + + /* Is NaN. */ + /* bfloat16 has two types of NaN - quiet and signalling. + Quiet NaN has bit[6] == 1 && faction != 0, whereas + signalling Nan's have bit[0] == 0 && fraction != 0. + Chose this specific encoding as it is the same form + as used by other IEEE 754 encodings in GAS. */ + case 0: + words[0] = 0x7fff; + break; + + default: + break; + } + + *sizeP = 2; + + md_number_to_chars (litP, (valueT) words[0], sizeof (LITTLENUM_TYPE)); + + return NULL; + } + return ieee_md_atof (type, litP, sizeP, target_big_endian); } @@ -2107,6 +2155,7 @@ const pseudo_typeS md_pseudo_table[] = { {"variant_pcs", s_variant_pcs, 0}, #endif {"float16", float_cons, 'h'}, + {"bfloat16", float_cons, 'b'}, {0, 0, 0} }; |