73 lines
2.6 KiB
Diff
73 lines
2.6 KiB
Diff
From d802fd5eb24bba0c274edeea5aff33e794927aaa Mon Sep 17 00:00:00 2001
|
|
From: Lulu Cheng <chenglulu@loongson.cn>
|
|
Date: Fri, 26 Jan 2024 11:14:00 +0800
|
|
Subject: [PATCH 127/188] 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.
|
|
---
|
|
gcc/config/loongarch/loongarch.cc | 22 ++++++++++++++-----
|
|
...icit-relocs-medium-call36-auto-tls-ld-gd.c | 5 +++++
|
|
2 files changed, 21 insertions(+), 6 deletions(-)
|
|
create mode 100644 gcc/testsuite/gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c
|
|
|
|
diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
|
|
index 84b949021..0050813df 100644
|
|
--- a/gcc/config/loongarch/loongarch.cc
|
|
+++ b/gcc/config/loongarch/loongarch.cc
|
|
@@ -2803,17 +2803,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 000000000..d1a482083
|
|
--- /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"
|
|
--
|
|
2.43.0
|
|
|