+2019-11-07 Mihail Ionescu <mihail.ionescu@arm.com>
+2019-11-07 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.
+
2019-11-07 Mihail Ionescu <mihail.ionescu@arm.com>
2019-11-07 Barnaby Wilks <barnaby.wilks@arm.com>
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);
}
{"variant_pcs", s_variant_pcs, 0},
#endif
{"float16", float_cons, 'h'},
+ {"bfloat16", float_cons, 'b'},
{0, 0, 0}
};
\f
--- /dev/null
+# name: Big endian bfloat16 literal directives
+# source: bfloat16-directive.s
+# as: -mbig-endian
+# objdump: -s --section=.data
+
+.*: +file format .*
+
+Contents of section \.data:
+ 0000 41403dfc 000042f7 8000c2f7 7fff7f80 .*
+ 0010 ff807f7f ff7f0080 80800001 8001007f .*
+ 0020 807f3f80 bf804000 c000 .*
--- /dev/null
+# name: Little endian bfloat16 literal directives
+# source: bfloat16-directive.s
+# as: -mlittle-endian
+# objdump: -s --section=.data
+
+.*: +file format .*
+
+Contents of section \.data:
+ 0000 4041fc3d 0000f742 0080f7c2 ff7f807f .*
+ 0010 80ff7f7f 7fff8000 80800100 01807f00 .*
+ 0020 7f80803f 80bf0040 00c0 .*