x86: introduce .hfloat directive

This is to be able to generate data passed to {,V}CVTPH2PS and acted
upon by AVX512-FP16 insns. To be able to also use the hex forms
supported for other floating point formats, a small addition to the
generic hex_float() is needed.

Extend existing x86 testcases.
This commit is contained in:
Jan Beulich
2021-08-11 08:32:54 +02:00
parent 8f2200fe8e
commit 7d19d09629
7 changed files with 21 additions and 6 deletions

View File

@ -512,7 +512,7 @@ const char EXP_CHARS[] = "eE";
/* Chars that mean this number is a floating point constant /* Chars that mean this number is a floating point constant
As in 0f12.456 As in 0f12.456
or 0d1.2345e12. */ or 0d1.2345e12. */
const char FLT_CHARS[] = "fFdDxX"; const char FLT_CHARS[] = "fFdDxXhH";
/* Tables for lexical analysis. */ /* Tables for lexical analysis. */
static char mnemonic_chars[256]; static char mnemonic_chars[256];
@ -1356,6 +1356,7 @@ const pseudo_typeS md_pseudo_table[] =
{"ffloat", float_cons, 'f'}, {"ffloat", float_cons, 'f'},
{"dfloat", float_cons, 'd'}, {"dfloat", float_cons, 'd'},
{"tfloat", float_cons, 'x'}, {"tfloat", float_cons, 'x'},
{"hfloat", float_cons, 'h'},
{"value", cons, 2}, {"value", cons, 2},
{"slong", signed_cons, 4}, {"slong", signed_cons, 4},
{"noopt", s_ignore, 0}, {"noopt", s_ignore, 0},

View File

@ -1313,18 +1313,21 @@ data type. Constructors build these data types into memory.
@cindex @code{single} directive, i386 @cindex @code{single} directive, i386
@cindex @code{double} directive, i386 @cindex @code{double} directive, i386
@cindex @code{tfloat} directive, i386 @cindex @code{tfloat} directive, i386
@cindex @code{hfloat} directive, i386
@cindex @code{float} directive, x86-64 @cindex @code{float} directive, x86-64
@cindex @code{single} directive, x86-64 @cindex @code{single} directive, x86-64
@cindex @code{double} directive, x86-64 @cindex @code{double} directive, x86-64
@cindex @code{tfloat} directive, x86-64 @cindex @code{tfloat} directive, x86-64
@cindex @code{hfloat} directive, x86-64
@itemize @bullet @itemize @bullet
@item @item
Floating point constructors are @samp{.float} or @samp{.single}, Floating point constructors are @samp{.float} or @samp{.single},
@samp{.double}, and @samp{.tfloat} for 32-, 64-, and 80-bit formats. @samp{.double}, @samp{.tfloat}, and @samp{.hfloat} for 32-, 64-, 80-, and
These correspond to instruction mnemonic suffixes @samp{s}, @samp{l}, 16-bit formats respectively. The former three correspond to instruction
and @samp{t}. @samp{t} stands for 80-bit (ten byte) real. The 80387 mnemonic suffixes @samp{s}, @samp{l}, and @samp{t}. @samp{t} stands for
only supports this format via the @samp{fldt} (load 80-bit real to stack 80-bit (ten byte) real. The 80387 only supports this format via the
top) and @samp{fstpt} (store 80-bit real and pop stack) instructions. @samp{fldt} (load 80-bit real to stack top) and @samp{fstpt} (store 80-bit
real and pop stack) instructions.
@cindex @code{word} directive, i386 @cindex @code{word} directive, i386
@cindex @code{long} directive, i386 @cindex @code{long} directive, i386

View File

@ -4852,6 +4852,11 @@ hex_float (int float_type, char *bytes)
switch (float_type) switch (float_type)
{ {
case 'h':
case 'H':
length = 2;
break;
case 'f': case 'f':
case 'F': case 'F':
case 's': case 's':

View File

@ -14,3 +14,4 @@ Contents of section .data:
0060 00000000 00000080 fe3f0000 00000000 .* 0060 00000000 00000080 fe3f0000 00000000 .*
0070 00000080 fdbf0000 00000000 00000080 .* 0070 00000080 fdbf0000 00000000 00000080 .*
0080 ff030000 aaaaaaaa aaaaaaaa aaaaaaaa .* 0080 ff030000 aaaaaaaa aaaaaaaa aaaaaaaa .*
0090 003c00c0 003c5555 55555555 55555555 .*

View File

@ -14,3 +14,4 @@ Contents of section .data:
0060 00000000 00000080 fe3f0000 00000000 .* 0060 00000000 00000080 fe3f0000 00000000 .*
0070 00000000 00000080 fdbf0000 00000000 .* 0070 00000000 00000080 fdbf0000 00000000 .*
0080 00000000 00000080 ff030000 00000000 .* 0080 00000000 00000080 ff030000 00000000 .*
0090 003c00c0 003c5555 55555555 55555555 .*

View File

@ -12,3 +12,4 @@ Contents of section .data:
0050 ffffffff ffffffff ffffcccc cccccccc .* 0050 ffffffff ffffffff ffffcccc cccccccc .*
0060 00000000 00000080 fe3f0000 00000000 .* 0060 00000000 00000080 fe3f0000 00000000 .*
0070 0080fdbf 00000000 00000080 ff03aaaa .* 0070 0080fdbf 00000000 00000080 ff03aaaa .*
0080 003c00c0 003c5555 55555555 55555555 .*

View File

@ -29,3 +29,6 @@
.dc.x 0x:bffd80 .dc.x 0x:bffd80
.dcb.x 1, 0x:03ff80 .dcb.x 1, 0x:03ff80
.p2align 4,0xaa .p2align 4,0xaa
.hfloat 1, -2, 0x:3c00
.p2align 4,0x55