[PATCH] RISC-V: Add .bfloat16 directive
Kito Cheng
kito.cheng@sifive.com
Mon Jan 20 11:20:03 GMT 2025
Hi Jan:
> > --- a/gas/config/tc-riscv.c
> > +++ b/gas/config/tc-riscv.c
> > @@ -473,7 +473,7 @@ const char EXP_CHARS[] = "eE";
> >
> > /* Chars that mean this number is a floating point constant.
> > As in 0f12.456 or 0d1.2345e12. */
> > -const char FLT_CHARS[] = "rRsSfFdDxXpPhH";
> > +const char FLT_CHARS[] = "rRsSfFdDxXpPhHb";
>
> Is there a particular reason you add b here but not also B?
Reference AArch64's implementation so I didn't add B, will included in v2
>
> > --- /dev/null
> > +++ b/gas/testsuite/gas/riscv/bfloat16.d
> > @@ -0,0 +1,10 @@
> > +# source: bfloat16.s
> > +# objdump: -sj .data
> > +# as:
> > +
> > +.*:[ ]+file format .*
> > +
> > +Contents of section \.data:
> > + 0000 4041fc3d 0000f742 0080f7c2 ff7f807f.*
> > + 0010 80ff7f7f 7fff8000 80800100 01807f00.*
> > + 0020 7f80803f 80bf0040 00c0c1ff 81ff.*
>
> Are these expectations going to be okay for big-endian targets?
Thanks for reminding that, will split this into be and le version.
>
> > --- /dev/null
> > +++ b/gas/testsuite/gas/riscv/bfloat16.s
> > @@ -0,0 +1,21 @@
> > + .data
> > + .bfloat16 12.0
> > + .bfloat16 0.123
> > + .bfloat16 +0.0
> > + .bfloat16 123.4
> > + .bfloat16 -0.0
> > + .bfloat16 -123.4
> > + .bfloat16 NaN
> > + .bfloat16 Inf
> > + .bfloat16 -Inf
> > + .bfloat16 3.390e+38
> > + .bfloat16 -3.390e+38
> > + .bfloat16 1.175e-38
> > + .bfloat16 -1.175e-38
> > + .bfloat16 9.194e-41
> > + .bfloat16 -9.194e-41
> > + .bfloat16 1.167e-38
> > + .bfloat16 -1.167e-38
> > + .bfloat16 1.0, -1, 2.0, -2
> > + .bfloat16 0b:ffc1 # qNaNh
> > + .bfloat16 0b:ff81 # sNaNh
>
> I'm struggling with the comments here: What are the 'h' about? And
> aren't both values negative, which the comments then also ought to
> reflect?
Hmmmm, that's something I copy from float16.s, let me drop that...:P
>
> Jan
More information about the Binutils
mailing list