public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Implement tiered support for floating-point input operations
@ 2020-12-15 11:42 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-12-15 11:42 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

[-- Attachment #1: Type: text/plain, Size: 10433 bytes --]

This changes the implementation of input operations for floating-point
types from using Long_Long_Float for all floating-point types to using
a base type tailored to the type being operated on.

This comprises adjusting Ada.Text_IO.Float_IO and Ada.Text_IO.Complex_IO
to the new approach, as well as sibling packages in the Ada.Wide_Text_IO
and Ada.Wide_Wide_Text_IO hierarchies.

Note that this skips Short_Float, because Short_Float has always been a
copy of Float for GNAT and, for good measures, remove System.Fat_SFlt.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Remove s-fatsfl$(objext)
	and add s-valflt$(objext), s-vallfl$(objext), s-valllf$(objext).
	* exp_attr.adb (Find_Fat_Info): Merge Short_Float and Float cases.
	* exp_imgv.adb (Expand_Value_Attribute): Replace RE_Value_Real with
	RE_Value_Long_Long_Float for fixed-point types and use appropriate
	base type for floating-point types.
	* rtsfind.ads (RTU_Id): Remove System_Fat_IEEE_Long_Float,
	System_Fat_IEEE_Short_Float and System_Val_Real, add System_Val_Flt,
	System_Val_LFlt and System_Val_LLF.
	(RE_Id): Remove RE_Attr_IEEE_Long, RE_Fat_IEEE_Long,
	RE_Attr_IEEE_Short, RE_Fat_IEEE_Short, RE_Attr_Short_Float, add
	RE_Value_Float, RE_Value_Long_Float, RE_Value_Long_Long_Float,
	(RE_Unit_Table): Likewise.
	* libgnat/a-ticoau.ads: Add with clause for Float_Aux and make the
	package generic.
	(Get): Change parameter types to Num.
	(Put): Likewise.
	(Gets): Likewise.
	(Puts): Likewise.
	* libgnat/a-ticoau.adb: Remove clause and renaming for Float_Aux.
	(Get): Change parameter types to Num.
	(Gets): Likewise.
	(Put): Likewise.
	(Puts): Likewise.  Add conversion to Long_Long_Float.
	* libgnat/a-ticoio.adb: Remove with clause for Ada.Text_IO, add with
	clause for Float_Aux, add with and use clauses for System.Val_Flt,
	System.Val_LFlt and System.Val_LLF. Instantiate Float_Aux and
	Complex_Aux on Float, Long_Float, and Long_Long_Float.
	(OK_Float): New boolean constant.
	(OK_Long_Float): Likewise.
	(Get): Call appropriate Get routine from auxiliary package.
	(Get): Call appropriate Gets routine from auxiliary package.
	(Put): Call appropriate Put routine from auxiliary package.
	(Put): Call appropriate Puts routine from auxiliary package.
	* libgnat/a-tideau.adb: Remove with and use clause for Float_Aux.
	* libgnat/a-tifiau.adb: Likewise.
	* libgnat/a-tifiio.adb: Add with and use clause for System.Val_LLF.
	Instantiate Float_Aux on Long_Long_Float.
	(Get): Adjust call to Get routine from auxiliary package.
	(Get): Adjust call to Gets routine from auxiliary package.
	(Put): Adjust call to Put routine from auxiliary package.
	(Put): Adjust call to Puts routine from auxiliary package.
	* libgnat/a-tifiio__128.adb: Likewise.
	(Get): Likewise.
	(Get): Likewise.
	(Put): Likewise.
	(Put): Likewise.
	* libgnat/a-tiflau.ads: Make the package generic.
	(Get): Change parameter type to Num.
	(Put): Likewise.
	(Gets): Likewise.
	(Puts): Likewise.
	* libgnat/a-tiflau.adb: Remove clauses for System.Val_Real.
	(Get): Change parameter type to Num and call Scan routine.
	(Gets): Likewise.
	(Load_Real): Move to...
	(Put): Change parameter type and add conversion to Long_Long_Float.
	(Puts): Likewise.
	* libgnat/a-tiflio.adb: Add with and use clauses for System.Val_Flt,
	System.Val_LFlt and System.Val_LLF. Instantiate Float_Aux on Float,
	Long_Float and Long_Long_Float.
	(OK_Float): New boolean constant.
	(OK_Long_Float): Likewise.
	(Get): Call appropriate Get routine from auxiliary package.
	(Get): Call previous variant.
	(Get): Call appropriate Gets routine from auxiliary package.
	(Put): Call appropriate Put routine from auxiliary package.
	(Put): Call previous variant.
	(Put): Call appropriate Puts routine from auxiliary package.
	* libgnat/a-tigeau.ads (Load_Real): New procedure.
	* libgnat/a-tigeau.adb (Load_Real): ...here.
	* libgnat/a-wtcoau.ads: Add with clause for Float_Aux and make the
	package generic.
	(Get): Change parameter types to Num.
	(Put): Likewise.
	(Gets): Likewise.
	(Puts): Likewise.
	* libgnat/a-wtcoau.adb: Remove clause and renaming for Float_Aux.
	(Get): Change parameter types to Num.
	(Gets): Likewise.
	(Put): Likewise.
	(Puts): Likewise.  Add conversion to Long_Long_Float.
	* libgnat/a-wtcoio.ads: Remove use clause for Complex_Types and use
	qualified names throughout accordingly.
	* libgnat/a-wtcoio.adb: Remove clause for Ada.Unchecked_Conversion,
	add with clause for Float_Aux, add clauses for System.Val_Flt,
	System.Val_LFlt and System.Val_LLF. Add clause for Complex_Types.
	Instantiate Float_Aux and Complex_Aux on Float, Long_Float, and
	Long_Long_Float.  Remove LLF subtype and TFT instantiation.
	(OK_Float): New boolean constant.
	(OK_Long_Float): Likewise.
	(Get): Call appropriate Get routine from auxiliary package.
	(Get): Call appropriate Gets routine from auxiliary package.
	(Put): Call appropriate Put routine from auxiliary package.
	(Put): Call appropriate Puts routine from auxiliary package.
	* libgnat/a-wtdeau.adb: Remove with and use clause for Float_Aux.
	* libgnat/a-wtfiau.adb: Likewise.
	* libgnat/a-wtfiio.adb: Add with and use clause for System.Val_LLF.
	Instantiate Float_Aux on Long_Long_Float.
	(Get): Adjust call to Get routine from auxiliary package.
	(Get): Adjust call to Gets routine from auxiliary package.
	(Put): Adjust call to Put routine from auxiliary package.
	(Put): Adjust call to Puts routine from auxiliary package.
	* libgnat/a-wtfiio__128.adb: Likewise.
	(Get): Likewise.
	(Get): Likewise.
	(Put): Likewise.
	(Put): Likewise.
	* libgnat/a-wtflau.ads: Make the package generic.
	(Get): Change parameter type to Num.
	(Put): Likewise.
	(Gets): Likewise.
	(Puts): Likewise.
	* libgnat/a-wtflau.adb: Remove clauses for System.Val_Real.
	(Get): Change parameter type to Num and call Scan routine. Set
	Ptr parameter lazily.
	(Gets): Likewise.
	(Load_Real): Move to...
	(Put): Change parameter type and add conversion to Long_Long_Float.
	Bump buffer length to Max_Real_Image_Length.
	(Puts): Likewise.
	* libgnat/a-wtflio.adb: Add with and use clauses for System.Val_Flt,
	System.Val_LFlt and System.Val_LLF. Instantiate Float_Aux on Float,
	Long_Float and Long_Long_Float.
	(OK_Float): New boolean constant.
	(OK_Long_Float): Likewise.
	(Get): Call appropriate Get routine from auxiliary package.  Add
	pragma Unsuppress (Range_Check) and manual validity check.
	(Get): Call appropriate Gets routine from auxiliary package. Add
	pragma Unsuppress (Range_Check) and manual validity check.
	(Put): Call appropriate Put routine from auxiliary package.
	(Put): Call appropriate Puts routine from auxiliary package.
	* libgnat/a-wtgeau.ads (Load_Real): New procedure.
	* libgnat/a-wtgeau.adb (Load_Real): ...here.
	* libgnat/a-ztcoau.ads: Add with clause for Float_Aux and make the
	package generic.
	(Get): Change parameter types to Num.
	(Put): Likewise.
	(Gets): Likewise.
	(Puts): Likewise.
	* libgnat/a-ztcoau.adb: Remove clause and renaming for Float_Aux.
	(Get): Change parameter types to Num.
	(Gets): Likewise.
	(Put): Likewise.
	(Puts): Likewise.  Add conversion to Long_Long_Float.
	* libgnat/a-ztcoio.ads: Remove use clause for Complex_Types and use
	qualified names throughout accordingly.
	* libgnat/a-ztcoio.adb: Remove clause for Ada.Unchecked_Conversion,
	add with clause for Float_Aux, add clauses for System.Val_Flt,
	System.Val_LFlt and System.Val_LLF. Add clause for Complex_Types.
	Instantiate Float_Aux and Complex_Aux on Float, Long_Float, and
	Long_Long_Float. Remove LLF subtype and TFT instantiation.
	(OK_Float): New boolean constant.
	(OK_Long_Float): Likewise.
	(Get): Call appropriate Get routine from auxiliary package.
	(Get): Call appropriate Gets routine from auxiliary package.
	(Put): Call appropriate Put routine from auxiliary package.
	(Put): Call appropriate Puts routine from auxiliary package.
	* libgnat/a-ztdeau.adb: Remove with and use clause for Float_Aux.
	* libgnat/a-ztfiau.adb: Likewise.
	* libgnat/a-ztfiio.adb: Add with and use clause for System.Val_LLF.
	Instantiate Float_Aux on Long_Long_Float.
	(Get): Adjust call to Get routine from auxiliary package.
	(Get): Adjust call to Gets routine from auxiliary package.
	(Put): Adjust call to Put routine from auxiliary package.
	(Put): Adjust call to Puts routine from auxiliary package.
	* libgnat/a-ztfiio__128.adb: Likewise.
	(Get): Likewise.
	(Get): Likewise.
	(Put): Likewise.
	(Put): Likewise.
	* libgnat/a-ztflau.ads: Make the package generic.
	(Get): Change parameter type to Num.
	(Put): Likewise.
	(Gets): Likewise.
	(Puts): Likewise.
	* libgnat/a-ztflau.adb: Remove clauses for System.Val_Real.
	(Get): Change parameter type to Num and call Scan routine. Set
	Ptr parameter lazily.
	(Gets): Likewise.
	(Load_Real): Move to...
	(Put): Change parameter type and add conversion to Long_Long_Float.
	Bump buffer length to Max_Real_Image_Length.
	(Puts): Likewise.
	* libgnat/a-ztflio.adb: Add with and use clauses for System.Val_Flt,
	System.Val_LFlt and System.Val_LLF. Instantiate Float_Aux on Float,
	Long_Float and Long_Long_Float.
	(OK_Float): New boolean constant.
	(OK_Long_Float): Likewise.
	(Get): Call appropriate Get routine from auxiliary package.  Add
	pragma Unsuppress (Range_Check) and manual validity check.
	(Get): Call appropriate Gets routine from auxiliary package. Add
	pragma Unsuppress (Range_Check) and manual validity check.
	(Put): Call appropriate Put routine from auxiliary package.
	(Put): Call appropriate Puts routine from auxiliary package.
	* libgnat/a-ztgeau.ads (Load_Real): New procedure.
	* libgnat/a-ztgeau.adb (Load_Real): ...here.
	* libgnat/s-fatsfl.ads: Delete.
	* libgnat/s-valflt.ads: New package.
	* libgnat/s-vallfl.ads: Likewise.
	* libgnat/s-valllf.ads: Likewise.
	* libgnat/s-valrea.ads: Make generic. Add assertions, defensive
	code and clarify intent.
	(Scan_Real): Change parameter type to Num.
	(Value_Real): Likewise.
	* libgnat/s-valrea.adb: Instantiate Value_R on Uns.
	(Integer_to_Real): Change parameter and result to Num.
	Call Float_Control.Reset only if the mantissa is 64 bits.  Use
	a divide to compute the final value if the scale is negative.
	(Scan_Real): Change result to Num.
	(Value_Real): Likewise.
	* libgnat/s-valuer.adb: Add assertions, defensive code and
	clarify intent.
	(F_Limit): Delete.
	(I_Limit): Likewise.
	(Precision_Limit): Always use the integer limit.
	* libgnat/s-fatgen.adb: Add pragma Annotate.

[-- Attachment #2: patch.diff.gz --]
[-- Type: application/gzip, Size: 13787 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-15 11:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 11:42 [Ada] Implement tiered support for floating-point input operations Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).