]> git.ipfire.org Git - thirdparty/gcc.git/commit
LoongArch: Allow -mcmodel=extreme and model attribute with -mexplicit-relocs=auto
authorXi Ruoyao <xry111@xry111.site>
Thu, 7 Dec 2023 07:45:30 +0000 (15:45 +0800)
committerXi Ruoyao <xry111@xry111.site>
Tue, 12 Dec 2023 07:37:04 +0000 (15:37 +0800)
commit8c8b40e1c8bb4fbfba850bca47c768d99d12bef4
tree7e19cffab3008de797816ef4ef00d9b0a3820b26
parentf5f33b44b5dd4c41ae335445ae3f06b1ca3cfbcb
LoongArch: Allow -mcmodel=extreme and model attribute with -mexplicit-relocs=auto

There seems no real reason to require -mexplicit-relocs=always for
-mcmodel=extreme or model attribute.  As the linker does not know how to
relax a 3-operand la.local or la.global pseudo instruction, just emit
explicit relocs for SYMBOL_PCREL64, and under TARGET_CMODEL_EXTREME also
SYMBOL_GOT_DISP.

gcc/ChangeLog:

* config/loongarch/loongarch.cc (loongarch_explicit_relocs_p):
Return true for SYMBOL_PCREL64.  Return true for SYMBOL_GOT_DISP
if TARGET_CMODEL_EXTREME.
(loongarch_split_symbol): Check for la_opt_explicit_relocs !=
EXPLICIT_RELOCS_NONE instead of TARGET_EXPLICIT_RELOCS.
(loongarch_print_operand_reloc): Likewise.
(loongarch_option_override_internal): Likewise.
(loongarch_handle_model_attribute): Likewise.
* doc/invoke.texi (-mcmodel=extreme): Update the compatibility
between it and -mexplicit-relocs=.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/attr-model-3.c: New test.
* gcc.target/loongarch/attr-model-4.c: New test.
* gcc.target/loongarch/func-call-extreme-3.c: New test.
* gcc.target/loongarch/func-call-extreme-4.c: New test.
gcc/config/loongarch/loongarch.cc
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/loongarch/attr-model-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/attr-model-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/func-call-extreme-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/func-call-extreme-4.c [new file with mode: 0644]