1 /* Inline functions to test validity of reg classes for addressing modes. 2 Copyright (C) 2006-2018 Free Software Foundation, Inc. 3 4 This file is part of GCC. 5 6 GCC is free software; you can redistribute it and/or modify it under 7 the terms of the GNU General Public License as published by the Free 8 Software Foundation; either version 3, or (at your option) any later 9 version. 10 11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 12 WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with GCC; see the file COPYING3. If not see 18 <http://www.gnu.org/licenses/>. */ 19 20 /* Wrapper function to unify target macros MODE_CODE_BASE_REG_CLASS, 21 MODE_BASE_REG_REG_CLASS, MODE_BASE_REG_CLASS and BASE_REG_CLASS. 22 Arguments as for the MODE_CODE_BASE_REG_CLASS macro. */ 23 24 #ifndef GCC_ADDRESSES_H 25 #define GCC_ADDRESSES_H 26 27 static inline enum reg_class 28 base_reg_class (machine_mode mode ATTRIBUTE_UNUSED, 29 addr_space_t as ATTRIBUTE_UNUSED, 30 enum rtx_code outer_code ATTRIBUTE_UNUSED, 31 enum rtx_code index_code ATTRIBUTE_UNUSED) 32 { 33 #ifdef MODE_CODE_BASE_REG_CLASS 34 return MODE_CODE_BASE_REG_CLASS (MACRO_MODE (mode), as, outer_code, 35 index_code); 36 #else 37 #ifdef MODE_BASE_REG_REG_CLASS 38 if (index_code == REG) 39 return MODE_BASE_REG_REG_CLASS (MACRO_MODE (mode)); 40 #endif 41 #ifdef MODE_BASE_REG_CLASS 42 return MODE_BASE_REG_CLASS (MACRO_MODE (mode)); 43 #else 44 return BASE_REG_CLASS; 45 #endif 46 #endif 47 } 48 49 /* Wrapper function to unify target macros REGNO_MODE_CODE_OK_FOR_BASE_P, 50 REGNO_MODE_OK_FOR_REG_BASE_P, REGNO_MODE_OK_FOR_BASE_P and 51 REGNO_OK_FOR_BASE_P. 52 Arguments as for the REGNO_MODE_CODE_OK_FOR_BASE_P macro. */ 53 54 static inline bool 55 ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED, 56 machine_mode mode ATTRIBUTE_UNUSED, 57 addr_space_t as ATTRIBUTE_UNUSED, 58 enum rtx_code outer_code ATTRIBUTE_UNUSED, 59 enum rtx_code index_code ATTRIBUTE_UNUSED) 60 { 61 #ifdef REGNO_MODE_CODE_OK_FOR_BASE_P 62 return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as, 63 outer_code, index_code); 64 #else 65 #ifdef REGNO_MODE_OK_FOR_REG_BASE_P 66 if (index_code == REG) 67 return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode)); 68 #endif 69 #ifdef REGNO_MODE_OK_FOR_BASE_P 70 return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode)); 71 #else 72 return REGNO_OK_FOR_BASE_P (regno); 73 #endif 74 #endif 75 } 76 77 /* Wrapper around ok_for_base_p_1, for use after register allocation is 78 complete. Arguments as for the called function. */ 79 80 static inline bool 81 regno_ok_for_base_p (unsigned regno, machine_mode mode, addr_space_t as, 82 enum rtx_code outer_code, enum rtx_code index_code) 83 { 84 if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0) 85 regno = reg_renumber[regno]; 86 87 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code); 88 } 89 90 #endif /* GCC_ADDRESSES_H */ 91