[PATCH] TLS support for powerpc/powerpc64 (take 2)

Richard Henderson rth@redhat.com
Fri May 9 22:58:00 GMT 2003


On Fri, May 09, 2003 at 09:30:04AM -0700, Janis Johnson wrote:
> +static GTY(()) rtx rs6000_tls_symbol;
> +static rtx
> +rs6000_tls_get_addr ()
> +{
> +  if (!rs6000_tls_symbol)
> +    rs6000_tls_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tls_get_addr");

You should use init_one_libfunc instead of gen_rtx_SYMBOL_REF
so that the proper SYMBOL_REF_FLAGS are set.  I'm surprised
that you didn't see problems on the ppc64 port because of this.

> +rs6000_got_sym ()
> +{
> +  if (!rs6000_got_symbol)
> +    rs6000_got_symbol = gen_rtx_SYMBOL_REF (Pmode, "_GLOBAL_OFFSET_TABLE_");

This one's tougher.  Depends on how it gets used, but you probably
want to set SYMBOL_FLAG_LOCAL | SYMBOL_FLAG_EXTERNAL.  While it
might not make a difference, it's certainly more correct.

> +		{
> +		  char buf[30];
> +		  static int tls_got_labelno = 0;
> +		  rtx tempLR, lab, tmp3, mem;
> +		  rtx first, last;
> +
> +		  ASM_GENERATE_INTERNAL_LABEL (buf, "LTLS", tls_got_labelno++);
> +		  lab = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
> +		  tempLR = gen_reg_rtx (Pmode);
> +		  tmp1 = gen_reg_rtx (Pmode);
> +		  tmp2 = gen_reg_rtx (Pmode);
> +		  tmp3 = gen_reg_rtx (Pmode);
> +		  mem = gen_rtx_MEM (Pmode, tmp1);
> +		  RTX_UNCHANGING_P (mem) = 1;
> +
> +		  first = emit_insn (gen_load_toc_v4_PIC_1b (tempLR, lab,
> +							     gsym));
> +		  emit_move_insn (tmp1, tempLR);
> +		  emit_move_insn (tmp2, mem);
> +		  emit_insn (gen_addsi3 (tmp3, tmp1, tmp2));
> +		  last = emit_move_insn (got, tmp3);
> +		  REG_NOTES (last) = gen_rtx_EXPR_LIST (REG_EQUAL, gsym,
> +							REG_NOTES (last));
> +		  REG_NOTES (first) = gen_rtx_INSN_LIST (REG_LIBCALL, last,
> +							 REG_NOTES (first));
> +		  REG_NOTES (last) = gen_rtx_INSN_LIST (REG_RETVAL, first,
> +							REG_NOTES (last));
> +		}

I'm surprised that you have to work this hard to get the GOT pointer
for 32-bit mode PIC.  I'd have expected that you could just use
pic_offset_table_rtx and have the prologue set it up for you.

Certainly cleaning that up (if possible) should be a followup patch.



r~



More information about the Gcc-patches mailing list