This is to add new port specific hook implementation loongarch_c_mode_for_floating_type, remove macro defines for FLOAT_TYPE_SIZE and DOUBLE_TYPE_SIZE, and rename LONG_DOUBLE_TYPE_SIZE to LA_LONG_DOUBLE_TYPE_SIZE as we poison LONG_DOUBLE_TYPE_SIZE but some macros need LONG_DOUBLE_TYPE_SIZE.
gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_c_mode_for_floating_type): New function. (TARGET_C_MODE_FOR_FLOATING_TYPE): New macro. * config/loongarch/loongarch.h (FLOAT_TYPE_SIZE): Remove. (DOUBLE_TYPE_SIZE): Remove. (LONG_DOUBLE_TYPE_SIZE): Rename to ... (LA_LONG_DOUBLE_TYPE_SIZE): ... this. (UNITS_PER_FPVALUE): Replace LONG_DOUBLE_TYPE_SIZE with LA_LONG_DOUBLE_TYPE_SIZE. (MAX_FIXED_MODE_SIZE): Likewise. (STRUCTURE_SIZE_BOUNDARY): Likewise. (BIGGEST_ALIGNMENT): Likewise. --- gcc/config/loongarch/loongarch.cc | 15 +++++++++++++++ gcc/config/loongarch/loongarch.h | 13 ++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index e7835ae34ae..e4a51303d22 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -10946,6 +10946,18 @@ loongarch_builtin_support_vector_misalignment (machine_mode mode, is_packed); } +/* Implement TARGET_C_MODE_FOR_FLOATING_TYPE. Return TFmode or DFmode + for TI_LONG_DOUBLE_TYPE which is for long double type, go with the + default one for the others. */ + +static machine_mode +loongarch_c_mode_for_floating_type (enum tree_index ti) +{ + if (ti == TI_LONG_DOUBLE_TYPE) + return TARGET_64BIT ? TFmode : DFmode; + return default_mode_for_floating_type (ti); +} + static bool use_rsqrt_p (void) { @@ -11256,6 +11268,9 @@ loongarch_asm_code_end (void) #define TARGET_VECTORIZE_SUPPORT_VECTOR_MISALIGNMENT \ loongarch_builtin_support_vector_misalignment +#undef TARGET_C_MODE_FOR_FLOATING_TYPE +#define TARGET_C_MODE_FOR_FLOATING_TYPE loongarch_c_mode_for_floating_type + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-loongarch.h" diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index f7fe950f333..b9323aba394 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -151,7 +151,7 @@ along with GCC; see the file COPYING3. If not see #define UNITS_PER_FPVALUE \ (TARGET_SOFT_FLOAT ? 0 \ : TARGET_SINGLE_FLOAT ? UNITS_PER_FP_REG \ - : LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT) + : LA_LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT) /* The number of bytes in a double. */ #define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT) @@ -162,9 +162,8 @@ along with GCC; see the file COPYING3. If not see #define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) #define LONG_LONG_TYPE_SIZE 64 -#define FLOAT_TYPE_SIZE 32 -#define DOUBLE_TYPE_SIZE 64 -#define LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64) +/* LONG_DOUBLE_TYPE_SIZE get poisoned, so add LA_ prefix. */ +#define LA_LONG_DOUBLE_TYPE_SIZE (TARGET_64BIT ? 128 : 64) /* Define the sizes of fixed-point types. */ #define SHORT_FRACT_TYPE_SIZE 8 @@ -179,7 +178,7 @@ along with GCC; see the file COPYING3. If not see /* long double is not a fixed mode, but the idea is that, if we support long double, we also want a 128-bit integer type. */ -#define MAX_FIXED_MODE_SIZE LONG_DOUBLE_TYPE_SIZE +#define MAX_FIXED_MODE_SIZE LA_LONG_DOUBLE_TYPE_SIZE /* Width in bits of a pointer. */ #ifndef POINTER_SIZE @@ -200,11 +199,11 @@ along with GCC; see the file COPYING3. If not see #define STRUCTURE_SIZE_BOUNDARY 8 /* There is no point aligning anything to a rounder boundary than - LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is + LA_LONG_DOUBLE_TYPE_SIZE, unless under LSX/LASX the bigggest alignment is BITS_PER_LSX_REG/BITS_PER_LASX_REG/.. */ #define BIGGEST_ALIGNMENT \ (ISA_HAS_LASX? BITS_PER_LASX_REG \ - : (ISA_HAS_LSX ? BITS_PER_LSX_REG : LONG_DOUBLE_TYPE_SIZE)) + : (ISA_HAS_LSX ? BITS_PER_LSX_REG : LA_LONG_DOUBLE_TYPE_SIZE)) /* All accesses must be aligned. */ #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGN) -- 2.43.0