LoongArch: Add support code model extreme.
authorLulu Cheng <chenglulu@loongson.cn>
Thu, 18 Aug 2022 09:26:13 +0000 (17:26 +0800)
committerLulu Cheng <chenglulu@loongson.cn>
Sat, 20 Aug 2022 09:02:19 +0000 (17:02 +0800)
commit69458145262e4cef76410f5d42fe0d12b7c395fb
tree68c94097b721f9c913e1b18be17ebe76b29a9fb9
parente9dd050e0ccd644c3bb6d6538dc6187157f6b3e8
LoongArch: Add support code model extreme.

Use five instructions to calculate a signed 64-bit offset relative to the pc.

gcc/ChangeLog:

* config/loongarch/loongarch-opts.cc: Allow cmodel to be extreme.
* config/loongarch/loongarch.cc (loongarch_call_tls_get_addr):
Add extreme support for TLS GD and LD types.
(loongarch_legitimize_tls_address): Add extreme support for TLS LE
and IE.
(loongarch_split_symbol): When compiling with -mcmodel=extreme,
the symbol address will be obtained through five instructions.
(loongarch_print_operand_reloc): Add support.
(loongarch_print_operand): Add support.
(loongarch_print_operand_address): Add support.
(loongarch_option_override_internal): Set '-mcmodel=extreme' option
incompatible with '-mno-explicit-relocs'.
* config/loongarch/loongarch.md (@lui_l_hi20<mode>):
Loads bits 12-31 of data into registers.
(lui_h_lo20): Load bits 32-51 of the data and spell bits 0-31 of
the source register.
(lui_h_hi12): Load bits 52-63 of the data and spell bits 0-51 of
the source register.
* config/loongarch/predicates.md: Symbols need to be decomposed
when defining the macro TARGET_CMODEL_EXTREME
* doc/invoke.texi: Modify the description information of cmodel in the document.
Document -W[no-]extreme-plt.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/func-call-1.c: Add option '-mcmodel=normal'.
* gcc.target/loongarch/func-call-2.c: Likewise.
* gcc.target/loongarch/func-call-3.c: Likewise.
* gcc.target/loongarch/func-call-4.c: Likewise.
* gcc.target/loongarch/func-call-5.c: Likewise.
* gcc.target/loongarch/func-call-6.c: Likewise.
* gcc.target/loongarch/func-call-7.c: Likewise.
* gcc.target/loongarch/func-call-8.c: Likewise.
* gcc.target/loongarch/relocs-symbol-noaddend.c: Likewise.
* gcc.target/loongarch/func-call-extreme-1.c: New test.
* gcc.target/loongarch/func-call-extreme-2.c: New test.
16 files changed:
gcc/config/loongarch/loongarch-opts.cc
gcc/config/loongarch/loongarch.cc
gcc/config/loongarch/loongarch.md
gcc/config/loongarch/predicates.md
gcc/doc/invoke.texi
gcc/testsuite/gcc.target/loongarch/func-call-1.c
gcc/testsuite/gcc.target/loongarch/func-call-2.c
gcc/testsuite/gcc.target/loongarch/func-call-3.c
gcc/testsuite/gcc.target/loongarch/func-call-4.c
gcc/testsuite/gcc.target/loongarch/func-call-5.c
gcc/testsuite/gcc.target/loongarch/func-call-6.c
gcc/testsuite/gcc.target/loongarch/func-call-7.c
gcc/testsuite/gcc.target/loongarch/func-call-8.c
gcc/testsuite/gcc.target/loongarch/func-call-extreme-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/func-call-extreme-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/loongarch/relocs-symbol-noaddend.c