diff options
Diffstat (limited to 'gcc/config')
32 files changed, 209 insertions, 178 deletions
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index a9f5fba7ca5..f250e14a0c2 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -10818,10 +10818,8 @@ alpha_init_libfuncs (void) #undef TARGET_MACHINE_DEPENDENT_REORG #define TARGET_MACHINE_DEPENDENT_REORG alpha_reorg -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_false #undef TARGET_RETURN_IN_MEMORY diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 66709c7f31c..f53c8988b4f 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -133,10 +133,8 @@ static const struct attribute_spec arc_attribute_table[] = #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST arc_address_cost -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 3be2126be3d..83db0ec1cda 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -125,6 +125,8 @@ static int arm_adjust_cost (rtx, rtx, rtx, int); static int count_insns_for_constant (HOST_WIDE_INT, int); static int arm_get_strip_length (int); static bool arm_function_ok_for_sibcall (tree, tree); +static enum machine_mode arm_promote_function_mode (const_tree, enum machine_mode, + int *, const_tree, int); static void arm_internal_label (FILE *, const char *, unsigned long); static void arm_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); @@ -329,10 +331,8 @@ static const struct attribute_spec arm_attribute_table[] = #undef TARGET_INIT_LIBFUNCS #define TARGET_INIT_LIBFUNCS arm_init_libfuncs -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE arm_promote_function_mode #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES arm_promote_prototypes #undef TARGET_PASS_BY_REFERENCE @@ -3072,7 +3072,7 @@ arm_canonicalize_comparison (enum rtx_code code, enum machine_mode mode, /* Define how to find the value returned by a function. */ rtx -arm_function_value(const_tree type, const_tree func ATTRIBUTE_UNUSED) +arm_function_value(const_tree type, const_tree func) { enum machine_mode mode; int unsignedp ATTRIBUTE_UNUSED; @@ -3081,7 +3081,7 @@ arm_function_value(const_tree type, const_tree func ATTRIBUTE_UNUSED) mode = TYPE_MODE (type); /* Promote integer types. */ if (INTEGRAL_TYPE_P (type)) - PROMOTE_FUNCTION_MODE (mode, unsignedp, type); + mode = arm_promote_function_mode (type, mode, &unsignedp, func, 1); /* Promotes small structs returned in a register to full-word size for big-endian AAPCS. */ @@ -19094,6 +19094,19 @@ arm_promote_prototypes (const_tree t ATTRIBUTE_UNUSED) return !TARGET_AAPCS_BASED; } +static enum machine_mode +arm_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int *punsignedp ATTRIBUTE_UNUSED, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return ATTRIBUTE_UNUSED) +{ + if (GET_MODE_CLASS (mode) == MODE_INT + && GET_MODE_SIZE (mode) < 4) + return SImode; + + return mode; +} /* AAPCS based ABIs use short enums by default. */ diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 58ced2e7e51..082b5fabc3a 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -501,11 +501,6 @@ extern int arm_arch_hwdiv; (MODE) = SImode; \ } -#define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ - if (GET_MODE_CLASS (MODE) == MODE_INT \ - && GET_MODE_SIZE (MODE) < 4) \ - (MODE) = SImode; - /* Define this if most significant bit is lowest numbered in instructions that operate on numbered bit-fields. */ #define BITS_BIG_ENDIAN 0 diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 4f213062a4f..13887480d1f 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -6296,12 +6296,8 @@ bfin_expand_builtin (tree exp, rtx target ATTRIBUTE_UNUSED, #undef TARGET_SCHED_ISSUE_RATE #define TARGET_SCHED_ISSUE_RATE bfin_issue_rate -#undef TARGET_PROMOTE_PROTOTYPES -#define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_ARG_PARTIAL_BYTES #define TARGET_ARG_PARTIAL_BYTES bfin_arg_partial_bytes diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 66fc05d0f6e..a9fe9dee52f 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -85,6 +85,9 @@ static int in_code = 0; /* Fix for reg_overlap_mentioned_p. */ static int cris_reg_overlap_mentioned_p (rtx, rtx); +static enum machine_mode cris_promote_function_mode (const_tree, enum machine_mode, + int *, const_tree, int); + static void cris_print_base (rtx, FILE *); static void cris_print_index (rtx, FILE *); @@ -166,8 +169,9 @@ int cris_cpu_version = CRIS_DEFAULT_CPU_VERSION; #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST cris_address_cost -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE cris_promote_function_mode + #undef TARGET_STRUCT_VALUE_RTX #define TARGET_STRUCT_VALUE_RTX cris_struct_value_rtx #undef TARGET_SETUP_INCOMING_VARARGS @@ -3753,6 +3757,25 @@ cris_pass_by_reference (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED, || CRIS_FUNCTION_ARG_SIZE (mode, type) > 8); } +/* A combination of defining TARGET_PROMOTE_FUNCTION_MODE, promoting arguments + and *not* defining TARGET_PROMOTE_PROTOTYPES or PROMOTE_MODE gives the + best code size and speed for gcc, ipps and products in gcc-2.7.2. */ + +enum machine_mode +cris_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int *punsignedp ATTRIBUTE_UNUSED, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return) +{ + /* Defining PROMOTE_FUNCTION_RETURN in gcc-2.7.2 uncovered bug 981110 (even + when modifying FUNCTION_VALUE to return the promoted mode). Maybe + pointless as of now, but let's keep the old behavior. */ + if (for_return) + return mode; + return CRIS_PROMOTED_MODE (mode, *punsignedp, type); +} + static int cris_arg_partial_bytes (CUMULATIVE_ARGS *ca, enum machine_mode mode, diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index 920e354417e..39291079662 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -352,24 +352,10 @@ extern int target_flags; #define UNITS_PER_WORD 4 -/* A combination of defining PROMOTE_FUNCTION_MODE, - TARGET_PROMOTE_FUNCTION_ARGS that always returns true - and *not* defining TARGET_PROMOTE_PROTOTYPES or PROMOTE_MODE gives the - best code size and speed for gcc, ipps and products in gcc-2.7.2. */ #define CRIS_PROMOTED_MODE(MODE, UNSIGNEDP, TYPE) \ (GET_MODE_CLASS (MODE) == MODE_INT && GET_MODE_SIZE (MODE) < 4) \ ? SImode : MODE -#define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ - (MODE) = CRIS_PROMOTED_MODE (MODE, UNSIGNEDP, TYPE) - -/* Defining PROMOTE_FUNCTION_RETURN in gcc-2.7.2 uncovers bug 981110 (even - if defining FUNCTION_VALUE with MODE as PROMOTED_MODE ;-) - - FIXME: Report this when cris.h is part of GCC, so others can easily - see the problem. Maybe check other systems that define - TARGET_PROMOTE_FUNCTION_RETURN that always returns true. */ - /* We will be using prototype promotion, so they will be 32 bit. */ #define PARM_BOUNDARY 32 diff --git a/gcc/config/frv/frv.h b/gcc/config/frv/frv.h index 483ed77e9f7..dfb3fb8eeb1 100644 --- a/gcc/config/frv/frv.h +++ b/gcc/config/frv/frv.h @@ -1764,10 +1764,6 @@ typedef struct frv_stack { (Actually, on most machines, scalar values are returned in the same place regardless of mode). - If `TARGET_PROMOTE_FUNCTION_RETURN' is defined to return true, you - must apply the same promotion rules specified in `PROMOTE_MODE' if - VALTYPE is a scalar type. - If the precise function being called is known, FUNC is a tree node (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer. This makes it possible to use a different value-returning convention for specific diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index b2e950e52b8..71acdab0bb9 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -459,14 +459,8 @@ static const struct attribute_spec ia64_attribute_table[] = /* ??? ABI doesn't allow us to define this. */ #if 0 -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true -#endif - -/* ??? ABI doesn't allow us to define this. */ -#if 0 -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #endif /* ??? Investigate. */ diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index b99043efa99..ff0c868aaf2 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -189,10 +189,8 @@ static bool iq2000_legitimate_address_p (enum machine_mode, rtx, bool); #undef TARGET_HAVE_SWITCHABLE_BSS_SECTIONS #define TARGET_HAVE_SWITCHABLE_BSS_SECTIONS false -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true @@ -2186,15 +2184,14 @@ iq2000_select_section (tree decl, int reloc ATTRIBUTE_UNUSED, FUNC. */ rtx -iq2000_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED) +iq2000_function_value (const_tree valtype, const_tree func) { int reg = GP_RETURN; enum machine_mode mode = TYPE_MODE (valtype); int unsignedp = TYPE_UNSIGNED (valtype); - /* Since we define TARGET_PROMOTE_FUNCTION_RETURN that returns true, - we must promote the mode just as PROMOTE_MODE does. */ - mode = promote_mode (valtype, mode, &unsignedp, 1); + /* Since we promote return types, we must promote the mode here too. */ + mode = promote_function_mode (valtype, mode, &unsignedp, func, 1); return gen_rtx_REG (mode, reg); } diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index 3b0adef1074..170b4b00de6 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -192,10 +192,8 @@ static const struct attribute_spec mcore_attribute_table[] = #undef TARGET_MACHINE_DEPENDENT_REORG #define TARGET_MACHINE_DEPENDENT_REORG mcore_reorg -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true @@ -2730,14 +2728,15 @@ handle_structs_in_regs (enum machine_mode mode, const_tree type, int reg) } rtx -mcore_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED) +mcore_function_value (const_tree valtype, const_tree func) { enum machine_mode mode; int unsigned_p; mode = TYPE_MODE (valtype); - mode = promote_mode (valtype, mode, &unsigned_p, 1); + /* Since we promote return types, we must promote the mode here too. */ + mode = promote_function_mode (valtype, mode, &unsignedp, func, 1); return handle_structs_in_regs (mode, valtype, FIRST_RET_REG); } diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h index d5d6eeea8d5..222cb8942f9 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -279,7 +279,7 @@ extern void mips_expand_prologue (void); extern void mips_expand_before_return (void); extern void mips_expand_epilogue (bool); extern bool mips_can_use_return_insn (void); -extern rtx mips_function_value (const_tree, enum machine_mode); +extern rtx mips_function_value (const_tree, const_tree, enum machine_mode); extern bool mips_cannot_change_mode_class (enum machine_mode, enum machine_mode, enum reg_class); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 4a10fb47244..083b253faf0 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -4976,7 +4976,7 @@ mips_return_fpr_pair (enum machine_mode mode, VALTYPE is null and MODE is the mode of the return value. */ rtx -mips_function_value (const_tree valtype, enum machine_mode mode) +mips_function_value (const_tree valtype, const_tree func, enum machine_mode mode) { if (valtype) { @@ -4986,9 +4986,9 @@ mips_function_value (const_tree valtype, enum machine_mode mode) mode = TYPE_MODE (valtype); unsigned_p = TYPE_UNSIGNED (valtype); - /* Since TARGET_PROMOTE_FUNCTION_RETURN unconditionally returns true, - we must promote the mode just as PROMOTE_MODE does. */ - mode = promote_mode (valtype, mode, &unsigned_p, 1); + /* Since TARGET_PROMOTE_FUNCTION_MODE unconditionally promotes, + return values, promote the mode here too. */ + mode = promote_function_mode (valtype, mode, &unsigned_p, func, 1); /* Handle structures whose fields are returned in $f0/$f2. */ switch (mips_fpr_return_fields (valtype, fields)) @@ -14851,10 +14851,8 @@ mips_final_postscan_insn (FILE *file, rtx insn, rtx *opvec, int noperands) #undef TARGET_GIMPLIFY_VA_ARG_EXPR #define TARGET_GIMPLIFY_VA_ARG_EXPR mips_gimplify_va_arg_expr -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index a3ab2f8bb8f..8515ce10408 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2204,10 +2204,10 @@ enum reg_class #define FP_ARG_LAST (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1) #define LIBCALL_VALUE(MODE) \ - mips_function_value (NULL_TREE, MODE) + mips_function_value (NULL_TREE, NULL_TREE, MODE) #define FUNCTION_VALUE(VALTYPE, FUNC) \ - mips_function_value (VALTYPE, VOIDmode) + mips_function_value (VALTYPE, FUNC, VOIDmode) /* 1 if N is a possible register number for a function value. On the MIPS, R2 R3 and F0 F2 are the only register thus used. diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 67b1b2323b5..9e94279b85a 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -135,6 +135,9 @@ static void mmix_file_start (void); static void mmix_file_end (void); static bool mmix_rtx_costs (rtx, int, int, int *, bool); static rtx mmix_struct_value_rtx (tree, int); +static enum machine_mode mmix_promote_function_mode (const_tree, + enum machine_mode, + int *, const_tree, int); static bool mmix_pass_by_reference (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool); static bool mmix_frame_pointer_required (void); @@ -188,14 +191,9 @@ static bool mmix_frame_pointer_required (void); #undef TARGET_MACHINE_DEPENDENT_REORG #define TARGET_MACHINE_DEPENDENT_REORG mmix_reorg -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#if 0 -/* Apparently not doing TRT if int < register-size. FIXME: Perhaps - FUNCTION_VALUE and LIBCALL_VALUE needs tweaking as some ports say. */ -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true -#endif +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE mmix_promote_function_mode + #undef TARGET_STRUCT_VALUE_RTX #define TARGET_STRUCT_VALUE_RTX mmix_struct_value_rtx @@ -2692,6 +2690,28 @@ mmix_intval (rtx x) fatal_insn ("MMIX Internal: This is not a constant:", x); } +/* Worker function for TARGET_PROMOTE_FUNCTION_MODE. */ + +enum machine_mode +mmix_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int *punsignedp ATTRIBUTE_UNUSED, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return) +{ + /* Apparently not doing TRT if int < register-size. FIXME: Perhaps + FUNCTION_VALUE and LIBCALL_VALUE needs tweaking as some ports say. */ + if (for_return) + return mode; + + /* Promotion of modes currently generates slow code, extending before + operation, so we do it only for arguments. */ + if (GET_MODE_CLASS (mode) == MODE_INT + && GET_MODE_SIZE (mode) < 8) + return DImode; + else + return mode; +} /* Worker function for TARGET_STRUCT_VALUE_RTX. */ static rtx diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h index 72e35680ef5..41466545e21 100644 --- a/gcc/config/mmix/mmix.h +++ b/gcc/config/mmix/mmix.h @@ -182,23 +182,6 @@ extern int target_flags; #define FLOAT_WORDS_BIG_ENDIAN 1 #define UNITS_PER_WORD 8 -/* FIXME: Promotion of modes currently generates slow code, extending - before every operation. */ -/* I'm a little bit undecided about this one. It might be beneficial to - promote all operations. */ - -#define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ - do { \ - if (GET_MODE_CLASS (MODE) == MODE_INT \ - && GET_MODE_SIZE (MODE) < 8) \ - { \ - (MODE) = DImode; \ - /* Do the following some time later, \ - scrutinizing differences. */ \ - if (0) (UNSIGNEDP) = 0; \ - } \ - } while (0) - /* We need to align everything to 64 bits that can affect the alignment of other types. Since address N is interpreted in MMIX as (N modulo access_size), we must align. */ diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index 8e8db865e2b..bbd09f522e0 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -285,8 +285,8 @@ static size_t n_deferred_plabels = 0; #define TARGET_INIT_LIBFUNCS pa_hpux_init_libfuncs #endif -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE pa_promote_function_mode #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true @@ -9187,11 +9187,25 @@ insn_refs_are_delayed (rtx insn) && get_attr_type (insn) == TYPE_MILLI)); } +/* Promote the return value, but not the arguments. */ + +enum machine_mode +pa_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int *punsignedp ATTRIBUTE_UNUSED, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return) +{ + if (!for_return) + return mode; + return promote_mode (mode, punsignedp, type); +} + /* On the HP-PA the value is found in register(s) 28(-29), unless the mode is SF or DF. Then the value is returned in fr4 (32). - This must perform the same promotions as PROMOTE_MODE, else - TARGET_PROMOTE_FUNCTION_RETURN will not work correctly. + This must perform the same promotions as PROMOTE_MODE, else promoting + return values in TARGET_PROMOTE_FUNCTION_MODE will not work correctly. Small structures must be returned in a PARALLEL on PA64 in order to match the HP Compiler ABI. */ diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c index 358ef71e36b..ecec1f7121e 100644 --- a/gcc/config/picochip/picochip.c +++ b/gcc/config/picochip/picochip.c @@ -254,10 +254,8 @@ static char picochip_get_vliw_alu_id (void); #undef TARGET_ARG_PARTIAL_BYTES #define TARGET_ARG_PARTIAL_BYTES picochip_arg_partial_bytes -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true @@ -4144,7 +4142,7 @@ warn_of_byte_access (void) } rtx -picochip_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED, +picochip_function_value (const_tree valtype, const_tree func, bool outgoing ATTRIBUTE_UNUSED) { enum machine_mode mode = TYPE_MODE (valtype); @@ -4152,7 +4150,7 @@ picochip_function_value (const_tree valtype, const_tree func ATTRIBUTE_UNUSED, /* Since we define PROMOTE_FUNCTION_RETURN, we must promote the mode just as PROMOTE_MODE does. */ - mode = promote_mode (valtype, mode, &unsignedp, 1); + mode = promote_function_mode (valtype, mode, &unsignedp, func, 1); return gen_rtx_REG (mode, 0); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 25cacc46e91..8c0feb55057 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1347,10 +1347,8 @@ static const struct attribute_spec rs6000_attribute_table[] = /* On rs6000, function arguments are promoted, as are function return values. */ -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_RETURN_IN_MEMORY #define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory diff --git a/gcc/config/s390/s390-protos.h b/gcc/config/s390/s390-protos.h index 2329138cf1f..8b9ad5aedb5 100644 --- a/gcc/config/s390/s390-protos.h +++ b/gcc/config/s390/s390-protos.h @@ -125,6 +125,6 @@ extern void s390_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode, tree, int); #ifdef RTX_CODE extern rtx s390_function_arg (CUMULATIVE_ARGS *, enum machine_mode, tree, int); -extern rtx s390_function_value (const_tree, enum machine_mode); +extern rtx s390_function_value (const_tree, const_tree, enum machine_mode); #endif /* RTX_CODE */ #endif /* TREE_CODE */ diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index f5b2fa73d1f..25203ab52b6 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -8343,17 +8343,36 @@ s390_return_in_memory (const_tree type, const_tree fundecl ATTRIBUTE_UNUSED) return true; } +/* Function arguments and return values are promoted to word size. */ + +static enum machine_mode +s390_promote_function_mode (const_tree type, enum machine_mode mode, + int *punsignedp, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return ATTRIBUTE_UNUSED) +{ + if (INTEGRAL_MODE_P (mode) + && GET_MODE_SIZE (mode) < UNITS_PER_WORD) + { + if (POINTER_TYPE_P (type)) + *punsignedp = POINTERS_EXTEND_UNSIGNED; + return Pmode; + } + + return mode; +} + /* Define where to return a (scalar) value of type TYPE. If TYPE is null, define where to return a (scalar) value of mode MODE from a libcall. */ rtx -s390_function_value (const_tree type, enum machine_mode mode) +s390_function_value (const_tree type, const_tree fn, enum machine_mode mode) { if (type) { int unsignedp = TYPE_UNSIGNED (type); - mode = promote_mode (type, TYPE_MODE (type), &unsignedp, 1); + mode = promote_function_mode (type, TYPE_MODE (type), &unsignedp, fn, 1); } gcc_assert (GET_MODE_CLASS (mode) == MODE_INT || SCALAR_FLOAT_MODE_P (mode)); @@ -9998,10 +10017,8 @@ s390_reorg (void) #undef TARGET_GIMPLIFY_VA_ARG_EXPR #define TARGET_GIMPLIFY_VA_ARG_EXPR s390_gimplify_va_arg -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE s390_promote_function_mode #undef TARGET_PASS_BY_REFERENCE #define TARGET_PASS_BY_REFERENCE s390_pass_by_reference diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index f34b7f22567..4772367eee5 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -216,13 +216,6 @@ extern int s390_arch_flags; #endif #define MAX_BITS_PER_WORD 64 -/* Function arguments and return values are promoted to word size. */ -#define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ -if (INTEGRAL_MODE_P (MODE) && \ - GET_MODE_SIZE (MODE) < UNITS_PER_WORD) { \ - (MODE) = Pmode; \ - } - /* Allocation boundary (in *bits*) for storing arguments in argument list. */ #define PARM_BOUNDARY (TARGET_64BIT ? 64 : 32) @@ -697,10 +690,10 @@ CUMULATIVE_ARGS; /* Scalar return values. */ #define FUNCTION_VALUE(VALTYPE, FUNC) \ - s390_function_value ((VALTYPE), VOIDmode) + s390_function_value ((VALTYPE), (FUNC), VOIDmode) #define LIBCALL_VALUE(MODE) \ - s390_function_value (NULL, (MODE)) + s390_function_value (NULL, NULL, (MODE)) /* Only gpr 2 and fpr 0 are ever used as return registers. */ #define FUNCTION_VALUE_REGNO_P(N) ((N) == 2 || (N) == 16) diff --git a/gcc/config/score/score.c b/gcc/config/score/score.c index b75f3cfaebf..0241383fc86 100644 --- a/gcc/config/score/score.c +++ b/gcc/config/score/score.c @@ -89,11 +89,8 @@ #undef TARGET_ASM_OUTPUT_MI_THUNK #define TARGET_ASM_OUTPUT_MI_THUNK score_output_mi_thunk -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true - -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true diff --git a/gcc/config/score/score3.c b/gcc/config/score/score3.c index 4258d29e525..385620d33d6 100644 --- a/gcc/config/score/score3.c +++ b/gcc/config/score/score3.c @@ -859,15 +859,14 @@ score3_function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode mode, VALTYPE is the return type and MODE is VOIDmode. For libcalls, VALTYPE is null and MODE is the mode of the return value. */ rtx -score3_function_value (tree valtype, tree func ATTRIBUTE_UNUSED, - enum machine_mode mode) +score3_function_value (tree valtype, tree func, enum machine_mode mode) { if (valtype) { int unsignedp; mode = TYPE_MODE (valtype); unsignedp = TYPE_UNSIGNED (valtype); - mode = promote_mode (valtype, mode, &unsignedp, 1); + mode = promote_function_mode (valtype, mode, &unsignedp, func, 1); } return gen_rtx_REG (mode, RT_REGNUM); } diff --git a/gcc/config/score/score7.c b/gcc/config/score/score7.c index 9ab6ebd3004..368ac03a3ba 100644 --- a/gcc/config/score/score7.c +++ b/gcc/config/score/score7.c @@ -850,15 +850,14 @@ score7_function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode mode, VALTYPE is the return type and MODE is VOIDmode. For libcalls, VALTYPE is null and MODE is the mode of the return value. */ rtx -score7_function_value (tree valtype, tree func ATTRIBUTE_UNUSED, - enum machine_mode mode) +score7_function_value (tree valtype, tree func, enum machine_mode mode) { if (valtype) { int unsignedp; mode = TYPE_MODE (valtype); unsignedp = TYPE_UNSIGNED (valtype); - mode = promote_mode (valtype, mode, &unsignedp, 1); + mode = promote_function_mode (valtype, mode, &unsignedp, func, 1); } return gen_rtx_REG (mode, RT_REGNUM); } diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h index 35cd73021b9..dec662b197e 100644 --- a/gcc/config/sh/sh-protos.h +++ b/gcc/config/sh/sh-protos.h @@ -166,6 +166,8 @@ extern int sh_pass_in_reg_p (CUMULATIVE_ARGS *, enum machine_mode, tree); extern void sh_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, signed int, enum machine_mode); extern bool sh_promote_prototypes (const_tree); extern rtx sh_dwarf_register_span (rtx); +extern enum machine_mode sh_promote_function_mode (const_tree, enum machine_mode, + int *, const_tree, int); extern rtx replace_n_hard_rtx (rtx, rtx *, int , int); extern int shmedia_cleanup_truncate (rtx *, void *); diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 5b555f83e1a..9c919d0a774 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -438,9 +438,7 @@ static const struct attribute_spec sh_attribute_table[] = #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES sh_promote_prototypes #undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS sh_promote_prototypes -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN sh_promote_prototypes +#define TARGET_PROMOTE_FUNCTION_ARGS sh_promote_function_mode #undef TARGET_STRUCT_VALUE_RTX #define TARGET_STRUCT_VALUE_RTX sh_struct_value_rtx @@ -7896,6 +7894,16 @@ sh_dwarf_register_span (rtx reg) DBX_REGISTER_NUMBER (regno)))); } +enum machine_mode +sh_promote_function_mode (const_tree type, enum machine_mode mode, + int *punsignedp, const_tree funtype, int for_return) +{ + if (sh_promote_prototypes (funtype)) + return promote_mode (type, machine_mode, punsignedp); + else + return mode; +} + bool sh_promote_prototypes (const_tree type) { diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index baba1d98057..52cbe703458 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -404,6 +404,8 @@ static int get_some_local_dynamic_name_1 (rtx *, void *); static bool sparc_rtx_costs (rtx, int, int, int *, bool); static bool sparc_promote_prototypes (const_tree); static rtx sparc_struct_value_rtx (tree, int); +static enum machine_mode sparc_promote_function_mode (const_tree, enum machine_mode, + int *, const_tree, int); static bool sparc_return_in_memory (const_tree, const_tree); static bool sparc_strict_argument_naming (CUMULATIVE_ARGS *); static void sparc_va_start (tree, rtx); @@ -524,17 +526,8 @@ static bool fpu_option_set = false; #undef TARGET_ADDRESS_COST #define TARGET_ADDRESS_COST hook_int_rtx_bool_0 -/* This is only needed for TARGET_ARCH64, but since PROMOTE_FUNCTION_MODE is a - no-op for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime - test for this value. */ -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true - -/* This is only needed for TARGET_ARCH64, but since PROMOTE_FUNCTION_MODE is a - no-op for TARGET_ARCH32 this is ok. Otherwise we'd need to add a runtime - test for this value. */ -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE sparc_promote_function_mode #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES sparc_promote_prototypes @@ -4642,6 +4635,36 @@ sparc_promote_prototypes (const_tree fntype ATTRIBUTE_UNUSED) return TARGET_ARCH32 ? true : false; } +/* Handle promotion of pointer and integer arguments. */ + +static enum machine_mode +sparc_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int *punsignedp ATTRIBUTE_UNUSED, + const_tree fntype ATTRIBUTE_UNUSED, + int for_return ATTRIBUTE_UNUSED) +{ + if (POINTER_TYPE_P (type)) + { + *punsignedp = POINTERS_EXTEND_UNSIGNED; + return Pmode; + } + + /* For TARGET_ARCH64 we need this, as we don't have instructions + for arithmetic operations which do zero/sign extension at the same time, + so without this we end up with a srl/sra after every assignment to an + user variable, which means very very bad code. */ + + if (TARGET_ARCH64 + && GET_MODE_CLASS (mode) == MODE_INT + && GET_MODE_SIZE (mode) < UNITS_PER_WORD) + return word_mode; + + return mode; +} + + + /* Handle the TARGET_STRICT_ARGUMENT_NAMING target hook. */ static bool @@ -5784,7 +5807,8 @@ function_value (const_tree type, enum machine_mode mode, int incoming_p) mclass = MODE_INT; } - /* This must match PROMOTE_FUNCTION_MODE. */ + /* This must match sparc_promote_function_mode. + ??? Maybe 32-bit pointers should actually remain in Pmode? */ else if (mclass == MODE_INT && GET_MODE_SIZE (mode) < UNITS_PER_WORD) mode = word_mode; } diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 31c74095f75..3b713611f84 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -636,16 +636,6 @@ extern struct sparc_cpu_select sparc_select[]; if ptr_mode and Pmode are the same. */ #define POINTERS_EXTEND_UNSIGNED 1 -/* For TARGET_ARCH64 we need this, as we don't have instructions - for arithmetic operations which do zero/sign extension at the same time, - so without this we end up with a srl/sra after every assignment to an - user variable, which means very very bad code. */ -#define PROMOTE_FUNCTION_MODE(MODE, UNSIGNEDP, TYPE) \ -if (TARGET_ARCH64 \ - && GET_MODE_CLASS (MODE) == MODE_INT \ - && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ - (MODE) = word_mode; - /* Allocation boundary (in *bits*) for storing arguments in argument list. */ #define PARM_BOUNDARY (TARGET_ARCH64 ? 64 : 32) diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 2e646f98d4c..06b96c7b8ce 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -2640,10 +2640,8 @@ xstormy16_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) #undef TARGET_GIMPLIFY_VA_ARG_EXPR #define TARGET_GIMPLIFY_VA_ARG_EXPR xstormy16_gimplify_va_arg_expr -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 38f300aeef7..77ba2d9d017 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -185,10 +185,8 @@ static const int reg_nonleaf_alloc_order[FIRST_PSEUDO_REGISTER] = #undef TARGET_EXPAND_BUILTIN_VA_START #define TARGET_EXPAND_BUILTIN_VA_START xtensa_va_start -#undef TARGET_PROMOTE_FUNCTION_ARGS -#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_const_tree_true -#undef TARGET_PROMOTE_FUNCTION_RETURN -#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_const_tree_true +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote #undef TARGET_PROMOTE_PROTOTYPES #define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true diff --git a/gcc/config/xtensa/xtensa.h b/gcc/config/xtensa/xtensa.h index a9987c7609f..84d320bc95b 100644 --- a/gcc/config/xtensa/xtensa.h +++ b/gcc/config/xtensa/xtensa.h @@ -582,7 +582,7 @@ extern const enum reg_class xtensa_regno_to_class[FIRST_PSEUDO_REGISTER]; /* Define how to find the value returned by a library function assuming the value has mode MODE. Because we have defined - TARGET_PROMOTE_FUNCTION_RETURN that returns true, we have to + TARGET_PROMOTE_FUNCTION_MODE to promote everything, we have to perform the same promotions as PROMOTE_MODE. */ #define XTENSA_LIBCALL_VALUE(MODE, OUTGOINGP) \ gen_rtx_REG ((GET_MODE_CLASS (MODE) == MODE_INT \ |