1 /* -*- c-basic-offset: 8 -*- */
3 * Copyright © 2006 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * Eric Anholt <eric@anholt.net>
38 typedef unsigned char GLubyte;
39 typedef short GLshort;
40 typedef unsigned int GLuint;
42 typedef float GLfloat;
44 extern long int gen_level;
45 extern int advanced_flag;
48 #define WARN_ALWAYS (1 << 0)
49 #define WARN_ALL (1 << 31)
50 extern unsigned int warning_flags;
52 extern char *input_filename;
54 extern struct brw_context genasm_context;
55 extern struct brw_compile genasm_compile;
57 /* Predicate for Gen X and above */
58 #define IS_GENp(x) (gen_level >= (x)*10)
60 /* Predicate for Gen X exactly */
61 #define IS_GENx(x) (gen_level >= (x)*10 && gen_level < ((x)+1)*10)
63 /* Predicate to match Haswell processors */
64 #define IS_HASWELL(x) (gen_level == 75)
66 #include "brw_defines.h"
67 #include "brw_structs.h"
69 void yyerror (char *msg);
71 #define STRUCT_SIZE_ASSERT(TYPE, SIZE) \
73 char compile_time_assert_ ## TYPE ## _size[ \
74 (sizeof (struct TYPE) == (SIZE)) ? 1 : -1]; \
75 } _ ## TYPE ## SizeCheck
77 /* ensure nobody changes the size of struct brw_instruction */
78 STRUCT_SIZE_ASSERT(brw_instruction, 16);
80 #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
89 unsigned pred_control:4;
90 unsigned pred_inverse:1;
91 unsigned flag_reg_nr:1;
92 unsigned flag_subreg_nr:1;
96 unsigned access_mode:1;
97 unsigned compression_control:2; /* gen6: quater control */
98 unsigned thread_control:2;
99 unsigned dependency_control:2;
100 unsigned mask_control:1;
101 unsigned debug_control:1;
102 unsigned acc_wr_control:1;
104 unsigned end_of_thread:1;
108 int vert_stride, width, horiz_stride;
117 * This structure is the internal representation of source operands in the
123 uint32_t imm32; /* set if src_operand is expressing a branch offset */
124 char *reloc_target; /* bspec: branching instructions JIP and UIP are source operands */
138 enum assembler_instruction_type {
139 GEN4ASM_INSTRUCTION_GEN,
140 GEN4ASM_INSTRUCTION_GEN_RELOCATABLE,
141 GEN4ASM_INSTRUCTION_LABEL,
144 struct label_instruction {
149 char *first_reloc_target, *second_reloc_target; // JIP and UIP respectively
150 GLint first_reloc_offset, second_reloc_offset; // in number of instructions
154 * This structure is just the list container for instructions accumulated by
155 * the parser and labels.
157 struct brw_program_instruction {
158 enum assembler_instruction_type type;
159 unsigned inst_offset;
161 struct brw_instruction gen;
162 struct label_instruction label;
164 struct relocation reloc;
165 struct brw_program_instruction *next;
168 static inline bool is_label(struct brw_program_instruction *instruction)
170 return instruction->type == GEN4ASM_INSTRUCTION_LABEL;
173 static inline char *label_name(struct brw_program_instruction *i)
176 return i->insn.label.name;
179 static inline bool is_relocatable(struct brw_program_instruction *intruction)
181 return intruction->type == GEN4ASM_INSTRUCTION_GEN_RELOCATABLE;
185 * This structure is a list of instructions. It is the final output of the
189 struct brw_program_instruction *first;
190 struct brw_program_instruction *last;
193 extern struct brw_program compiled_program;
195 #define TYPE_B_INDEX 0
196 #define TYPE_UB_INDEX 1
197 #define TYPE_W_INDEX 2
198 #define TYPE_UW_INDEX 3
199 #define TYPE_D_INDEX 4
200 #define TYPE_UD_INDEX 5
201 #define TYPE_F_INDEX 6
203 #define TOTAL_TYPES 7
205 struct program_defaults {
207 int execute_type[TOTAL_TYPES];
209 int register_type_regfile;
210 struct region source_region;
211 struct region source_region_type[TOTAL_TYPES];
212 struct region dest_region;
213 struct region dest_region_type[TOTAL_TYPES];
215 extern struct program_defaults program_defaults;
217 struct declared_register {
221 struct region src_region;
225 struct declared_register *find_register(char *name);
226 void insert_register(struct declared_register *reg);
230 int yylex_destroy(void);
235 #endif /* __GEN4ASM_H__ */