TARGET_PROMOTE_PROTOTYPES is an optimization, not an ABI requirement.
TARGET_PROMOTE_FUNCTION_MODE should be used for ABI requirement. Like
xtensa, mcore ABI requires sign extension of signed 8/16-bit integer
arguments to 32 bits and zero extension of unsigned integer 8/16-bit
arguments to 32 bits:
1. Rename xtensa_promote_function_mode to
default_promote_function_mode_sign_extend to sign-extend signed 8/16-bit
integer arguments to 32 bits and zero-extend of unsigned 8/16-bit
integer arguments to 32 bits.
2. Replace xtensa_promote_function_mode with
default_promote_function_mode_sign_extend.
3. Remove TARGET_PROMOTE_PROTOTYPES for mcore and define
TARGET_PROMOTE_FUNCTION_MODE with
default_promote_function_mode_sign_extend to properly extend 8/16-bit
arguments to 32 bits.
Targets with the same ABI requirement should define
TARGET_PROMOTE_FUNCTION_MODE with
default_promote_function_mode_sign_extend.
gcc/
PR target/119979
PR target/120888
* targhooks.cc (default_promote_function_mode_sign_extend): New.
* targhooks.h (default_promote_function_mode_sign_extend):
Likewise.
* config/mcore/mcore.cc (TARGET_PROMOTE_FUNCTION_MODE): Use
default_promote_function_mode_sign_extend.
(TARGET_PROMOTE_PROTOTYPES): Removed.
* config/xtensa/xtensa.cc (xtensa_promote_function_mode): Removed.
(TARGET_PROMOTE_FUNCTION_MODE): Use
default_promote_function_mode_sign_extend.
gcc/testsuite/
PR target/119979
PR target/120888
* gcc.target/xtensa/pr120888-1.c: Removed to ...
* gcc.dg/zero-extend.c: This. Enable for mcore and xtensa.
* gcc.target/xtensa/pr120888-2.c: Removed to ...
* gcc.dg/sign-extend.c: This. Enable for mcore and xtensa.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
#define TARGET_MACHINE_DEPENDENT_REORG mcore_reorg
#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
-
+#define TARGET_PROMOTE_FUNCTION_MODE \
+ default_promote_function_mode_sign_extend
#undef TARGET_RETURN_IN_MEMORY
#define TARGET_RETURN_IN_MEMORY mcore_return_in_memory
#undef TARGET_MUST_PASS_IN_STACK
static void xtensa_trampoline_init (rtx, tree, rtx);
static bool xtensa_output_addr_const_extra (FILE *, rtx);
static bool xtensa_cannot_force_const_mem (machine_mode, rtx);
-static machine_mode xtensa_promote_function_mode (const_tree,
- machine_mode,
- int *, const_tree,
- int);
static reg_class_t xtensa_preferred_reload_class (rtx, reg_class_t);
static reg_class_t xtensa_preferred_output_reload_class (rtx, reg_class_t);
#define TARGET_EXPAND_BUILTIN_VA_START xtensa_va_start
#undef TARGET_PROMOTE_FUNCTION_MODE
-#define TARGET_PROMOTE_FUNCTION_MODE xtensa_promote_function_mode
+#define TARGET_PROMOTE_FUNCTION_MODE \
+ default_promote_function_mode_sign_extend
#undef TARGET_RETURN_IN_MEMORY
#define TARGET_RETURN_IN_MEMORY xtensa_return_in_memory
return pattern_cost (PATTERN (insn), speed);
}
-/* Worker function for TARGET_PROMOTE_FUNCTION_MODE. */
-
-static machine_mode
-xtensa_promote_function_mode (const_tree type, machine_mode mode,
- int *punsignedp, const_tree, int)
-{
- if (GET_MODE_CLASS (mode) == MODE_INT
- && GET_MODE_SIZE (mode) < GET_MODE_SIZE (SImode))
- return SImode;
-
- return promote_mode (type, mode, punsignedp);
-}
-
/* Worker function for TARGET_RETURN_IN_MEMORY. */
static bool
return promote_mode (type, mode, punsignedp);
}
+/* Sign-extend signed 8/16-bit integer arguments to 32 bits and
+ zero-extend unsigned 8/16-bit integer arguments to 32 bits. */
+
+machine_mode
+default_promote_function_mode_sign_extend (const_tree type,
+ machine_mode mode,
+ int *punsignedp,
+ const_tree, int)
+{
+ if (GET_MODE_CLASS (mode) == MODE_INT
+ && (GET_MODE_SIZE (as_a <scalar_int_mode> (mode))
+ < GET_MODE_SIZE (SImode)))
+ return SImode;
+
+ return promote_mode (type, mode, punsignedp);
+}
+
machine_mode
default_cc_modes_compatible (machine_mode m1, machine_mode m2)
{
int *, const_tree, int);
extern machine_mode default_promote_function_mode_always_promote
(const_tree, machine_mode, int *, const_tree, int);
+extern machine_mode default_promote_function_mode_sign_extend
+ (const_tree, machine_mode, int *, const_tree, int);
extern machine_mode default_cc_modes_compatible (machine_mode,
machine_mode);
-/* { dg-do compile } */
+/* { dg-do compile { target mcore-*-* xtensa-*-* } } */
/* { dg-options "-O1 -fdump-rtl-expand" } */
void s8(signed char c);
-/* { dg-do compile } */
+/* { dg-do compile { target mcore-*-* xtensa-*-* } } */
/* { dg-options "-O1 -fdump-rtl-expand" } */
void u8(unsigned char c);