From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 83581 invoked by alias); 11 Sep 2019 19:06:25 -0000 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 Received: (qmail 83573 invoked by uid 89); 11 Sep 2019 19:06:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.8 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,SPF_PASS autolearn=ham version=3.3.1 spammy=UD:hard-reg-set.h, hard-reg-set.h, hardregseth, shc X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.110.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Sep 2019 19:06:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3DB5A28 for ; Wed, 11 Sep 2019 12:06:21 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.99.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D9E623F59C for ; Wed, 11 Sep 2019 12:06:20 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [06/32] Pass an ABI to choose_hard_reg_mode References: Date: Wed, 11 Sep 2019 19:06:00 -0000 In-Reply-To: (Richard Sandiford's message of "Wed, 11 Sep 2019 20:02:26 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00785.txt.bz2 choose_hard_reg_mode previously took a boolean saying whether the mode needed to be call-preserved. This patch replaces it with an optional ABI pointer instead, so that the function can use that to test whether a value is call-saved. default_dwarf_frame_reg_mode uses eh_edge_abi because that's the ABI that matters for unwinding. Targets need to override the hook if they want something different. 2019-09-11 Richard Sandiford gcc/ * rtl.h (predefined_function_abi): Declare. (choose_hard_reg_mode): Take a pointer to a predefined_function_abi instead of a boolean call_save flag. * config/gcn/gcn.c (gcn_hard_regno_caller_save_mode): Update call accordingly. * config/i386/i386.h (HARD_REGNO_CALLER_SAVE_MODE): Likewise. * config/ia64/ia64.h (HARD_REGNO_CALLER_SAVE_MODE): Likewise. * config/mips/mips.c (mips_hard_regno_caller_save_mode): Likewise. * config/msp430/msp430.h (HARD_REGNO_CALLER_SAVE_MODE): Likewise. * config/rs6000/rs6000.h (HARD_REGNO_CALLER_SAVE_MODE): Likewise. * config/sh/sh.c (sh_hard_regno_caller_save_mode): Likewise. * reginfo.c (init_reg_modes_target): Likewise. (choose_hard_reg_mode): Take a pointer to a predefined_function_abi instead of a boolean call_save flag. * targhooks.c: Include function-abi.h. (default_dwarf_frame_reg_mode): Update call to choose_hard_reg_mode, using eh_edge_abi to choose the mode. Index: gcc/rtl.h =================================================================== --- gcc/rtl.h 2019-09-11 19:47:24.418262673 +0100 +++ gcc/rtl.h 2019-09-11 19:47:39.478156547 +0100 @@ -36,6 +36,8 @@ #define GCC_RTL_H #include "hard-reg-set.h" +class predefined_function_abi; + /* Value used by some passes to "recognize" noop moves as valid instructions. */ #define NOOP_MOVE_INSN_CODE INT_MAX @@ -3383,7 +3385,8 @@ extern bool val_signbit_known_clear_p (m unsigned HOST_WIDE_INT); /* In reginfo.c */ -extern machine_mode choose_hard_reg_mode (unsigned int, unsigned int, bool); +extern machine_mode choose_hard_reg_mode (unsigned int, unsigned int, + const predefined_function_abi *); extern const HARD_REG_SET &simplifiable_subregs (const subreg_shape &); /* In emit-rtl.c */ Index: gcc/config/gcn/gcn.c =================================================================== --- gcc/config/gcn/gcn.c 2019-09-10 19:56:45.333178060 +0100 +++ gcc/config/gcn/gcn.c 2019-09-11 19:47:39.466156632 +0100 @@ -3017,7 +3017,7 @@ gcn_hard_regno_rename_ok (unsigned int f gcn_hard_regno_caller_save_mode (unsigned int regno, unsigned int nregs, machine_mode regmode) { - machine_mode result = choose_hard_reg_mode (regno, nregs, false); + machine_mode result = choose_hard_reg_mode (regno, nregs, NULL); if (VECTOR_MODE_P (result) && !VECTOR_MODE_P (regmode)) result = (nregs == 1 ? SImode : DImode); Index: gcc/config/i386/i386.h =================================================================== --- gcc/config/i386/i386.h 2019-08-27 07:24:49.455527415 +0100 +++ gcc/config/i386/i386.h 2019-09-11 19:47:39.466156632 +0100 @@ -1256,7 +1256,7 @@ #define AVOID_CCMODE_COPIES #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \ (CC_REGNO_P (REGNO) ? VOIDmode \ : (MODE) == VOIDmode && (NREGS) != 1 ? VOIDmode \ - : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS), false) \ + : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS), NULL) \ : (MODE) == HImode && !((GENERAL_REGNO_P (REGNO) \ && TARGET_PARTIAL_REG_STALL) \ || MASK_REGNO_P (REGNO)) ? SImode \ Index: gcc/config/ia64/ia64.h =================================================================== --- gcc/config/ia64/ia64.h 2019-09-10 19:57:04.693041422 +0100 +++ gcc/config/ia64/ia64.h 2019-09-11 19:47:39.466156632 +0100 @@ -562,7 +562,7 @@ #define REG_ALLOC_ORDER \ #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \ ((FR_REGNO_P (REGNO) && (NREGS) == 1) ? RFmode \ - : choose_hard_reg_mode ((REGNO), (NREGS), false)) + : choose_hard_reg_mode ((REGNO), (NREGS), NULL)) /* Handling Leaf Functions */ Index: gcc/config/mips/mips.c =================================================================== --- gcc/config/mips/mips.c 2019-09-11 19:47:32.874203085 +0100 +++ gcc/config/mips/mips.c 2019-09-11 19:47:39.470156604 +0100 @@ -22174,7 +22174,7 @@ mips_hard_regno_caller_save_mode (unsign /* For performance, avoid saving/restoring upper parts of a register by returning MODE as save mode when the mode is known. */ if (mode == VOIDmode) - return choose_hard_reg_mode (regno, nregs, false); + return choose_hard_reg_mode (regno, nregs, NULL); else return mode; } Index: gcc/config/msp430/msp430.h =================================================================== --- gcc/config/msp430/msp430.h 2019-08-15 15:26:04.800237365 +0100 +++ gcc/config/msp430/msp430.h 2019-09-11 19:47:39.474156575 +0100 @@ -467,7 +467,7 @@ #define DWARF2_ASM_LINE_DEBUG_INFO 1 when spilling hard registers when they may contain PSImode values. */ #define HARD_REGNO_CALLER_SAVE_MODE(REGNO,NREGS,MODE) \ ((TARGET_LARGE && ((NREGS) <= 2)) ? PSImode \ - : choose_hard_reg_mode ((REGNO), (NREGS), false)) + : choose_hard_reg_mode ((REGNO), (NREGS), NULL)) #define ACCUMULATE_OUTGOING_ARGS 1 Index: gcc/config/rs6000/rs6000.h =================================================================== --- gcc/config/rs6000/rs6000.h 2019-09-10 19:57:04.701041365 +0100 +++ gcc/config/rs6000/rs6000.h 2019-09-11 19:47:39.474156575 +0100 @@ -1038,7 +1038,7 @@ #define HARD_REGNO_CALLER_SAVE_MODE(REGN ? DFmode \ : (MODE) == TDmode && FP_REGNO_P (REGNO) \ ? DImode \ - : choose_hard_reg_mode ((REGNO), (NREGS), false)) + : choose_hard_reg_mode ((REGNO), (NREGS), NULL)) #define VSX_VECTOR_MODE(MODE) \ ((MODE) == V4SFmode \ Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c 2019-09-10 19:57:04.705041337 +0100 +++ gcc/config/sh/sh.c 2019-09-11 19:47:39.474156575 +0100 @@ -10634,7 +10634,7 @@ sh_hard_regno_caller_save_mode (unsigned && ((regno - FIRST_FP_REG) & 1) == 0))) return mode; - return choose_hard_reg_mode (regno, nregs, false); + return choose_hard_reg_mode (regno, nregs, NULL); } /* Implement TARGET_CAN_CHANGE_MODE_CLASS. */ Index: gcc/reginfo.c =================================================================== --- gcc/reginfo.c 2019-09-11 19:47:32.898202916 +0100 +++ gcc/reginfo.c 2019-09-11 19:47:39.474156575 +0100 @@ -442,7 +442,7 @@ init_reg_modes_target (void) for (i = 0; i < FIRST_PSEUDO_REGISTER; i++) { - reg_raw_mode[i] = choose_hard_reg_mode (i, 1, false); + reg_raw_mode[i] = choose_hard_reg_mode (i, 1, NULL); /* If we couldn't find a valid mode, just use the previous mode if it is suitable, otherwise fall back on word_mode. */ @@ -550,10 +550,11 @@ memory_move_secondary_cost (machine_mode /* Return a machine mode that is legitimate for hard reg REGNO and large enough to save nregs. If we can't find one, return VOIDmode. - If CALL_SAVED is true, only consider modes that are call saved. */ + If ABI is nonnull, only consider modes that are preserved across + calls that use ABI. */ machine_mode choose_hard_reg_mode (unsigned int regno ATTRIBUTE_UNUSED, - unsigned int nregs, bool call_saved) + unsigned int nregs, const predefined_function_abi *abi) { unsigned int /* machine_mode */ m; machine_mode found_mode = VOIDmode, mode; @@ -567,32 +568,28 @@ choose_hard_reg_mode (unsigned int regno FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) if (hard_regno_nregs (regno, mode) == nregs && targetm.hard_regno_mode_ok (regno, mode) - && (!call_saved - || !targetm.hard_regno_call_part_clobbered (0, regno, mode)) + && (!abi || !abi->clobbers_reg_p (mode, regno)) && maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode))) found_mode = mode; FOR_EACH_MODE_IN_CLASS (mode, MODE_FLOAT) if (hard_regno_nregs (regno, mode) == nregs && targetm.hard_regno_mode_ok (regno, mode) - && (!call_saved - || !targetm.hard_regno_call_part_clobbered (0, regno, mode)) + && (!abi || !abi->clobbers_reg_p (mode, regno)) && maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode))) found_mode = mode; FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_FLOAT) if (hard_regno_nregs (regno, mode) == nregs && targetm.hard_regno_mode_ok (regno, mode) - && (!call_saved - || !targetm.hard_regno_call_part_clobbered (0, regno, mode)) + && (!abi || !abi->clobbers_reg_p (mode, regno)) && maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode))) found_mode = mode; FOR_EACH_MODE_IN_CLASS (mode, MODE_VECTOR_INT) if (hard_regno_nregs (regno, mode) == nregs && targetm.hard_regno_mode_ok (regno, mode) - && (!call_saved - || !targetm.hard_regno_call_part_clobbered (0, regno, mode)) + && (!abi || !abi->clobbers_reg_p (mode, regno)) && maybe_gt (GET_MODE_SIZE (mode), GET_MODE_SIZE (found_mode))) found_mode = mode; @@ -605,8 +602,7 @@ choose_hard_reg_mode (unsigned int regno mode = (machine_mode) m; if (hard_regno_nregs (regno, mode) == nregs && targetm.hard_regno_mode_ok (regno, mode) - && (!call_saved - || !targetm.hard_regno_call_part_clobbered (0, regno, mode))) + && (!abi || !abi->clobbers_reg_p (mode, regno))) return mode; } Index: gcc/targhooks.c =================================================================== --- gcc/targhooks.c 2019-09-11 19:47:32.906202859 +0100 +++ gcc/targhooks.c 2019-09-11 19:47:39.478156547 +0100 @@ -83,6 +83,7 @@ Software Foundation; either version 3, o #include "real.h" #include "langhooks.h" #include "sbitmap.h" +#include "function-abi.h" bool default_legitimate_address_p (machine_mode mode ATTRIBUTE_UNUSED, @@ -1928,8 +1929,9 @@ default_dwarf_frame_reg_mode (int regno) { machine_mode save_mode = reg_raw_mode[regno]; - if (targetm.hard_regno_call_part_clobbered (0, regno, save_mode)) - save_mode = choose_hard_reg_mode (regno, 1, true); + if (targetm.hard_regno_call_part_clobbered (eh_edge_abi.id (), + regno, save_mode)) + save_mode = choose_hard_reg_mode (regno, 1, &eh_edge_abi); return save_mode; }