aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorLulu Cheng <chenglulu@loongson.cn>2024-01-26 11:14:00 +0800
committerLulu Cheng <chenglulu@loongson.cn>2024-02-02 09:16:19 +0800
commit3932899a833f82537f96826daa5af8568b66adfc (patch)
tree0c5802fc97a4ccb2917b65369cfe0ca6c6bbc051 /gcc
parent5fbd80223e15520038b81f6cce8d3d30d93b3502 (diff)
downloadgcc-3932899a833f82537f96826daa5af8568b66adfc.zip
gcc-3932899a833f82537f96826daa5af8568b66adfc.tar.gz
gcc-3932899a833f82537f96826daa5af8568b66adfc.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/config/loongarch/loongarch.cc22
-rw-r--r--gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c5
2 files changed, 21 insertions, 6 deletions
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 987a374..e1e69ef 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -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,
diff --git a/gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c
new file mode 100644
index 0000000..d1a4820
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c
@@ -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"