From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3820 invoked by alias); 25 Aug 2007 15:36:10 -0000 Received: (qmail 3774 invoked by uid 22791); 25 Aug 2007 15:36:09 -0000 X-Spam-Check-By: sourceware.org Received: from gateway.codesourcery.com (HELO sparrowhawk.codesourcery.com) (65.74.133.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 25 Aug 2007 15:36:04 +0000 Received: from sparrowhawk.codesourcery.com (localhost.localdomain [127.0.0.1]) by sparrowhawk.codesourcery.com (8.13.1/8.13.1) with ESMTP id l7PFa3Om031292; Sat, 25 Aug 2007 08:36:03 -0700 Received: (from kazu@localhost) by sparrowhawk.codesourcery.com (8.13.1/8.13.1/Submit) id l7PFa18t031289; Sat, 25 Aug 2007 08:36:01 -0700 Date: Sat, 25 Aug 2007 15:59:00 -0000 Message-Id: <200708251536.l7PFa18t031289@sparrowhawk.codesourcery.com> From: Kazu Hirata To: gcc-patches@gcc.gnu.org CC: law@redhat.com, schwab@suse.de CC: nathan@codesourcery.com CC: zippel@linux-m68k.org Subject: [patch] m68k: Fix binary compatibility problem with -mno-strict-align. (Take 2) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg01712.txt.bz2 Hi, Attached is a revised patch to fix binary compatibility problem with -mno-strict-align on m68k-elf. The previous iteration of this patch is at: http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01437.html In this iteration, Nathan has made a change to effectively comment out TARGET_RETURN_IN_MEMORY and m68k_return_in_memory if M68K_HONOR_TARGET_STRICT_ALIGNMENT is defined. This way, this patch has no effect on m68k-linux, preserving the ABI. Tested on m68k-elf. OK to apply? Kazu Hirata 2007-08-25 Nathan Sidwell Kazu Hirata * gcc/config/m68k/linux.h (M68K_HONOR_TARGET_STRICT_ALIGNMENT): Redefine as 0. * config/m68k/m68k.c (TARGET_RETURN_IN_MEMORY): New. (m68k_return_in_memory): New. * gcc/config/m68k/m68k.h (M68K_HONOR_TARGET_STRICT_ALIGNMENT): New. Index: gcc/config/m68k/linux.h =================================================================== --- gcc/config/m68k/linux.h (revision 127787) +++ gcc/config/m68k/linux.h (working copy) @@ -31,6 +31,8 @@ along with GCC; see the file COPYING3. #undef STRICT_ALIGNMENT #define STRICT_ALIGNMENT 0 +#undef M68K_HONOR_TARGET_STRICT_ALIGNMENT +#define M68K_HONOR_TARGET_STRICT_ALIGNMENT 0 /* Here are four prefixes that are used by asm_fprintf to facilitate customization for alternate assembler syntaxes. Index: gcc/config/m68k/m68k.c =================================================================== --- gcc/config/m68k/m68k.c (revision 127787) +++ gcc/config/m68k/m68k.c (working copy) @@ -134,6 +134,9 @@ static void m68k_compute_frame_layout (v static bool m68k_save_reg (unsigned int regno, bool interrupt_handler); static bool m68k_ok_for_sibcall_p (tree, tree); static bool m68k_rtx_costs (rtx, int, int, int *); +#if M68K_HONOR_TARGET_STRICT_ALIGNMENT +static bool m68k_return_in_memory (tree, tree); +#endif /* Specify the identification number of the library being built */ @@ -205,6 +208,11 @@ int m68k_last_compare_had_fp_operands; #undef TARGET_FUNCTION_OK_FOR_SIBCALL #define TARGET_FUNCTION_OK_FOR_SIBCALL m68k_ok_for_sibcall_p +#if M68K_HONOR_TARGET_STRICT_ALIGNMENT +#undef TARGET_RETURN_IN_MEMORY +#define TARGET_RETURN_IN_MEMORY m68k_return_in_memory +#endif + static const struct attribute_spec m68k_attribute_table[] = { /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */ @@ -4386,3 +4394,25 @@ m68k_function_value (const_tree valtype, else return gen_rtx_REG (mode, D0_REG); } + +/* Worker function for TARGET_RETURN_IN_MEMORY. */ +#if M68K_HONOR_TARGET_STRICT_ALIGNMENT +static bool +m68k_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED) +{ + enum machine_mode mode = TYPE_MODE (type); + + if (mode == BLKmode) + return true; + + /* If TYPE's known alignment is less than the alignment of MODE that + would contain the structure, then return in memory. We need to + do so to maintain the compatibility between code compiled with + -mstrict-align and that compiled with -mno-strict-align. */ + if (AGGREGATE_TYPE_P (type) + && TYPE_ALIGN (type) < GET_MODE_ALIGNMENT (mode)) + return true; + + return false; +} +#endif Index: gcc/config/m68k/m68k.h =================================================================== --- gcc/config/m68k/m68k.h (revision 127787) +++ gcc/config/m68k/m68k.h (working copy) @@ -310,6 +310,7 @@ along with GCC; see the file COPYING3. #define BIGGEST_ALIGNMENT (TARGET_ALIGN_INT ? 32 : 16) #define STRICT_ALIGNMENT (TARGET_STRICT_ALIGNMENT) +#define M68K_HONOR_TARGET_STRICT_ALIGNMENT 1 #define INT_TYPE_SIZE (TARGET_SHORT ? 16 : 32)