From: WANG Xuerui <[email protected]> These all-caps built-in macros, while defined in the 2022.01.13 version of the original *LoongArch Toolchain Conventions* document [1], are deprecated since version 2023.04.20 [2] by [3], and since the recent *Software Development and Build Convention for LoongArch Architectures* document was released in July 2023, they have completely disappeared. Now that it is nearing the end of 2025 and a new LoongArch target is added, better not include the cruft for not deviating from the official specs, and a cleaner ecosystem.
[1]: https://github.com/loongson/LoongArch-Documentation/blob/2022.01.13/docs/LoongArch-toolchain-conventions-EN.adoc#cc-preprocessor-definitions [2]: https://github.com/loongson/LoongArch-Documentation/blob/2023.04.20/docs/LoongArch-toolchain-conventions-EN.adoc#cc-preprocessor-built-in-macro-definitions [3]: https://github.com/loongson/LoongArch-Documentation/pull/28 [4]: https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc#83-architecture-related-cc-pre-defined-macros gcc/ChangeLog: * config/loongarch/loongarch-c.cc (loongarch_define_unconditional_macros): Do not define legacy compatibility macros for LA32. (loongarch_update_cpp_builtins): Ditto. Signed-off-by: WANG Xuerui <[email protected]> --- gcc/config/loongarch/loongarch-c.cc | 35 ++++++++++++++++++----------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/gcc/config/loongarch/loongarch-c.cc b/gcc/config/loongarch/loongarch-c.cc index 6e2f8f43818..b91ba8dd73d 100644 --- a/gcc/config/loongarch/loongarch-c.cc +++ b/gcc/config/loongarch/loongarch-c.cc @@ -79,12 +79,15 @@ loongarch_define_unconditional_macros (cpp_reader *pfile) builtin_define ("__builtin_infq=__builtin_inff128"); builtin_define ("__builtin_huge_valq=__builtin_huge_valf128"); - /* Native Data Sizes. */ - builtin_define_with_int_value ("_LOONGARCH_SZINT", INT_TYPE_SIZE); - builtin_define_with_int_value ("_LOONGARCH_SZLONG", LONG_TYPE_SIZE); - builtin_define_with_int_value ("_LOONGARCH_SZPTR", POINTER_SIZE); - builtin_define_with_int_value ("_LOONGARCH_FPSET", 32); - builtin_define_with_int_value ("_LOONGARCH_SPFPSET", 32); + /* Legacy compatibility macros for native data sizes. */ + if (TARGET_ABI_LP64) + { + builtin_define_with_int_value ("_LOONGARCH_SZINT", INT_TYPE_SIZE); + builtin_define_with_int_value ("_LOONGARCH_SZLONG", LONG_TYPE_SIZE); + builtin_define_with_int_value ("_LOONGARCH_SZPTR", POINTER_SIZE); + builtin_define_with_int_value ("_LOONGARCH_FPSET", 32); + builtin_define_with_int_value ("_LOONGARCH_SPFPSET", 32); + } } static void @@ -100,13 +103,19 @@ loongarch_update_cpp_builtins (cpp_reader *pfile) builtin_define_with_value ("__loongarch_tune", loongarch_tune_strings[la_target.cpu_tune], 1); - builtin_undef ("_LOONGARCH_ARCH"); - builtin_define_with_value ("_LOONGARCH_ARCH", - loongarch_arch_strings[la_target.cpu_arch], 1); - - builtin_undef ("_LOONGARCH_TUNE"); - builtin_define_with_value ("_LOONGARCH_TUNE", - loongarch_tune_strings[la_target.cpu_tune], 1); + /* Legacy compatibility macros for arch/tune info. */ + if (TARGET_64BIT) + { + builtin_undef ("_LOONGARCH_ARCH"); + builtin_define_with_value ("_LOONGARCH_ARCH", + loongarch_arch_strings[la_target.cpu_arch], + 1); + + builtin_undef ("_LOONGARCH_TUNE"); + builtin_define_with_value ("_LOONGARCH_TUNE", + loongarch_tune_strings[la_target.cpu_tune], + 1); + } builtin_undef ("__loongarch_double_float"); builtin_undef ("__loongarch_single_float"); -- 2.52.0
