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
25 * @file gen8_generator.h
27 * Code generation for Gen8+ hardware, replacing the brw_eu_emit.c layer.
33 #include "main/macros.h"
36 #include "gen8_instruction.h"
38 class gen8_generator
{
40 gen8_generator(struct brw_context
*brw
,
41 struct gl_shader_program
*shader_prog
,
42 struct gl_program
*prog
,
47 * Instruction emitters.
51 gen8_instruction *OP(struct brw_reg dst, struct brw_reg src);
53 gen8_instruction *OP(struct brw_reg d, struct brw_reg, struct brw_reg);
55 gen8_instruction *OP(struct brw_reg d, \
56 struct brw_reg, struct brw_reg, struct brw_reg);
98 gen8_instruction
*CMP(struct brw_reg dst
, unsigned conditional
,
99 struct brw_reg src0
, struct brw_reg src1
);
100 gen8_instruction
*IF(unsigned predicate
);
101 gen8_instruction
*ELSE();
102 gen8_instruction
*ENDIF();
104 gen8_instruction
*BREAK();
105 gen8_instruction
*CONTINUE();
106 gen8_instruction
*WHILE();
108 gen8_instruction
*HALT();
110 gen8_instruction
*MATH(unsigned math_function
,
112 struct brw_reg src0
);
113 gen8_instruction
*MATH(unsigned math_function
,
116 struct brw_reg src1
);
117 gen8_instruction
*NOP();
120 void disassemble(FILE *out
, int start
, int end
);
123 gen8_instruction
*alu3(unsigned opcode
,
127 struct brw_reg src2
);
129 gen8_instruction
*math(unsigned math_function
,
131 struct brw_reg src0
);
133 gen8_instruction
*next_inst(unsigned opcode
);
135 struct gl_shader_program
*shader_prog
;
136 struct gl_program
*prog
;
138 struct brw_context
*brw
;
139 struct intel_context
*intel
;
140 struct gl_context
*ctx
;
142 gen8_instruction
*store
;
145 unsigned next_inst_offset
;
148 * Control flow stacks:
150 * if_stack contains IF and ELSE instructions which must be patched with
151 * the final jump offsets (and popped) once the matching ENDIF is encountered.
153 * We actually store an array index into the store, rather than pointers
154 * to the instructions. This is necessary since we may realloc the store.
160 int if_stack_array_size
;
163 int loop_stack_depth
;
164 int loop_stack_array_size
;
166 int if_depth_in_loop
;
168 void push_if_stack(gen8_instruction
*inst
);
169 gen8_instruction
*pop_if_stack();
172 void patch_IF_ELSE(gen8_instruction
*if_inst
,
173 gen8_instruction
*else_inst
,
174 gen8_instruction
*endif_inst
);
176 unsigned next_ip(unsigned ip
) const;
177 unsigned find_next_block_end(unsigned start_ip
) const;
178 unsigned find_loop_end(unsigned start
) const;
180 void patch_jump_targets();
183 * Default state for new instructions.
187 unsigned access_mode
;
188 unsigned mask_control
;
189 unsigned flag_subreg_nr
;
190 unsigned conditional_mod
;
192 bool predicate_inverse
;