--with-gnu-ld uses different x- fiile under aix 4.1
[official-gcc.git] / gcc / basic-block.h
blobd54ffe8b26c51890344a36adf28bf1aaf6e79725
1 /* Define control and data flow tables, and regsets.
2 Copyright (C) 1987, 1997, 1998, 1999 Free Software Foundation, Inc.
4 This file is part of GNU CC.
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.
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.
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. */
22 #include "bitmap.h"
23 #include "sbitmap.h"
25 typedef bitmap regset; /* Head of register set linked list. */
27 /* Clear a register set by freeing up the linked list. */
28 #define CLEAR_REG_SET(HEAD) bitmap_clear (HEAD)
30 /* Copy a register set to another register set. */
31 #define COPY_REG_SET(TO, FROM) bitmap_copy (TO, FROM)
33 /* `and' a register set with a second register set. */
34 #define AND_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_AND)
36 /* `and' the complement of a register set with a register set. */
37 #define AND_COMPL_REG_SET(TO, FROM) \
38 bitmap_operation (TO, TO, FROM, BITMAP_AND_COMPL)
40 /* Inclusive or a register set with a second register set. */
41 #define IOR_REG_SET(TO, FROM) bitmap_operation (TO, TO, FROM, BITMAP_IOR)
43 /* Or into TO the register set FROM1 `and'ed with the complement of FROM2. */
44 #define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \
45 bitmap_ior_and_compl (TO, FROM1, FROM2)
47 /* Clear a single register in a register set. */
48 #define CLEAR_REGNO_REG_SET(HEAD, REG) bitmap_clear_bit (HEAD, REG)
50 /* Set a single register in a register set. */
51 #define SET_REGNO_REG_SET(HEAD, REG) bitmap_set_bit (HEAD, REG)
53 /* Return true if a register is set in a register set. */
54 #define REGNO_REG_SET_P(TO, REG) bitmap_bit_p (TO, REG)
56 /* Copy the hard registers in a register set to the hard register set. */
57 #define REG_SET_TO_HARD_REG_SET(TO, FROM) \
58 do { \
59 int i_; \
60 CLEAR_HARD_REG_SET (TO); \
61 for (i_ = 0; i_ < FIRST_PSEUDO_REGISTER; i_++) \
62 if (REGNO_REG_SET_P (FROM, i_)) \
63 SET_HARD_REG_BIT (TO, i_); \
64 } while (0)
66 /* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
67 register number and executing CODE for all registers that are set. */
68 #define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, CODE) \
69 EXECUTE_IF_SET_IN_BITMAP (REGSET, MIN, REGNUM, CODE)
71 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
72 REGNUM to the register number and executing CODE for all registers that are
73 set in the first regset and not set in the second. */
74 #define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
75 EXECUTE_IF_AND_COMPL_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE)
77 /* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
78 REGNUM to the register number and executing CODE for all registers that are
79 set in both regsets. */
80 #define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
81 EXECUTE_IF_AND_IN_BITMAP (REGSET1, REGSET2, MIN, REGNUM, CODE)
83 /* Allocate a register set with oballoc. */
84 #define OBSTACK_ALLOC_REG_SET(OBSTACK) BITMAP_OBSTACK_ALLOC (OBSTACK)
86 /* Allocate a register set with alloca. */
87 #define ALLOCA_REG_SET() BITMAP_ALLOCA ()
89 /* Do any cleanup needed on a regset when it is no longer used. */
90 #define FREE_REG_SET(REGSET) BITMAP_FREE(REGSET)
92 /* Do any one-time initializations needed for regsets. */
93 #define INIT_ONCE_REG_SET() BITMAP_INIT_ONCE ()
95 /* Grow any tables needed when the number of registers is calculated
96 or extended. For the linked list allocation, nothing needs to
97 be done, other than zero the statistics on the first allocation. */
98 #define MAX_REGNO_REG_SET(NUM_REGS, NEW_P, RENUMBER_P)
100 /* Number of basic blocks in the current function. */
102 extern int n_basic_blocks;
104 /* Index by basic block number, get first insn in the block. */
106 extern rtx *x_basic_block_head;
108 /* Index by basic block number, get last insn in the block. */
110 extern rtx *x_basic_block_end;
112 /* Index by basic block number, determine whether the block can be reached
113 through a computed jump. */
115 extern char *basic_block_computed_jump_target;
117 /* Index by basic block number, get address of regset
118 describing the registers live at the start of that block. */
120 extern regset *basic_block_live_at_start;
122 /* What registers are live at the setjmp call. */
124 extern regset regs_live_at_setjmp;
126 /* Indexed by n, gives number of basic block that (REG n) is used in.
127 If the value is REG_BLOCK_GLOBAL (-2),
128 it means (REG n) is used in more than one basic block.
129 REG_BLOCK_UNKNOWN (-1) means it hasn't been seen yet so we don't know.
130 This information remains valid for the rest of the compilation
131 of the current function; it is used to control register allocation. */
133 #define REG_BLOCK_UNKNOWN -1
134 #define REG_BLOCK_GLOBAL -2
136 #define REG_BASIC_BLOCK(N) (VARRAY_REG (reg_n_info, N)->basic_block)
138 /* List of integers.
139 These are used for storing things like predecessors, etc.
141 This scheme isn't very space efficient, especially on 64 bit machines.
142 The interface is designed so that the implementation can be replaced with
143 something more efficient if desirable. */
145 typedef struct int_list {
146 struct int_list *next;
147 int val;
148 } int_list;
150 typedef int_list *int_list_ptr;
152 /* Integer list elements are allocated in blocks to reduce the frequency
153 of calls to malloc and to reduce the associated space overhead. */
155 typedef struct int_list_block {
156 struct int_list_block *next;
157 int nodes_left;
158 #define INT_LIST_NODES_IN_BLK 500
159 struct int_list nodes[INT_LIST_NODES_IN_BLK];
160 } int_list_block;
162 /* Given a pointer to the list, return pointer to first element. */
163 #define INT_LIST_FIRST(il) (il)
165 /* Given a pointer to a list element, return pointer to next element. */
166 #define INT_LIST_NEXT(p) ((p)->next)
168 /* Return non-zero if P points to the end of the list. */
169 #define INT_LIST_END(p) ((p) == NULL)
171 /* Return element pointed to by P. */
172 #define INT_LIST_VAL(p) ((p)->val)
174 #define INT_LIST_SET_VAL(p, new_val) ((p)->val = (new_val))
176 extern void free_int_list PROTO ((int_list_block **));
178 /* Stuff for recording basic block info. */
180 #define BLOCK_HEAD(B) x_basic_block_head[(B)]
181 #define BLOCK_END(B) x_basic_block_end[(B)]
183 /* Special block numbers [markers] for entry and exit. */
184 #define ENTRY_BLOCK (-1)
185 #define EXIT_BLOCK (-2)
187 /* from flow.c */
188 extern void free_regset_vector PROTO ((regset *, int nelts));
189 extern int *uid_block_number;
190 #define BLOCK_NUM(INSN) uid_block_number[INSN_UID (INSN)]
192 extern void dump_bb_data PROTO ((FILE *, int_list_ptr *, int_list_ptr *,
193 int));
194 extern void free_bb_mem PROTO ((void));
195 extern void free_basic_block_vars PROTO ((int));
197 extern void compute_preds_succs PROTO ((int_list_ptr *, int_list_ptr *,
198 int *, int *));
199 extern void compute_dominators PROTO ((sbitmap *, sbitmap *,
200 int_list_ptr *, int_list_ptr *));