1 | /* Define control and data flow tables, and regsets. |
---|
2 | Copyright (C) 1987, 1997 Free Software Foundation, Inc. |
---|
3 | |
---|
4 | This file is part of GNU CC. |
---|
5 | |
---|
6 | GNU CC is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | GNU CC is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with GNU CC; see the file COPYING. If not, write to |
---|
18 | the Free Software Foundation, 59 Temple Place - Suite 330, |
---|
19 | Boston, MA 02111-1307, USA. */ |
---|
20 | |
---|
21 | |
---|
22 | #include "bitmap.h" |
---|
23 | |
---|
24 | typedef bitmap regset; /* Head of register set linked list. */ |
---|
25 | |
---|
26 | /* Clear a register set by freeing up the linked list. */ |
---|
27 | #define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD) |
---|
28 | |
---|
29 | /* Copy a register set to another register set. */ |
---|
30 | #define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM) |
---|
31 | |
---|
32 | /* `and' a register set with a second register set. */ |
---|
33 | #define AND_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_AND) |
---|
34 | |
---|
35 | /* `and' the complement of a register set with a register set. */ |
---|
36 | #define AND_COMPL_REG_SET(TO, FROM) \ |
---|
37 | bitmap_operation (TO, TO, FROM, BITMAP_AND_COMPL) |
---|
38 | |
---|
39 | /* Inclusive or a register set with a second register set. */ |
---|
40 | #define IOR_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_IOR) |
---|
41 | |
---|
42 | /* Or into TO the register set FROM1 `and'ed with the complement of FROM2. */ |
---|
43 | #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \ |
---|
44 | bitmap_ior_and_compl (TO, FROM1, FROM2) |
---|
45 | |
---|
46 | /* Clear a single register in a register set. */ |
---|
47 | #define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG) |
---|
48 | |
---|
49 | /* Set a single register in a register set. */ |
---|
50 | #define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG) |
---|
51 | |
---|
52 | /* Return true if a register is set in a register set. */ |
---|
53 | #define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG) |
---|
54 | |
---|
55 | /* Copy the hard registers in a register set to the hard register set. */ |
---|
56 | #define REG_SET_TO_HARD_REG_SET(TO, FROM) \ |
---|
57 | do { \ |
---|
58 | int i_; \ |
---|
59 | CLEAR_HARD_REG_SET (TO); \ |
---|
60 | for (i_ = 0; i_ < FIRST_PSEUDO_REGISTER; i_++) \ |
---|
61 | if (REGNO_REG_SET_P (FROM, i_)) \ |
---|
62 | SET_HARD_REG_BIT (TO, i_); \ |
---|
63 | } while (0) |
---|
64 | |
---|
65 | /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the |
---|
66 | register number and executing CODE for all registers that are set. */ |
---|
67 | #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, CODE) \ |
---|
68 | EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, CODE) |
---|
69 | |
---|
70 | /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting |
---|
71 | REGNUM to the register number and executing CODE for all registers that are |
---|
72 | set in the first regset and not set in the second. */ |
---|
73 | #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \ |
---|
74 | EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE) |
---|
75 | |
---|
76 | /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting |
---|
77 | REGNUM to the register number and executing CODE for all registers that are |
---|
78 | set in both regsets. */ |
---|
79 | #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \ |
---|
80 | EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE) |
---|
81 | |
---|
82 | /* Allocate a register set with oballoc. */ |
---|
83 | #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK) |
---|
84 | |
---|
85 | /* Allocate a register set with alloca. */ |
---|
86 | #define ALLOCA_REG_SET() BITMAP_ALLOCA () |
---|
87 | |
---|
88 | /* Do any cleanup needed on a regset when it is no longer used. */ |
---|
89 | #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET) |
---|
90 | |
---|
91 | /* Do any one-time initializations needed for regsets. */ |
---|
92 | #define INIT_ONCE_REG_SET() BITMAP_INIT_ONCE () |
---|
93 | |
---|
94 | /* Grow any tables needed when the number of registers is calculated |
---|
95 | or extended. For the linked list allocation, nothing needs to |
---|
96 | be done, other than zero the statistics on the first allocation. */ |
---|
97 | #define MAX_REGNO_REG_SET(NUM_REGS, NEW_P, RENUMBER_P) |
---|
98 | |
---|
99 | /* Number of basic blocks in the current function. */ |
---|
100 | |
---|
101 | extern int n_basic_blocks; |
---|
102 | |
---|
103 | /* Index by basic block number, get first insn in the block. */ |
---|
104 | |
---|
105 | extern rtx *basic_block_head; |
---|
106 | |
---|
107 | /* Index by basic block number, get last insn in the block. */ |
---|
108 | |
---|
109 | extern rtx *basic_block_end; |
---|
110 | |
---|
111 | /* Index by basic block number, get address of regset |
---|
112 | describing the registers live at the start of that block. */ |
---|
113 | |
---|
114 | extern regset *basic_block_live_at_start; |
---|
115 | |
---|
116 | /* What registers are live at the setjmp call. */ |
---|
117 | |
---|
118 | extern regset regs_live_at_setjmp; |
---|
119 | |
---|
120 | /* Indexed by n, gives number of basic block that (REG n) is used in. |
---|
121 | If the value is REG_BLOCK_GLOBAL (-2), |
---|
122 | it means (REG n) is used in more than one basic block. |
---|
123 | REG_BLOCK_UNKNOWN (-1) means it hasn't been seen yet so we don't know. |
---|
124 | This information remains valid for the rest of the compilation |
---|
125 | of the current function; it is used to control register allocation. */ |
---|
126 | |
---|
127 | #define REG_BLOCK_UNKNOWN -1 |
---|
128 | #define REG_BLOCK_GLOBAL -2 |
---|
129 | |
---|
130 | #define REG_BASIC_BLOCK(N) (reg_n_info[(N)].basic_block) |
---|