]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/addresses.h
Correct a function pre/postcondition [PR102403].
[thirdparty/gcc.git] / gcc / addresses.h
CommitLineData
c4963a0a 1/* Inline functions to test validity of reg classes for addressing modes.
99dee823 2 Copyright (C) 2006-2021 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
c4963a0a 27static inline enum reg_class
ef4bddc2 28base_reg_class (machine_mode mode ATTRIBUTE_UNUSED,
86fc3d06 29 addr_space_t as ATTRIBUTE_UNUSED,
c4963a0a
BS
30 enum rtx_code outer_code ATTRIBUTE_UNUSED,
31 enum rtx_code index_code ATTRIBUTE_UNUSED)
32{
33#ifdef MODE_CODE_BASE_REG_CLASS
05210ba6
RS
34 return MODE_CODE_BASE_REG_CLASS (MACRO_MODE (mode), as, outer_code,
35 index_code);
c4963a0a
BS
36#else
37#ifdef MODE_BASE_REG_REG_CLASS
38 if (index_code == REG)
05210ba6 39 return MODE_BASE_REG_REG_CLASS (MACRO_MODE (mode));
c4963a0a
BS
40#endif
41#ifdef MODE_BASE_REG_CLASS
05210ba6 42 return MODE_BASE_REG_CLASS (MACRO_MODE (mode));
c4963a0a
BS
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
54static inline bool
c6dfaad5 55ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED,
ef4bddc2 56 machine_mode mode ATTRIBUTE_UNUSED,
86fc3d06 57 addr_space_t as ATTRIBUTE_UNUSED,
c4963a0a
BS
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
05210ba6 62 return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as,
86fc3d06 63 outer_code, index_code);
c4963a0a
BS
64#else
65#ifdef REGNO_MODE_OK_FOR_REG_BASE_P
66 if (index_code == REG)
05210ba6 67 return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode));
c4963a0a
BS
68#endif
69#ifdef REGNO_MODE_OK_FOR_BASE_P
05210ba6 70 return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode));
c4963a0a
BS
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
80static inline bool
ef4bddc2 81regno_ok_for_base_p (unsigned regno, machine_mode mode, addr_space_t as,
c4963a0a
BS
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
86fc3d06 87 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code);
c4963a0a 88}
f1717f8d
KC
89
90#endif /* GCC_ADDRESSES_H */