]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/addresses.h
tree-optimization/114736 - SLP DFS walk issue
[thirdparty/gcc.git] / gcc / addresses.h
CommitLineData
c4963a0a 1/* Inline functions to test validity of reg classes for addressing modes.
a945c346 2 Copyright (C) 2006-2024 Free Software Foundation, Inc.
c4963a0a
BS
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
9dcd6f09 8Software Foundation; either version 3, or (at your option) any later
c4963a0a
BS
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
9dcd6f09
NC
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
c4963a0a
BS
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
f1717f8d
KC
24#ifndef GCC_ADDRESSES_H
25#define GCC_ADDRESSES_H
26
cb3e0eac 27inline enum reg_class
ef4bddc2 28base_reg_class (machine_mode mode ATTRIBUTE_UNUSED,
86fc3d06 29 addr_space_t as ATTRIBUTE_UNUSED,
c4963a0a 30 enum rtx_code outer_code ATTRIBUTE_UNUSED,
bc4466b9
KL
31 enum rtx_code index_code ATTRIBUTE_UNUSED,
32 rtx_insn *insn ATTRIBUTE_UNUSED = NULL)
c4963a0a 33{
bc4466b9
KL
34#ifdef INSN_BASE_REG_CLASS
35 return INSN_BASE_REG_CLASS (insn);
36#else
c4963a0a 37#ifdef MODE_CODE_BASE_REG_CLASS
05210ba6
RS
38 return MODE_CODE_BASE_REG_CLASS (MACRO_MODE (mode), as, outer_code,
39 index_code);
c4963a0a
BS
40#else
41#ifdef MODE_BASE_REG_REG_CLASS
42 if (index_code == REG)
05210ba6 43 return MODE_BASE_REG_REG_CLASS (MACRO_MODE (mode));
c4963a0a
BS
44#endif
45#ifdef MODE_BASE_REG_CLASS
05210ba6 46 return MODE_BASE_REG_CLASS (MACRO_MODE (mode));
c4963a0a
BS
47#else
48 return BASE_REG_CLASS;
49#endif
50#endif
bc4466b9 51#endif
c4963a0a
BS
52}
53
dfa15b49
HW
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
c4963a0a
BS
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
cb3e0eac 69inline bool
c6dfaad5 70ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED,
ef4bddc2 71 machine_mode mode ATTRIBUTE_UNUSED,
86fc3d06 72 addr_space_t as ATTRIBUTE_UNUSED,
c4963a0a 73 enum rtx_code outer_code ATTRIBUTE_UNUSED,
bc4466b9
KL
74 enum rtx_code index_code ATTRIBUTE_UNUSED,
75 rtx_insn* insn ATTRIBUTE_UNUSED = NULL)
c4963a0a 76{
bc4466b9
KL
77#ifdef REGNO_OK_FOR_INSN_BASE_P
78 return REGNO_OK_FOR_INSN_BASE_P (regno, insn);
79#else
c4963a0a 80#ifdef REGNO_MODE_CODE_OK_FOR_BASE_P
05210ba6 81 return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as,
86fc3d06 82 outer_code, index_code);
c4963a0a
BS
83#else
84#ifdef REGNO_MODE_OK_FOR_REG_BASE_P
85 if (index_code == REG)
05210ba6 86 return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode));
c4963a0a
BS
87#endif
88#ifdef REGNO_MODE_OK_FOR_BASE_P
05210ba6 89 return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode));
c4963a0a
BS
90#else
91 return REGNO_OK_FOR_BASE_P (regno);
92#endif
93#endif
bc4466b9 94#endif
c4963a0a
BS
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
cb3e0eac 100inline bool
ef4bddc2 101regno_ok_for_base_p (unsigned regno, machine_mode mode, addr_space_t as,
bc4466b9
KL
102 enum rtx_code outer_code, enum rtx_code index_code,
103 rtx_insn *insn = NULL)
c4963a0a
BS
104{
105 if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
106 regno = reg_renumber[regno];
107
bc4466b9 108 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code, insn);
c4963a0a 109}
f1717f8d
KC
110
111#endif /* GCC_ADDRESSES_H */