GCC Middle and Back End API Reference
addresses.h
Go to the documentation of this file.
1/* Inline functions to test validity of reg classes for addressing modes.
2 Copyright (C) 2006-2026 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 around the TARGET_BASE_REG_CLASS hook. MEM is the
21 MEM rtx being addressed, if known, and INSN is the instruction it
22 belongs to, if known; both may be null. */
23
24#ifndef GCC_ADDRESSES_H
25#define GCC_ADDRESSES_H
26
27inline enum reg_class
28base_reg_class (machine_mode mode, addr_space_t as,
29 enum rtx_code outer_code, enum rtx_code index_code,
30 rtx mem = NULL_RTX, rtx_insn *insn = NULL)
31{
32 return (enum reg_class) targetm.base_reg_class (mode, as, outer_code,
33 index_code, mem, insn);
34}
35
36inline enum reg_class
37index_reg_class (rtx_insn *insn ATTRIBUTE_UNUSED = NULL)
38{
39#ifdef INSN_INDEX_REG_CLASS
40 return INSN_INDEX_REG_CLASS (insn);
41#else
42 return INDEX_REG_CLASS;
43#endif
44}
45
46/* Wrapper function to unify target macros REGNO_MODE_CODE_OK_FOR_BASE_P,
47 REGNO_MODE_OK_FOR_REG_BASE_P, REGNO_MODE_OK_FOR_BASE_P and
48 REGNO_OK_FOR_BASE_P.
49 Arguments as for the REGNO_MODE_CODE_OK_FOR_BASE_P macro. */
50
51inline bool
52ok_for_base_p_1 (unsigned regno ATTRIBUTE_UNUSED,
53 machine_mode mode ATTRIBUTE_UNUSED,
54 addr_space_t as ATTRIBUTE_UNUSED,
55 enum rtx_code outer_code ATTRIBUTE_UNUSED,
56 enum rtx_code index_code ATTRIBUTE_UNUSED,
57 rtx_insn* insn ATTRIBUTE_UNUSED = NULL)
58{
59#ifdef REGNO_OK_FOR_INSN_BASE_P
60 return REGNO_OK_FOR_INSN_BASE_P (regno, insn);
61#else
62#ifdef REGNO_MODE_CODE_OK_FOR_BASE_P
63 return REGNO_MODE_CODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode), as,
64 outer_code, index_code);
65#else
66#ifdef REGNO_MODE_OK_FOR_REG_BASE_P
67 if (index_code == REG)
68 return REGNO_MODE_OK_FOR_REG_BASE_P (regno, MACRO_MODE (mode));
69#endif
70#ifdef REGNO_MODE_OK_FOR_BASE_P
71 return REGNO_MODE_OK_FOR_BASE_P (regno, MACRO_MODE (mode));
72#else
73 return REGNO_OK_FOR_BASE_P (regno);
74#endif
75#endif
76#endif
77}
78
79/* Wrapper around ok_for_base_p_1, for use after register allocation is
80 complete. Arguments as for the called function. */
81
82inline bool
83regno_ok_for_base_p (unsigned regno, machine_mode mode, addr_space_t as,
84 enum rtx_code outer_code, enum rtx_code index_code,
85 rtx_insn *insn = NULL)
86{
87 if (regno >= FIRST_PSEUDO_REGISTER && reg_renumber[regno] >= 0)
88 regno = reg_renumber[regno];
89
90 return ok_for_base_p_1 (regno, mode, as, outer_code, index_code, insn);
91}
92
93#endif /* GCC_ADDRESSES_H */
bool ok_for_base_p_1(unsigned regno, machine_mode mode, addr_space_t as, enum rtx_code outer_code, enum rtx_code index_code, rtx_insn *insn=NULL)
Definition addresses.h:52
enum reg_class index_reg_class(rtx_insn *insn=NULL)
Definition addresses.h:37
bool regno_ok_for_base_p(unsigned regno, machine_mode mode, addr_space_t as, enum rtx_code outer_code, enum rtx_code index_code, rtx_insn *insn=NULL)
Definition addresses.h:83
enum reg_class base_reg_class(machine_mode mode, addr_space_t as, enum rtx_code outer_code, enum rtx_code index_code, rtx mem=NULL_RTX, rtx_insn *insn=NULL)
Definition addresses.h:28
struct rtx_def * rtx
Definition coretypes.h:57
unsigned char addr_space_t
Definition coretypes.h:191
short * reg_renumber
Definition ira.cc:2555
#define MACRO_MODE(MODE)
Definition machmode.h:885
#define NULL_RTX
Definition rtl.h:709
rtx_code
Definition rtl.h:48
Definition rtl.h:549
#define NULL
Definition system.h:58
struct gcc_target targetm