This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] improve front-end floating point attributes computation


The internal tree nodes for the standard Ada floating point types are
derived from back-end information provided via a type registration hook.
 
The registration is performed by the set_targ elaboration code, constructing
the FPT_Mode_Table which cstand.Create_Standard scans later on to construct
front-end type nodes.
 
But downstream within the compiler, the Standard type nodes aren't the only
source of information regarding floating point types: the ttypes package is
also used for this purpose in many places.
 
The two sources of information (ttypes' exposed values and attributes in tree
nodes for standard floating types) have to agree. A range of bad things might
happen otherwise.
 
Now it turns out that the Set_Targ functions used to initialize ttypes for
floating point values don't use the FPT_Mode_Table at all. They resort to gigi
functions conveying back-end attributes instead.
 
Keeping the two in sync is a pain, in particular when it comes to
Long_Long_Float. The gigi code resorts to the WIDEST_HARDWARE_FP_SIZE macro
which is not so well defined, and the get_target_long_double_size function
doesn't compute what the name implies.
 
This patch is a first step towards fixing this by providing a common ground to
initialize both ttypes and the front-end nodes from the FPT_Mode_Table.
 
The basic idea is to generalize what cstand.Create_Float_Types does: refer to
specific C (back-end) types to initialize the Ada type nodes. 

No functional change. This allows removing code in gigi, which will be done
as a separate patch.

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

2015-01-06  Olivier Hainque  <hainque@adacore.com>

	* set_targ.ads (C_Type_For): New function. Return the name of
	a C type supported by the back-end and suitable as a basis to
	construct the standard Ada floating point type identified by
	the T parameter. This is used as a common ground to feed both
	ttypes values and the GNAT tree nodes for the standard floating
	point types.
	* set_targ.adb (Long_Double_Index): The index at which "long
	double" gets registered in the FPT_Mode_Table. This is useful to
	know whether we have a "long double" available at all and get at
	it's characteristics without having to search the FPT_Mode_Table
	when we need to decide which C type should be used as the
	basis for Long_Long_Float in Ada.
	(Register_Float_Type): Fill Long_Double_Index.
	(FPT_Mode_Index_For): New function. Return the index in
	FPT_Mode_Table that designates the entry corresponding to the
	provided C type name.
	(FPT_Mode_Index_For): New function. Return the index in
	FPT_Mode_Table that designates the entry for a back-end type
	suitable as a basis to construct the standard Ada floating point
	type identified by the input T parameter.
	(elaboration code): Register_Back_End_Types unconditionally,
	so C_Type_For can operate regardless of -gnateT. Do it
	early so we can query it for the floating point sizes, via
	FPT_Mode_Index_For. Initialize Float_Size, Double_Size and
	Long_Double_Size from the FPT_Mode_Table, as cstand will do.
	* cstand.adb (Create_Float_Types): Use C_Type_For to determine
	which C type should be used as the basis for the construction
	of the Standard Ada floating point types.
	* get_targ.ads (Get_Float_Size, Get_Double_Size,
	Get_Long_Double_Size): Remove.
	* get_targ.adb: Likewise.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]