From 5a5c5784d89008664ab42c17efcab7198b132456 Mon Sep 17 00:00:00 2001 From: Claudiu Zissulescu Date: Mon, 5 Dec 2016 12:16:38 +0100 Subject: [PATCH] [ARC] Remove unused patterns, refactor unspec+offset pattern gen. 2016-12-05 Claudiu Zissulescu * config/arc/arc-protos.h (insn_is_tls_gd_dispatch): Remove. * config/arc/arc.c (arc_unspec_offset): New function. (arc_finalize_pic): Change. (arc_emit_call_tls_get_addr): Likewise. (arc_legitimize_tls_address): Likewise. (arc_legitimize_pic_address): Likewise. (insn_is_tls_gd_dispatch): Remove. * config/arc/arc.h (INSN_REFERENCES_ARE_DELAYED): Change. * config/arc/arc.md (ls_gd_load): Remove unused pattern. (tls_gd_dispatch): Likewise. From-SVN: r243244 --- gcc/ChangeLog | 13 ++++++++++++ gcc/config/arc/arc-protos.h | 1 - gcc/config/arc/arc.c | 41 ++++++++++++++++--------------------- gcc/config/arc/arc.h | 2 +- gcc/config/arc/arc.md | 34 ------------------------------ 5 files changed, 32 insertions(+), 59 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5d66a96f2fe..c5095c2599c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2016-12-05 Claudiu Zissulescu + + * config/arc/arc-protos.h (insn_is_tls_gd_dispatch): Remove. + * config/arc/arc.c (arc_unspec_offset): New function. + (arc_finalize_pic): Change. + (arc_emit_call_tls_get_addr): Likewise. + (arc_legitimize_tls_address): Likewise. + (arc_legitimize_pic_address): Likewise. + (insn_is_tls_gd_dispatch): Remove. + * config/arc/arc.h (INSN_REFERENCES_ARE_DELAYED): Change. + * config/arc/arc.md (ls_gd_load): Remove unused pattern. + (tls_gd_dispatch): Likewise. + 2016-12-025 Andre Vieira * config/arm/arm.c (TARGET_ASM_INIT_SECTIONS): Fix wrong undef diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h index 83a0b731e70..bdbf7ce77f2 100644 --- a/gcc/config/arc/arc-protos.h +++ b/gcc/config/arc/arc-protos.h @@ -121,6 +121,5 @@ extern int regno_clobbered_p (unsigned int, rtx_insn *, machine_mode, int); extern int arc_return_slot_offset (void); extern bool arc_legitimize_reload_address (rtx *, machine_mode, int, int); extern void arc_secondary_reload_conv (rtx, rtx, rtx, bool); -extern bool insn_is_tls_gd_dispatch (rtx_insn *); extern void arc_cpu_cpp_builtins (cpp_reader *); extern bool arc_store_addr_hazard_p (rtx_insn *, rtx_insn *); diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 832f567a79b..a0aa16e75b4 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -2771,6 +2771,15 @@ arc_return_slot_offset () /* PIC */ +/* Helper to generate unspec constant. */ + +static rtx +arc_unspec_offset (rtx loc, int unspec) +{ + return gen_rtx_CONST (Pmode, gen_rtx_UNSPEC (Pmode, gen_rtvec (1, loc), + unspec)); +} + /* Emit special PIC prologues and epilogues. */ /* If the function has any GOTOFF relocations, then the GOTBASE register has to be setup in the prologue @@ -2796,9 +2805,7 @@ arc_finalize_pic (void) gcc_assert (flag_pic != 0); pat = gen_rtx_SYMBOL_REF (Pmode, "_DYNAMIC"); - pat = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, pat), ARC_UNSPEC_GOT); - pat = gen_rtx_CONST (Pmode, pat); - + pat = arc_unspec_offset (pat, ARC_UNSPEC_GOT); pat = gen_rtx_SET (baseptr_rtx, pat); emit_insn (pat); @@ -4866,8 +4873,7 @@ arc_emit_call_tls_get_addr (rtx sym, int reloc, rtx eqv) start_sequence (); - rtx x = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, sym), reloc); - x = gen_rtx_CONST (Pmode, x); + rtx x = arc_unspec_offset (sym, reloc); emit_move_insn (r0, x); use_reg (&call_fusage, r0); @@ -4923,17 +4929,18 @@ arc_legitimize_tls_address (rtx addr, enum tls_model model) addr = gen_rtx_CONST (Pmode, addr); base = arc_legitimize_tls_address (base, TLS_MODEL_GLOBAL_DYNAMIC); return gen_rtx_PLUS (Pmode, force_reg (Pmode, base), addr); + case TLS_MODEL_GLOBAL_DYNAMIC: return arc_emit_call_tls_get_addr (addr, UNSPEC_TLS_GD, addr); + case TLS_MODEL_INITIAL_EXEC: - addr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_TLS_IE); - addr = gen_rtx_CONST (Pmode, addr); + addr = arc_unspec_offset (addr, UNSPEC_TLS_IE); addr = copy_to_mode_reg (Pmode, gen_const_mem (Pmode, addr)); return gen_rtx_PLUS (Pmode, arc_get_tp (), addr); + case TLS_MODEL_LOCAL_EXEC: local_exec: - addr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_TLS_OFF); - addr = gen_rtx_CONST (Pmode, addr); + addr = arc_unspec_offset (addr, UNSPEC_TLS_OFF); return gen_rtx_PLUS (Pmode, arc_get_tp (), addr); default: gcc_unreachable (); @@ -4964,14 +4971,11 @@ arc_legitimize_pic_address (rtx orig, rtx oldx) else if (!flag_pic) return orig; else if (CONSTANT_POOL_ADDRESS_P (addr) || SYMBOL_REF_LOCAL_P (addr)) - return gen_rtx_CONST (Pmode, - gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), - ARC_UNSPEC_GOTOFFPC)); + return arc_unspec_offset (addr, ARC_UNSPEC_GOTOFFPC); /* This symbol must be referenced via a load from the Global Offset Table (@GOTPC). */ - pat = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), ARC_UNSPEC_GOT); - pat = gen_rtx_CONST (Pmode, pat); + pat = arc_unspec_offset (addr, ARC_UNSPEC_GOT); pat = gen_const_mem (Pmode, pat); if (oldx == NULL) @@ -9985,15 +9989,6 @@ arc_dwarf_register_span (rtx rtl) return p; } -/* We can't inline this in INSN_REFERENCES_ARE_DELAYED because - resource.h doesn't include the required header files. */ - -bool -insn_is_tls_gd_dispatch (rtx_insn *insn) -{ - return recog_memoized (insn) == CODE_FOR_tls_gd_dispatch; -} - /* Return true if OP is an acceptable memory operand for ARCompact 16-bit load instructions of MODE. diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 611ef54df22..64bd9e0212c 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -1612,7 +1612,7 @@ extern enum arc_function_type arc_compute_function_type (struct function *); && (get_attr_type (X) == TYPE_CALL || get_attr_type (X) == TYPE_SFUNC)) #define INSN_REFERENCES_ARE_DELAYED(insn) \ - (INSN_SETS_ARE_DELAYED (insn) && !insn_is_tls_gd_dispatch (insn)) + (INSN_SETS_ARE_DELAYED (insn)) #define CALL_ATTR(X, NAME) \ ((CALL_P (X) || NONJUMP_INSN_P (X)) \ diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index 925fcd6d1ad..18bc68f8f5e 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -5486,21 +5486,6 @@ [(set_attr "is_sfunc" "yes") (set_attr "predicable" "yes")]) -(define_insn "tls_gd_load" - [(set (match_operand:SI 0 "dest_reg_operand" "=Rcq#q,c") - (unspec:SI [(match_operand:SI 1 "register_operand" "Rcq#q,c") - (match_operand:SI 2 "symbolic_operand" "X,X")] - UNSPEC_TLS_GD))] - "" - ".tls_gd_ld %2`ld%? %0,[%1]" - [(set_attr "type" "load") - ; if the linker has to patch this into IE, we need a long insn - ; (FIXME: or two short insn, ld_s / jl_s. missing -Os optimization.) - (set_attr_alternative "iscompact" - [(cond [(ne (symbol_ref "arc_tp_regno == 30") (const_int 0)) - (const_string "*")] (const_string "maybe")) - (const_string "*")])]) - (define_insn "tls_gd_get_addr" [(set (reg:SI R0_REG) (call:SI (mem:SI (unspec:SI [(match_operand:SI 0 @@ -5514,25 +5499,6 @@ ; With TARGET_MEDIUM_CALLS, plt calls are not predicable. (set_attr "predicable" "no")]) -; We make this call specific to the tls symbol to avoid commoning this -; with calls for other symbols; we want the linker to be able to -(define_insn "tls_gd_dispatch" - [(set (reg:SI R0_REG) - (unspec:SI - [(reg:SI R0_REG) - (call (mem:SI (match_operand:SI 0 "register_operand" "Rcq,q,c")) - (const_int 0)) - (match_operand:SI 1 "symbolic_operand" "X,X,X")] - UNSPEC_TLS_GD)) - (clobber (reg:SI RETURN_ADDR_REGNUM)) - (clobber (reg:DI R10_REG)) - (clobber (reg:SI R12_REG))] - "" - ".tls_gd_call %1`jl%!%* [%0]" - [(set_attr "type" "call") - (set_attr "iscompact" "maybe,false,*") - (set_attr "predicable" "no,no,yes")]) - ;; For thread pointer builtins (define_expand "get_thread_pointersi" [(set (match_operand:SI 0 "register_operand") (match_dup 1))] -- 2.30.2