aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/m68k
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2018-01-24 23:36:29 +0000
committerJoseph Myers <jsm28@gcc.gnu.org>2018-01-24 23:36:29 +0000
commitd3719ee2c078a1518c9e21efae0cf438d4ffb8d6 (patch)
tree78006b330fd44f5969627c5072238fcce69394a2 /gcc/config/m68k
parent5e77d9b130abdd5878557d34839e1b159a7f68ef (diff)
Fix m68k-linux-gnu libgcc build for ColdFire (PR target/68467).
PR target/68467 is libgcc failing to build for m68k-linux-gnu configured for ColdFire. Jeff has an analysis in the PR identifying the problem as resulting from the callers of libcalls with 1-byte or 2-byte arguments wanting to push just 1 or 2 bytes on the stack, while the libcall implementations have the normal C ABI and expect 4-byte arguments. For normal C functions, I believe the TARGET_PROMOTE_PROTOTYPES definition would ensure such arguments get passed as 4-byte, but that does not apply for libcalls. This patch fixes the issue by defining TARGET_PROMOTE_FUNCTION_MODE for m68k. The definition is conservative, only applying promotions in the case of arguments to libcalls; otherwise it returns the unpromoted type, which I believe matches what the default implementation of the hook would have done on m68k. I have tested that this fixes the libgcc build for ColdFire, and, in conjunction with one glibc patch, this enables glibc to build cleanly for ColdFire and to pass the compilation parts of the glibc testsuite except for one test unrelated to this patch (while glibc and the compilation parts of the testsuite continue to build OK for non-ColdFire m68k, as expected). I have *not* run any GCC tests for this patch, or any execution tests for m68k. PR target/68467 * config/m68k/m68k.c (m68k_promote_function_mode): New function. (TARGET_PROMOTE_FUNCTION_MODE): New macro. From-SVN: r257032
Diffstat (limited to 'gcc/config/m68k')
-rw-r--r--gcc/config/m68k/m68k.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index 9e35357c897..495a80b759e 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -192,6 +192,8 @@ m68k_excess_precision (enum excess_precision_type);
static unsigned int m68k_hard_regno_nregs (unsigned int, machine_mode);
static bool m68k_hard_regno_mode_ok (unsigned int, machine_mode);
static bool m68k_modes_tieable_p (machine_mode, machine_mode);
+static machine_mode m68k_promote_function_mode (const_tree, machine_mode,
+ int *, const_tree, int);
/* Initialize the GCC target structure. */
@@ -347,6 +349,9 @@ static bool m68k_modes_tieable_p (machine_mode, machine_mode);
#undef TARGET_MODES_TIEABLE_P
#define TARGET_MODES_TIEABLE_P m68k_modes_tieable_p
+#undef TARGET_PROMOTE_FUNCTION_MODE
+#define TARGET_PROMOTE_FUNCTION_MODE m68k_promote_function_mode
+
static const struct attribute_spec m68k_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req,
@@ -6621,4 +6626,20 @@ m68k_push_rounding (poly_int64 bytes)
return (bytes + 1) & ~1;
}
+/* Implement TARGET_PROMOTE_FUNCTION_MODE. */
+
+static machine_mode
+m68k_promote_function_mode (const_tree type, machine_mode mode,
+ int *punsignedp ATTRIBUTE_UNUSED,
+ const_tree fntype ATTRIBUTE_UNUSED,
+ int for_return)
+{
+ /* Promote libcall arguments narrower than int to match the normal C
+ ABI (for which promotions are handled via
+ TARGET_PROMOTE_PROTOTYPES). */
+ if (type == NULL_TREE && !for_return && (mode == QImode || mode == HImode))
+ return SImode;
+ return mode;
+}
+
#include "gt-m68k.h"