GCC Middle and Back End API Reference
regset.h
Go to the documentation of this file.
1/* Define regsets.
2 Copyright (C) 1987-2024 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#ifndef GCC_REGSET_H
21#define GCC_REGSET_H
22
23/* TODO: regset is just a bitmap in its implementation. The compiler does
24 not consistently use one or the other, i.e. sometimes variables are
25 declared as bitmap but they are actually regsets and regset accessors
26 are used, and vice versa, or mixed (see e.g. spilled_regs in IRA).
27
28 This should be cleaned up, either by just dropping the regset type, or
29 by changing all bitmaps that are really regsets to the regset type. For
30 the latter option, a good start would be to change everything allocated
31 on the reg_obstack to regset. */
32
33
34/* Head of register set linked list. */
36
37/* A pointer to a regset_head. */
38typedef bitmap regset;
39
40/* Allocate a register set with oballoc. */
41#define ALLOC_REG_SET(OBSTACK) BITMAP_ALLOC (OBSTACK)
42
43/* Do any cleanup needed on a regset when it is no longer used. */
44#define FREE_REG_SET(REGSET) BITMAP_FREE (REGSET)
45
46/* Initialize a new regset. */
47#define INIT_REG_SET(HEAD) bitmap_initialize (HEAD, &reg_obstack)
48
49/* Clear a register set by freeing up the linked list. */
50#define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD)
51
52/* True if the register set is empty. */
53#define REG_SET_EMPTY_P(HEAD) bitmap_empty_p (HEAD)
54
55/* Copy a register set to another register set. */
56#define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM)
57
58/* Compare two register sets. */
59#define REG_SET_EQUAL_P(A, B) bitmap_equal_p (A, B)
60
61/* `and' a register set with a second register set. */
62#define AND_REG_SET(TO, FROM) bitmap_and_into (TO, FROM)
63
64/* `and' the complement of a register set with a register set. */
65#define AND_COMPL_REG_SET(TO, FROM) bitmap_and_compl_into (TO, FROM)
66
67/* Inclusive or a register set with a second register set. */
68#define IOR_REG_SET(TO, FROM) bitmap_ior_into (TO, FROM)
69
70/* Same, but with FROM being a HARD_REG_SET. */
71#define IOR_REG_SET_HRS(TO, FROM) \
72 bitmap_ior_into (TO, bitmap_view<HARD_REG_SET> (FROM))
73
74/* Exclusive or a register set with a second register set. */
75#define XOR_REG_SET(TO, FROM) bitmap_xor_into (TO, FROM)
76
77/* Or into TO the register set FROM1 `and'ed with the complement of FROM2. */
78#define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \
79 bitmap_ior_and_compl_into (TO, FROM1, FROM2)
80
81/* Clear a single register in a register set. */
82#define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG)
83
84/* Set a single register in a register set. */
85#define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG)
86
87/* Return true if a register is set in a register set. */
88#define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG)
89
90/* Copy the hard registers in a register set to the hard register set. */
92#define REG_SET_TO_HARD_REG_SET(TO, FROM) \
93do { \
94 CLEAR_HARD_REG_SET (TO); \
95 reg_set_to_hard_reg_set (&TO, FROM); \
96} while (0)
97
99
100/* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
101 register number and executing CODE for all registers that are set. */
102#define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, RSI) \
103 EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, RSI)
104
105/* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
106 REGNUM to the register number and executing CODE for all registers that are
107 set in the first regset and not set in the second. */
108#define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
109 EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI)
110
111/* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
112 REGNUM to the register number and executing CODE for all registers that are
113 set in both regsets. */
114#define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, RSI) \
115 EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, RSI) \
116
117/* An obstack for regsets. */
119
120/* In df-core.cc (which should use regset consistently instead of bitmap...) */
121extern void dump_regset (regset, FILE *);
122
123#endif /* GCC_REGSET_H */
Definition bitmap.h:328
const class bitmap_head * const_bitmap
Definition coretypes.h:52
class bitmap_head * bitmap
Definition coretypes.h:51
HARD_REG_ELT_TYPE HARD_REG_SET
Definition hard-reg-set.h:47
bitmap_obstack reg_obstack
Definition df-core.cc:397
bitmap_head regset_head
Definition regset.h:35
bitmap regset
Definition regset.h:38
void dump_regset(regset, FILE *)
Definition df-core.cc:2094
bitmap_iterator reg_set_iterator
Definition regset.h:98
void reg_set_to_hard_reg_set(HARD_REG_SET *, const_bitmap)
Definition reginfo.cc:151
Definition bitmap.h:519
Definition bitmap.h:294