1/* Inline functions to test validity of reg classes for addressing modes.
2 Copyright (C) 2006-2023 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along 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
27inline enum reg_class
28base_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)
33{
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
52}
53
54inline enum reg_class
55index_reg_class (rtx_insn *insn ATTRIBUTE_UNUSED = NULL)
56{
57#ifdef INSN_INDEX_REG_CLASS
58 return INSN_INDEX_REG_CLASS (insn);
59#else
60 return INDEX_REG_CLASS;
61#endif
62}
63
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. */
68
69inline bool
70ok_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)
76{
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
95}
96
97/* Wrapper around ok_for_base_p_1, for use after register allocation is
98 complete. Arguments as for the called function. */
99
100inline bool
101regno_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)
104{
105 if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
106 regno = reg_renumber[regno];
107
108 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code, insn);
109}
110
111#endif /* GCC_ADDRESSES_H */
112

source code of gcc/addresses.h