[c++] [testsuite] adjust contracts9.C for negative addresses
[official-gcc.git] / gcc / addresses.h
blobeaffeedbb22de66e39661b0b3bc7135b9c4b6685
1 /* Inline functions to test validity of reg classes for addressing modes.
2 Copyright (C) 2006-2024 Free Software Foundation, Inc.
4 This file is part of GCC.
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.
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.
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/>. */
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. */
24 #ifndef GCC_ADDRESSES_H
25 #define GCC_ADDRESSES_H
27 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 rtx_insn *insn ATTRIBUTE_UNUSED = NULL)
34 #ifdef INSN_BASE_REG_CLASS
35 return INSN_BASE_REG_CLASS (insn);
36 #else
37 #ifdef MODE_CODE_BASE_REG_CLASS
38 return MODE_CODE_BASE_REG_CLASS (MACRO_MODE (mode), as, outer_code,
39 index_code);
40 #else
41 #ifdef MODE_BASE_REG_REG_CLASS
42 if (index_code == REG)
43 return MODE_BASE_REG_REG_CLASS (MACRO_MODE (mode));
44 #endif
45 #ifdef MODE_BASE_REG_CLASS
46 return MODE_BASE_REG_CLASS (MACRO_MODE (mode));
47 #else
48 return BASE_REG_CLASS;
49 #endif
50 #endif
51 #endif
54 inline enum reg_class
55 index_reg_class (rtx_insn *insn ATTRIBUTE_UNUSED = NULL)
57 #ifdef INSN_INDEX_REG_CLASS
58 return INSN_INDEX_REG_CLASS (insn);
59 #else
60 return INDEX_REG_CLASS;
61 #endif
64 /* Wrapper function to unify target macros REGNO_MODE_CODE_OK_FOR_BASE_P,
65 REGNO_MODE_OK_FOR_REG_BASE_P, REGNO_MODE_OK_FOR_BASE_P and
66 REGNO_OK_FOR_BASE_P.
67 Arguments as for the REGNO_MODE_CODE_OK_FOR_BASE_P macro. */
69 inline bool
70 ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED,
71 machine_mode mode ATTRIBUTE_UNUSED,
72 addr_space_t as ATTRIBUTE_UNUSED,
73 enum rtx_code outer_code ATTRIBUTE_UNUSED,
74 enum rtx_code index_code ATTRIBUTE_UNUSED,
75 rtx_insn* insn ATTRIBUTE_UNUSED = NULL)
77 #ifdef REGNO_OK_FOR_INSN_BASE_P
78 return REGNO_OK_FOR_INSN_BASE_P (regno, insn);
79 #else
80 #ifdef REGNO_MODE_CODE_OK_FOR_BASE_P
81 return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as,
82 outer_code, index_code);
83 #else
84 #ifdef REGNO_MODE_OK_FOR_REG_BASE_P
85 if (index_code == REG)
86 return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode));
87 #endif
88 #ifdef REGNO_MODE_OK_FOR_BASE_P
89 return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode));
90 #else
91 return REGNO_OK_FOR_BASE_P (regno);
92 #endif
93 #endif
94 #endif
97 /* Wrapper around ok_for_base_p_1, for use after register allocation is
98 complete. Arguments as for the called function. */
100 inline bool
101 regno_ok_for_base_p (unsigned regno, machine_mode mode, addr_space_t as,
102 enum rtx_code outer_code, enum rtx_code index_code,
103 rtx_insn *insn = NULL)
105 if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
106 regno = reg_renumber[regno];
108 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code, insn);
111 #endif /* GCC_ADDRESSES_H */