From: Nick Clifton Date: Thu, 13 Jan 2011 17:20:20 +0000 (+0000) Subject: Import this fix from the mainline: X-Git-Tag: releases/gcc-4.5.3~315 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=799ea90443e6a07336da874dec73ae19a8c06095;p=thirdparty%2Fgcc.git Import this fix from the mainline: 2010-10-19 Nick Clifton * config/rx/rx.c (rx_function_value): Small integer types are promoted to SImode. (rx_promote_function_mode): New function. (TARGET_PROMOTE_FUNCTION_MODE): Define. From-SVN: r168754 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e531cac02d15..fb32568e36d8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2011-01-13 Nick Clifton + + Import this fix from the mainline: + 2010-10-19 Nick Clifton + + * config/rx/rx.c (rx_function_value): Small integer types are + promoted to SImode. + (rx_promote_function_mode): New function. + (TARGET_PROMOTE_FUNCTION_MODE): Define. + 2011-01-07 Rainer Orth Backport from mainline: diff --git a/gcc/config/rx/rx.c b/gcc/config/rx/rx.c index 6847d4b2e413..77e3fcfc4785 100644 --- a/gcc/config/rx/rx.c +++ b/gcc/config/rx/rx.c @@ -821,7 +821,32 @@ rx_function_value (const_tree ret_type, const_tree fn_decl_or_type ATTRIBUTE_UNUSED, bool outgoing ATTRIBUTE_UNUSED) { - return gen_rtx_REG (TYPE_MODE (ret_type), FUNC_RETURN_REGNUM); + enum machine_mode mode = TYPE_MODE (ret_type); + + /* RX ABI specifies that small integer types are + promoted to int when returned by a function. */ + if (GET_MODE_SIZE (mode) > 0 && GET_MODE_SIZE (mode) < 4) + return gen_rtx_REG (SImode, FUNC_RETURN_REGNUM); + + return gen_rtx_REG (mode, FUNC_RETURN_REGNUM); +} + +/* TARGET_PROMOTE_FUNCTION_MODE must behave in the same way with + regard to function returns as does TARGET_FUNCTION_VALUE. */ + +static enum machine_mode +rx_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, + enum machine_mode mode, + int * punsignedp ATTRIBUTE_UNUSED, + const_tree funtype ATTRIBUTE_UNUSED, + int for_return) +{ + if (for_return != 1 + || GET_MODE_SIZE (mode) >= 4 + || GET_MODE_SIZE (mode) < 1) + return mode; + + return SImode; } static bool @@ -2759,6 +2784,9 @@ rx_compare_redundant (rtx cmp) #undef TARGET_CC_MODES_COMPATIBLE #define TARGET_CC_MODES_COMPATIBLE rx_cc_modes_compatible +#undef TARGET_PROMOTE_FUNCTION_MODE +#define TARGET_PROMOTE_FUNCTION_MODE rx_promote_function_mode + struct gcc_target targetm = TARGET_INITIALIZER; /* #include "gt-rx.h" */