913a1ed85de247194ad996161aeb87ddd4f0799e
2 * Copyright © 2012 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 * Eric Anholt <eric@anholt.net>
32 #include "brw_shader.h"
38 DECLARE_RALLOC_CXX_OPERATORS(bblock_link
)
40 bblock_link(bblock_t
*block
)
46 struct exec_node link
;
47 struct bblock_t
*block
;
51 struct backend_instruction
;
56 DECLARE_RALLOC_CXX_OPERATORS(bblock_t
)
60 void add_successor(void *mem_ctx
, bblock_t
*successor
);
61 void dump(backend_visitor
*v
);
64 struct exec_node link
;
66 struct backend_instruction
*start
;
67 struct backend_instruction
*end
;
72 struct exec_list parents
;
73 struct exec_list children
;
76 /* If the current basic block ends in an IF, ELSE, or ENDIF instruction,
77 * these pointers will hold the locations of the other associated control
80 * Otherwise they are NULL.
82 struct backend_instruction
*if_inst
;
83 struct backend_instruction
*else_inst
;
84 struct backend_instruction
*endif_inst
;
89 DECLARE_RALLOC_CXX_OPERATORS(cfg_t
)
91 cfg_t(exec_list
*instructions
);
94 bblock_t
*new_block();
95 void set_next_block(bblock_t
**cur
, bblock_t
*block
, int ip
);
96 void make_block_array();
98 void dump(backend_visitor
*v
);
102 /** Ordered list (by ip) of basic blocks */
103 struct exec_list block_list
;
104 struct bblock_t
**blocks
;
108 #define foreach_block_and_inst(__block, __type, __inst, __cfg) \
109 foreach_block (__block, __cfg) \
110 foreach_inst_in_block (__type, __inst, __block)
112 #define foreach_block(__block, __cfg) \
113 foreach_list_typed (bblock_t, __block, link, &(__cfg)->block_list)
115 #define foreach_block_safe(__block, __cfg) \
116 foreach_list_typed_safe (bblock_t, __block, link, &(__cfg)->block_list)
118 #define foreach_inst_in_block(__type, __inst, __block) \
119 for (__type *__inst = (__type *)__block->start; \
120 __inst != __block->end->next; \
121 __inst = (__type *)__inst->next)
123 #define foreach_inst_in_block_safe(__type, __inst, __block) \
124 for (__type *__inst = (__type *)__block->start, \
125 *__next = (__type *)__inst->next, \
126 *__end = (__type *)__block->end->next->next; \
129 __next = (__type *)__next->next)
131 #define foreach_inst_in_block_reverse(__type, __inst, __block) \
132 for (__type *__inst = (__type *)__block->end; \
133 __inst != __block->start->prev; \
134 __inst = (__type *)__inst->prev)
136 #endif /* BRW_CFG_H */