Projects
openEuler:24.03:SP1:Everything
gcc
_service:tar_scm:0124-LoongArch-Merge-template-...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0124-LoongArch-Merge-template-got_load_tls_-ld-gd-le-ie.patch of Package gcc
From 3f45bbfe924ffe38832b2ad0050589b9f188422e Mon Sep 17 00:00:00 2001 From: Lulu Cheng <chenglulu@loongson.cn> Date: Thu, 25 Jan 2024 14:44:39 +0800 Subject: [PATCH 124/188] LoongArch: Merge template got_load_tls_{ld/gd/le/ie}. gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_load_tls): Load all types of tls symbols through one function. (loongarch_got_load_tls_gd): Delete. (loongarch_got_load_tls_ld): Delete. (loongarch_got_load_tls_ie): Delete. (loongarch_got_load_tls_le): Delete. (loongarch_call_tls_get_addr): Modify the called function name. (loongarch_legitimize_tls_address): Likewise. * config/loongarch/loongarch.md (@got_load_tls_gd<mode>): Delete. (@load_tls<mode>): New template. (@got_load_tls_ld<mode>): Delete. (@got_load_tls_le<mode>): Delete. (@got_load_tls_ie<mode>): Delete. --- gcc/config/loongarch/loongarch.cc | 47 +++++------------------- gcc/config/loongarch/loongarch.md | 59 ++++++++++++------------------- 2 files changed, 30 insertions(+), 76 deletions(-) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 612a9c138..ced7e58c2 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -2732,36 +2732,12 @@ loongarch_add_offset (rtx temp, rtx reg, HOST_WIDE_INT offset) /* The __tls_get_attr symbol. */ static GTY (()) rtx loongarch_tls_symbol; -/* Load an entry from the GOT for a TLS GD access. */ +/* Load an entry for a TLS access. */ static rtx -loongarch_got_load_tls_gd (rtx dest, rtx sym) +loongarch_load_tls (rtx dest, rtx sym) { - return gen_got_load_tls_gd (Pmode, dest, sym); -} - -/* Load an entry from the GOT for a TLS LD access. */ - -static rtx -loongarch_got_load_tls_ld (rtx dest, rtx sym) -{ - return gen_got_load_tls_ld (Pmode, dest, sym); -} - -/* Load an entry from the GOT for a TLS IE access. */ - -static rtx -loongarch_got_load_tls_ie (rtx dest, rtx sym) -{ - return gen_got_load_tls_ie (Pmode, dest, sym); -} - -/* Add in the thread pointer for a TLS LE access. */ - -static rtx -loongarch_got_load_tls_le (rtx dest, rtx sym) -{ - return gen_got_load_tls_le (Pmode, dest, sym); + return gen_load_tls (Pmode, dest, sym); } /* Return an instruction sequence that calls __tls_get_addr. SYM is @@ -2805,14 +2781,7 @@ loongarch_call_tls_get_addr (rtx sym, enum loongarch_symbol_type type, rtx v0) emit_insn (gen_tls_low (Pmode, a0, high, loc)); } else - { - if (type == SYMBOL_TLSLDM) - emit_insn (loongarch_got_load_tls_ld (a0, loc)); - else if (type == SYMBOL_TLSGD) - emit_insn (loongarch_got_load_tls_gd (a0, loc)); - else - gcc_unreachable (); - } + emit_insn (loongarch_load_tls (a0, loc)); if (flag_plt) { @@ -2949,10 +2918,10 @@ loongarch_legitimize_tls_address (rtx loc) /* la.tls.ie; tp-relative add. */ tp = gen_rtx_REG (Pmode, THREAD_POINTER_REGNUM); tmp1 = gen_reg_rtx (Pmode); + tmp2 = loongarch_unspec_address (loc, SYMBOL_TLS_IE); dest = gen_reg_rtx (Pmode); if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE) { - tmp2 = loongarch_unspec_address (loc, SYMBOL_TLS_IE); tmp3 = gen_reg_rtx (Pmode); rtx high = gen_rtx_HIGH (Pmode, copy_rtx (tmp2)); high = loongarch_force_temporary (tmp3, high); @@ -2975,7 +2944,7 @@ loongarch_legitimize_tls_address (rtx loc) emit_insn (gen_ld_from_got (Pmode, tmp1, high, tmp2)); } else - emit_insn (loongarch_got_load_tls_ie (tmp1, loc)); + emit_insn (loongarch_load_tls (tmp1, tmp2)); emit_insn (gen_add3_insn (dest, tmp1, tp)); } break; @@ -3007,11 +2976,11 @@ loongarch_legitimize_tls_address (rtx loc) tp = gen_rtx_REG (Pmode, THREAD_POINTER_REGNUM); tmp1 = gen_reg_rtx (Pmode); + tmp2 = loongarch_unspec_address (loc, SYMBOL_TLS_LE); dest = gen_reg_rtx (Pmode); if (la_opt_explicit_relocs != EXPLICIT_RELOCS_NONE) { - tmp2 = loongarch_unspec_address (loc, SYMBOL_TLS_LE); tmp3 = gen_reg_rtx (Pmode); rtx high = gen_rtx_HIGH (Pmode, copy_rtx (tmp2)); high = loongarch_force_temporary (tmp3, high); @@ -3039,7 +3008,7 @@ loongarch_legitimize_tls_address (rtx loc) } } else - emit_insn (loongarch_got_load_tls_le (tmp1, loc)); + emit_insn (loongarch_load_tls (tmp1, tmp2)); emit_insn (gen_add3_insn (dest, tmp1, tp)); } break; diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index 23d8dc126..4f9a92334 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -51,10 +51,7 @@ UNSPEC_BITREV_8B ;; TLS - UNSPEC_TLS_GD - UNSPEC_TLS_LD - UNSPEC_TLS_LE - UNSPEC_TLS_IE + UNSPEC_TLS ;; Stack tie UNSPEC_TIE @@ -2701,45 +2698,33 @@ ;; Thread-Local Storage -(define_insn "@got_load_tls_gd<mode>" +(define_insn "@load_tls<mode>" [(set (match_operand:P 0 "register_operand" "=r") (unspec:P [(match_operand:P 1 "symbolic_operand" "")] - UNSPEC_TLS_GD))] + UNSPEC_TLS))] "" - "la.tls.gd\t%0,%1" - [(set_attr "got" "load") - (set_attr "mode" "<MODE>")]) - -(define_insn "@got_load_tls_ld<mode>" - [(set (match_operand:P 0 "register_operand" "=r") - (unspec:P - [(match_operand:P 1 "symbolic_operand" "")] - UNSPEC_TLS_LD))] - "" - "la.tls.ld\t%0,%1" - [(set_attr "got" "load") - (set_attr "mode" "<MODE>")]) +{ + enum loongarch_symbol_type symbol_type; + gcc_assert (loongarch_symbolic_constant_p (operands[1], &symbol_type)); -(define_insn "@got_load_tls_le<mode>" - [(set (match_operand:P 0 "register_operand" "=r") - (unspec:P - [(match_operand:P 1 "symbolic_operand" "")] - UNSPEC_TLS_LE))] - "" - "la.tls.le\t%0,%1" - [(set_attr "got" "load") - (set_attr "mode" "<MODE>")]) + switch (symbol_type) + { + case SYMBOL_TLS_LE: + return "la.tls.le\t%0,%1"; + case SYMBOL_TLS_IE: + return "la.tls.ie\t%0,%1"; + case SYMBOL_TLSLDM: + return "la.tls.ld\t%0,%1"; + case SYMBOL_TLSGD: + return "la.tls.gd\t%0,%1"; -(define_insn "@got_load_tls_ie<mode>" - [(set (match_operand:P 0 "register_operand" "=r") - (unspec:P - [(match_operand:P 1 "symbolic_operand" "")] - UNSPEC_TLS_IE))] - "" - "la.tls.ie\t%0,%1" - [(set_attr "got" "load") - (set_attr "mode" "<MODE>")]) + default: + gcc_unreachable (); + } +} + [(set_attr "mode" "<MODE>") + (set_attr "insn_count" "2")]) ;; Move operand 1 to the high word of operand 0 using movgr2frh.w, preserving the ;; value in the low word. -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2