On Thu, 2024-02-29 at 09:42 +0800, mengqinggang wrote: > Generate la.tls.desc macro instruction for TLS descriptors model. > > la.tls.desc expand to > pcalau12i $a0, %desc_pc_hi20(a) > ld.d $a1, $a0, %desc_ld_pc_lo12(a) > addi.d $a0, $a0, %desc_add_pc_lo12(a) > jirl $ra, $a1, %desc_call(a) > > The default is TLS descriptors, but can be configure with > -mtls-dialect={desc,trad}.
Please keep trad as the default for now. Glibc-2.40 will be released after GCC 14.1 but we don't want to end up in a situation where the default configuration of the latest GCC release creating something not working with latest Glibc release. And there's also musl libc we need to take into account. Or you can write some autoconf test for if the assembler supports tlsdesc and check TARGET_GLIBC_MAJOR & TARGET_GLIBC_MINOR for Glibc version to decide if enable desc by default. If you want this but don't have time to implement you can leave trad the default and I'll take care of this. /* snip */ > +(define_insn "@got_load_tls_desc<mode>" > + [(set (match_operand:P 0 "register_operand" "=r") > + (unspec:P > + [(match_operand:P 1 "symbolic_operand" "")] > + UNSPEC_TLS_DESC)) > + (clobber (reg:SI FCC0_REGNUM)) > + (clobber (reg:SI FCC1_REGNUM)) > + (clobber (reg:SI FCC2_REGNUM)) > + (clobber (reg:SI FCC3_REGNUM)) > + (clobber (reg:SI FCC4_REGNUM)) > + (clobber (reg:SI FCC5_REGNUM)) > + (clobber (reg:SI FCC6_REGNUM)) > + (clobber (reg:SI FCC7_REGNUM)) > + (clobber (reg:SI A1_REGNUM)) > + (clobber (reg:SI RETURN_ADDR_REGNUM))] Ok, the clobber list is correct. > + "TARGET_TLS_DESC" > + "la.tls.desc\t%0,%1" With -mexplicit-relocs=always we should emit %desc_pc_lo12 etc. instead of la.tls.desc. As we don't want to add too many code we can just hard code the 4 instructions here instead of splitting this insn, just something like { return TARGET_EXPLICIT_RELOCS_ALWAS ? "......" : "la.tls.desc\t%0,%1"; } > + [(set_attr "got" "load") > + (set_attr "mode" "<MODE>")]) We need (set_attr "length" "16") in this list as this actually expands into 16 bytes. -- Xi Ruoyao <xry...@xry111.site> School of Aerospace Science and Technology, Xidian University