Message ID | 4FFE744F.40405@codesourcery.com |
---|---|
State | New |
Headers | show |
Chung-Lin Tang <cltang@codesourcery.com> writes: > @@ -2851,11 +2851,12 @@ mips_call_tls_get_addr (rtx sym, enum mips_symbol_ > /* Return a pseudo register that contains the current thread pointer. */ > > static rtx > -mips_get_tp (void) > +mips_get_tp (rtx target) > { > - rtx tp, fn; > + rtx fn; > + rtx tp = (target != NULL_RTX && REG_P (target) > + ? target : gen_reg_rtx (Pmode)); > > - tp = gen_reg_rtx (Pmode); > if (TARGET_MIPS16) > { > mips_need_mips16_rdhwr_p = true; Sorry for being fussy, but let's do it the other way around: rename mips_get_tp to mips_expand_builtin_thread_pointer: /* Implement TARGET_EXPAND_BUILTIN_THREAD_POINTER. */ static rtx mips_expand_builtin_thread_pointer (rtx tp) { rtx fn; if (TARGET_MIPS16) ... } (i.e. always using the passed-in tp, which is safe with your 1/6 patch), then change mips_get_tp as follows: /* Return a pseudo register that contains the current thread pointer. */ static rtx mips_get_tp (void) { return mips_expand_builtin_thread_pointer (gen_reg_rtx (Pmode)); } OK with that change, thanks. Richard
On 2012/7/13 02:45 AM, Richard Sandiford wrote: > /* Implement TARGET_EXPAND_BUILTIN_THREAD_POINTER. */ > > static rtx > mips_expand_builtin_thread_pointer (rtx tp) > { > rtx fn; > > if (TARGET_MIPS16) > ... > } > > (i.e. always using the passed-in tp, which is safe with your 1/6 patch), > then change mips_get_tp as follows: > > /* Return a pseudo register that contains the current thread pointer. */ > > static rtx > mips_get_tp (void) > { > return mips_expand_builtin_thread_pointer (gen_reg_rtx (Pmode)); > } > > OK with that change, thanks. > > Richard > Thanks! This looks prettier :) I'll change to this form before applying. Chung-Lin
Index: config/mips/mips.c =================================================================== --- config/mips/mips.c (revision 189431) +++ config/mips/mips.c (working copy) @@ -2851,11 +2851,12 @@ mips_call_tls_get_addr (rtx sym, enum mips_symbol_ /* Return a pseudo register that contains the current thread pointer. */ static rtx -mips_get_tp (void) +mips_get_tp (rtx target) { - rtx tp, fn; + rtx fn; + rtx tp = (target != NULL_RTX && REG_P (target) + ? target : gen_reg_rtx (Pmode)); - tp = gen_reg_rtx (Pmode); if (TARGET_MIPS16) { mips_need_mips16_rdhwr_p = true; @@ -2919,7 +2920,7 @@ mips_legitimize_tls_address (rtx loc) break; case TLS_MODEL_INITIAL_EXEC: - tp = mips_get_tp (); + tp = mips_get_tp (NULL_RTX); tmp1 = gen_reg_rtx (Pmode); tmp2 = mips_unspec_address (loc, SYMBOL_GOTTPREL); if (Pmode == DImode) @@ -2931,7 +2932,7 @@ mips_legitimize_tls_address (rtx loc) break; case TLS_MODEL_LOCAL_EXEC: - tmp1 = mips_get_tp (); + tmp1 = mips_get_tp (NULL_RTX); offset = mips_unspec_address (loc, SYMBOL_TPREL); if (mips_split_p[SYMBOL_TPREL]) { @@ -13884,6 +13885,13 @@ mips_expand_builtin (tree exp, rtx target, rtx sub } gcc_unreachable (); } + +static rtx +mips_expand_builtin_thread_pointer (rtx target) +{ + return mips_get_tp (target); +} + /* An entry in the MIPS16 constant pool. VALUE is the pool constant, MODE is its mode, and LABEL is the CODE_LABEL associated with it. */ @@ -17567,6 +17575,10 @@ mips_expand_vec_minmax (rtx target, rtx op0, rtx o #undef TARGET_EXPAND_BUILTIN #define TARGET_EXPAND_BUILTIN mips_expand_builtin +#undef TARGET_EXPAND_BUILTIN_THREAD_POINTER +#define TARGET_EXPAND_BUILTIN_THREAD_POINTER \ + mips_expand_builtin_thread_pointer + #undef TARGET_HAVE_TLS #define TARGET_HAVE_TLS HAVE_AS_TLS