This is the mail archive of the
mailing list for the binutils project.
Re: [PATCH][binutils][Arm][2/3] Add support for float16 (IEEE and Alternative formats) for Arm backend.
- From: Barnaby Wilks <Barnaby dot Wilks at arm dot com>
- To: Richard Earnshaw <Richard dot Earnshaw at arm dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Cc: nd <nd at arm dot com>, "nickc at redhat dot com" <nickc at redhat dot com>, "Ramana Radhakrishnan" <Ramana dot Radhakrishnan at arm dot com>
- Date: Mon, 15 Jul 2019 15:44:00 +0000
- Subject: Re: [PATCH][binutils][Arm][2/3] Add support for float16 (IEEE and Alternative formats) for Arm backend.
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=arm.com;dmarc=pass action=none header.from=arm.com;dkim=pass header.d=arm.com;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OIOGpTFpkZnNSpJnU2Mwi5t/5TGH03Yj8bGgd79FPD0=; b=KFXzzAzLpDvMX2YexQ2uSzImnR5i21bveEMNV3Bhv0SL8XcBoY+4/cFNf+Q5f9ZdMtmRDJ270k8gEZSky+5qtVpGxisCuejd8a1fPpafA9bDhDP646Z65Sc8D56swuoynHGpghQHS1QvzlPulnX+xJRBK4DD1wIC1vx9f1R9Ttt3EvQ3SLgWdHs7KZT8Jk1pmB1s4wbshFCLmqk8R5cTCnVOalewO/pPg27FRZ9t+4oPuIr002v0RRxTAHE0k9Bl7L/7E6Evjc1SQSuOIbIpXzMjejDTTdLR5Gc/p+Bltpv44Kk8HniIOvbUo8wzuwOjVDBF+Gt4RAJeiN9AvV2j6g==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kGEAREE3am7nakF76IdQKNKVWNvjyh4WOOVZwfhwB47SWsOXtFWVoi2c+Gc8be0gPupdSjSubBew+0F6U5d2oxFgvM17UEcmKhGuKD4uVhYzOsmq6zJ2scbuFuqk+A7XksdqqtEhqX8Q+N/SCXsaZ3jahafN236aqjHq0vLYk2y/wcTNdsUDwC9o/pITJ1qa/11/FTfMzTyUAgNLK6+xxU4dnoFgGaRDxOa6mtwjReqppIZcwgzT3MV/yoiJi4EG3OEuB8hUgO0CGoMnpu7eSRrk0v9nBRJsH4/lAHb6jBSO4Pon9Sy6xoin2T7qf6/CdihVgXIotSCsIWpryvpEMw==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Barnaby dot Wilks at arm dot com;
- References: <firstname.lastname@example.org> <email@example.com> <firstname.lastname@example.org>
Yep agreed, a dedicated directive would make more sense really - originally I did have something
along those lines (.ieee_fp16_format/.alternative_fp16_format directives for switching between formats), but then
changed upon finding a EABI attribute for the same thing, and seeing that was how GCC did it.
Like you say though, for files that contain a mix of float16's in both IEEE and Alternative formats what would be the
EABI attribute for that be?
This could be solved by just restricting to one format (in which
case a command line option may make more sense), or by inventing
a new EABI attribute? (I'm don't really know much about that, so have no idea if it's feasible).
On 7/15/19 10:16 AM, Richard Earnshaw (lists) wrote:
> On 11/07/2019 16:26, Barnaby Wilks wrote:
>> This is part of a patch series that implements a directive for
>> assembling 16-bit floating point constants for Arm and AArch64.
>> This patch implements the float16 directive for both the IEEE 754
>> format and the Arm alternative format for the
>> Arm backend >
>> The syntax of the directive is:
>> .float16 <0-n decimal numbers>
>> .float16 12.0
>> .float16 0.23, 433.1, 0.06
>> The Arm alternative format is almost identical to the IEEE 754
>> format, except that it doesn't
>> encode for NaNs or Infinity (instead an exponent of 0x1F represents a
>> normalized number in the range
>> 65536 to 131008).
>> The alternative format is documented in the reference manual:
>> Which format is used is controlled by the
>> .eabi_attribute Tag_ABI_FP_16bit_format, <...>
>> directive, where if
>> <...> = 1 then use the IEEE 754 half-precision format else if
>> <...> = 2 then use the Arm alternative format
>> Added testcases to verify the correct encoding for both formats (for
>> both big and little endian targets),
>> as well as tests verifying that warnings are thrown if trying to
>> encode NaN or Infinity when using
>> the Arm alternative format.
>> The encodings have been cross referenced with GCC's encoding for
>> __fp16 types to ensure consistency.
>> Cross compiled and regtested on arm-none-eabi and
>> I don't have write access, so if it's OK then could someone commit on
>> my behalf?
> Hi Barney,
> thanks for the patch.
> I'm not sure that using the build attributes to control selection of
> the format is the best idea. Firstly, build attributes are not
> available when not assembling for ELF (we have PE-coff support in the
> assembler as well); secondly, build attributes should reflect what was
> placed in the assembly file, not control what goes into it. So this
> is a case of the coach before the horse.
> I think, if we want to support the Arm alternate FP format in GAS at
> all, we need either a new command line option, or a new directive (or
> possibly both). Then the code in BFD that does automatic
> build-attribute selection should be updated to reflect the tri-state
> situation: no format specified; IEEE format specified; or ARM
> Alternate format specified.
> Note that GAS can currently only reflect show build attributes that
> affect the whole file, so switching during assembly is a little
> dubious as things stand.
>> 2019-07-11 Barnaby Wilks<email@example.com>
>> * config/tc-arm.c (md_atof): Set precision for float16 type.
>> (enum fp_16bit_format): Add enum to represent the 2 float16
>> (arm_is_largest_exponent_ok): Check for whether to encode with
>> the IEEE or alternative
>> * config/tc-arm.h (TC_LARGEST_EXPONENT_IS_NORMAL): Macro that
>> expands to
>> (arm_is_largest_exponent_ok): Add prototype for
>> arm_is_largest_exponent_ok function.
>> * testsuite/gas/arm/float16-bad.d: New test.
>> * testsuite/gas/arm/float16-bad.l: New test.
>> * testsuite/gas/arm/float16-bad.s: New test.
>> * testsuite/gas/arm/float16-be.d: New test.
>> * testsuite/gas/arm/float16-be.s: New test.
>> * testsuite/gas/arm/float16-le.d: New test.
>> * testsuite/gas/arm/float16-le.s: New test.