diff options
author | Xi Ruoyao <xry111@xry111.site> | 2024-01-26 18:28:32 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@xry111.site> | 2024-03-09 17:50:00 +0800 |
commit | 42cd49aa48c7ca99e8d5e91ce582d41fdb75f3fc (patch) | |
tree | b158b847f7af2dac9249bf145744759f26b932fc /gcc/config/loongarch | |
parent | e8cc1f956b75a6bf74c5f5262ddced9451dcccac (diff) | |
download | gcc-42cd49aa48c7ca99e8d5e91ce582d41fdb75f3fc.zip gcc-42cd49aa48c7ca99e8d5e91ce582d41fdb75f3fc.tar.gz gcc-42cd49aa48c7ca99e8d5e91ce582d41fdb75f3fc.tar.bz2 |
LoongArch: Emit R_LARCH_RELAX for TLS IE with non-extreme code model to allow the IE to LE linker relaxation
In Binutils we need to make IE to LE relaxation only allowed when there
is an R_LARCH_RELAX after R_LARCH_TLE_IE_PC_{HI20,LO12} so an invalid
"partial" relaxation won't happen with the extreme code model. So if we
are emitting %ie_pc_{hi20,lo12} in a non-extreme code model, emit an
R_LARCH_RELAX to allow the relaxation. The IE to LE relaxation does not
require the pcalau12i and the ld instruction to be adjacent, so we don't
need to limit ourselves to use the macro.
For the distro maintainers backporting changes: this change depends on
r14-8721, without r14-8721 R_LARCH_RELAX can be emitted mistakenly in
the extreme code model.
gcc/ChangeLog:
* config/loongarch/loongarch.cc (loongarch_print_operand_reloc):
Support 'Q' for R_LARCH_RELAX for TLS IE.
(loongarch_output_move): Use 'Q' to print R_LARCH_RELAX for TLS
IE.
* config/loongarch/loongarch.md (ld_from_got<mode>): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/tls-ie-relax.c: New test.
* gcc.target/loongarch/tls-ie-norelax.c: New test.
* gcc.target/loongarch/tls-ie-extreme.c: New test.
Diffstat (limited to 'gcc/config/loongarch')
-rw-r--r-- | gcc/config/loongarch/loongarch.cc | 15 | ||||
-rw-r--r-- | gcc/config/loongarch/loongarch.md | 2 |
2 files changed, 15 insertions, 2 deletions
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 0428b6e..70e31bb 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -4981,7 +4981,7 @@ loongarch_output_move (rtx dest, rtx src) if (type == SYMBOL_TLS_LE) return "lu12i.w\t%0,%h1"; else - return "pcalau12i\t%0,%h1"; + return "%Q1pcalau12i\t%0,%h1"; } if (src_code == CONST_INT) @@ -6145,6 +6145,7 @@ loongarch_print_operand_reloc (FILE *file, rtx op, bool hi64_part, 'L' Print the low-part relocation associated with OP. 'm' Print one less than CONST_INT OP in decimal. 'N' Print the inverse of the integer branch condition for comparison OP. + 'Q' Print R_LARCH_RELAX for TLS IE. 'r' Print address 12-31bit relocation associated with OP. 'R' Print address 32-51bit relocation associated with OP. 'T' Print 'f' for (eq:CC ...), 't' for (ne:CC ...), @@ -6282,6 +6283,18 @@ loongarch_print_operand (FILE *file, rtx op, int letter) letter); break; + case 'Q': + if (!TARGET_LINKER_RELAXATION) + break; + + if (code == HIGH) + op = XEXP (op, 0); + + if (loongarch_classify_symbolic_expression (op) == SYMBOL_TLS_IE) + fprintf (file, ".reloc\t.,R_LARCH_RELAX\n\t"); + + break; + case 'r': loongarch_print_operand_reloc (file, op, false /* hi64_part */, true /* lo_reloc */); diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index f3b5c64..525e1e8 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2620,7 +2620,7 @@ (match_operand:P 2 "symbolic_operand")))] UNSPEC_LOAD_FROM_GOT))] "" - "ld.<d>\t%0,%1,%L2" + "%Q2ld.<d>\t%0,%1,%L2" [(set_attr "type" "move")] ) |