On 12/7/18 8:05 PM, Andreas Krebbel wrote: > On 07/12/2012 08:52 AM, Chung-Lin Tang wrote: >> * config/s390/s390.c (s390_builtin,code_for_builtin_64, >> code_for_builtin_31,s390_init_builtins,s390_expand_builtin): >> Remove. >> (s390_expand_builtin_thread_pointer): Add hook function for >> TARGET_EXPAND_BUILTIN_THREAD_POINTER. >> (s390_expand_builtin_set_thread_pointer): Add hook function for >> TARGET_EXPAND_BUILTIN_SET_THREAD_POINTER. > > I've tested your patches on s390x. No regressions. > > The patch is ok. > > Bye, > > -Andreas- >
S390 parts updated to use MD pattern. Sorry Andreas, would you mind testing the updated patches again? Thanks, Chung-Lin * config/s390/s390.c (s390_builtin,code_for_builtin_64, code_for_builtin_31,s390_init_builtins,s390_expand_builtin): Remove. * config/s390/s390.md (get_tp_64,get_tp_31,set_tp_64,set_tp_31): Remove. (get_thread_pointer<mode>,set_thread_pointer<mode>): New, adapted from removed patterns.
Index: config/s390/s390.c =================================================================== --- config/s390/s390.c (revision 190742) +++ config/s390/s390.c (working copy) @@ -9217,132 +9217,6 @@ s390_gimplify_va_arg (tree valist, tree type, gimp return build_va_arg_indirect_ref (addr); } - -/* Builtins. */ - -enum s390_builtin -{ - S390_BUILTIN_THREAD_POINTER, - S390_BUILTIN_SET_THREAD_POINTER, - - S390_BUILTIN_max -}; - -static enum insn_code const code_for_builtin_64[S390_BUILTIN_max] = { - CODE_FOR_get_tp_64, - CODE_FOR_set_tp_64 -}; - -static enum insn_code const code_for_builtin_31[S390_BUILTIN_max] = { - CODE_FOR_get_tp_31, - CODE_FOR_set_tp_31 -}; - -static void -s390_init_builtins (void) -{ - tree ftype; - - ftype = build_function_type_list (ptr_type_node, NULL_TREE); - add_builtin_function ("__builtin_thread_pointer", ftype, - S390_BUILTIN_THREAD_POINTER, BUILT_IN_MD, - NULL, NULL_TREE); - - ftype = build_function_type_list (void_type_node, ptr_type_node, NULL_TREE); - add_builtin_function ("__builtin_set_thread_pointer", ftype, - S390_BUILTIN_SET_THREAD_POINTER, BUILT_IN_MD, - NULL, NULL_TREE); -} - -/* Expand an expression EXP that calls a built-in function, - with result going to TARGET if that's convenient - (and in mode MODE if that's convenient). - SUBTARGET may be used as the target for computing one of EXP's operands. - IGNORE is nonzero if the value is to be ignored. */ - -static rtx -s390_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED, - enum machine_mode mode ATTRIBUTE_UNUSED, - int ignore ATTRIBUTE_UNUSED) -{ -#define MAX_ARGS 2 - - enum insn_code const *code_for_builtin = - TARGET_64BIT ? code_for_builtin_64 : code_for_builtin_31; - - tree fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); - unsigned int fcode = DECL_FUNCTION_CODE (fndecl); - enum insn_code icode; - rtx op[MAX_ARGS], pat; - int arity; - bool nonvoid; - tree arg; - call_expr_arg_iterator iter; - - if (fcode >= S390_BUILTIN_max) - internal_error ("bad builtin fcode"); - icode = code_for_builtin[fcode]; - if (icode == 0) - internal_error ("bad builtin fcode"); - - nonvoid = TREE_TYPE (TREE_TYPE (fndecl)) != void_type_node; - - arity = 0; - FOR_EACH_CALL_EXPR_ARG (arg, iter, exp) - { - const struct insn_operand_data *insn_op; - - if (arg == error_mark_node) - return NULL_RTX; - if (arity > MAX_ARGS) - return NULL_RTX; - - insn_op = &insn_data[icode].operand[arity + nonvoid]; - - op[arity] = expand_expr (arg, NULL_RTX, insn_op->mode, EXPAND_NORMAL); - - if (!(*insn_op->predicate) (op[arity], insn_op->mode)) - op[arity] = copy_to_mode_reg (insn_op->mode, op[arity]); - arity++; - } - - if (nonvoid) - { - enum machine_mode tmode = insn_data[icode].operand[0].mode; - if (!target - || GET_MODE (target) != tmode - || !(*insn_data[icode].operand[0].predicate) (target, tmode)) - target = gen_reg_rtx (tmode); - } - - switch (arity) - { - case 0: - pat = GEN_FCN (icode) (target); - break; - case 1: - if (nonvoid) - pat = GEN_FCN (icode) (target, op[0]); - else - pat = GEN_FCN (icode) (op[0]); - break; - case 2: - pat = GEN_FCN (icode) (target, op[0], op[1]); - break; - default: - gcc_unreachable (); - } - if (!pat) - return NULL_RTX; - emit_insn (pat); - - if (nonvoid) - return target; - else - return const0_rtx; -} - - /* Output assembly code for the trampoline template to stdio stream FILE. @@ -10785,11 +10659,6 @@ s390_loop_unroll_adjust (unsigned nunroll, struct #undef TARGET_RETURN_IN_MEMORY #define TARGET_RETURN_IN_MEMORY s390_return_in_memory -#undef TARGET_INIT_BUILTINS -#define TARGET_INIT_BUILTINS s390_init_builtins -#undef TARGET_EXPAND_BUILTIN -#define TARGET_EXPAND_BUILTIN s390_expand_builtin - #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA s390_output_addr_const_extra Index: config/s390/s390.md =================================================================== --- config/s390/s390.md (revision 190742) +++ config/s390/s390.md (working copy) @@ -8637,28 +8637,17 @@ ;;- Thread-local storage support. ;; -(define_expand "get_tp_64" - [(set (match_operand:DI 0 "nonimmediate_operand" "") (reg:DI TP_REGNUM))] - "TARGET_64BIT" +(define_expand "get_thread_pointer<mode>" + [(set (match_operand:P 0 "nonimmediate_operand" "") (reg:P TP_REGNUM))] + "" "") -(define_expand "get_tp_31" - [(set (match_operand:SI 0 "nonimmediate_operand" "") (reg:SI TP_REGNUM))] - "!TARGET_64BIT" +(define_expand "set_thread_pointer<mode>" + [(set (reg:P TP_REGNUM) (match_operand:P 0 "nonimmediate_operand" "")) + (set (reg:P TP_REGNUM) (unspec_volatile:P [(reg:P TP_REGNUM)] UNSPECV_SET_TP))] + "" "") -(define_expand "set_tp_64" - [(set (reg:DI TP_REGNUM) (match_operand:DI 0 "nonimmediate_operand" "")) - (set (reg:DI TP_REGNUM) (unspec_volatile:DI [(reg:DI TP_REGNUM)] UNSPECV_SET_TP))] - "TARGET_64BIT" - "") - -(define_expand "set_tp_31" - [(set (reg:SI TP_REGNUM) (match_operand:SI 0 "nonimmediate_operand" "")) - (set (reg:SI TP_REGNUM) (unspec_volatile:SI [(reg:SI TP_REGNUM)] UNSPECV_SET_TP))] - "!TARGET_64BIT" - "") - (define_insn "*set_tp" [(set (reg TP_REGNUM) (unspec_volatile [(reg TP_REGNUM)] UNSPECV_SET_TP))] ""