LoongArch: Added support for loading __get_tls_addr symbol address using call36.

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_call_tls_get_addr):
	Add support for call36.

gcc/testsuite/ChangeLog:

	* gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c: New test.
This commit is contained in:
Lulu Cheng 2024-01-26 11:14:00 +08:00
parent 5fbd80223e
commit 3932899a83
2 changed files with 21 additions and 6 deletions

View file

@ -2807,17 +2807,27 @@ loongarch_call_tls_get_addr (rtx sym, enum loongarch_symbol_type type, rtx v0)
case CMODEL_MEDIUM:
{
rtx reg = gen_reg_rtx (Pmode);
if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE)
{
emit_insn (gen_pcalau12i (Pmode, reg, loongarch_tls_symbol));
rtx call = gen_call_value_internal_1 (Pmode, v0, reg,
loongarch_tls_symbol,
const0_rtx);
insn = emit_call_insn (call);
rtx call;
if (HAVE_AS_SUPPORT_CALL36)
call = gen_call_value_internal (v0, loongarch_tls_symbol,
const0_rtx);
else
{
rtx reg = gen_reg_rtx (Pmode);
emit_insn (gen_pcalau12i (Pmode, reg,
loongarch_tls_symbol));
call = gen_call_value_internal_1 (Pmode, v0, reg,
loongarch_tls_symbol,
const0_rtx);
}
insn = emit_call_insn (call);
}
else
{
rtx reg = gen_reg_rtx (Pmode);
emit_move_insn (reg, loongarch_tls_symbol);
insn = emit_call_insn (gen_call_value_internal (v0,
reg,

View file

@ -0,0 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fPIC -mexplicit-relocs=auto -mcmodel=medium -fplt" } */
/* { dg-final { scan-assembler "pcaddu18i\t\\\$r1,%call36\\\(__tls_get_addr\\\)" { target { tls_native && loongarch_call36_support } } } } */
#include "./explicit-relocs-auto-tls-ld-gd.c"