This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Add support for the -mdouble=x flag
ClosedPublic

Authored by aykevl on Mar 14 2020, 11:35 AM.

Details

Summary

This flag is used by avr-gcc (starting with v10) to set the width of the double type. The double type is by default interpreted as a 32-bit floating point number in avr-gcc instead of a 64-bit floating point number as is common on other architectures. Starting with GCC 10, a new option has been added to control this behavior:
https://gcc.gnu.org/wiki/avr-gcc#Deviations_from_the_Standard

This commit keeps the default double at 32 bits but adds support for the -mdouble flag (-mdouble=32 and -mdouble=64) to control this behavior.

Diff Detail

Event Timeline

aykevl created this revision.Mar 14 2020, 11:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2020, 11:35 AM

The GCC side commits can be found on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92055
So it seems that we will have both -mlong-double-{64,80,128} (80 is used by x86 fp80) and -mlong-double={32,64}... (I actually prefer = to -)

clang/lib/Driver/ToolChains/Clang.cpp
4594

Nit: move this before the -mlong-double- processing.

clang/test/CodeGen/mdouble.c
2

Maybe name this file avr-mdouble.c

clang/test/Driver/mdouble.c
2

-unknown-unknown can be deleted

aykevl updated this revision to Diff 250418.Mar 15 2020, 7:06 AM

Fixed nits.

aykevl marked 3 inline comments as done.EditedMar 15 2020, 7:18 AM

The GCC side commits can be found on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92055
So it seems that we will have both -mlong-double-{64,80,128} (80 is used by x86 fp80) and -mlong-double={32,64}... (I actually prefer = to -)

Yeah I honestly think the -mlong-double-{64,80,128} flags are pretty ugly, they should have been -mlong-double={64,80,128}. Unfortunately I don't think that can be changed anymore.
I briefly considered using the -mdouble-{32,64} format for AVR but apart from it being rather ugly, avr-gcc uses -mdouble={32,64} (with = instead of -). That means there will be two closely related flags in Clang with a different format. I can change it if necessary, although I have a slight preference to match avr-gcc.

clang/test/CodeGen/mdouble.c
2

I named this mdouble.c instead of avr-mdouble.c as it seems to me that this flag may be useful for other targets as well and tests can be added to the same file. I can rename this if you think avr-mdouble.c is more appropriate.

MaskRay accepted this revision.Mar 15 2020, 7:55 AM
This revision is now accepted and ready to land.Mar 15 2020, 7:55 AM
This revision was automatically updated to reflect the committed changes.