Message ID | 05735865-dd91-4bc3-ae58-e394af4e516f@gjlay.de |
---|---|
State | New |
Headers | show |
Series | [avr] Implement TARGET_FLOATN_MODE | expand |
On 10/4/24 7:46 AM, Georg-Johann Lay wrote: > This patch implements TARGET_FLOATN_MODE which maps > _Float32[x] to SFmode and _Float64[x] to DFmode. > > There is currently no library support for extended float types, > but these settings are more reasonable for avr (and they make > more tests pass). > > Ok for trunk? > > Johann > > -- > > AVR: Implement TARGET_FLOATN_MODE. > > gcc/ > * config/avr/avr.cc (avr_floatn_mode): New static function. > (TARGET_FLOATN_MODE): New define. OK Jeff
On Fri, Oct 04, 2024 at 08:09:48AM -0600, Jeff Law wrote: > > > On 10/4/24 7:46 AM, Georg-Johann Lay wrote: > > This patch implements TARGET_FLOATN_MODE which maps > > _Float32[x] to SFmode and _Float64[x] to DFmode. > > > > There is currently no library support for extended float types, > > but these settings are more reasonable for avr (and they make > > more tests pass). > > > > Ok for trunk? > > > > Johann > > > > -- > > > > AVR: Implement TARGET_FLOATN_MODE. > > > > gcc/ > > * config/avr/avr.cc (avr_floatn_mode): New static function. > > (TARGET_FLOATN_MODE): New define. > OK This is certainly incorrect. As specified by e.g. ISO C23 H.2.3 Extended floating types, the requirement on the extended floating types is: "For each of its basic formats, IEC 60559 specifies an extended format whose maximum exponent and precision exceed those of the basic format it is associated with. Extended formats are intended for arithmetic with more precision and exponent range than is available in the basic formats used for the input data." So, while SFmode is a good mode to use for _Float32 and DFmode is a good mode to use for _Float64, SFmode isn't a good mode to use for _Float32x and neither is DFmode a good mode to use for _Float64x. I'd expect you want DFmode for _Float32x and opt_scalar_float_mode () for _Float64x. Jakub
Am 04.10.24 um 16:32 schrieb Jakub Jelinek: > On Fri, Oct 04, 2024 at 08:09:48AM -0600, Jeff Law wrote: >> >> >> On 10/4/24 7:46 AM, Georg-Johann Lay wrote: >>> This patch implements TARGET_FLOATN_MODE which maps >>> _Float32[x] to SFmode and _Float64[x] to DFmode. >>> >>> There is currently no library support for extended float types, >>> but these settings are more reasonable for avr (and they make >>> more tests pass). >>> >>> Ok for trunk? >>> >>> Johann >>> >>> -- >>> >>> AVR: Implement TARGET_FLOATN_MODE. >>> >>> gcc/ >>> * config/avr/avr.cc (avr_floatn_mode): New static function. >>> (TARGET_FLOATN_MODE): New define. >> OK > > This is certainly incorrect. > > As specified by e.g. ISO C23 H.2.3 Extended floating types, the requirement > on the extended floating types is: > "For each of its basic formats, IEC 60559 specifies an extended format whose maximum exponent and > precision exceed those of the basic format it is associated with. Extended formats are intended for > arithmetic with more precision and exponent range than is available in the basic formats used for > the input data." > So, while SFmode is a good mode to use for _Float32 and DFmode is a good > mode to use for _Float64, SFmode isn't a good mode to use for _Float32x and > neither is DFmode a good mode to use for _Float64x. > I'd expect you want DFmode for _Float32x and opt_scalar_float_mode () for > _Float64x. > > Jakub Thanks for the clarification. So I guess that hook is not needed at all, and the default implementation is already the best avr can do. Johann
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc index 92013c3845d..b73c251b64b 100644 --- a/gcc/config/avr/avr.cc +++ b/gcc/config/avr/avr.cc @@ -15473,6 +15473,24 @@ avr_c_mode_for_floating_type (tree_index ti) } +/* Implement `TARGET_FLOATN_MODE'. */ + +static opt_scalar_float_mode +avr_floatn_mode (int n, bool /*extended*/) +{ + if (n == 32) + return SFmode; + + // Notice that -m[long-]double= just tells which library (AVR-LibC + // or libgcc/libf7) is providing symbols like sin. DFmode support + // is provided by libf7 no matter what. + if (n == 64) + return DFmode; + + return opt_scalar_float_mode (); +} + + /* Worker function for `FLOAT_LIB_COMPARE_RETURNS_BOOL'. */ bool @@ -15705,6 +15723,9 @@ avr_use_lra_p () #undef TARGET_C_MODE_FOR_FLOATING_TYPE #define TARGET_C_MODE_FOR_FLOATING_TYPE avr_c_mode_for_floating_type +#undef TARGET_FLOATN_MODE +#define TARGET_FLOATN_MODE avr_floatn_mode + gcc_target targetm = TARGET_INITIALIZER;