blob: 70caeb4132a6f6a08cacee215d922bea6ac1fb34 [file] [log] [blame]
Eric Anholt22a10632006-08-22 10:15:33 -07001%{
2/*
3 * Copyright © 2006 Intel Corporation
4 *
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:
11 *
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
14 * Software.
15 *
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
22 * SOFTWARE.
23 *
24 * Authors:
25 * Eric Anholt <eric@anholt.net>
26 *
27 */
28
29#include <stdio.h>
Eric Anholtf2f18562006-08-22 12:46:37 -070030#include <string.h>
Keith Packard2d4d4012008-03-30 00:58:28 -070031#include <stdlib.h>
Xiang, Haihao27b43032010-12-13 16:07:16 +080032#include <assert.h>
Eric Anholt22a10632006-08-22 10:15:33 -070033#include "gen4asm.h"
34#include "brw_defines.h"
35
Xiang, Haihao27b43032010-12-13 16:07:16 +080036#define DEFAULT_EXECSIZE (ffs(program_defaults.execute_size) - 1)
37#define DEFAULT_DSTREGION -1
Xiang Haihao549b7512009-06-30 10:02:33 +080038
Xiang, Haihao27b43032010-12-13 16:07:16 +080039extern long int gen_level;
40extern int advanced_flag;
41extern int yylineno;
42extern int need_export;
Homer Hsing88dfdf32012-09-24 10:06:35 +080043static struct src_operand src_null_reg =
44{
45 .reg_file = BRW_ARCHITECTURE_REGISTER_FILE,
46 .reg_nr = BRW_ARF_NULL,
Homer Hsingb899aba2012-09-27 14:56:30 +080047 .reg_type = BRW_REGISTER_TYPE_UD,
Homer Hsing88dfdf32012-09-24 10:06:35 +080048};
49static struct dst_operand dst_null_reg =
50{
51 .reg_file = BRW_ARCHITECTURE_REGISTER_FILE,
52 .reg_nr = BRW_ARF_NULL,
53};
Homer Hsing7e2461b2012-09-27 14:48:14 +080054static struct dst_operand ip_dst =
55{
56 .reg_file = BRW_ARCHITECTURE_REGISTER_FILE,
57 .reg_nr = BRW_ARF_IP,
58 .reg_type = BRW_REGISTER_TYPE_UD,
59 .address_mode = BRW_ADDRESS_DIRECT,
60 .horiz_stride = 1,
61 .writemask = 0xF,
62};
63static struct src_operand ip_src =
64{
65 .reg_file = BRW_ARCHITECTURE_REGISTER_FILE,
66 .reg_nr = BRW_ARF_IP,
67 .reg_type = BRW_REGISTER_TYPE_UD,
68 .address_mode = BRW_ADDRESS_DIRECT,
69 .swizzle_x = BRW_CHANNEL_X,
70 .swizzle_y = BRW_CHANNEL_Y,
71 .swizzle_z = BRW_CHANNEL_Z,
72 .swizzle_w = BRW_CHANNEL_W,
73};
Xiang, Haihao27b43032010-12-13 16:07:16 +080074
75static int get_type_size(GLuint type);
Eric Anholtc8939ed2006-08-30 10:50:56 -070076int set_instruction_dest(struct brw_instruction *instr,
77 struct dst_operand *dest);
Keith Packard2d4d4012008-03-30 00:58:28 -070078int set_instruction_src0(struct brw_instruction *instr,
Eric Anholtc8939ed2006-08-30 10:50:56 -070079 struct src_operand *src);
80int set_instruction_src1(struct brw_instruction *instr,
81 struct src_operand *src);
Homer Hsinga034bcb2012-09-07 14:38:13 +080082int set_instruction_dest_three_src(struct brw_instruction *instr,
83 struct dst_operand *dest);
84int set_instruction_src0_three_src(struct brw_instruction *instr,
85 struct src_operand *src);
86int set_instruction_src1_three_src(struct brw_instruction *instr,
87 struct src_operand *src);
88int set_instruction_src2_three_src(struct brw_instruction *instr,
89 struct src_operand *src);
Eric Anholtc8939ed2006-08-30 10:50:56 -070090void set_instruction_options(struct brw_instruction *instr,
91 struct brw_instruction *options);
92void set_instruction_predicate(struct brw_instruction *instr,
93 struct brw_instruction *predicate);
Eric Anholt1e907c72006-08-31 10:21:15 -070094void set_direct_dst_operand(struct dst_operand *dst, struct direct_reg *reg,
95 int type);
Eric Anholtc8939ed2006-08-30 10:50:56 -070096void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg,
97 int type);
98
Eric Anholt22a10632006-08-22 10:15:33 -070099%}
100
101%start ROOT
102
103%union {
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800104 char *string;
Eric Anholt22a10632006-08-22 10:15:33 -0700105 int integer;
106 double number;
107 struct brw_instruction instruction;
108 struct brw_program program;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800109 struct region region;
110 struct regtype regtype;
Eric Anholt74c81af2006-08-30 11:10:45 -0700111 struct direct_reg direct_reg;
112 struct indirect_reg indirect_reg;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800113 struct condition condition;
114 struct declared_register symbol_reg;
Keith Packard2d4d4012008-03-30 00:58:28 -0700115 imm32_t imm32;
Eric Anholt6a88ada2006-08-28 22:11:18 -0700116
Eric Anholt2dac0a12006-08-29 15:29:31 -0700117 struct dst_operand dst_operand;
Eric Anholt6a88ada2006-08-28 22:11:18 -0700118 struct src_operand src_operand;
Eric Anholt22a10632006-08-22 10:15:33 -0700119}
120
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800121%token COLON
Eric Anholt22a10632006-08-22 10:15:33 -0700122%token SEMICOLON
123%token LPAREN RPAREN
124%token LANGLE RANGLE
125%token LCURLY RCURLY
Eric Anholt3bcf6b22006-08-29 18:31:34 -0700126%token LSQUARE RSQUARE
Xiang, Haihao27b43032010-12-13 16:07:16 +0800127%token COMMA EQ
128%token ABS DOT
129%token PLUS MINUS MULTIPLY DIVIDE
Eric Anholt22a10632006-08-22 10:15:33 -0700130
Eric Anholtc8939ed2006-08-30 10:50:56 -0700131%token <integer> TYPE_UD TYPE_D TYPE_UW TYPE_W TYPE_UB TYPE_B
132%token <integer> TYPE_VF TYPE_HF TYPE_V TYPE_F
Eric Anholt22a10632006-08-22 10:15:33 -0700133
Eric Anholt908f37d2006-08-25 17:33:02 -0700134%token ALIGN1 ALIGN16 SECHALF COMPR SWITCH ATOMIC NODDCHK NODDCLR
Xiang, Haihao55d81c42010-10-08 13:53:22 +0800135%token MASK_DISABLE BREAKPOINT ACCWRCTRL EOT
Eric Anholt22a10632006-08-22 10:15:33 -0700136
Keith Packard2033aea2008-04-23 23:10:40 -0700137%token SEQ ANY2H ALL2H ANY4H ALL4H ANY8H ALL8H ANY16H ALL16H ANYV ALLV
138%token <integer> ZERO EQUAL NOT_ZERO NOT_EQUAL GREATER GREATER_EQUAL LESS LESS_EQUAL
139%token <integer> ROUND_INCREMENT OVERFLOW UNORDERED
Eric Anholt883408e2006-08-25 13:38:03 -0700140%token <integer> GENREG MSGREG ADDRESSREG ACCREG FLAGREG
141%token <integer> MASKREG AMASK IMASK LMASK CMASK
142%token <integer> MASKSTACKREG LMS IMS MASKSTACKDEPTHREG IMSD LMSD
143%token <integer> NOTIFYREG STATEREG CONTROLREG IPREG
Eric Anholt3bcf6b22006-08-29 18:31:34 -0700144%token GENREGFILE MSGREGFILE
Eric Anholt22a10632006-08-22 10:15:33 -0700145
Eric Anholtf914c6a2006-08-25 11:05:10 -0700146%token <integer> MOV FRC RNDU RNDD RNDE RNDZ NOT LZD
147%token <integer> MUL MAC MACH LINE SAD2 SADA2 DP4 DPH DP3 DP2
Xiang, Haihaof1f52082010-10-19 13:26:24 +0800148%token <integer> AVG ADD SEL AND OR XOR SHR SHL ASR CMP CMPN PLN
Homer Hsing9e711a42012-09-14 08:56:36 +0800149%token <integer> ADDC BFI1 BFREV CBIT F16TO32 F32TO16 FBH FBL
Eric Anholtc8939ed2006-08-30 10:50:56 -0700150%token <integer> SEND NOP JMPI IF IFF WHILE ELSE BREAK CONT HALT MSAVE
Eric Anholtf914c6a2006-08-25 11:05:10 -0700151%token <integer> PUSH MREST POP WAIT DO ENDIF ILLEGAL
Xiang, Haihao54055322010-10-27 09:42:56 +0800152%token <integer> MATH_INST
Homer Hsingb1ef3bc2012-09-14 09:02:01 +0800153%token <integer> MAD LRP BFE BFI2 SUBB
Homer Hsinga7b1c092012-09-21 12:33:13 +0800154%token <integer> CALL RET
Homer Hsing88dfdf32012-09-24 10:06:35 +0800155%token <integer> BRD BRC
Eric Anholtf914c6a2006-08-25 11:05:10 -0700156
Zhao Yakui93f2a4f2012-10-22 16:13:51 -0400157%token NULL_TOKEN MATH SAMPLER GATEWAY READ WRITE URB THREAD_SPAWNER VME DATA_PORT CRE
Eric Anholt22a10632006-08-22 10:15:33 -0700158
159%token MSGLEN RETURNLEN
Eric Anholte8651962006-08-24 16:37:04 -0700160%token <integer> ALLOCATE USED COMPLETE TRANSPOSE INTERLEAVE
Keith Packard2d4d4012008-03-30 00:58:28 -0700161%token SATURATE
Eric Anholt22a10632006-08-22 10:15:33 -0700162
163%token <integer> INTEGER
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800164%token <string> STRING
Eric Anholt22a10632006-08-22 10:15:33 -0700165%token <number> NUMBER
166
Eric Anholt3d360792006-08-25 09:36:28 -0700167%token <integer> INV LOG EXP SQRT RSQ POW SIN COS SINCOS INTDIV INTMOD
168%token <integer> INTDIVMOD
169%token SIGNED SCALAR
170
Eric Anholt6a88ada2006-08-28 22:11:18 -0700171%token <integer> X Y Z W
172
Xiang, Haihao27b43032010-12-13 16:07:16 +0800173%token <integer> KERNEL_PRAGMA END_KERNEL_PRAGMA CODE_PRAGMA END_CODE_PRAGMA
174%token <integer> REG_COUNT_PAYLOAD_PRAGMA REG_COUNT_TOTAL_PRAGMA DECLARE_PRAGMA
175%token <integer> BASE ELEMENTSIZE SRCREGION DSTREGION TYPE
176
177%token <integer> DEFAULT_EXEC_SIZE_PRAGMA DEFAULT_REG_TYPE_PRAGMA
178%nonassoc SUBREGNUM
179%nonassoc SNDOPR
180%left PLUS MINUS
181%left MULTIPLY DIVIDE
182%right UMINUS
183%nonassoc DOT
184%nonassoc STR_SYMBOL_REG
185%nonassoc EMPTEXECSIZE
186%nonassoc LPAREN
187
188%type <integer> exp sndopr
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800189%type <integer> simple_int
Eric Anholt22a10632006-08-22 10:15:33 -0700190%type <instruction> instruction unaryinstruction binaryinstruction
Homer Hsinga034bcb2012-09-07 14:38:13 +0800191%type <instruction> binaryaccinstruction trinaryinstruction sendinstruction
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800192%type <instruction> jumpinstruction
193%type <instruction> breakinstruction syncinstruction
Eric Anholt2dac0a12006-08-29 15:29:31 -0700194%type <instruction> msgtarget
Eric Anholt0ed5d932006-08-28 23:05:51 -0700195%type <instruction> instoptions instoption_list predicate
Xiang, Haihao54055322010-10-27 09:42:56 +0800196%type <instruction> mathinstruction
Homer Hsinga7b1c092012-09-21 12:33:13 +0800197%type <instruction> subroutineinstruction
Homer Hsing88dfdf32012-09-24 10:06:35 +0800198%type <instruction> multibranchinstruction
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800199%type <instruction> nopinstruction loopinstruction ifelseinstruction haltinstruction
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800200%type <string> label
Eric Anholt22a10632006-08-22 10:15:33 -0700201%type <program> instrseq
Eric Anholt19f1c1c2006-08-22 12:41:09 -0700202%type <integer> instoption
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800203%type <integer> unaryop binaryop binaryaccop breakop
Homer Hsinga034bcb2012-09-07 14:38:13 +0800204%type <integer> trinaryop
Xiang, Haihao27b43032010-12-13 16:07:16 +0800205%type <condition> conditionalmodifier
206%type <integer> condition saturate negate abs chansel
Eric Anholt2dac0a12006-08-29 15:29:31 -0700207%type <integer> writemask_x writemask_y writemask_z writemask_w
Xiang, Haihao27b43032010-12-13 16:07:16 +0800208%type <integer> srcimmtype execsize dstregion immaddroffset
Eric Anholt56c4ccf2006-08-24 14:35:10 -0700209%type <integer> subregnum sampler_datatype
Eric Anholte8651962006-08-24 16:37:04 -0700210%type <integer> urb_swizzle urb_allocate urb_used urb_complete
Eric Anholt3d360792006-08-25 09:36:28 -0700211%type <integer> math_function math_signed math_scalar
Eric Anholt0ed5d932006-08-28 23:05:51 -0700212%type <integer> predctrl predstate
Xiang, Haihao27b43032010-12-13 16:07:16 +0800213%type <region> region region_wh indirectregion declare_srcregion;
214%type <regtype> regtype
Eric Anholt1d7d0422006-08-25 16:52:09 -0700215%type <direct_reg> directgenreg directmsgreg addrreg accreg flagreg maskreg
Xiang, Haihao27b43032010-12-13 16:07:16 +0800216%type <direct_reg> maskstackreg notifyreg
Keith Packard2d4d4012008-03-30 00:58:28 -0700217/* %type <direct_reg> maskstackdepthreg */
Eric Anholt1d7d0422006-08-25 16:52:09 -0700218%type <direct_reg> statereg controlreg ipreg nullreg
219%type <direct_reg> dstoperandex_typed srcarchoperandex_typed
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800220%type <direct_reg> sendleadreg
Eric Anholt3bcf6b22006-08-29 18:31:34 -0700221%type <indirect_reg> indirectgenreg indirectmsgreg addrparam
Keith Packard2d4d4012008-03-30 00:58:28 -0700222%type <integer> mask_subreg maskstack_subreg
Xiang, Haihao27b43032010-12-13 16:07:16 +0800223%type <integer> declare_elementsize declare_dstregion declare_type
Keith Packard2d4d4012008-03-30 00:58:28 -0700224/* %type <intger> maskstackdepth_subreg */
Xiang, Haihao27b43032010-12-13 16:07:16 +0800225%type <symbol_reg> symbol_reg symbol_reg_p;
Eric Anholt22a10632006-08-22 10:15:33 -0700226%type <imm32> imm32
Eric Anholt2dac0a12006-08-29 15:29:31 -0700227%type <dst_operand> dst dstoperand dstoperandex dstreg post_dst writemask
Xiang, Haihao27b43032010-12-13 16:07:16 +0800228%type <dst_operand> declare_base
Eric Anholt6a88ada2006-08-28 22:11:18 -0700229%type <src_operand> directsrcoperand srcarchoperandex directsrcaccoperand
Eric Anholt2d298742006-08-30 09:57:20 -0700230%type <src_operand> indirectsrcoperand
Eric Anholt6a88ada2006-08-28 22:11:18 -0700231%type <src_operand> src srcimm imm32reg payload srcacc srcaccimm swizzle
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800232%type <src_operand> relativelocation relativelocation2
Eric Anholt22a10632006-08-22 10:15:33 -0700233%%
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800234simple_int: INTEGER { $$ = $1; }
235 | MINUS INTEGER { $$ = -$2;}
236;
237
Zou Nan hai5608d272009-10-20 14:51:04 +0800238exp: INTEGER { $$ = $1; }
Zou Nan hai5608d272009-10-20 14:51:04 +0800239 | exp PLUS exp { $$ = $1 + $3; }
240 | exp MINUS exp { $$ = $1 - $3; }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800241 | exp MULTIPLY exp { $$ = $1 * $3; }
242 | exp DIVIDE exp { if ($3) $$ = $1 / $3; else YYERROR;}
243 | MINUS exp %prec UMINUS { $$ = -$2;}
Zou Nan hai5608d272009-10-20 14:51:04 +0800244 | LPAREN exp RPAREN { $$ = $2; }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800245 ;
Eric Anholt22a10632006-08-22 10:15:33 -0700246
247ROOT: instrseq
248 {
249 compiled_program = $1;
250 }
251;
252
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800253
254label: STRING COLON
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800255;
256
Xiang, Haihao27b43032010-12-13 16:07:16 +0800257declare_base: BASE EQ dstreg
258 {
259 $$ = $3;
260 }
261;
262declare_elementsize: ELEMENTSIZE EQ exp
263 {
264 $$ = $3;
265 }
266;
267declare_srcregion: /* empty */
268 {
269 /* XXX is this default correct?*/
270 memset (&$$, '\0', sizeof ($$));
271 $$.vert_stride = ffs(0);
272 $$.width = ffs(1) - 1;
273 $$.horiz_stride = ffs(0);
274 }
275 | SRCREGION EQ region
276 {
277 $$ = $3;
278 }
279;
280declare_dstregion: /* empty */
281 {
282 $$ = 1;
283 }
284 | DSTREGION EQ dstregion
285 {
286 $$ = $3;
287 }
288;
289declare_type: TYPE EQ regtype
290 {
291 $$ = $3.type;
292 }
293;
294declare_pragma: DECLARE_PRAGMA STRING declare_base declare_elementsize declare_srcregion declare_dstregion declare_type
295 {
Homer Hsinge6d61ac2012-09-17 13:34:38 +0800296 struct declared_register *reg;
297 int defined;
298 defined = (reg = find_register($2)) != NULL;
299 if (defined) {
Xiang, Haihao27b43032010-12-13 16:07:16 +0800300 fprintf(stderr, "WARNING: %s already defined\n", $2);
Homer Hsing2ab4c0d2012-09-20 14:04:20 +0800301 free($2); // $2 has been malloc'ed by strdup
Homer Hsinge6d61ac2012-09-17 13:34:38 +0800302 } else {
Xiang, Haihao27b43032010-12-13 16:07:16 +0800303 reg = calloc(sizeof(struct declared_register), 1);
Homer Hsing2ab4c0d2012-09-20 14:04:20 +0800304 reg->name = $2;
Homer Hsinge6d61ac2012-09-17 13:34:38 +0800305 }
Homer Hsinge6d61ac2012-09-17 13:34:38 +0800306 reg->base.reg_file = $3.reg_file;
307 reg->base.reg_nr = $3.reg_nr;
308 reg->base.subreg_nr = $3.subreg_nr;
309 reg->element_size = $4;
310 reg->src_region = $5;
311 reg->dst_region = $6;
312 reg->type = $7;
313 if (!defined) {
Xiang, Haihao27b43032010-12-13 16:07:16 +0800314 insert_register(reg);
315 }
316 }
317;
318
319reg_count_total_pragma: REG_COUNT_TOTAL_PRAGMA exp
320;
321reg_count_payload_pragma: REG_COUNT_PAYLOAD_PRAGMA exp
322;
323
324default_exec_size_pragma: DEFAULT_EXEC_SIZE_PRAGMA exp
325 {
326 program_defaults.execute_size = $2;
327 }
328;
329default_reg_type_pragma: DEFAULT_REG_TYPE_PRAGMA regtype
330 {
331 program_defaults.register_type = $2.type;
332 }
333;
334pragma: reg_count_total_pragma
335 |reg_count_payload_pragma
336 |default_exec_size_pragma
337 |default_reg_type_pragma
338 |declare_pragma
339;
340
341instrseq: instrseq pragma
342 {
343 $$ = $1;
344 }
345 | instrseq instruction SEMICOLON
Eric Anholt22a10632006-08-22 10:15:33 -0700346 {
347 struct brw_program_instruction *list_entry =
348 calloc(sizeof(struct brw_program_instruction), 1);
Zou Nan haidb8aedc2010-04-21 11:02:21 +0800349 list_entry->instruction = $2;
350 list_entry->next = NULL;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800351 if ($1.last) {
352 $1.last->next = list_entry;
353 } else {
354 $1.first = list_entry;
355 }
Zou Nan haidb8aedc2010-04-21 11:02:21 +0800356 $1.last = list_entry;
357 $$ = $1;
Eric Anholt22a10632006-08-22 10:15:33 -0700358 }
359 | instruction SEMICOLON
360 {
361 struct brw_program_instruction *list_entry =
362 calloc(sizeof(struct brw_program_instruction), 1);
363 list_entry->instruction = $1;
364
365 list_entry->next = NULL;
366
367 $$.first = list_entry;
Zou Nan haidb8aedc2010-04-21 11:02:21 +0800368 $$.last = list_entry;
Eric Anholt22a10632006-08-22 10:15:33 -0700369 }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800370 | instrseq SEMICOLON
371 {
372 $$ = $1;
373 }
374 | instrseq label
375 {
376 struct brw_program_instruction *list_entry =
377 calloc(sizeof(struct brw_program_instruction), 1);
378 list_entry->string = strdup($2);
379 list_entry->islabel = 1;
Zou Nan haidb8aedc2010-04-21 11:02:21 +0800380 list_entry->next = NULL;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800381 if ($1.last) {
382 $1.last->next = list_entry;
383 } else {
384 $1.first = list_entry;
385 }
Zou Nan haidb8aedc2010-04-21 11:02:21 +0800386 $1.last = list_entry;
387 $$ = $1;
388 }
389 | label
390 {
391 struct brw_program_instruction *list_entry =
392 calloc(sizeof(struct brw_program_instruction), 1);
Zou Nan haic6f2da42009-10-28 10:14:19 +0800393 list_entry->string = strdup($1);
Zou Nanhaibe9bcee2008-12-09 18:38:54 -0800394 list_entry->islabel = 1;
Zou Nan haidb8aedc2010-04-21 11:02:21 +0800395
396 list_entry->next = NULL;
397
398 $$.first = list_entry;
399 $$.last = list_entry;
400 }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800401 | pragma
402 {
403 $$.first = NULL;
404 $$.last = NULL;
405 }
Chen, Yangyang66649d72010-12-13 15:36:02 +0800406 | instrseq error SEMICOLON {
407 $$ = $1;
Eric Anholt22a10632006-08-22 10:15:33 -0700408 }
409;
410
411/* 1.4.1: Instruction groups */
Homer Hsing74383f42012-09-18 13:25:53 +0800412// binaryinstruction: Source operands cannot be accumulators
413// binaryaccinstruction: Source operands can be accumulators
Eric Anholt22a10632006-08-22 10:15:33 -0700414instruction: unaryinstruction
415 | binaryinstruction
416 | binaryaccinstruction
Homer Hsinga034bcb2012-09-07 14:38:13 +0800417 | trinaryinstruction
418 | sendinstruction
Eric Anholt1e907c72006-08-31 10:21:15 -0700419 | jumpinstruction
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800420 | ifelseinstruction
Eric Anholt4ee9c3d2006-09-01 13:37:51 -0700421 | breakinstruction
Eric Anholt1f58efa2006-09-01 11:56:12 -0700422 | syncinstruction
Xiang, Haihao54055322010-10-27 09:42:56 +0800423 | mathinstruction
Homer Hsinga7b1c092012-09-21 12:33:13 +0800424 | subroutineinstruction
Homer Hsing88dfdf32012-09-24 10:06:35 +0800425 | multibranchinstruction
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800426 | nopinstruction
427 | haltinstruction
428 | loopinstruction
Homer Hsing88dfdf32012-09-24 10:06:35 +0800429;
430
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800431ifelseinstruction: ENDIF
432 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400433 // for Gen4
434 if(IS_GENp(6)) { // For gen6+.
Homer Hsingc56d7862012-09-28 13:46:21 +0800435 fprintf(stderr, "ENDIF Syntax error: should be 'ENDIF execsize relativelocation'\n");
436 YYERROR;
437 }
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800438 memset(&$$, 0, sizeof($$));
439 $$.header.opcode = $1;
440 $$.header.thread_control |= BRW_THREAD_SWITCH;
441 $$.bits1.da1.dest_horiz_stride = 1;
442 $$.bits1.da1.src1_reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
443 $$.bits1.da1.src1_reg_type = BRW_REGISTER_TYPE_UD;
444 }
445 | ENDIF execsize relativelocation instoptions
446 {
Homer Hsingc56d7862012-09-28 13:46:21 +0800447 // for Gen6+
448 /* Gen6, Gen7 bspec: predication is prohibited */
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400449 if(!IS_GENp(6)) { // for gen6-
Homer Hsingc56d7862012-09-28 13:46:21 +0800450 fprintf(stderr, "ENDIF Syntax error: should be 'ENDIF'\n");
451 YYERROR;
452 }
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800453 memset(&$$, 0, sizeof($$));
454 $$.header.opcode = $1;
455 $$.header.execution_size = $2;
456 $$.first_reloc_target = $3.reloc_target;
457 $$.first_reloc_offset = $3.imm32;
458 }
459 | ELSE execsize relativelocation instoptions
460 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400461 if(!IS_GENp(6)) {
462 // for Gen4, Gen5. gen_level < 60
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800463 /* Set the istack pop count, which must always be 1. */
464 $3.imm32 |= (1 << 16);
465
466 memset(&$$, 0, sizeof($$));
467 $$.header.opcode = $1;
468 $$.header.execution_size = $2;
469 $$.header.thread_control |= BRW_THREAD_SWITCH;
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800470 set_instruction_dest(&$$, &ip_dst);
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800471 set_instruction_src0(&$$, &ip_src);
472 set_instruction_src1(&$$, &$3);
473 $$.first_reloc_target = $3.reloc_target;
474 $$.first_reloc_offset = $3.imm32;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400475 } else if(IS_GENp(6)) {
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800476 memset(&$$, 0, sizeof($$));
477 $$.header.opcode = $1;
478 $$.header.execution_size = $2;
479 $$.first_reloc_target = $3.reloc_target;
480 $$.first_reloc_offset = $3.imm32;
481 } else {
482 fprintf(stderr, "'ELSE' instruction is not implemented.\n");
483 YYERROR;
484 }
485 }
486 | predicate IF execsize relativelocation
487 {
Homer Hsing2ad18c12012-09-28 14:02:25 +0800488 /* for Gen4, Gen5 */
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800489 /* The branch instructions require that the IP register
490 * be the destination and first source operand, while the
491 * offset is the second source operand. The offset is added
492 * to the pre-incremented IP.
493 */
Homer Hsing2ad18c12012-09-28 14:02:25 +0800494 /* for Gen6 */
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400495 if(IS_GENp(7)) {
496 /* Error in Gen7+. */
Homer Hsing2ad18c12012-09-28 14:02:25 +0800497 fprintf(stderr, "Syntax error: IF should be 'IF execsize JIP UIP'\n");
498 YYERROR;
499 }
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800500 memset(&$$, 0, sizeof($$));
Homer Hsing2ad18c12012-09-28 14:02:25 +0800501 set_instruction_predicate(&$$, &$1);
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800502 $$.header.opcode = $2;
503 $$.header.execution_size = $3;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400504 if(!IS_GENp(6)) {
Homer Hsing2ad18c12012-09-28 14:02:25 +0800505 $$.header.thread_control |= BRW_THREAD_SWITCH;
506 set_instruction_dest(&$$, &ip_dst);
507 set_instruction_src0(&$$, &ip_src);
508 set_instruction_src1(&$$, &$4);
509 }
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800510 $$.first_reloc_target = $4.reloc_target;
511 $$.first_reloc_offset = $4.imm32;
512 }
513 | predicate IF execsize relativelocation relativelocation
514 {
515 /* for Gen7+ */
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400516 if(!IS_GENp(7)) {
Homer Hsing2ad18c12012-09-28 14:02:25 +0800517 fprintf(stderr, "Syntax error: IF should be 'IF execsize relativelocation'\n");
518 YYERROR;
519 }
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800520 memset(&$$, 0, sizeof($$));
521 set_instruction_predicate(&$$, &$1);
522 $$.header.opcode = $2;
523 $$.header.execution_size = $3;
524 $$.first_reloc_target = $4.reloc_target;
525 $$.first_reloc_offset = $4.imm32;
526 $$.second_reloc_target = $5.reloc_target;
527 $$.second_reloc_offset = $5.imm32;
528 }
529;
530
531loopinstruction: predicate WHILE execsize relativelocation instoptions
532 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400533 if(!IS_GENp(6)) {
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800534 /* The branch instructions require that the IP register
535 * be the destination and first source operand, while the
536 * offset is the second source operand. The offset is added
537 * to the pre-incremented IP.
538 */
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800539 set_instruction_dest(&$$, &ip_dst);
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800540 memset(&$$, 0, sizeof($$));
541 set_instruction_predicate(&$$, &$1);
542 $$.header.opcode = $2;
543 $$.header.execution_size = $3;
544 $$.header.thread_control |= BRW_THREAD_SWITCH;
545 set_instruction_src0(&$$, &ip_src);
546 set_instruction_src1(&$$, &$4);
547 $$.first_reloc_target = $4.reloc_target;
548 $$.first_reloc_offset = $4.imm32;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400549 } else if (IS_GENp(6)) {
Homer Hsinge8cb1952012-09-28 14:05:51 +0800550 /* Gen6 spec:
551 dest must have the same element size as src0.
552 dest horizontal stride must be 1. */
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800553 memset(&$$, 0, sizeof($$));
554 set_instruction_predicate(&$$, &$1);
555 $$.header.opcode = $2;
556 $$.header.execution_size = $3;
557 $$.first_reloc_target = $4.reloc_target;
558 $$.first_reloc_offset = $4.imm32;
Homer Hsing72a3c192012-09-27 13:51:33 +0800559 } else {
560 fprintf(stderr, "'WHILE' instruction is not implemented!\n");
561 YYERROR;
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800562 }
563 }
564 | DO
565 {
566 // deprecated
567 memset(&$$, 0, sizeof($$));
568 $$.header.opcode = $1;
569 };
570
571haltinstruction: predicate HALT execsize relativelocation relativelocation instoptions
572 {
Homer Hsingce555522012-09-27 15:44:15 +0800573 // for Gen6, Gen7
574 /* Gen6, Gen7 bspec: dst and src0 must be the null reg. */
Homer Hsing4bf84ec2012-09-24 10:12:26 +0800575 memset(&$$, 0, sizeof($$));
576 set_instruction_predicate(&$$, &$1);
577 $$.header.opcode = $2;
578 $$.header.execution_size = $3;
579 $$.first_reloc_target = $4.reloc_target;
580 $$.first_reloc_offset = $4.imm32;
581 $$.second_reloc_target = $5.reloc_target;
582 $$.second_reloc_offset = $5.imm32;
583 set_instruction_dest(&$$, &dst_null_reg);
584 set_instruction_src0(&$$, &src_null_reg);
585 };
586
Homer Hsing88dfdf32012-09-24 10:06:35 +0800587multibranchinstruction:
588 predicate BRD execsize relativelocation instoptions
589 {
590 /* Gen7 bspec: dest must be null. use Switch option */
591 memset(&$$, 0, sizeof($$));
592 set_instruction_predicate(&$$, &$1);
593 $$.header.opcode = $2;
594 $$.header.execution_size = $3;
595 $$.header.thread_control |= BRW_THREAD_SWITCH;
596 $$.first_reloc_target = $4.reloc_target;
597 $$.first_reloc_offset = $4.imm32;
598 set_instruction_dest(&$$, &dst_null_reg);
599 }
Homer Hsing88dfdf32012-09-24 10:06:35 +0800600 | predicate BRC execsize relativelocation relativelocation instoptions
601 {
602 /* Gen7 bspec: dest must be null. src0 must be null. use Switch option */
603 memset(&$$, 0, sizeof($$));
604 set_instruction_predicate(&$$, &$1);
605 $$.header.opcode = $2;
606 $$.header.execution_size = $3;
607 $$.header.thread_control |= BRW_THREAD_SWITCH;
608 $$.first_reloc_target = $4.reloc_target;
609 $$.first_reloc_offset = $4.imm32;
610 $$.second_reloc_target = $5.reloc_target;
611 $$.second_reloc_offset = $5.imm32;
612 set_instruction_dest(&$$, &dst_null_reg);
613 set_instruction_src0(&$$, &src_null_reg);
614 }
Homer Hsinga7b1c092012-09-21 12:33:13 +0800615;
616
617subroutineinstruction:
618 predicate CALL execsize dst relativelocation instoptions
619 {
Homer Hsing75296822012-09-27 15:31:56 +0800620 /*
621 Gen6 bspec:
622 source, dest type should be DWORD.
623 dest must be QWord aligned.
624 source0 region control must be <2,2,1>.
625 execution size must be 2.
626 QtrCtrl is prohibited.
627 JIP is an immediate operand, must be of type W.
628 Gen7 bspec:
629 source, dest type should be DWORD.
630 dest must be QWord aligned.
631 source0 region control must be <2,2,1>.
632 execution size must be 2.
633 */
Homer Hsinga7b1c092012-09-21 12:33:13 +0800634 memset(&$$, 0, sizeof($$));
635 set_instruction_predicate(&$$, &$1);
636 $$.header.opcode = $2;
Homer Hsing75296822012-09-27 15:31:56 +0800637 $$.header.execution_size = 1; /* execution size must be 2. Here 1 is encoded 2. */
638
639 $4.reg_type = BRW_REGISTER_TYPE_D; /* dest type should be DWORD */
Homer Hsinga7b1c092012-09-21 12:33:13 +0800640 set_instruction_dest(&$$, &$4);
Homer Hsing75296822012-09-27 15:31:56 +0800641
642 struct src_operand src0;
643 memset(&src0, 0, sizeof(src0));
644 src0.reg_type = BRW_REGISTER_TYPE_D; /* source type should be DWORD */
645 /* source0 region control must be <2,2,1>. */
646 src0.horiz_stride = 1; /*encoded 1*/
647 src0.width = 1; /*encoded 2*/
648 src0.vert_stride = 2; /*encoded 2*/
649 set_instruction_src0(&$$, &src0);
650
Homer Hsinga7b1c092012-09-21 12:33:13 +0800651 $$.first_reloc_target = $5.reloc_target;
652 $$.first_reloc_offset = $5.imm32;
653 }
654 | predicate RET execsize dstoperandex src instoptions
655 {
Homer Hsing3de439e2012-09-27 15:39:28 +0800656 /*
657 Gen6, 7:
658 source cannot be accumulator.
659 dest must be null.
660 src0 region control must be <2,2,1> (not specified clearly. should be same as CALL)
661 */
Homer Hsinga7b1c092012-09-21 12:33:13 +0800662 memset(&$$, 0, sizeof($$));
663 set_instruction_predicate(&$$, &$1);
664 $$.header.opcode = $2;
Homer Hsing3de439e2012-09-27 15:39:28 +0800665 $$.header.execution_size = 1; /* execution size of RET should be 2 */
Homer Hsingc91bd8c2012-09-27 16:20:39 +0800666 set_instruction_dest(&$$, &dst_null_reg);
Homer Hsing3de439e2012-09-27 15:39:28 +0800667 $5.reg_type = BRW_REGISTER_TYPE_D;
668 $5.horiz_stride = 1; /*encoded 1*/
669 $5.width = 1; /*encoded 2*/
670 $5.vert_stride = 2; /*encoded 2*/
Homer Hsinga7b1c092012-09-21 12:33:13 +0800671 set_instruction_src0(&$$, &$5);
672 }
Eric Anholt22a10632006-08-22 10:15:33 -0700673;
674
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700675unaryinstruction:
676 predicate unaryop conditionalmodifier saturate execsize
677 dst srcaccimm instoptions
Eric Anholt22a10632006-08-22 10:15:33 -0700678 {
Homer Hsing81859af2012-09-14 09:34:58 +0800679 memset(&$$, 0, sizeof($$));
Eric Anholt22a10632006-08-22 10:15:33 -0700680 $$.header.opcode = $2;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000681 $$.header.destreg__conditionalmod = $3.cond;
Eric Anholt90aea512006-08-22 14:46:39 -0700682 $$.header.saturate = $4;
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700683 $$.header.execution_size = $5;
Eric Anholt19f1c1c2006-08-22 12:41:09 -0700684 set_instruction_options(&$$, &$8);
Eric Anholt0ed5d932006-08-28 23:05:51 -0700685 set_instruction_predicate(&$$, &$1);
Eric Anholt2dac0a12006-08-29 15:29:31 -0700686 if (set_instruction_dest(&$$, &$6) != 0)
687 YYERROR;
Eric Anholt6a88ada2006-08-28 22:11:18 -0700688 if (set_instruction_src0(&$$, &$7) != 0)
689 YYERROR;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800690
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800691 if ($3.flag_subreg_nr != -1) {
Xiang, Haihao4d75db52012-07-17 16:16:11 +0800692 if ($$.header.predicate_control != BRW_PREDICATE_NONE &&
693 ($1.bits2.da1.flag_reg_nr != $3.flag_reg_nr ||
694 $1.bits2.da1.flag_subreg_nr != $3.flag_subreg_nr))
695 fprintf(stderr, "WARNING: must use the same flag register if both prediction and conditional modifier are enabled\n");
696
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800697 $$.bits2.da1.flag_reg_nr = $3.flag_reg_nr;
Xiang, Haihao2f772dd2012-07-17 14:18:54 +0800698 $$.bits2.da1.flag_subreg_nr = $3.flag_subreg_nr;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800699 }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800700
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400701 if (!IS_GENp(6) &&
Xiang, Haihao27b43032010-12-13 16:07:16 +0800702 get_type_size($$.bits1.da1.dest_reg_type) * (1 << $$.header.execution_size) == 64)
703 $$.header.compression_control = BRW_COMPRESSION_COMPRESSED;
Eric Anholt22a10632006-08-22 10:15:33 -0700704 }
705;
706
Homer Hsing4285d9c2012-09-14 08:41:16 +0800707unaryop: MOV | FRC | RNDU | RNDD | RNDE | RNDZ | NOT | LZD | BFREV | CBIT
Homer Hsing9e711a42012-09-14 08:56:36 +0800708 | F16TO32 | F32TO16 | FBH | FBL
Eric Anholt22a10632006-08-22 10:15:33 -0700709;
710
Homer Hsing74383f42012-09-18 13:25:53 +0800711// Source operands cannot be accumulators
Eric Anholt22a10632006-08-22 10:15:33 -0700712binaryinstruction:
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700713 predicate binaryop conditionalmodifier saturate execsize
714 dst src srcimm instoptions
Eric Anholt22a10632006-08-22 10:15:33 -0700715 {
Homer Hsing81859af2012-09-14 09:34:58 +0800716 memset(&$$, 0, sizeof($$));
Eric Anholt22a10632006-08-22 10:15:33 -0700717 $$.header.opcode = $2;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000718 $$.header.destreg__conditionalmod = $3.cond;
Eric Anholt90aea512006-08-22 14:46:39 -0700719 $$.header.saturate = $4;
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700720 $$.header.execution_size = $5;
Eric Anholt19f1c1c2006-08-22 12:41:09 -0700721 set_instruction_options(&$$, &$9);
Eric Anholt0ed5d932006-08-28 23:05:51 -0700722 set_instruction_predicate(&$$, &$1);
Eric Anholt2dac0a12006-08-29 15:29:31 -0700723 if (set_instruction_dest(&$$, &$6) != 0)
724 YYERROR;
Eric Anholt6a88ada2006-08-28 22:11:18 -0700725 if (set_instruction_src0(&$$, &$7) != 0)
726 YYERROR;
727 if (set_instruction_src1(&$$, &$8) != 0)
728 YYERROR;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800729
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800730 if ($3.flag_subreg_nr != -1) {
Xiang, Haihao4d75db52012-07-17 16:16:11 +0800731 if ($$.header.predicate_control != BRW_PREDICATE_NONE &&
732 ($1.bits2.da1.flag_reg_nr != $3.flag_reg_nr ||
733 $1.bits2.da1.flag_subreg_nr != $3.flag_subreg_nr))
734 fprintf(stderr, "WARNING: must use the same flag register if both prediction and conditional modifier are enabled\n");
735
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800736 $$.bits2.da1.flag_reg_nr = $3.flag_reg_nr;
Xiang, Haihao2f772dd2012-07-17 14:18:54 +0800737 $$.bits2.da1.flag_subreg_nr = $3.flag_subreg_nr;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800738 }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800739
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400740 if (!IS_GENp(6) &&
Xiang, Haihao27b43032010-12-13 16:07:16 +0800741 get_type_size($$.bits1.da1.dest_reg_type) * (1 << $$.header.execution_size) == 64)
742 $$.header.compression_control = BRW_COMPRESSION_COMPRESSED;
Eric Anholt22a10632006-08-22 10:15:33 -0700743 }
744;
745
Homer Hsingbebe8172012-09-18 13:47:22 +0800746/* bspec: BFI1 should not access accumulator. */
747binaryop: MUL | MAC | MACH | LINE | SAD2 | SADA2 | DP4 | DPH | DP3 | DP2 | PLN | BFI1
Eric Anholtedc82a02006-08-25 17:42:05 -0700748;
Eric Anholt22a10632006-08-22 10:15:33 -0700749
Homer Hsing74383f42012-09-18 13:25:53 +0800750// Source operands can be accumulators
Eric Anholt22a10632006-08-22 10:15:33 -0700751binaryaccinstruction:
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700752 predicate binaryaccop conditionalmodifier saturate execsize
753 dst srcacc srcimm instoptions
Eric Anholt22a10632006-08-22 10:15:33 -0700754 {
Homer Hsing81859af2012-09-14 09:34:58 +0800755 memset(&$$, 0, sizeof($$));
Eric Anholt22a10632006-08-22 10:15:33 -0700756 $$.header.opcode = $2;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000757 $$.header.destreg__conditionalmod = $3.cond;
Eric Anholt90aea512006-08-22 14:46:39 -0700758 $$.header.saturate = $4;
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700759 $$.header.execution_size = $5;
Eric Anholt19f1c1c2006-08-22 12:41:09 -0700760 set_instruction_options(&$$, &$9);
Eric Anholt0ed5d932006-08-28 23:05:51 -0700761 set_instruction_predicate(&$$, &$1);
Eric Anholt2dac0a12006-08-29 15:29:31 -0700762 if (set_instruction_dest(&$$, &$6) != 0)
763 YYERROR;
Eric Anholt6a88ada2006-08-28 22:11:18 -0700764 if (set_instruction_src0(&$$, &$7) != 0)
765 YYERROR;
766 if (set_instruction_src1(&$$, &$8) != 0)
767 YYERROR;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800768
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800769 if ($3.flag_subreg_nr != -1) {
Xiang, Haihao4d75db52012-07-17 16:16:11 +0800770 if ($$.header.predicate_control != BRW_PREDICATE_NONE &&
771 ($1.bits2.da1.flag_reg_nr != $3.flag_reg_nr ||
772 $1.bits2.da1.flag_subreg_nr != $3.flag_subreg_nr))
773 fprintf(stderr, "WARNING: must use the same flag register if both prediction and conditional modifier are enabled\n");
774
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800775 $$.bits2.da1.flag_reg_nr = $3.flag_reg_nr;
Xiang, Haihao2f772dd2012-07-17 14:18:54 +0800776 $$.bits2.da1.flag_subreg_nr = $3.flag_subreg_nr;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +0800777 }
Xiang, Haihao27b43032010-12-13 16:07:16 +0800778
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400779 if (!IS_GENp(6) &&
Xiang, Haihao27b43032010-12-13 16:07:16 +0800780 get_type_size($$.bits1.da1.dest_reg_type) * (1 << $$.header.execution_size) == 64)
781 $$.header.compression_control = BRW_COMPRESSION_COMPRESSED;
Eric Anholt22a10632006-08-22 10:15:33 -0700782 }
783;
784
Homer Hsingbebe8172012-09-18 13:47:22 +0800785/* TODO: bspec says ADDC/SUBB/CMP/CMPN/SHL/BFI1 cannot use accumulator as dest. */
786binaryaccop: AVG | ADD | SEL | AND | OR | XOR | SHR | SHL | ASR | CMP | CMPN | ADDC | SUBB
Eric Anholt22a10632006-08-22 10:15:33 -0700787;
788
Homer Hsing8ca55682012-09-13 11:05:50 +0800789trinaryop: MAD | LRP | BFE | BFI2
Homer Hsinga034bcb2012-09-07 14:38:13 +0800790;
791
792trinaryinstruction:
793 predicate trinaryop conditionalmodifier saturate execsize
794 dst src src src instoptions
795{
796 memset(&$$, 0, sizeof($$));
797
798 $$.header.predicate_control = $1.header.predicate_control;
799 $$.header.predicate_inverse = $1.header.predicate_inverse;
Damien Lespiau31259c52013-01-15 14:05:23 +0000800 $$.bits1.da3src.flag_reg_nr = $1.bits2.da1.flag_reg_nr;
801 $$.bits1.da3src.flag_subreg_nr = $1.bits2.da1.flag_subreg_nr;
Homer Hsinga034bcb2012-09-07 14:38:13 +0800802
803 $$.header.opcode = $2;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000804 $$.header.destreg__conditionalmod = $3.cond;
Homer Hsinga034bcb2012-09-07 14:38:13 +0800805 $$.header.saturate = $4;
806 $$.header.execution_size = $5;
807
808 if (set_instruction_dest_three_src(&$$, &$6))
809 YYERROR;
810 if (set_instruction_src0_three_src(&$$, &$7))
811 YYERROR;
812 if (set_instruction_src1_three_src(&$$, &$8))
813 YYERROR;
814 if (set_instruction_src2_three_src(&$$, &$9))
815 YYERROR;
816 set_instruction_options(&$$, &$10);
817
818 if ($3.flag_subreg_nr != -1) {
819 if ($$.header.predicate_control != BRW_PREDICATE_NONE &&
820 ($1.bits2.da1.flag_reg_nr != $3.flag_reg_nr ||
821 $1.bits2.da1.flag_subreg_nr != $3.flag_subreg_nr))
822 fprintf(stderr, "WARNING: must use the same flag register if both prediction and conditional modifier are enabled\n");
823 }
824}
Eric Anholtedc82a02006-08-25 17:42:05 -0700825;
Eric Anholt22a10632006-08-22 10:15:33 -0700826
Zou Nan hai5608d272009-10-20 14:51:04 +0800827sendinstruction: predicate SEND execsize exp post_dst payload msgtarget
828 MSGLEN exp RETURNLEN exp instoptions
Eric Anholt22a10632006-08-22 10:15:33 -0700829 {
Eric Anholt56c4ccf2006-08-24 14:35:10 -0700830 /* Send instructions are messy. The first argument is the
831 * post destination -- the grf register that the response
832 * starts from. The second argument is the current
833 * destination, which is the start of the message arguments
834 * to the shared function, and where src0 payload is loaded
835 * to if not null. The payload is typically based on the
836 * grf 0 thread payload of your current thread, and is
837 * implicitly loaded if non-null.
838 */
Homer Hsing81859af2012-09-14 09:34:58 +0800839 memset(&$$, 0, sizeof($$));
Eric Anholtf914c6a2006-08-25 11:05:10 -0700840 $$.header.opcode = $2;
Eric Anholt56c4ccf2006-08-24 14:35:10 -0700841 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000842 $$.header.destreg__conditionalmod = $4; /* msg reg index */
Eric Anholt0ed5d932006-08-28 23:05:51 -0700843 set_instruction_predicate(&$$, &$1);
Eric Anholt2dac0a12006-08-29 15:29:31 -0700844 if (set_instruction_dest(&$$, &$5) != 0)
845 YYERROR;
Xiang, Haihaodcdde532010-10-21 14:33:35 +0800846
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400847 if (IS_GENp(6)) {
Xiang, Haihaodcdde532010-10-21 14:33:35 +0800848 struct src_operand src0;
849
850 memset(&src0, 0, sizeof(src0));
851 src0.address_mode = BRW_ADDRESS_DIRECT;
Xiang, Haihao46ffdd52011-05-25 14:29:14 +0800852
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400853 if (IS_GENp(7))
Xiang, Haihao46ffdd52011-05-25 14:29:14 +0800854 src0.reg_file = BRW_GENERAL_REGISTER_FILE;
855 else
856 src0.reg_file = BRW_MESSAGE_REGISTER_FILE;
857
Xiang, Haihaodcdde532010-10-21 14:33:35 +0800858 src0.reg_type = BRW_REGISTER_TYPE_D;
859 src0.reg_nr = $4;
860 src0.subreg_nr = 0;
861 set_instruction_src0(&$$, &src0);
862 } else {
863 if (set_instruction_src0(&$$, &$6) != 0)
864 YYERROR;
865 }
866
Eric Anholt56c4ccf2006-08-24 14:35:10 -0700867 $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE;
868 $$.bits1.da1.src1_reg_type = BRW_REGISTER_TYPE_D;
Xiang Haihao549b7512009-06-30 10:02:33 +0800869
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400870 if (IS_GENp(5)) {
871 if (IS_GENp(6)) {
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000872 $$.header.destreg__conditionalmod = $7.bits2.send_gen5.sfid;
Xiang, Haihao4f777e72010-10-08 15:07:51 +0800873 } else {
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000874 $$.header.destreg__conditionalmod = $4; /* msg reg index */
Xiang, Haihao4f777e72010-10-08 15:07:51 +0800875 $$.bits2.send_gen5.sfid = $7.bits2.send_gen5.sfid;
876 $$.bits2.send_gen5.end_of_thread = $12.bits3.generic_gen5.end_of_thread;
877 }
878
Xiang Haihao549b7512009-06-30 10:02:33 +0800879 $$.bits3.generic_gen5 = $7.bits3.generic_gen5;
880 $$.bits3.generic_gen5.msg_length = $9;
881 $$.bits3.generic_gen5.response_length = $11;
882 $$.bits3.generic_gen5.end_of_thread =
883 $12.bits3.generic_gen5.end_of_thread;
884 } else {
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000885 $$.header.destreg__conditionalmod = $4; /* msg reg index */
Xiang Haihao549b7512009-06-30 10:02:33 +0800886 $$.bits3.generic = $7.bits3.generic;
887 $$.bits3.generic.msg_length = $9;
888 $$.bits3.generic.response_length = $11;
889 $$.bits3.generic.end_of_thread =
890 $12.bits3.generic.end_of_thread;
891 }
Eric Anholt6c98c8d2006-08-22 11:54:19 -0700892 }
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800893 | predicate SEND execsize dst sendleadreg payload directsrcoperand instoptions
Feng, Boqun37d68102011-04-19 08:43:22 +0800894 {
Homer Hsing81859af2012-09-14 09:34:58 +0800895 memset(&$$, 0, sizeof($$));
Feng, Boqun37d68102011-04-19 08:43:22 +0800896 $$.header.opcode = $2;
897 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000898 $$.header.destreg__conditionalmod = $5.reg_nr; /* msg reg index */
Feng, Boqun37d68102011-04-19 08:43:22 +0800899
900 set_instruction_predicate(&$$, &$1);
901
902 if (set_instruction_dest(&$$, &$4) != 0)
903 YYERROR;
904 if (set_instruction_src0(&$$, &$6) != 0)
905 YYERROR;
906 /* XXX is this correct? */
907 if (set_instruction_src1(&$$, &$7) != 0)
908 YYERROR;
909 }
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800910 | predicate SEND execsize dst sendleadreg payload imm32reg instoptions
Feng, Boqun37d68102011-04-19 08:43:22 +0800911 {
912 if ($7.reg_type != BRW_REGISTER_TYPE_UD &&
913 $7.reg_type != BRW_REGISTER_TYPE_D &&
914 $7.reg_type != BRW_REGISTER_TYPE_V) {
915 fprintf (stderr, "%d: non-int D/UD/V representation: %d,type=%d\n", yylineno, $7.imm32, $7.reg_type);
916 YYERROR;
917 }
Homer Hsing81859af2012-09-14 09:34:58 +0800918 memset(&$$, 0, sizeof($$));
Feng, Boqun37d68102011-04-19 08:43:22 +0800919 $$.header.opcode = $2;
920 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000921 $$.header.destreg__conditionalmod = $5.reg_nr; /* msg reg index */
Feng, Boqun37d68102011-04-19 08:43:22 +0800922
923 set_instruction_predicate(&$$, &$1);
924 if (set_instruction_dest(&$$, &$4) != 0)
925 YYERROR;
926 if (set_instruction_src0(&$$, &$6) != 0)
927 YYERROR;
928 $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE;
929 $$.bits1.da1.src1_reg_type = $7.reg_type;
930 $$.bits3.ud = $7.imm32;
931 }
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800932 | predicate SEND execsize dst sendleadreg sndopr imm32reg instoptions
Xiang, Haihao85da7b92011-02-17 13:24:11 +0800933 {
934 struct src_operand src0;
Xiang, Haihao27b43032010-12-13 16:07:16 +0800935
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400936 if (!IS_GENp(6)) {
Xiang, Haihao85da7b92011-02-17 13:24:11 +0800937 fprintf(stderr, "error: the syntax of send instruction\n");
938 YYERROR;
939 }
940
941 if ($7.reg_type != BRW_REGISTER_TYPE_UD &&
942 $7.reg_type != BRW_REGISTER_TYPE_D &&
943 $7.reg_type != BRW_REGISTER_TYPE_V) {
944 fprintf (stderr, "%d: non-int D/UD/V representation: %d,type=%d\n", yylineno, $7.imm32, $7.reg_type);
945 YYERROR;
946 }
947
Homer Hsing81859af2012-09-14 09:34:58 +0800948 memset(&$$, 0, sizeof($$));
Xiang, Haihao85da7b92011-02-17 13:24:11 +0800949 $$.header.opcode = $2;
950 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000951 $$.header.destreg__conditionalmod = ($6 & EX_DESC_SFID_MASK); /* SFID */
Xiang, Haihao85da7b92011-02-17 13:24:11 +0800952 set_instruction_predicate(&$$, &$1);
953
954 if (set_instruction_dest(&$$, &$4) != 0)
955 YYERROR;
956
957 memset(&src0, 0, sizeof(src0));
958 src0.address_mode = BRW_ADDRESS_DIRECT;
Xiang, Haihao46ffdd52011-05-25 14:29:14 +0800959
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400960 if (IS_GENp(7)) {
Xiang, Haihao46ffdd52011-05-25 14:29:14 +0800961 src0.reg_file = BRW_GENERAL_REGISTER_FILE;
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800962 src0.reg_type = BRW_REGISTER_TYPE_UB;
963 } else {
Xiang, Haihao46ffdd52011-05-25 14:29:14 +0800964 src0.reg_file = BRW_MESSAGE_REGISTER_FILE;
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800965 src0.reg_type = BRW_REGISTER_TYPE_D;
966 }
Xiang, Haihao46ffdd52011-05-25 14:29:14 +0800967
Xiang, Haihao85da7b92011-02-17 13:24:11 +0800968 src0.reg_nr = $5.reg_nr;
969 src0.subreg_nr = 0;
970 set_instruction_src0(&$$, &src0);
971
972 $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE;
973 $$.bits1.da1.src1_reg_type = $7.reg_type;
974 $$.bits3.ud = $7.imm32;
975 $$.bits3.generic_gen5.end_of_thread = !!($6 & EX_DESC_EOT_MASK);
976 }
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800977 | predicate SEND execsize dst sendleadreg sndopr directsrcoperand instoptions
978 {
979 struct src_operand src0;
980
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -0400981 if (!IS_GENp(6)) {
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800982 fprintf(stderr, "error: the syntax of send instruction\n");
983 YYERROR;
984 }
985
986 if ($7.reg_file != BRW_ARCHITECTURE_REGISTER_FILE ||
987 ($7.reg_nr & 0xF0) != BRW_ARF_ADDRESS ||
988 ($7.reg_nr & 0x0F) != 0 ||
989 $7.subreg_nr != 0) {
990 fprintf (stderr, "%d: scalar register must be a0.0<0;1,0>:ud\n", yylineno);
991 YYERROR;
992 }
993
Homer Hsing81859af2012-09-14 09:34:58 +0800994 memset(&$$, 0, sizeof($$));
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800995 $$.header.opcode = $2;
996 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +0000997 $$.header.destreg__conditionalmod = ($6 & EX_DESC_SFID_MASK); /* SFID */
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +0800998 set_instruction_predicate(&$$, &$1);
999
1000 if (set_instruction_dest(&$$, &$4) != 0)
1001 YYERROR;
1002
1003 memset(&src0, 0, sizeof(src0));
1004 src0.address_mode = BRW_ADDRESS_DIRECT;
1005
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001006 if (IS_GENp(7)) {
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +08001007 src0.reg_file = BRW_GENERAL_REGISTER_FILE;
1008 src0.reg_type = BRW_REGISTER_TYPE_UB;
1009 } else {
1010 src0.reg_file = BRW_MESSAGE_REGISTER_FILE;
1011 src0.reg_type = BRW_REGISTER_TYPE_D;
1012 }
1013
1014 src0.reg_nr = $5.reg_nr;
1015 src0.subreg_nr = 0;
1016 set_instruction_src0(&$$, &src0);
1017
1018 set_instruction_src1(&$$, &$7);
1019 $$.bits3.generic_gen5.end_of_thread = !!($6 & EX_DESC_EOT_MASK);
1020 }
1021 | predicate SEND execsize dst sendleadreg payload sndopr imm32reg instoptions
Xiang, Haihao27b43032010-12-13 16:07:16 +08001022 {
1023 if ($8.reg_type != BRW_REGISTER_TYPE_UD &&
1024 $8.reg_type != BRW_REGISTER_TYPE_D &&
1025 $8.reg_type != BRW_REGISTER_TYPE_V) {
1026 fprintf (stderr, "%d: non-int D/UD/V representation: %d,type=%d\n", yylineno, $8.imm32, $8.reg_type);
1027 YYERROR;
1028 }
Homer Hsing81859af2012-09-14 09:34:58 +08001029 memset(&$$, 0, sizeof($$));
Xiang, Haihao27b43032010-12-13 16:07:16 +08001030 $$.header.opcode = $2;
1031 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +00001032 $$.header.destreg__conditionalmod = $5.reg_nr; /* msg reg index */
Xiang, Haihao27b43032010-12-13 16:07:16 +08001033
1034 set_instruction_predicate(&$$, &$1);
1035 if (set_instruction_dest(&$$, &$4) != 0)
1036 YYERROR;
1037 if (set_instruction_src0(&$$, &$6) != 0)
1038 YYERROR;
1039 $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE;
1040 $$.bits1.da1.src1_reg_type = $8.reg_type;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001041 if (IS_GENx(5)) {
Xiang, Haihao27b43032010-12-13 16:07:16 +08001042 $$.bits2.send_gen5.sfid = ($7 & EX_DESC_SFID_MASK);
1043 $$.bits3.ud = $8.imm32;
1044 $$.bits3.generic_gen5.end_of_thread = !!($7 & EX_DESC_EOT_MASK);
1045 }
1046 else
1047 $$.bits3.ud = $8.imm32;
1048 }
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +08001049 | predicate SEND execsize dst sendleadreg payload exp directsrcoperand instoptions
Xiang, Haihao27b43032010-12-13 16:07:16 +08001050 {
Homer Hsing81859af2012-09-14 09:34:58 +08001051 memset(&$$, 0, sizeof($$));
Xiang, Haihao27b43032010-12-13 16:07:16 +08001052 $$.header.opcode = $2;
1053 $$.header.execution_size = $3;
Damien Lespiaue71f1d22013-01-14 19:13:19 +00001054 $$.header.destreg__conditionalmod = $5.reg_nr; /* msg reg index */
Xiang, Haihao27b43032010-12-13 16:07:16 +08001055
1056 set_instruction_predicate(&$$, &$1);
1057
1058 if (set_instruction_dest(&$$, &$4) != 0)
1059 YYERROR;
1060 if (set_instruction_src0(&$$, &$6) != 0)
1061 YYERROR;
1062 /* XXX is this correct? */
1063 if (set_instruction_src1(&$$, &$8) != 0)
1064 YYERROR;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001065 if (IS_GENx(5)) {
Xiang, Haihao27b43032010-12-13 16:07:16 +08001066 $$.bits2.send_gen5.sfid = $7;
1067 }
1068 }
1069
Eric Anholtedc82a02006-08-25 17:42:05 -07001070;
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001071
Xiang, Haihao27b43032010-12-13 16:07:16 +08001072sndopr: exp %prec SNDOPR
1073 {
1074 $$ = $1;
1075 }
1076;
1077
1078jumpinstruction: predicate JMPI execsize relativelocation2
Eric Anholt1e907c72006-08-31 10:21:15 -07001079 {
Eric Anholt1e907c72006-08-31 10:21:15 -07001080 /* The jump instruction requires that the IP register
1081 * be the destination and first source operand, while the
1082 * offset is the second source operand. The next instruction
1083 * is the post-incremented IP plus the offset.
1084 */
Homer Hsing81859af2012-09-14 09:34:58 +08001085 memset(&$$, 0, sizeof($$));
Zou Nanhaibe9bcee2008-12-09 18:38:54 -08001086 $$.header.opcode = $2;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001087 $$.header.execution_size = ffs(1) - 1;
1088 if(advanced_flag)
1089 $$.header.mask_control = BRW_MASK_DISABLE;
Zou Nanhaibe9bcee2008-12-09 18:38:54 -08001090 set_instruction_predicate(&$$, &$1);
Eric Anholt1e907c72006-08-31 10:21:15 -07001091 set_instruction_dest(&$$, &ip_dst);
Eric Anholt1e907c72006-08-31 10:21:15 -07001092 set_instruction_src0(&$$, &ip_src);
Xiang, Haihao27b43032010-12-13 16:07:16 +08001093 set_instruction_src1(&$$, &$4);
Homer Hsingb0b540f2012-09-21 10:06:20 +08001094 $$.first_reloc_target = $4.reloc_target;
Homer Hsing4bf84ec2012-09-24 10:12:26 +08001095 $$.first_reloc_offset = $4.imm32;
Eric Anholt356ce762006-08-31 10:27:48 -07001096 }
1097;
1098
Xiang, Haihao54055322010-10-27 09:42:56 +08001099mathinstruction: predicate MATH_INST execsize dst src srcimm math_function instoptions
1100 {
Homer Hsing81859af2012-09-14 09:34:58 +08001101 memset(&$$, 0, sizeof($$));
Xiang, Haihao54055322010-10-27 09:42:56 +08001102 $$.header.opcode = $2;
Damien Lespiaue71f1d22013-01-14 19:13:19 +00001103 $$.header.destreg__conditionalmod = $7;
Xiang, Haihao54055322010-10-27 09:42:56 +08001104 $$.header.execution_size = $3;
1105 set_instruction_options(&$$, &$8);
1106 set_instruction_predicate(&$$, &$1);
1107 if (set_instruction_dest(&$$, &$4) != 0)
1108 YYERROR;
1109 if (set_instruction_src0(&$$, &$5) != 0)
1110 YYERROR;
1111 if (set_instruction_src1(&$$, &$6) != 0)
1112 YYERROR;
1113 }
1114;
1115
Homer Hsing4bf84ec2012-09-24 10:12:26 +08001116breakinstruction: predicate breakop execsize relativelocation relativelocation instoptions
Eric Anholt4ee9c3d2006-09-01 13:37:51 -07001117 {
Homer Hsingce555522012-09-27 15:44:15 +08001118 // for Gen6, Gen7
Homer Hsing81859af2012-09-14 09:34:58 +08001119 memset(&$$, 0, sizeof($$));
Homer Hsing4bf84ec2012-09-24 10:12:26 +08001120 set_instruction_predicate(&$$, &$1);
1121 $$.header.opcode = $2;
1122 $$.header.execution_size = $3;
1123 $$.first_reloc_target = $4.reloc_target;
1124 $$.first_reloc_offset = $4.imm32;
1125 $$.second_reloc_target = $5.reloc_target;
1126 $$.second_reloc_offset = $5.imm32;
Eric Anholt4ee9c3d2006-09-01 13:37:51 -07001127 }
1128;
1129
Homer Hsing4bf84ec2012-09-24 10:12:26 +08001130breakop: BREAK | CONT
Eric Anholtedc82a02006-08-25 17:42:05 -07001131;
Eric Anholtf914c6a2006-08-25 11:05:10 -07001132
Keith Packard2d4d4012008-03-30 00:58:28 -07001133/*
Eric Anholtf914c6a2006-08-25 11:05:10 -07001134maskpushop: MSAVE | PUSH
1135;
Keith Packard2d4d4012008-03-30 00:58:28 -07001136 */
Eric Anholtf914c6a2006-08-25 11:05:10 -07001137
Eric Anholt1f58efa2006-09-01 11:56:12 -07001138syncinstruction: predicate WAIT notifyreg
1139 {
Xiang, Haihao27b43032010-12-13 16:07:16 +08001140 struct dst_operand notify_dst;
Keith Packard2d4d4012008-03-30 00:58:28 -07001141 struct src_operand notify_src;
Eric Anholt1f58efa2006-09-01 11:56:12 -07001142
Homer Hsing81859af2012-09-14 09:34:58 +08001143 memset(&$$, 0, sizeof($$));
Eric Anholt1f58efa2006-09-01 11:56:12 -07001144 $$.header.opcode = $2;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001145 $$.header.execution_size = ffs(1) - 1;
1146 set_direct_dst_operand(&notify_dst, &$3, BRW_REGISTER_TYPE_D);
1147 set_instruction_dest(&$$, &notify_dst);
Xiang, Haihao852216d2011-02-16 15:26:24 +08001148 set_direct_src_operand(&notify_src, &$3, BRW_REGISTER_TYPE_D);
Keith Packard2d4d4012008-03-30 00:58:28 -07001149 set_instruction_src0(&$$, &notify_src);
Homer Hsingb899aba2012-09-27 14:56:30 +08001150 set_instruction_src1(&$$, &src_null_reg);
Eric Anholt1f58efa2006-09-01 11:56:12 -07001151 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08001152
Eric Anholt1f58efa2006-09-01 11:56:12 -07001153;
1154
Homer Hsing4bf84ec2012-09-24 10:12:26 +08001155nopinstruction: NOP
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001156 {
Homer Hsing81859af2012-09-14 09:34:58 +08001157 memset(&$$, 0, sizeof($$));
Eric Anholtf914c6a2006-08-25 11:05:10 -07001158 $$.header.opcode = $1;
Homer Hsing4bf84ec2012-09-24 10:12:26 +08001159 };
Eric Anholt22a10632006-08-22 10:15:33 -07001160
1161/* XXX! */
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001162payload: directsrcoperand
Eric Anholt22a10632006-08-22 10:15:33 -07001163;
1164
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001165post_dst: dst
Eric Anholt22a10632006-08-22 10:15:33 -07001166;
1167
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001168msgtarget: NULL_TOKEN
1169 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001170 if (IS_GENp(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001171 $$.bits2.send_gen5.sfid= BRW_MESSAGE_TARGET_NULL;
1172 $$.bits3.generic_gen5.header_present = 0; /* ??? */
1173 } else {
1174 $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_NULL;
1175 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001176 }
1177 | SAMPLER LPAREN INTEGER COMMA INTEGER COMMA
1178 sampler_datatype RPAREN
1179 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001180 if (IS_GENp(7)) {
Xiang, Haihao67d4ed62011-05-23 13:45:04 +08001181 $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_SAMPLER;
1182 $$.bits3.generic_gen5.header_present = 1; /* ??? */
1183 $$.bits3.sampler_gen7.binding_table_index = $3;
1184 $$.bits3.sampler_gen7.sampler = $5;
1185 $$.bits3.sampler_gen7.simd_mode = 2; /* SIMD16, maybe we should add a new parameter */
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001186 } else if (IS_GENp(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001187 $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_SAMPLER;
1188 $$.bits3.generic_gen5.header_present = 1; /* ??? */
1189 $$.bits3.sampler_gen5.binding_table_index = $3;
1190 $$.bits3.sampler_gen5.sampler = $5;
1191 $$.bits3.sampler_gen5.simd_mode = 2; /* SIMD16, maybe we should add a new parameter */
1192 } else {
1193 $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_SAMPLER;
1194 $$.bits3.sampler.binding_table_index = $3;
1195 $$.bits3.sampler.sampler = $5;
1196 switch ($7) {
1197 case TYPE_F:
1198 $$.bits3.sampler.return_format =
1199 BRW_SAMPLER_RETURN_FORMAT_FLOAT32;
1200 break;
1201 case TYPE_UD:
1202 $$.bits3.sampler.return_format =
1203 BRW_SAMPLER_RETURN_FORMAT_UINT32;
1204 break;
1205 case TYPE_D:
1206 $$.bits3.sampler.return_format =
1207 BRW_SAMPLER_RETURN_FORMAT_SINT32;
1208 break;
1209 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001210 }
1211 }
Eric Anholt3d360792006-08-25 09:36:28 -07001212 | MATH math_function saturate math_signed math_scalar
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001213 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001214 if (IS_GENp(6)) {
Homer Hsing5d727892012-10-23 09:21:15 +08001215 fprintf (stderr, "Gen6+ doesn't have math function\n");
Xiang, Haihao718cd6c2010-10-09 12:52:08 +08001216 YYERROR;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001217 } else if (IS_GENx(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001218 $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_MATH;
1219 $$.bits3.generic_gen5.header_present = 0;
1220 $$.bits3.math_gen5.function = $2;
1221 if ($3 == BRW_INSTRUCTION_SATURATE)
1222 $$.bits3.math_gen5.saturate = 1;
1223 else
1224 $$.bits3.math_gen5.saturate = 0;
1225 $$.bits3.math_gen5.int_type = $4;
1226 $$.bits3.math_gen5.precision = BRW_MATH_PRECISION_FULL;
1227 $$.bits3.math_gen5.data_type = $5;
1228 } else {
1229 $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_MATH;
1230 $$.bits3.math.function = $2;
1231 if ($3 == BRW_INSTRUCTION_SATURATE)
1232 $$.bits3.math.saturate = 1;
1233 else
1234 $$.bits3.math.saturate = 0;
1235 $$.bits3.math.int_type = $4;
1236 $$.bits3.math.precision = BRW_MATH_PRECISION_FULL;
1237 $$.bits3.math.data_type = $5;
1238 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001239 }
1240 | GATEWAY
1241 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001242 if (IS_GENp(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001243 $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_GATEWAY;
1244 $$.bits3.generic_gen5.header_present = 0; /* ??? */
1245 } else {
1246 $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_GATEWAY;
1247 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001248 }
Zou Nan hai807f8762008-06-18 15:05:19 -07001249 | READ LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA
1250 INTEGER RPAREN
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001251 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001252 if (IS_GENx(7)) {
Xiang, Haihaoc8d6bf32011-05-23 13:32:32 +08001253 $$.bits2.send_gen5.sfid =
Xiang, Haihaoe97f0bc2011-05-30 16:30:48 +08001254 BRW_MESSAGE_TARGET_DP_SC;
Xiang, Haihaoc8d6bf32011-05-23 13:32:32 +08001255 $$.bits3.generic_gen5.header_present = 1;
1256 $$.bits3.dp_gen7.binding_table_index = $3;
1257 $$.bits3.dp_gen7.msg_control = $7;
1258 $$.bits3.dp_gen7.msg_type = $9;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001259 } else if (IS_GENx(6)) {
Xiang, Haihaoa8458d52010-10-09 11:09:47 +08001260 $$.bits2.send_gen5.sfid =
Xiang, Haihaoe97f0bc2011-05-30 16:30:48 +08001261 BRW_MESSAGE_TARGET_DP_SC;
Xiang, Haihaoa8458d52010-10-09 11:09:47 +08001262 $$.bits3.generic_gen5.header_present = 1;
Damien Lespiau668e0df2013-01-15 16:40:06 +00001263 $$.bits3.gen6_dp_sampler_const_cache.binding_table_index = $3;
1264 $$.bits3.gen6_dp_sampler_const_cache.msg_control = $7;
1265 $$.bits3.gen6_dp_sampler_const_cache.msg_type = $9;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001266 } else if (IS_GENx(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001267 $$.bits2.send_gen5.sfid =
1268 BRW_MESSAGE_TARGET_DATAPORT_READ;
1269 $$.bits3.generic_gen5.header_present = 1;
1270 $$.bits3.dp_read_gen5.binding_table_index = $3;
1271 $$.bits3.dp_read_gen5.target_cache = $5;
1272 $$.bits3.dp_read_gen5.msg_control = $7;
1273 $$.bits3.dp_read_gen5.msg_type = $9;
1274 } else {
1275 $$.bits3.generic.msg_target =
1276 BRW_MESSAGE_TARGET_DATAPORT_READ;
1277 $$.bits3.dp_read.binding_table_index = $3;
1278 $$.bits3.dp_read.target_cache = $5;
1279 $$.bits3.dp_read.msg_control = $7;
1280 $$.bits3.dp_read.msg_type = $9;
1281 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001282 }
Eric Anholt43313942006-08-24 15:26:10 -07001283 | WRITE LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA
1284 INTEGER RPAREN
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001285 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001286 if (IS_GENx(7)) {
Xiang, Haihaoc8d6bf32011-05-23 13:32:32 +08001287 $$.bits2.send_gen5.sfid =
Xiang, Haihaoe97f0bc2011-05-30 16:30:48 +08001288 BRW_MESSAGE_TARGET_DP_RC;
Xiang, Haihaoc8d6bf32011-05-23 13:32:32 +08001289 $$.bits3.generic_gen5.header_present = 1;
1290 $$.bits3.dp_gen7.binding_table_index = $3;
1291 $$.bits3.dp_gen7.msg_control = $5;
1292 $$.bits3.dp_gen7.msg_type = $7;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001293 } else if (IS_GENx(6)) {
Xiang, Haihao61784db2010-10-08 16:48:15 +08001294 $$.bits2.send_gen5.sfid =
Xiang, Haihaoe97f0bc2011-05-30 16:30:48 +08001295 BRW_MESSAGE_TARGET_DP_RC;
Xiang, Haihao61784db2010-10-08 16:48:15 +08001296 /* Sandybridge supports headerlesss message for render target write.
1297 * Currently the GFX assembler doesn't support it. so the program must provide
1298 * message header
1299 */
1300 $$.bits3.generic_gen5.header_present = 1;
1301 $$.bits3.dp_write_gen6.binding_table_index = $3;
1302 $$.bits3.dp_write_gen6.msg_control = $5;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001303 $$.bits3.dp_write_gen6.msg_type = $7;
Xiang, Haihao61784db2010-10-08 16:48:15 +08001304 $$.bits3.dp_write_gen6.send_commit_msg = $9;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001305 } else if (IS_GENx(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001306 $$.bits2.send_gen5.sfid =
1307 BRW_MESSAGE_TARGET_DATAPORT_WRITE;
1308 $$.bits3.generic_gen5.header_present = 1;
1309 $$.bits3.dp_write_gen5.binding_table_index = $3;
1310 $$.bits3.dp_write_gen5.pixel_scoreboard_clear = ($5 & 0x8) >> 3;
1311 $$.bits3.dp_write_gen5.msg_control = $5 & 0x7;
1312 $$.bits3.dp_write_gen5.msg_type = $7;
1313 $$.bits3.dp_write_gen5.send_commit_msg = $9;
1314 } else {
1315 $$.bits3.generic.msg_target =
1316 BRW_MESSAGE_TARGET_DATAPORT_WRITE;
1317 $$.bits3.dp_write.binding_table_index = $3;
1318 /* The msg control field of brw_struct.h is split into
1319 * msg control and pixel_scoreboard_clear, even though
1320 * pixel_scoreboard_clear isn't common to all write messages.
1321 */
1322 $$.bits3.dp_write.pixel_scoreboard_clear = ($5 & 0x8) >> 3;
1323 $$.bits3.dp_write.msg_control = $5 & 0x7;
1324 $$.bits3.dp_write.msg_type = $7;
1325 $$.bits3.dp_write.send_commit_msg = $9;
1326 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001327 }
Xiang, Haihao14c0bd02010-11-01 16:16:25 +08001328 | WRITE LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA
1329 INTEGER COMMA INTEGER RPAREN
1330 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001331 if (IS_GENx(7)) {
Xiang, Haihaoc8d6bf32011-05-23 13:32:32 +08001332 $$.bits2.send_gen5.sfid =
Xiang, Haihaoe97f0bc2011-05-30 16:30:48 +08001333 BRW_MESSAGE_TARGET_DP_RC;
Xiang, Haihaoc8d6bf32011-05-23 13:32:32 +08001334 $$.bits3.generic_gen5.header_present = ($11 != 0);
1335 $$.bits3.dp_gen7.binding_table_index = $3;
1336 $$.bits3.dp_gen7.msg_control = $5;
1337 $$.bits3.dp_gen7.msg_type = $7;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001338 } else if (IS_GENx(6)) {
Xiang, Haihao14c0bd02010-11-01 16:16:25 +08001339 $$.bits2.send_gen5.sfid =
Xiang, Haihaoe97f0bc2011-05-30 16:30:48 +08001340 BRW_MESSAGE_TARGET_DP_RC;
Xiang, Haihao14c0bd02010-11-01 16:16:25 +08001341 $$.bits3.generic_gen5.header_present = ($11 != 0);
1342 $$.bits3.dp_write_gen6.binding_table_index = $3;
1343 $$.bits3.dp_write_gen6.msg_control = $5;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001344 $$.bits3.dp_write_gen6.msg_type = $7;
Xiang, Haihao14c0bd02010-11-01 16:16:25 +08001345 $$.bits3.dp_write_gen6.send_commit_msg = $9;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001346 } else if (IS_GENx(5)) {
Xiang, Haihao14c0bd02010-11-01 16:16:25 +08001347 $$.bits2.send_gen5.sfid =
1348 BRW_MESSAGE_TARGET_DATAPORT_WRITE;
1349 $$.bits3.generic_gen5.header_present = ($11 != 0);
1350 $$.bits3.dp_write_gen5.binding_table_index = $3;
1351 $$.bits3.dp_write_gen5.pixel_scoreboard_clear = ($5 & 0x8) >> 3;
1352 $$.bits3.dp_write_gen5.msg_control = $5 & 0x7;
1353 $$.bits3.dp_write_gen5.msg_type = $7;
1354 $$.bits3.dp_write_gen5.send_commit_msg = $9;
1355 } else {
1356 $$.bits3.generic.msg_target =
1357 BRW_MESSAGE_TARGET_DATAPORT_WRITE;
1358 $$.bits3.dp_write.binding_table_index = $3;
1359 /* The msg control field of brw_struct.h is split into
1360 * msg control and pixel_scoreboard_clear, even though
1361 * pixel_scoreboard_clear isn't common to all write messages.
1362 */
1363 $$.bits3.dp_write.pixel_scoreboard_clear = ($5 & 0x8) >> 3;
1364 $$.bits3.dp_write.msg_control = $5 & 0x7;
1365 $$.bits3.dp_write.msg_type = $7;
1366 $$.bits3.dp_write.send_commit_msg = $9;
1367 }
1368 }
Eric Anholte8651962006-08-24 16:37:04 -07001369 | URB INTEGER urb_swizzle urb_allocate urb_used urb_complete
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001370 {
1371 $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_URB;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001372 if (IS_GENp(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001373 $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_URB;
1374 $$.bits3.generic_gen5.header_present = 1;
1375 $$.bits3.urb_gen5.opcode = BRW_URB_OPCODE_WRITE;
1376 $$.bits3.urb_gen5.offset = $2;
1377 $$.bits3.urb_gen5.swizzle_control = $3;
1378 $$.bits3.urb_gen5.pad = 0;
1379 $$.bits3.urb_gen5.allocate = $4;
1380 $$.bits3.urb_gen5.used = $5;
1381 $$.bits3.urb_gen5.complete = $6;
1382 } else {
1383 $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_URB;
1384 $$.bits3.urb.opcode = BRW_URB_OPCODE_WRITE;
1385 $$.bits3.urb.offset = $2;
1386 $$.bits3.urb.swizzle_control = $3;
1387 $$.bits3.urb.pad = 0;
1388 $$.bits3.urb.allocate = $4;
1389 $$.bits3.urb.used = $5;
1390 $$.bits3.urb.complete = $6;
1391 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001392 }
Zou Nan hai26afe902008-06-18 15:04:11 -07001393 | THREAD_SPAWNER LPAREN INTEGER COMMA INTEGER COMMA
1394 INTEGER RPAREN
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001395 {
1396 $$.bits3.generic.msg_target =
1397 BRW_MESSAGE_TARGET_THREAD_SPAWNER;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001398 if (IS_GENp(5)) {
Xiang Haihao549b7512009-06-30 10:02:33 +08001399 $$.bits2.send_gen5.sfid =
1400 BRW_MESSAGE_TARGET_THREAD_SPAWNER;
1401 $$.bits3.generic_gen5.header_present = 0;
1402 $$.bits3.thread_spawner_gen5.opcode = $3;
1403 $$.bits3.thread_spawner_gen5.requester_type = $5;
1404 $$.bits3.thread_spawner_gen5.resource_select = $7;
1405 } else {
1406 $$.bits3.generic.msg_target =
1407 BRW_MESSAGE_TARGET_THREAD_SPAWNER;
1408 $$.bits3.thread_spawner.opcode = $3;
1409 $$.bits3.thread_spawner.requester_type = $5;
1410 $$.bits3.thread_spawner.resource_select = $7;
1411 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001412 }
Zhou Chang52399862011-04-14 11:51:29 +08001413 | VME LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA INTEGER RPAREN
1414 {
1415 $$.bits3.generic.msg_target =
1416 BRW_MESSAGE_TARGET_VME;
1417
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001418 if (IS_GENp(6)) {
Zhou Chang52399862011-04-14 11:51:29 +08001419 $$.bits2.send_gen5.sfid =
1420 BRW_MESSAGE_TARGET_VME;
1421 $$.bits3.vme_gen6.binding_table_index = $3;
1422 $$.bits3.vme_gen6.search_path_index = $5;
1423 $$.bits3.vme_gen6.lut_subindex = $7;
1424 $$.bits3.vme_gen6.message_type = $9;
1425 $$.bits3.generic_gen5.header_present = 1;
1426 } else {
Homer Hsing5d727892012-10-23 09:21:15 +08001427 fprintf (stderr, "Gen6- doesn't have vme function\n");
Zhou Chang52399862011-04-14 11:51:29 +08001428 YYERROR;
1429 }
1430 }
Zhao Yakui93f2a4f2012-10-22 16:13:51 -04001431 | CRE LPAREN INTEGER COMMA INTEGER RPAREN
1432 {
1433 if (gen_level < 75) {
Homer Hsing5d727892012-10-23 09:21:15 +08001434 fprintf (stderr, "Below Gen7.5 doesn't have CRE function\n");
Zhao Yakui93f2a4f2012-10-22 16:13:51 -04001435 YYERROR;
1436 }
1437 $$.bits3.generic.msg_target =
1438 BRW_MESSAGE_TARGET_CRE;
1439
1440 $$.bits2.send_gen5.sfid =
1441 BRW_MESSAGE_TARGET_CRE;
1442 $$.bits3.cre_gen75.binding_table_index = $3;
1443 $$.bits3.cre_gen75.message_type = $5;
1444 $$.bits3.generic_gen5.header_present = 1;
1445 }
Xiang, Haihao27050392011-06-10 16:04:30 +08001446
1447 | DATA_PORT LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA
1448 INTEGER COMMA INTEGER COMMA INTEGER RPAREN
1449 {
1450 $$.bits2.send_gen5.sfid = $3;
1451 $$.bits3.generic_gen5.header_present = ($13 != 0);
1452
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001453 if (IS_GENp(7)) {
Xiang, Haihao27050392011-06-10 16:04:30 +08001454 if ($3 != BRW_MESSAGE_TARGET_DP_SC &&
1455 $3 != BRW_MESSAGE_TARGET_DP_RC &&
1456 $3 != BRW_MESSAGE_TARGET_DP_CC &&
1457 $3 != BRW_MESSAGE_TARGET_DP_DC) {
1458 fprintf (stderr, "error: wrong cache type\n");
1459 YYERROR;
1460 }
1461
1462 $$.bits3.dp_gen7.category = $11;
1463 $$.bits3.dp_gen7.binding_table_index = $9;
1464 $$.bits3.dp_gen7.msg_control = $7;
1465 $$.bits3.dp_gen7.msg_type = $5;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001466 } else if (IS_GENx(6)) {
Xiang, Haihao27050392011-06-10 16:04:30 +08001467 if ($3 != BRW_MESSAGE_TARGET_DP_SC &&
1468 $3 != BRW_MESSAGE_TARGET_DP_RC &&
1469 $3 != BRW_MESSAGE_TARGET_DP_CC) {
1470 fprintf (stderr, "error: wrong cache type\n");
1471 YYERROR;
1472 }
1473
1474 $$.bits3.dp_gen6.send_commit_msg = $11;
1475 $$.bits3.dp_gen6.binding_table_index = $9;
1476 $$.bits3.dp_gen6.msg_control = $7;
1477 $$.bits3.dp_gen6.msg_type = $5;
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04001478 } else if (!IS_GENp(5)) {
Homer Hsing5d727892012-10-23 09:21:15 +08001479 fprintf (stderr, "Gen6- doesn't support data port for sampler/render/constant/data cache\n");
Xiang, Haihao27050392011-06-10 16:04:30 +08001480 YYERROR;
1481 }
1482 }
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001483;
1484
Eric Anholte8651962006-08-24 16:37:04 -07001485urb_allocate: ALLOCATE { $$ = 1; }
1486 | /* empty */ { $$ = 0; }
Eric Anholt3d360792006-08-25 09:36:28 -07001487;
Eric Anholte8651962006-08-24 16:37:04 -07001488
1489urb_used: USED { $$ = 1; }
1490 | /* empty */ { $$ = 0; }
Eric Anholt3d360792006-08-25 09:36:28 -07001491;
Eric Anholte8651962006-08-24 16:37:04 -07001492
1493urb_complete: COMPLETE { $$ = 1; }
1494 | /* empty */ { $$ = 0; }
Eric Anholt3d360792006-08-25 09:36:28 -07001495;
Eric Anholte8651962006-08-24 16:37:04 -07001496
1497urb_swizzle: TRANSPOSE { $$ = BRW_URB_SWIZZLE_TRANSPOSE; }
1498 | INTERLEAVE { $$ = BRW_URB_SWIZZLE_INTERLEAVE; }
1499 | /* empty */ { $$ = BRW_URB_SWIZZLE_NONE; }
Eric Anholt3d360792006-08-25 09:36:28 -07001500;
Eric Anholte8651962006-08-24 16:37:04 -07001501
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001502sampler_datatype:
1503 TYPE_F
1504 | TYPE_UD
1505 | TYPE_D
Eric Anholt3d360792006-08-25 09:36:28 -07001506;
1507
1508math_function: INV | LOG | EXP | SQRT | POW | SIN | COS | SINCOS | INTDIV
1509 | INTMOD | INTDIVMOD
1510;
1511
1512math_signed: /* empty */ { $$ = 0; }
1513 | SIGNED { $$ = 1; }
Eric Anholtedc82a02006-08-25 17:42:05 -07001514;
Eric Anholt3d360792006-08-25 09:36:28 -07001515
1516math_scalar: /* empty */ { $$ = 0; }
1517 | SCALAR { $$ = 1; }
Eric Anholtedc82a02006-08-25 17:42:05 -07001518;
Eric Anholt56c4ccf2006-08-24 14:35:10 -07001519
Eric Anholt22a10632006-08-22 10:15:33 -07001520/* 1.4.2: Destination register */
1521
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001522dst: dstoperand | dstoperandex
Eric Anholt3d360792006-08-25 09:36:28 -07001523;
Eric Anholt22a10632006-08-22 10:15:33 -07001524
Xiang, Haihao27b43032010-12-13 16:07:16 +08001525dstoperand: symbol_reg dstregion
1526 {
1527 memset (&$$, '\0', sizeof ($$));
1528 $$.reg_file = $1.base.reg_file;
1529 $$.reg_nr = $1.base.reg_nr;
1530 $$.subreg_nr = $1.base.subreg_nr;
1531 if ($2 == DEFAULT_DSTREGION) {
1532 $$.horiz_stride = $1.dst_region;
1533 } else {
1534 $$.horiz_stride = $2;
1535 }
1536 $$.reg_type = $1.type;
1537 }
1538 | dstreg dstregion writemask regtype
Eric Anholt22a10632006-08-22 10:15:33 -07001539 {
1540 /* Returns an instruction with just the destination register
1541 * filled in.
1542 */
Keith Packard2d4d4012008-03-30 00:58:28 -07001543 memset (&$$, '\0', sizeof ($$));
Eric Anholt2dac0a12006-08-29 15:29:31 -07001544 $$.reg_file = $1.reg_file;
1545 $$.reg_nr = $1.reg_nr;
1546 $$.subreg_nr = $1.subreg_nr;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001547 $$.address_mode = $1.address_mode;
1548 $$.address_subreg_nr = $1.address_subreg_nr;
1549 $$.indirect_offset = $1.indirect_offset;
Eric Anholt2dac0a12006-08-29 15:29:31 -07001550 $$.horiz_stride = $2;
1551 $$.writemask_set = $3.writemask_set;
1552 $$.writemask = $3.writemask;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001553 $$.reg_type = $4.type;
Eric Anholt22a10632006-08-22 10:15:33 -07001554 }
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001555;
Eric Anholt22a10632006-08-22 10:15:33 -07001556
Eric Anholt883408e2006-08-25 13:38:03 -07001557/* The dstoperandex returns an instruction with just the destination register
1558 * filled in.
1559 */
1560dstoperandex: dstoperandex_typed dstregion regtype
Eric Anholt22a10632006-08-22 10:15:33 -07001561 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001562 memset (&$$, '\0', sizeof ($$));
Eric Anholt2dac0a12006-08-29 15:29:31 -07001563 $$.reg_file = $1.reg_file;
1564 $$.reg_nr = $1.reg_nr;
1565 $$.subreg_nr = $1.subreg_nr;
1566 $$.horiz_stride = $2;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001567 $$.reg_type = $3.type;
Eric Anholt22a10632006-08-22 10:15:33 -07001568 }
Eric Anholt883408e2006-08-25 13:38:03 -07001569 | maskstackreg
1570 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001571 memset (&$$, '\0', sizeof ($$));
Eric Anholt2dac0a12006-08-29 15:29:31 -07001572 $$.reg_file = $1.reg_file;
1573 $$.reg_nr = $1.reg_nr;
1574 $$.subreg_nr = $1.subreg_nr;
1575 $$.horiz_stride = 1;
1576 $$.reg_type = BRW_REGISTER_TYPE_UW;
Eric Anholt883408e2006-08-25 13:38:03 -07001577 }
1578 | controlreg
1579 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001580 memset (&$$, '\0', sizeof ($$));
Eric Anholt2dac0a12006-08-29 15:29:31 -07001581 $$.reg_file = $1.reg_file;
1582 $$.reg_nr = $1.reg_nr;
1583 $$.subreg_nr = $1.subreg_nr;
1584 $$.horiz_stride = 1;
1585 $$.reg_type = BRW_REGISTER_TYPE_UD;
Eric Anholt883408e2006-08-25 13:38:03 -07001586 }
1587 | ipreg
1588 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001589 memset (&$$, '\0', sizeof ($$));
Eric Anholt2dac0a12006-08-29 15:29:31 -07001590 $$.reg_file = $1.reg_file;
1591 $$.reg_nr = $1.reg_nr;
1592 $$.subreg_nr = $1.subreg_nr;
1593 $$.horiz_stride = 1;
1594 $$.reg_type = BRW_REGISTER_TYPE_UD;
Eric Anholt883408e2006-08-25 13:38:03 -07001595 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08001596 | nullreg dstregion regtype
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001597 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001598 memset (&$$, '\0', sizeof ($$));
Eric Anholt2dac0a12006-08-29 15:29:31 -07001599 $$.reg_file = $1.reg_file;
1600 $$.reg_nr = $1.reg_nr;
1601 $$.subreg_nr = $1.subreg_nr;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001602 $$.horiz_stride = $2;
1603 $$.reg_type = $3.type;
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001604 }
1605;
Eric Anholt22a10632006-08-22 10:15:33 -07001606
Eric Anholt883408e2006-08-25 13:38:03 -07001607dstoperandex_typed: accreg | flagreg | addrreg | maskreg
1608;
1609
Xiang, Haihao27b43032010-12-13 16:07:16 +08001610symbol_reg: STRING %prec STR_SYMBOL_REG
1611 {
1612 struct declared_register *dcl_reg = find_register($1);
1613
1614 if (dcl_reg == NULL) {
1615 fprintf(stderr, "can't find register %s\n", $1);
1616 YYERROR;
1617 }
1618
1619 memcpy(&$$, dcl_reg, sizeof(*dcl_reg));
Homer Hsing2ab4c0d2012-09-20 14:04:20 +08001620 free($1); // $1 has been malloc'ed by strdup
Xiang, Haihao27b43032010-12-13 16:07:16 +08001621 }
1622 | symbol_reg_p
1623 {
1624 $$=$1;
1625 }
1626;
1627
1628symbol_reg_p: STRING LPAREN exp RPAREN
1629 {
1630 struct declared_register *dcl_reg = find_register($1);
1631
1632 if (dcl_reg == NULL) {
1633 fprintf(stderr, "can't find register %s\n", $1);
1634 YYERROR;
1635 }
1636
1637 memcpy(&$$, dcl_reg, sizeof(*dcl_reg));
1638 $$.base.reg_nr += $3;
Homer Hsing2ab4c0d2012-09-20 14:04:20 +08001639 free($1);
Xiang, Haihao27b43032010-12-13 16:07:16 +08001640 }
1641 | STRING LPAREN exp COMMA exp RPAREN
1642 {
1643 struct declared_register *dcl_reg = find_register($1);
1644
1645 if (dcl_reg == NULL) {
1646 fprintf(stderr, "can't find register %s\n", $1);
1647 YYERROR;
1648 }
1649
1650 memcpy(&$$, dcl_reg, sizeof(*dcl_reg));
1651 $$.base.reg_nr += $3;
1652 $$.base.subreg_nr += $5;
Homer Hsing599d7d22012-10-16 14:14:25 +08001653 if(advanced_flag) {
1654 $$.base.reg_nr += $$.base.subreg_nr / (32 / get_type_size(dcl_reg->type));
1655 $$.base.subreg_nr = $$.base.subreg_nr % (32 / get_type_size(dcl_reg->type));
1656 } else {
1657 $$.base.reg_nr += $$.base.subreg_nr / 32;
1658 $$.base.subreg_nr = $$.base.subreg_nr % 32;
1659 }
Homer Hsing2ab4c0d2012-09-20 14:04:20 +08001660 free($1);
Xiang, Haihao27b43032010-12-13 16:07:16 +08001661 }
1662;
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001663/* Returns a partially complete destination register consisting of the
1664 * direct or indirect register addressing fields, but not stride or writemask.
1665 */
Eric Anholt22a10632006-08-22 10:15:33 -07001666dstreg: directgenreg
1667 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001668 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001669 $$.address_mode = BRW_ADDRESS_DIRECT;
Eric Anholt2dac0a12006-08-29 15:29:31 -07001670 $$.reg_file = $1.reg_file;
1671 $$.reg_nr = $1.reg_nr;
1672 $$.subreg_nr = $1.subreg_nr;
Eric Anholt22a10632006-08-22 10:15:33 -07001673 }
1674 | directmsgreg
Eric Anholta34d1e02006-08-22 14:52:14 -07001675 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001676 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001677 $$.address_mode = BRW_ADDRESS_DIRECT;
Eric Anholt2dac0a12006-08-29 15:29:31 -07001678 $$.reg_file = $1.reg_file;
1679 $$.reg_nr = $1.reg_nr;
1680 $$.subreg_nr = $1.subreg_nr;
Eric Anholta34d1e02006-08-22 14:52:14 -07001681 }
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001682 | indirectgenreg
1683 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001684 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001685 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
1686 $$.reg_file = $1.reg_file;
1687 $$.address_subreg_nr = $1.address_subreg_nr;
1688 $$.indirect_offset = $1.indirect_offset;
1689 }
1690 | indirectmsgreg
1691 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001692 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001693 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
1694 $$.reg_file = $1.reg_file;
1695 $$.address_subreg_nr = $1.address_subreg_nr;
1696 $$.indirect_offset = $1.indirect_offset;
1697 }
Eric Anholt22a10632006-08-22 10:15:33 -07001698;
1699
1700/* 1.4.3: Source register */
Eric Anholt0d929b42006-08-22 13:33:41 -07001701srcaccimm: srcacc | imm32reg
Eric Anholt22a10632006-08-22 10:15:33 -07001702;
1703
Eric Anholt2d298742006-08-30 09:57:20 -07001704srcacc: directsrcaccoperand | indirectsrcoperand
Eric Anholt22a10632006-08-22 10:15:33 -07001705;
1706
Xiang, Haihao27b43032010-12-13 16:07:16 +08001707srcimm: directsrcoperand | indirectsrcoperand| imm32reg
Eric Anholtedc82a02006-08-25 17:42:05 -07001708;
Eric Anholt0d929b42006-08-22 13:33:41 -07001709
1710imm32reg: imm32 srcimmtype
Eric Anholt22a10632006-08-22 10:15:33 -07001711 {
Eric Anholt6a88ada2006-08-28 22:11:18 -07001712 union {
1713 int i;
1714 float f;
1715 } intfloat;
Keith Packard2d4d4012008-03-30 00:58:28 -07001716 uint32_t d;
Eric Anholt6a88ada2006-08-28 22:11:18 -07001717
Eric Anholt22a10632006-08-22 10:15:33 -07001718 switch ($2) {
1719 case BRW_REGISTER_TYPE_UD:
Eric Anholt22a10632006-08-22 10:15:33 -07001720 case BRW_REGISTER_TYPE_D:
Keith Packard2d4d4012008-03-30 00:58:28 -07001721 case BRW_REGISTER_TYPE_V:
Xiang, Haihao27b43032010-12-13 16:07:16 +08001722 case BRW_REGISTER_TYPE_VF:
Keith Packard2d4d4012008-03-30 00:58:28 -07001723 switch ($1.r) {
1724 case imm32_d:
1725 d = $1.u.d;
1726 break;
1727 default:
Xiang, Haihao27b43032010-12-13 16:07:16 +08001728 fprintf (stderr, "%d: non-int D/UD/V/VF representation: %d,type=%d\n", yylineno, $1.r, $2);
Keith Packard2d4d4012008-03-30 00:58:28 -07001729 YYERROR;
1730 }
Eric Anholt22a10632006-08-22 10:15:33 -07001731 break;
Eric Anholt0d929b42006-08-22 13:33:41 -07001732 case BRW_REGISTER_TYPE_UW:
Eric Anholt0d929b42006-08-22 13:33:41 -07001733 case BRW_REGISTER_TYPE_W:
Keith Packard2d4d4012008-03-30 00:58:28 -07001734 switch ($1.r) {
1735 case imm32_d:
1736 d = $1.u.d;
1737 break;
1738 default:
1739 fprintf (stderr, "non-int W/UW representation\n");
1740 YYERROR;
1741 }
1742 d &= 0xffff;
1743 d |= d << 16;
Eric Anholt0d929b42006-08-22 13:33:41 -07001744 break;
Eric Anholt22a10632006-08-22 10:15:33 -07001745 case BRW_REGISTER_TYPE_F:
Keith Packard2d4d4012008-03-30 00:58:28 -07001746 switch ($1.r) {
1747 case imm32_f:
1748 intfloat.f = $1.u.f;
1749 break;
1750 case imm32_d:
1751 intfloat.f = (float) $1.u.d;
1752 break;
1753 default:
1754 fprintf (stderr, "non-float F representation\n");
1755 YYERROR;
1756 }
1757 d = intfloat.i;
Eric Anholt22a10632006-08-22 10:15:33 -07001758 break;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001759#if 0
Keith Packard2d4d4012008-03-30 00:58:28 -07001760 case BRW_REGISTER_TYPE_VF:
1761 fprintf (stderr, "Immediate type VF not supported yet\n");
1762 YYERROR;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001763#endif
Eric Anholt0d929b42006-08-22 13:33:41 -07001764 default:
1765 fprintf(stderr, "unknown immediate type %d\n", $2);
1766 YYERROR;
Eric Anholt22a10632006-08-22 10:15:33 -07001767 }
Keith Packard2d4d4012008-03-30 00:58:28 -07001768 memset (&$$, '\0', sizeof ($$));
1769 $$.reg_file = BRW_IMMEDIATE_VALUE;
1770 $$.reg_type = $2;
1771 $$.imm32 = d;
Eric Anholt22a10632006-08-22 10:15:33 -07001772 }
1773;
1774
Eric Anholt5297b2a2006-08-25 16:50:17 -07001775directsrcaccoperand: directsrcoperand
Xiang, Haihao27b43032010-12-13 16:07:16 +08001776 | accreg region regtype
Eric Anholt2a0f1352006-08-25 17:44:55 -07001777 {
Xiang, Haihao27b43032010-12-13 16:07:16 +08001778 set_direct_src_operand(&$$, &$1, $3.type);
1779 $$.vert_stride = $2.vert_stride;
1780 $$.width = $2.width;
1781 $$.horiz_stride = $2.horiz_stride;
1782 $$.default_region = $2.is_default;
Eric Anholt2a0f1352006-08-25 17:44:55 -07001783 }
Eric Anholt2c787652006-08-25 13:53:48 -07001784;
1785
1786/* Returns a source operand in the src0 fields of an instruction. */
Eric Anholt5297b2a2006-08-25 16:50:17 -07001787srcarchoperandex: srcarchoperandex_typed region regtype
Eric Anholt2c787652006-08-25 13:53:48 -07001788 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001789 memset (&$$, '\0', sizeof ($$));
Eric Anholt6a88ada2006-08-28 22:11:18 -07001790 $$.reg_file = $1.reg_file;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001791 $$.reg_type = $3.type;
Eric Anholt6a88ada2006-08-28 22:11:18 -07001792 $$.subreg_nr = $1.subreg_nr;
1793 $$.reg_nr = $1.reg_nr;
1794 $$.vert_stride = $2.vert_stride;
1795 $$.width = $2.width;
1796 $$.horiz_stride = $2.horiz_stride;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001797 $$.default_region = $2.is_default;
Eric Anholt6a88ada2006-08-28 22:11:18 -07001798 $$.negate = 0;
1799 $$.abs = 0;
Eric Anholt2c787652006-08-25 13:53:48 -07001800 }
1801 | maskstackreg
1802 {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001803 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UB);
Eric Anholt2c787652006-08-25 13:53:48 -07001804 }
1805 | controlreg
1806 {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001807 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD);
Eric Anholt2c787652006-08-25 13:53:48 -07001808 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08001809/* | statereg
Eric Anholt2c787652006-08-25 13:53:48 -07001810 {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001811 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD);
Xiang, Haihao27b43032010-12-13 16:07:16 +08001812 }*/
Eric Anholt2c787652006-08-25 13:53:48 -07001813 | notifyreg
1814 {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001815 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD);
Eric Anholt2c787652006-08-25 13:53:48 -07001816 }
1817 | ipreg
1818 {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001819 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD);
Eric Anholt2c787652006-08-25 13:53:48 -07001820 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08001821 | nullreg region regtype
Eric Anholt2c787652006-08-25 13:53:48 -07001822 {
Xiang, Haihao27b43032010-12-13 16:07:16 +08001823 if ($3.is_default) {
1824 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD);
1825 } else {
1826 set_direct_src_operand(&$$, &$1, $3.type);
1827 }
1828 $$.default_region = 1;
Eric Anholt2c787652006-08-25 13:53:48 -07001829 }
1830;
1831
Eric Anholt5297b2a2006-08-25 16:50:17 -07001832srcarchoperandex_typed: flagreg | addrreg | maskreg
Eric Anholt22a10632006-08-22 10:15:33 -07001833;
1834
Xiang, Haihao128053f2012-06-29 16:47:10 +08001835sendleadreg: symbol_reg
1836 {
1837 memset (&$$, '\0', sizeof ($$));
1838 $$.reg_file = $1.base.reg_file;
1839 $$.reg_nr = $1.base.reg_nr;
1840 $$.subreg_nr = $1.base.subreg_nr;
1841 }
1842 | directgenreg | directmsgreg
Xiang, Haihao0b5f7fa2011-08-11 15:35:14 +08001843;
1844
Eric Anholt2d298742006-08-30 09:57:20 -07001845src: directsrcoperand | indirectsrcoperand
Eric Anholt22a10632006-08-22 10:15:33 -07001846;
1847
Xiang, Haihao27b43032010-12-13 16:07:16 +08001848directsrcoperand: negate abs symbol_reg region regtype
1849 {
1850 memset (&$$, '\0', sizeof ($$));
1851 $$.address_mode = BRW_ADDRESS_DIRECT;
1852 $$.reg_file = $3.base.reg_file;
1853 $$.reg_nr = $3.base.reg_nr;
1854 $$.subreg_nr = $3.base.subreg_nr;
1855 if ($5.is_default) {
1856 $$.reg_type = $3.type;
1857 } else {
1858 $$.reg_type = $5.type;
1859 }
1860 if ($4.is_default) {
1861 $$.vert_stride = $3.src_region.vert_stride;
1862 $$.width = $3.src_region.width;
1863 $$.horiz_stride = $3.src_region.horiz_stride;
1864 } else {
1865 $$.vert_stride = $4.vert_stride;
1866 $$.width = $4.width;
1867 $$.horiz_stride = $4.horiz_stride;
1868 }
1869 $$.negate = $1;
1870 $$.abs = $2;
1871 }
1872 | statereg region regtype
1873 {
1874 if($2.is_default ==1 && $3.is_default == 1)
1875 {
1876 set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD);
1877 }
1878 else{
1879 memset (&$$, '\0', sizeof ($$));
1880 $$.address_mode = BRW_ADDRESS_DIRECT;
1881 $$.reg_file = $1.reg_file;
1882 $$.reg_nr = $1.reg_nr;
1883 $$.subreg_nr = $1.subreg_nr;
1884 $$.vert_stride = $2.vert_stride;
1885 $$.width = $2.width;
1886 $$.horiz_stride = $2.horiz_stride;
1887 $$.reg_type = $3.type;
1888 }
1889 }
1890 | negate abs directgenreg region regtype swizzle
Eric Anholt22a10632006-08-22 10:15:33 -07001891 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001892 memset (&$$, '\0', sizeof ($$));
Eric Anholt2d298742006-08-30 09:57:20 -07001893 $$.address_mode = BRW_ADDRESS_DIRECT;
Eric Anholt6a88ada2006-08-28 22:11:18 -07001894 $$.reg_file = $3.reg_file;
1895 $$.reg_nr = $3.reg_nr;
1896 $$.subreg_nr = $3.subreg_nr;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001897 $$.reg_type = $5.type;
Eric Anholt6a88ada2006-08-28 22:11:18 -07001898 $$.vert_stride = $4.vert_stride;
1899 $$.width = $4.width;
1900 $$.horiz_stride = $4.horiz_stride;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001901 $$.default_region = $4.is_default;
Eric Anholt6a88ada2006-08-28 22:11:18 -07001902 $$.negate = $1;
1903 $$.abs = $2;
1904 $$.swizzle_set = $6.swizzle_set;
1905 $$.swizzle_x = $6.swizzle_x;
1906 $$.swizzle_y = $6.swizzle_y;
1907 $$.swizzle_z = $6.swizzle_z;
1908 $$.swizzle_w = $6.swizzle_w;
Eric Anholt22a10632006-08-22 10:15:33 -07001909 }
Eric Anholt5297b2a2006-08-25 16:50:17 -07001910 | srcarchoperandex
Eric Anholt22a10632006-08-22 10:15:33 -07001911;
1912
Eric Anholt2d298742006-08-30 09:57:20 -07001913indirectsrcoperand:
1914 negate abs indirectgenreg indirectregion regtype swizzle
1915 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001916 memset (&$$, '\0', sizeof ($$));
Eric Anholt2d298742006-08-30 09:57:20 -07001917 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
1918 $$.reg_file = $3.reg_file;
1919 $$.address_subreg_nr = $3.address_subreg_nr;
1920 $$.indirect_offset = $3.indirect_offset;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001921 $$.reg_type = $5.type;
Eric Anholt2d298742006-08-30 09:57:20 -07001922 $$.vert_stride = $4.vert_stride;
1923 $$.width = $4.width;
1924 $$.horiz_stride = $4.horiz_stride;
1925 $$.negate = $1;
1926 $$.abs = $2;
1927 $$.swizzle_set = $6.swizzle_set;
1928 $$.swizzle_x = $6.swizzle_x;
1929 $$.swizzle_y = $6.swizzle_y;
1930 $$.swizzle_z = $6.swizzle_z;
1931 $$.swizzle_w = $6.swizzle_w;
1932 }
1933;
1934
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001935/* 1.4.4: Address Registers */
1936/* Returns a partially-completed indirect_reg consisting of the address
1937 * register fields for register-indirect access.
1938 */
Xiang, Haihao27b43032010-12-13 16:07:16 +08001939addrparam: addrreg COMMA immaddroffset
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001940 {
Xiang, Haihao27b43032010-12-13 16:07:16 +08001941 if ($3 < -512 || $3 > 511) {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001942 fprintf(stderr, "Address immediate offset %d out of"
Xiang, Haihao27b43032010-12-13 16:07:16 +08001943 "range %d\n", $3, yylineno);
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001944 YYERROR;
1945 }
Keith Packard2d4d4012008-03-30 00:58:28 -07001946 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001947 $$.address_subreg_nr = $1.subreg_nr;
Xiang, Haihao27b43032010-12-13 16:07:16 +08001948 $$.indirect_offset = $3;
1949 }
1950 | addrreg
1951 {
1952 memset (&$$, '\0', sizeof ($$));
1953 $$.address_subreg_nr = $1.subreg_nr;
1954 $$.indirect_offset = 0;
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001955 }
1956;
1957
1958/* The immaddroffset provides an immediate offset value added to the addresses
1959 * from the address register in register-indirect register access.
1960 */
1961immaddroffset: /* empty */ { $$ = 0; }
Zou Nan hai5608d272009-10-20 14:51:04 +08001962 | exp
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001963;
1964
1965
Eric Anholtedc82a02006-08-25 17:42:05 -07001966/* 1.4.5: Register files and register numbers */
Zou Nan hai5608d272009-10-20 14:51:04 +08001967subregnum: DOT exp
Eric Anholt22a10632006-08-22 10:15:33 -07001968 {
1969 $$ = $2;
1970 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08001971 | %prec SUBREGNUM
Eric Anholt22a10632006-08-22 10:15:33 -07001972 {
1973 /* Default to subreg 0 if unspecified. */
1974 $$ = 0;
1975 }
1976;
1977
Eric Anholt569990b2006-08-25 09:46:18 -07001978directgenreg: GENREG subregnum
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001979 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001980 memset (&$$, '\0', sizeof ($$));
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001981 $$.reg_file = BRW_GENERAL_REGISTER_FILE;
Eric Anholt569990b2006-08-25 09:46:18 -07001982 $$.reg_nr = $1;
1983 $$.subreg_nr = $2;
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001984 }
Eric Anholtedc82a02006-08-25 17:42:05 -07001985;
Eric Anholt6c98c8d2006-08-22 11:54:19 -07001986
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001987indirectgenreg: GENREGFILE LSQUARE addrparam RSQUARE
1988 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001989 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07001990 $$.reg_file = BRW_GENERAL_REGISTER_FILE;
1991 $$.address_subreg_nr = $3.address_subreg_nr;
1992 $$.indirect_offset = $3.indirect_offset;
1993 }
1994;
1995
Eric Anholt569990b2006-08-25 09:46:18 -07001996directmsgreg: MSGREG subregnum
Eric Anholt22a10632006-08-22 10:15:33 -07001997 {
Keith Packard2d4d4012008-03-30 00:58:28 -07001998 memset (&$$, '\0', sizeof ($$));
Eric Anholta34d1e02006-08-22 14:52:14 -07001999 $$.reg_file = BRW_MESSAGE_REGISTER_FILE;
Eric Anholt569990b2006-08-25 09:46:18 -07002000 $$.reg_nr = $1;
2001 $$.subreg_nr = $2;
Eric Anholt22a10632006-08-22 10:15:33 -07002002 }
2003;
2004
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002005indirectmsgreg: MSGREGFILE LSQUARE addrparam RSQUARE
2006 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002007 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002008 $$.reg_file = BRW_MESSAGE_REGISTER_FILE;
2009 $$.address_subreg_nr = $3.address_subreg_nr;
2010 $$.indirect_offset = $3.indirect_offset;
2011 }
2012;
2013
Eric Anholt883408e2006-08-25 13:38:03 -07002014addrreg: ADDRESSREG subregnum
2015 {
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002016 if ($1 != 0) {
2017 fprintf(stderr,
2018 "address register number %d out of range", $1);
2019 YYERROR;
2020 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002021 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002022 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2023 $$.reg_nr = BRW_ARF_ADDRESS | $1;
2024 $$.subreg_nr = $2;
2025 }
2026;
2027
Eric Anholt569990b2006-08-25 09:46:18 -07002028accreg: ACCREG subregnum
2029 {
Eric Anholt569990b2006-08-25 09:46:18 -07002030 if ($1 > 1) {
2031 fprintf(stderr,
2032 "accumulator register number %d out of range", $1);
2033 YYERROR;
2034 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002035 memset (&$$, '\0', sizeof ($$));
Eric Anholt569990b2006-08-25 09:46:18 -07002036 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2037 $$.reg_nr = BRW_ARF_ACCUMULATOR | $1;
2038 $$.subreg_nr = $2;
2039 }
2040;
2041
Xiang, Haihaof3f6ba22012-07-17 13:46:59 +08002042flagreg: FLAGREG subregnum
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002043 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04002044 if ((!IS_GENp(7) && $1) > 0 ||
2045 (IS_GENp(7) && $1 > 1)) {
Xiang, Haihaof3f6ba22012-07-17 13:46:59 +08002046 fprintf(stderr,
2047 "flag register number %d out of range\n", $1);
2048 YYERROR;
2049 }
2050
2051 if ($2 > 1) {
2052 fprintf(stderr,
2053 "flag subregister number %d out of range\n", $1);
2054 YYERROR;
2055 }
2056
Keith Packard2d4d4012008-03-30 00:58:28 -07002057 memset (&$$, '\0', sizeof ($$));
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002058 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
Xiang, Haihaof3f6ba22012-07-17 13:46:59 +08002059 $$.reg_nr = BRW_ARF_FLAG | $1;
2060 $$.subreg_nr = $2;
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002061 }
2062;
2063
Eric Anholt883408e2006-08-25 13:38:03 -07002064maskreg: MASKREG subregnum
2065 {
2066 if ($1 > 0) {
2067 fprintf(stderr,
2068 "mask register number %d out of range", $1);
2069 YYERROR;
2070 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002071 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002072 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2073 $$.reg_nr = BRW_ARF_MASK;
2074 $$.subreg_nr = $2;
2075 }
2076 | mask_subreg
2077 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002078 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002079 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2080 $$.reg_nr = BRW_ARF_MASK;
2081 $$.subreg_nr = $1;
2082 }
2083;
2084
2085mask_subreg: AMASK | IMASK | LMASK | CMASK
2086;
2087
2088maskstackreg: MASKSTACKREG subregnum
2089 {
2090 if ($1 > 0) {
2091 fprintf(stderr,
2092 "mask stack register number %d out of range", $1);
2093 YYERROR;
2094 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002095 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002096 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2097 $$.reg_nr = BRW_ARF_MASK_STACK;
2098 $$.subreg_nr = $2;
2099 }
2100 | maskstack_subreg
2101 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002102 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002103 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2104 $$.reg_nr = BRW_ARF_MASK_STACK;
2105 $$.subreg_nr = $1;
2106 }
2107;
2108
2109maskstack_subreg: IMS | LMS
2110;
2111
Keith Packard2d4d4012008-03-30 00:58:28 -07002112/*
Eric Anholt883408e2006-08-25 13:38:03 -07002113maskstackdepthreg: MASKSTACKDEPTHREG subregnum
2114 {
2115 if ($1 > 0) {
2116 fprintf(stderr,
2117 "mask stack register number %d out of range", $1);
2118 YYERROR;
2119 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002120 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002121 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2122 $$.reg_nr = BRW_ARF_MASK_STACK_DEPTH;
2123 $$.subreg_nr = $2;
2124 }
2125 | maskstackdepth_subreg
2126 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002127 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002128 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2129 $$.reg_nr = BRW_ARF_MASK_STACK_DEPTH;
2130 $$.subreg_nr = $1;
2131 }
2132;
2133
2134maskstackdepth_subreg: IMSD | LMSD
2135;
Keith Packard2d4d4012008-03-30 00:58:28 -07002136 */
Eric Anholt883408e2006-08-25 13:38:03 -07002137
Xiang, Haihao27b43032010-12-13 16:07:16 +08002138notifyreg: NOTIFYREG regtype
Eric Anholt883408e2006-08-25 13:38:03 -07002139 {
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04002140 int num_notifyreg = (IS_GENp(6)) ? 3 : 2;
Xiang, Haihao852216d2011-02-16 15:26:24 +08002141
2142 if ($1 > num_notifyreg) {
Eric Anholt883408e2006-08-25 13:38:03 -07002143 fprintf(stderr,
2144 "notification register number %d out of range",
2145 $1);
2146 YYERROR;
2147 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002148 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002149 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
Xiang, Haihao852216d2011-02-16 15:26:24 +08002150
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04002151 if (IS_GENp(6)) {
Xiang, Haihao852216d2011-02-16 15:26:24 +08002152 $$.reg_nr = BRW_ARF_NOTIFICATION_COUNT;
2153 $$.subreg_nr = $1;
2154 } else {
2155 $$.reg_nr = BRW_ARF_NOTIFICATION_COUNT | $1;
2156 $$.subreg_nr = 0;
2157 }
Eric Anholt883408e2006-08-25 13:38:03 -07002158 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08002159/*
2160 | NOTIFYREG regtype
2161 {
2162 if ($1 > 1) {
2163 fprintf(stderr,
2164 "notification register number %d out of range",
2165 $1);
2166 YYERROR;
2167 }
2168 memset (&$$, '\0', sizeof ($$));
2169 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2170 $$.reg_nr = BRW_ARF_NOTIFICATION_COUNT;
2171 $$.subreg_nr = 0;
2172 }
2173*/
Eric Anholt883408e2006-08-25 13:38:03 -07002174;
2175
2176statereg: STATEREG subregnum
2177 {
2178 if ($1 > 0) {
2179 fprintf(stderr,
2180 "state register number %d out of range", $1);
2181 YYERROR;
2182 }
2183 if ($2 > 1) {
2184 fprintf(stderr,
2185 "state subregister number %d out of range", $1);
2186 YYERROR;
2187 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002188 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002189 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2190 $$.reg_nr = BRW_ARF_STATE | $1;
2191 $$.subreg_nr = $2;
2192 }
2193;
2194
2195controlreg: CONTROLREG subregnum
2196 {
2197 if ($1 > 0) {
2198 fprintf(stderr,
2199 "control register number %d out of range", $1);
2200 YYERROR;
2201 }
2202 if ($2 > 2) {
2203 fprintf(stderr,
2204 "control subregister number %d out of range", $1);
2205 YYERROR;
2206 }
Keith Packard2d4d4012008-03-30 00:58:28 -07002207 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002208 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2209 $$.reg_nr = BRW_ARF_CONTROL | $1;
2210 $$.subreg_nr = $2;
2211 }
2212;
2213
Xiang, Haihao27b43032010-12-13 16:07:16 +08002214ipreg: IPREG regtype
Eric Anholt883408e2006-08-25 13:38:03 -07002215 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002216 memset (&$$, '\0', sizeof ($$));
Eric Anholt883408e2006-08-25 13:38:03 -07002217 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2218 $$.reg_nr = BRW_ARF_IP;
2219 $$.subreg_nr = 0;
2220 }
2221;
2222
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002223nullreg: NULL_TOKEN
2224 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002225 memset (&$$, '\0', sizeof ($$));
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002226 $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE;
2227 $$.reg_nr = BRW_ARF_NULL;
2228 $$.subreg_nr = 0;
2229 }
Eric Anholt22a10632006-08-22 10:15:33 -07002230;
2231
Eric Anholt1e907c72006-08-31 10:21:15 -07002232/* 1.4.6: Relative locations */
Homer Hsingc0ebde22012-09-21 10:14:31 +08002233relativelocation:
Homer Hsing4bf84ec2012-09-24 10:12:26 +08002234 simple_int
Eric Anholt1e907c72006-08-31 10:21:15 -07002235 {
Homer Hsingc0ebde22012-09-21 10:14:31 +08002236 if (($1 > 32767) || ($1 < -32768)) {
Eric Anholt1e907c72006-08-31 10:21:15 -07002237 fprintf(stderr,
Xiang, Haihao27b43032010-12-13 16:07:16 +08002238 "error: relative offset %d out of range \n",
Homer Hsingc0ebde22012-09-21 10:14:31 +08002239 $1);
Eric Anholt1e907c72006-08-31 10:21:15 -07002240 YYERROR;
2241 }
2242
Keith Packard2d4d4012008-03-30 00:58:28 -07002243 memset (&$$, '\0', sizeof ($$));
Eric Anholt1e907c72006-08-31 10:21:15 -07002244 $$.reg_file = BRW_IMMEDIATE_VALUE;
2245 $$.reg_type = BRW_REGISTER_TYPE_D;
Homer Hsingc0ebde22012-09-21 10:14:31 +08002246 $$.imm32 = $1 & 0x0000ffff;
2247 }
2248 | STRING
2249 {
2250 memset (&$$, '\0', sizeof ($$));
2251 $$.reg_file = BRW_IMMEDIATE_VALUE;
2252 $$.reg_type = BRW_REGISTER_TYPE_D;
2253 $$.reloc_target = $1;
Eric Anholt1e907c72006-08-31 10:21:15 -07002254 }
2255;
2256
2257relativelocation2:
Homer Hsingb0b540f2012-09-21 10:06:20 +08002258 STRING
Eric Anholt1e907c72006-08-31 10:21:15 -07002259 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002260 memset (&$$, '\0', sizeof ($$));
Eric Anholt1e907c72006-08-31 10:21:15 -07002261 $$.reg_file = BRW_IMMEDIATE_VALUE;
2262 $$.reg_type = BRW_REGISTER_TYPE_D;
Homer Hsingb0b540f2012-09-21 10:06:20 +08002263 $$.reloc_target = $1;
2264 }
2265 | exp
2266 {
2267 memset (&$$, '\0', sizeof ($$));
2268 $$.reg_file = BRW_IMMEDIATE_VALUE;
2269 $$.reg_type = BRW_REGISTER_TYPE_D;
2270 $$.imm32 = $1;
Eric Anholt1e907c72006-08-31 10:21:15 -07002271 }
2272 | directgenreg region regtype
2273 {
Xiang, Haihao27b43032010-12-13 16:07:16 +08002274 set_direct_src_operand(&$$, &$1, $3.type);
2275 $$.vert_stride = $2.vert_stride;
2276 $$.width = $2.width;
2277 $$.horiz_stride = $2.horiz_stride;
2278 $$.default_region = $2.is_default;
2279 }
2280 | symbol_reg_p
2281 {
2282 memset (&$$, '\0', sizeof ($$));
2283 $$.address_mode = BRW_ADDRESS_DIRECT;
2284 $$.reg_file = $1.base.reg_file;
2285 $$.reg_nr = $1.base.reg_nr;
2286 $$.subreg_nr = $1.base.subreg_nr;
2287 $$.reg_type = $1.type;
2288 $$.vert_stride = $1.src_region.vert_stride;
2289 $$.width = $1.src_region.width;
2290 $$.horiz_stride = $1.src_region.horiz_stride;
2291 }
2292 | indirectgenreg indirectregion regtype
2293 {
2294 memset (&$$, '\0', sizeof ($$));
2295 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
2296 $$.reg_file = $1.reg_file;
2297 $$.address_subreg_nr = $1.address_subreg_nr;
2298 $$.indirect_offset = $1.indirect_offset;
2299 $$.reg_type = $3.type;
Eric Anholt1e907c72006-08-31 10:21:15 -07002300 $$.vert_stride = $2.vert_stride;
2301 $$.width = $2.width;
2302 $$.horiz_stride = $2.horiz_stride;
2303 }
2304;
2305
Eric Anholt22a10632006-08-22 10:15:33 -07002306/* 1.4.7: Regions */
Xiang, Haihao27b43032010-12-13 16:07:16 +08002307dstregion: /* empty */
2308 {
2309 $$ = DEFAULT_DSTREGION;
2310 }
2311 |LANGLE exp RANGLE
Eric Anholt22a10632006-08-22 10:15:33 -07002312 {
2313 /* Returns a value for a horiz_stride field of an
2314 * instruction.
2315 */
2316 if ($2 != 1 && $2 != 2 && $2 != 4) {
2317 fprintf(stderr, "Invalid horiz size %d\n", $2);
2318 }
Eric Anholt0edcb252006-08-22 13:15:38 -07002319 $$ = ffs($2);
Eric Anholt22a10632006-08-22 10:15:33 -07002320 }
2321;
2322
Xiang, Haihao27b43032010-12-13 16:07:16 +08002323region: /* empty */
2324 {
2325 /* XXX is this default value correct?*/
2326 memset (&$$, '\0', sizeof ($$));
2327 $$.vert_stride = ffs(0);
2328 $$.width = ffs(1) - 1;
2329 $$.horiz_stride = ffs(0);
2330 $$.is_default = 1;
2331 }
2332 |LANGLE exp RANGLE
2333 {
2334 /* XXX is this default value correct for accreg?*/
2335 memset (&$$, '\0', sizeof ($$));
2336 $$.vert_stride = ffs($2);
2337 $$.width = ffs(1) - 1;
2338 $$.horiz_stride = ffs(0);
2339 }
2340 |LANGLE exp COMMA exp COMMA exp RANGLE
Eric Anholt22a10632006-08-22 10:15:33 -07002341 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002342 memset (&$$, '\0', sizeof ($$));
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002343 $$.vert_stride = ffs($2);
2344 $$.width = ffs($4) - 1;
Eric Anholtd4c82e82006-08-22 13:08:26 -07002345 $$.horiz_stride = ffs($6);
Eric Anholt22a10632006-08-22 10:15:33 -07002346 }
Zou Nan haic6f2da42009-10-28 10:14:19 +08002347 | LANGLE exp SEMICOLON exp COMMA exp RANGLE
2348 {
2349 memset (&$$, '\0', sizeof ($$));
2350 $$.vert_stride = ffs($2);
2351 $$.width = ffs($4) - 1;
2352 $$.horiz_stride = ffs($6);
2353 }
Eric Anholt22a10632006-08-22 10:15:33 -07002354
Xiang, Haihao27b43032010-12-13 16:07:16 +08002355;
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002356/* region_wh is used in specifying indirect operands where rather than having
2357 * a vertical stride, you use subsequent address registers to get a new base
Eric Anholt2d298742006-08-30 09:57:20 -07002358 * offset for the next row.
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002359 */
Zou Nan hai5608d272009-10-20 14:51:04 +08002360region_wh: LANGLE exp COMMA exp RANGLE
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002361 {
Keith Packard2d4d4012008-03-30 00:58:28 -07002362 memset (&$$, '\0', sizeof ($$));
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002363 $$.vert_stride = BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL;
2364 $$.width = ffs($2) - 1;
2365 $$.horiz_stride = ffs($4);
2366 }
2367;
2368
Eric Anholt2d298742006-08-30 09:57:20 -07002369indirectregion: region | region_wh
2370;
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002371
Eric Anholt22a10632006-08-22 10:15:33 -07002372/* 1.4.8: Types */
2373
2374/* regtype returns an integer register type suitable for inserting into an
2375 * instruction.
2376 */
Xiang, Haihao27b43032010-12-13 16:07:16 +08002377regtype: /* empty */
2378 { $$.type = program_defaults.register_type;$$.is_default = 1;}
2379 | TYPE_F { $$.type = BRW_REGISTER_TYPE_F;$$.is_default = 0; }
2380 | TYPE_UD { $$.type = BRW_REGISTER_TYPE_UD;$$.is_default = 0; }
2381 | TYPE_D { $$.type = BRW_REGISTER_TYPE_D;$$.is_default = 0; }
2382 | TYPE_UW { $$.type = BRW_REGISTER_TYPE_UW;$$.is_default = 0; }
2383 | TYPE_W { $$.type = BRW_REGISTER_TYPE_W;$$.is_default = 0; }
2384 | TYPE_UB { $$.type = BRW_REGISTER_TYPE_UB;$$.is_default = 0; }
2385 | TYPE_B { $$.type = BRW_REGISTER_TYPE_B;$$.is_default = 0; }
Eric Anholtedc82a02006-08-25 17:42:05 -07002386;
2387
Xiang, Haihao27b43032010-12-13 16:07:16 +08002388srcimmtype: /* empty */
2389 {
2390 /* XXX change to default when pragma parse is done */
2391 $$ = BRW_REGISTER_TYPE_D;
2392 }
2393 |TYPE_F { $$ = BRW_REGISTER_TYPE_F; }
Keith Packard2d4d4012008-03-30 00:58:28 -07002394 | TYPE_UD { $$ = BRW_REGISTER_TYPE_UD; }
2395 | TYPE_D { $$ = BRW_REGISTER_TYPE_D; }
2396 | TYPE_UW { $$ = BRW_REGISTER_TYPE_UW; }
2397 | TYPE_W { $$ = BRW_REGISTER_TYPE_W; }
2398 | TYPE_V { $$ = BRW_REGISTER_TYPE_V; }
2399 | TYPE_VF { $$ = BRW_REGISTER_TYPE_VF; }
Eric Anholt22a10632006-08-22 10:15:33 -07002400;
2401
Eric Anholt6a88ada2006-08-28 22:11:18 -07002402/* 1.4.10: Swizzle control */
2403/* Returns the swizzle control for an align16 instruction's source operand
2404 * in the src0 fields.
2405 */
2406swizzle: /* empty */
2407 {
2408 $$.swizzle_set = 0;
2409 $$.swizzle_x = BRW_CHANNEL_X;
2410 $$.swizzle_y = BRW_CHANNEL_Y;
2411 $$.swizzle_z = BRW_CHANNEL_Z;
2412 $$.swizzle_w = BRW_CHANNEL_W;
2413 }
2414 | DOT chansel
2415 {
2416 $$.swizzle_set = 1;
2417 $$.swizzle_x = $2;
2418 $$.swizzle_y = $2;
2419 $$.swizzle_z = $2;
2420 $$.swizzle_w = $2;
2421 }
2422 | DOT chansel chansel chansel chansel
2423 {
2424 $$.swizzle_set = 1;
2425 $$.swizzle_x = $2;
2426 $$.swizzle_y = $3;
2427 $$.swizzle_z = $4;
2428 $$.swizzle_w = $5;
2429 }
2430;
2431
2432chansel: X | Y | Z | W
2433;
2434
Eric Anholt2dac0a12006-08-29 15:29:31 -07002435/* 1.4.9: Write mask */
2436/* Returns a partially completed dst_operand, with just the writemask bits
2437 * filled out.
2438 */
2439writemask: /* empty */
2440 {
2441 $$.writemask_set = 0;
2442 $$.writemask = 0xf;
2443 }
2444 | DOT writemask_x writemask_y writemask_z writemask_w
2445 {
2446 $$.writemask_set = 1;
2447 $$.writemask = $2 | $3 | $4 | $5;
2448 }
Eric Anholtc8939ed2006-08-30 10:50:56 -07002449;
Eric Anholt2dac0a12006-08-29 15:29:31 -07002450
2451writemask_x: /* empty */ { $$ = 0; }
2452 | X { $$ = 1 << BRW_CHANNEL_X; }
Eric Anholtc8939ed2006-08-30 10:50:56 -07002453;
Eric Anholt2dac0a12006-08-29 15:29:31 -07002454
2455writemask_y: /* empty */ { $$ = 0; }
2456 | Y { $$ = 1 << BRW_CHANNEL_Y; }
Eric Anholtc8939ed2006-08-30 10:50:56 -07002457;
Eric Anholt2dac0a12006-08-29 15:29:31 -07002458
2459writemask_z: /* empty */ { $$ = 0; }
2460 | Z { $$ = 1 << BRW_CHANNEL_Z; }
Eric Anholtc8939ed2006-08-30 10:50:56 -07002461;
Eric Anholt2dac0a12006-08-29 15:29:31 -07002462
2463writemask_w: /* empty */ { $$ = 0; }
2464 | W { $$ = 1 << BRW_CHANNEL_W; }
Eric Anholtc8939ed2006-08-30 10:50:56 -07002465;
Eric Anholt2dac0a12006-08-29 15:29:31 -07002466
Eric Anholtedc82a02006-08-25 17:42:05 -07002467/* 1.4.11: Immediate values */
Zou Nan hai5608d272009-10-20 14:51:04 +08002468imm32: exp { $$.r = imm32_d; $$.u.d = $1; }
Keith Packard2d4d4012008-03-30 00:58:28 -07002469 | NUMBER { $$.r = imm32_f; $$.u.f = $1; }
Eric Anholtedc82a02006-08-25 17:42:05 -07002470;
Eric Anholt22a10632006-08-22 10:15:33 -07002471
2472/* 1.4.12: Predication and modifiers */
Eric Anholt0ed5d932006-08-28 23:05:51 -07002473predicate: /* empty */
2474 {
2475 $$.header.predicate_control = BRW_PREDICATE_NONE;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +08002476 $$.bits2.da1.flag_reg_nr = 0;
Xiang, Haihao2f772dd2012-07-17 14:18:54 +08002477 $$.bits2.da1.flag_subreg_nr = 0;
Eric Anholt0ed5d932006-08-28 23:05:51 -07002478 $$.header.predicate_inverse = 0;
2479 }
2480 | LPAREN predstate flagreg predctrl RPAREN
2481 {
2482 $$.header.predicate_control = $4;
2483 /* XXX: Should deal with erroring when the user tries to
2484 * set a predicate for one flag register and conditional
2485 * modification on the other flag register.
2486 */
Xiang, Haihao3ffbe962012-07-17 15:05:31 +08002487 $$.bits2.da1.flag_reg_nr = ($3.reg_nr & 0xF);
Xiang, Haihao2f772dd2012-07-17 14:18:54 +08002488 $$.bits2.da1.flag_subreg_nr = $3.subreg_nr;
Eric Anholt0ed5d932006-08-28 23:05:51 -07002489 $$.header.predicate_inverse = $2;
2490 }
2491;
2492
2493predstate: /* empty */ { $$ = 0; }
2494 | PLUS { $$ = 0; }
2495 | MINUS { $$ = 1; }
2496;
2497
Keith Packard2033aea2008-04-23 23:10:40 -07002498predctrl: /* empty */ { $$ = BRW_PREDICATE_NORMAL; }
Eric Anholt0ed5d932006-08-28 23:05:51 -07002499 | DOT X { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_X; }
2500 | DOT Y { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Y; }
2501 | DOT Z { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Z; }
2502 | DOT W { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_W; }
Keith Packard2033aea2008-04-23 23:10:40 -07002503 | ANYV { $$ = BRW_PREDICATE_ALIGN1_ANYV; }
2504 | ALLV { $$ = BRW_PREDICATE_ALIGN1_ALLV; }
Eric Anholt0ed5d932006-08-28 23:05:51 -07002505 | ANY2H { $$ = BRW_PREDICATE_ALIGN1_ANY2H; }
2506 | ALL2H { $$ = BRW_PREDICATE_ALIGN1_ALL2H; }
2507 | ANY4H { $$ = BRW_PREDICATE_ALIGN1_ANY4H; }
2508 | ALL4H { $$ = BRW_PREDICATE_ALIGN1_ALL4H; }
2509 | ANY8H { $$ = BRW_PREDICATE_ALIGN1_ANY8H; }
2510 | ALL8H { $$ = BRW_PREDICATE_ALIGN1_ALL8H; }
2511 | ANY16H { $$ = BRW_PREDICATE_ALIGN1_ANY16H; }
2512 | ALL16H { $$ = BRW_PREDICATE_ALIGN1_ALL16H; }
Eric Anholtdc96c562006-08-22 14:42:45 -07002513;
2514
2515negate: /* empty */ { $$ = 0; }
2516 | MINUS { $$ = 1; }
Eric Anholtedc82a02006-08-25 17:42:05 -07002517;
Eric Anholtdc96c562006-08-22 14:42:45 -07002518
2519abs: /* empty */ { $$ = 0; }
2520 | ABS { $$ = 1; }
Eric Anholtedc82a02006-08-25 17:42:05 -07002521;
Eric Anholt22a10632006-08-22 10:15:33 -07002522
Xiang, Haihao27b43032010-12-13 16:07:16 +08002523execsize: /* empty */ %prec EMPTEXECSIZE
2524 {
2525 $$ = ffs(program_defaults.execute_size) - 1;
2526 }
2527 |LPAREN exp RPAREN
Eric Anholt22a10632006-08-22 10:15:33 -07002528 {
2529 /* Returns a value for the execution_size field of an
2530 * instruction.
2531 */
2532 if ($2 != 1 && $2 != 2 && $2 != 4 && $2 != 8 && $2 != 16 &&
2533 $2 != 32) {
2534 fprintf(stderr, "Invalid execution size %d\n", $2);
2535 YYERROR;
2536 }
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002537 $$ = ffs($2) - 1;
Eric Anholt22a10632006-08-22 10:15:33 -07002538 }
2539;
2540
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002541saturate: /* empty */ { $$ = BRW_INSTRUCTION_NORMAL; }
Xiang, Haihao27b43032010-12-13 16:07:16 +08002542 | SATURATE { $$ = BRW_INSTRUCTION_SATURATE; }
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002543;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002544conditionalmodifier: condition
2545 {
2546 $$.cond = $1;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +08002547 $$.flag_reg_nr = 0;
Xiang, Haihao2f772dd2012-07-17 14:18:54 +08002548 $$.flag_subreg_nr = -1;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002549 }
2550 | condition DOT flagreg
2551 {
2552 $$.cond = $1;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +08002553 $$.flag_reg_nr = ($3.reg_nr & 0xF);
Xiang, Haihao2f772dd2012-07-17 14:18:54 +08002554 $$.flag_subreg_nr = $3.subreg_nr;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002555 }
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002556
Xiang, Haihao27b43032010-12-13 16:07:16 +08002557condition: /* empty */ { $$ = BRW_CONDITIONAL_NONE; }
Keith Packard2033aea2008-04-23 23:10:40 -07002558 | ZERO
2559 | EQUAL
2560 | NOT_ZERO
2561 | NOT_EQUAL
2562 | GREATER
2563 | GREATER_EQUAL
2564 | LESS
2565 | LESS_EQUAL
2566 | ROUND_INCREMENT
2567 | OVERFLOW
2568 | UNORDERED
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002569;
2570
Eric Anholt22a10632006-08-22 10:15:33 -07002571/* 1.4.13: Instruction options */
Zou Nan haic6f2da42009-10-28 10:14:19 +08002572instoptions: /* empty */
2573 { memset(&$$, 0, sizeof($$)); }
2574 | LCURLY instoption_list RCURLY
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002575 { $$ = $2; }
2576;
2577
Homer Hsing5d589db2012-09-21 12:35:35 +08002578instoption_list:instoption_list COMMA instoption
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002579 {
Homer Hsing5d589db2012-09-21 12:35:35 +08002580 $$ = $1;
2581 switch ($3) {
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002582 case ALIGN1:
2583 $$.header.access_mode = BRW_ALIGN_1;
2584 break;
2585 case ALIGN16:
2586 $$.header.access_mode = BRW_ALIGN_16;
2587 break;
Eric Anholt908f37d2006-08-25 17:33:02 -07002588 case SECHALF:
2589 $$.header.compression_control |= BRW_COMPRESSION_2NDHALF;
2590 break;
2591 case COMPR:
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04002592 if (!IS_GENp(6)) {
Xiang, Haihaoc2382ca2010-10-09 13:57:48 +08002593 $$.header.compression_control |=
2594 BRW_COMPRESSION_COMPRESSED;
2595 }
Eric Anholt908f37d2006-08-25 17:33:02 -07002596 break;
2597 case SWITCH:
2598 $$.header.thread_control |= BRW_THREAD_SWITCH;
2599 break;
2600 case ATOMIC:
2601 $$.header.thread_control |= BRW_THREAD_ATOMIC;
2602 break;
2603 case NODDCHK:
2604 $$.header.dependency_control |= BRW_DEPENDENCY_NOTCHECKED;
2605 break;
2606 case NODDCLR:
2607 $$.header.dependency_control |= BRW_DEPENDENCY_NOTCLEARED;
2608 break;
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002609 case MASK_DISABLE:
2610 $$.header.mask_control = BRW_MASK_DISABLE;
2611 break;
Eric Anholt908f37d2006-08-25 17:33:02 -07002612 case BREAKPOINT:
2613 $$.header.debug_control = BRW_DEBUG_BREAKPOINT;
2614 break;
Xiang, Haihao55d81c42010-10-08 13:53:22 +08002615 case ACCWRCTRL:
2616 $$.header.acc_wr_control = BRW_ACCWRCTRL_ACCWRCTRL;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002617 }
2618 }
Homer Hsing5d589db2012-09-21 12:35:35 +08002619 | instoption_list instoption
Xiang, Haihao27b43032010-12-13 16:07:16 +08002620 {
Homer Hsing5d589db2012-09-21 12:35:35 +08002621 $$ = $1;
2622 switch ($2) {
Xiang, Haihao27b43032010-12-13 16:07:16 +08002623 case ALIGN1:
2624 $$.header.access_mode = BRW_ALIGN_1;
2625 break;
2626 case ALIGN16:
2627 $$.header.access_mode = BRW_ALIGN_16;
2628 break;
2629 case SECHALF:
2630 $$.header.compression_control |= BRW_COMPRESSION_2NDHALF;
2631 break;
2632 case COMPR:
Gwenole Beauchesne8aa95282012-10-22 16:13:51 -04002633 if (!IS_GENp(6)) {
Xiang, Haihao27b43032010-12-13 16:07:16 +08002634 $$.header.compression_control |=
2635 BRW_COMPRESSION_COMPRESSED;
2636 }
2637 break;
2638 case SWITCH:
2639 $$.header.thread_control |= BRW_THREAD_SWITCH;
2640 break;
2641 case ATOMIC:
2642 $$.header.thread_control |= BRW_THREAD_ATOMIC;
2643 break;
2644 case NODDCHK:
2645 $$.header.dependency_control |= BRW_DEPENDENCY_NOTCHECKED;
2646 break;
2647 case NODDCLR:
2648 $$.header.dependency_control |= BRW_DEPENDENCY_NOTCLEARED;
2649 break;
2650 case MASK_DISABLE:
2651 $$.header.mask_control = BRW_MASK_DISABLE;
2652 break;
2653 case BREAKPOINT:
2654 $$.header.debug_control = BRW_DEBUG_BREAKPOINT;
Xiang, Haihao55d81c42010-10-08 13:53:22 +08002655 break;
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002656 case EOT:
Eric Anholt56c4ccf2006-08-24 14:35:10 -07002657 /* XXX: EOT shouldn't be an instoption, I don't think */
2658 $$.bits3.generic.end_of_thread = 1;
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002659 break;
2660 }
2661 }
2662 | /* empty, header defaults to zeroes. */
Eric Anholte609d6b2006-08-24 12:36:56 -07002663 {
Homer Hsing81859af2012-09-14 09:34:58 +08002664 memset(&$$, 0, sizeof($$));
Eric Anholte609d6b2006-08-24 12:36:56 -07002665 }
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002666;
Eric Anholt22a10632006-08-22 10:15:33 -07002667
Eric Anholt16324212006-08-24 14:47:21 -07002668instoption: ALIGN1 { $$ = ALIGN1; }
2669 | ALIGN16 { $$ = ALIGN16; }
Eric Anholt908f37d2006-08-25 17:33:02 -07002670 | SECHALF { $$ = SECHALF; }
2671 | COMPR { $$ = COMPR; }
2672 | SWITCH { $$ = SWITCH; }
2673 | ATOMIC { $$ = ATOMIC; }
2674 | NODDCHK { $$ = NODDCHK; }
2675 | NODDCLR { $$ = NODDCLR; }
Eric Anholt16324212006-08-24 14:47:21 -07002676 | MASK_DISABLE { $$ = MASK_DISABLE; }
Eric Anholt908f37d2006-08-25 17:33:02 -07002677 | BREAKPOINT { $$ = BREAKPOINT; }
Xiang, Haihao55d81c42010-10-08 13:53:22 +08002678 | ACCWRCTRL { $$ = ACCWRCTRL; }
Eric Anholt16324212006-08-24 14:47:21 -07002679 | EOT { $$ = EOT; }
Eric Anholt6c98c8d2006-08-22 11:54:19 -07002680;
Eric Anholt22a10632006-08-22 10:15:33 -07002681
2682%%
2683extern int yylineno;
Keith Packard2d4d4012008-03-30 00:58:28 -07002684extern char *input_filename;
2685
2686int errors;
Eric Anholt22a10632006-08-22 10:15:33 -07002687
2688void yyerror (char *msg)
2689{
Keith Packard2d4d4012008-03-30 00:58:28 -07002690 fprintf(stderr, "%s: %d: %s at \"%s\"\n",
2691 input_filename, yylineno, msg, lex_text());
2692 ++errors;
Eric Anholt22a10632006-08-22 10:15:33 -07002693}
2694
Xiang, Haihao27b43032010-12-13 16:07:16 +08002695static int get_type_size(GLuint type)
2696{
2697 int size = 1;
2698
2699 switch (type) {
2700 case BRW_REGISTER_TYPE_F:
2701 case BRW_REGISTER_TYPE_UD:
2702 case BRW_REGISTER_TYPE_D:
2703 size = 4;
2704 break;
2705
2706 case BRW_REGISTER_TYPE_UW:
2707 case BRW_REGISTER_TYPE_W:
2708 size = 2;
2709 break;
2710
2711 case BRW_REGISTER_TYPE_UB:
2712 case BRW_REGISTER_TYPE_B:
2713 size = 1;
2714 break;
2715
2716 default:
2717 assert(0);
2718 size = 1;
2719 break;
2720 }
2721
2722 return size;
2723}
2724
2725static int get_subreg_address(GLuint regfile, GLuint type, GLuint subreg, GLuint address_mode)
2726{
2727 int unit_size = 1;
2728
2729 if (address_mode == BRW_ADDRESS_DIRECT) {
2730 if (advanced_flag == 1) {
2731 if ((regfile == BRW_GENERAL_REGISTER_FILE ||
2732 regfile == BRW_MESSAGE_REGISTER_FILE ||
2733 regfile == BRW_ARCHITECTURE_REGISTER_FILE)) {
2734
2735 unit_size = get_type_size(type);
2736 }
2737 }
2738 } else {
Xiang, Haihao27b43032010-12-13 16:07:16 +08002739 unit_size = 1;
2740 }
2741
2742 return subreg * unit_size;
2743}
2744
Homer Hsinge221b0a2012-10-18 12:37:31 +08002745/* only used in indirect address mode.
2746 * input: sub-register number of an address register
2747 * output: the value of AddrSubRegNum in the instruction binary code
2748 *
2749 * input output(advanced_flag==0) output(advanced_flag==1)
2750 * a0.0 0 0
2751 * a0.1 invalid input 1
2752 * a0.2 1 2
2753 * a0.3 invalid input 3
2754 * a0.4 2 4
2755 * a0.5 invalid input 5
2756 * a0.6 3 6
2757 * a0.7 invalid input 7
2758 * a0.8 4 invalid input
2759 * a0.10 5 invalid input
2760 * a0.12 6 invalid input
2761 * a0.14 7 invalid input
2762 */
2763static int get_indirect_subreg_address(GLuint subreg)
2764{
2765 return advanced_flag == 0 ? subreg / 2 : subreg;
2766}
2767
Xiang, Haihao27b43032010-12-13 16:07:16 +08002768static void reset_instruction_src_region(struct brw_instruction *instr,
2769 struct src_operand *src)
2770{
2771 if (!src->default_region)
2772 return;
2773
2774 if (src->reg_file == BRW_ARCHITECTURE_REGISTER_FILE &&
2775 ((src->reg_nr & 0xF0) == BRW_ARF_ADDRESS)) {
2776 src->vert_stride = ffs(0);
2777 src->width = ffs(1) - 1;
2778 src->horiz_stride = ffs(0);
2779 } else if (src->reg_file == BRW_ARCHITECTURE_REGISTER_FILE &&
2780 ((src->reg_nr & 0xF0) == BRW_ARF_ACCUMULATOR)) {
2781 int horiz_stride = 1, width, vert_stride;
2782 if (instr->header.compression_control == BRW_COMPRESSION_COMPRESSED) {
2783 width = 16;
2784 } else {
2785 width = 8;
2786 }
2787
2788 if (width > (1 << instr->header.execution_size))
2789 width = (1 << instr->header.execution_size);
2790
2791 vert_stride = horiz_stride * width;
2792 src->vert_stride = ffs(vert_stride);
2793 src->width = ffs(width) - 1;
2794 src->horiz_stride = ffs(horiz_stride);
2795 } else if ((src->reg_file == BRW_ARCHITECTURE_REGISTER_FILE) &&
2796 (src->reg_nr == BRW_ARF_NULL) &&
2797 (instr->header.opcode == BRW_OPCODE_SEND)) {
2798 src->vert_stride = ffs(8);
2799 src->width = ffs(8) - 1;
2800 src->horiz_stride = ffs(1);
2801 } else {
2802
2803 int horiz_stride = 1, width, vert_stride;
2804
2805 if (instr->header.execution_size == 0) { /* scalar */
2806 horiz_stride = 0;
2807 width = 1;
2808 vert_stride = 0;
2809 } else {
2810 if ((instr->header.opcode == BRW_OPCODE_MUL) ||
2811 (instr->header.opcode == BRW_OPCODE_MAC) ||
2812 (instr->header.opcode == BRW_OPCODE_CMP) ||
2813 (instr->header.opcode == BRW_OPCODE_ASR) ||
2814 (instr->header.opcode == BRW_OPCODE_ADD) ||
2815 (instr->header.opcode == BRW_OPCODE_SHL)) {
2816 horiz_stride = 0;
2817 width = 1;
2818 vert_stride = 0;
2819 } else {
2820 width = (1 << instr->header.execution_size) / horiz_stride;
2821 vert_stride = horiz_stride * width;
Xiang, Haihaoe7f4dc62011-03-01 16:43:02 +08002822
2823 if (get_type_size(src->reg_type) * (width + src->subreg_nr) > 32) {
2824 horiz_stride = 0;
2825 width = 1;
2826 vert_stride = 0;
2827 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08002828 }
2829 }
2830
2831 src->vert_stride = ffs(vert_stride);
2832 src->width = ffs(width) - 1;
2833 src->horiz_stride = ffs(horiz_stride);
2834 }
2835}
2836
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002837/**
2838 * Fills in the destination register information in instr from the bits in dst.
2839 */
Eric Anholt2dac0a12006-08-29 15:29:31 -07002840int set_instruction_dest(struct brw_instruction *instr,
2841 struct dst_operand *dest)
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002842{
Xiang, Haihao27b43032010-12-13 16:07:16 +08002843 if (dest->horiz_stride == DEFAULT_DSTREGION)
2844 dest->horiz_stride = ffs(1);
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002845 if (dest->address_mode == BRW_ADDRESS_DIRECT &&
2846 instr->header.access_mode == BRW_ALIGN_1) {
Eric Anholt2dac0a12006-08-29 15:29:31 -07002847 instr->bits1.da1.dest_reg_file = dest->reg_file;
2848 instr->bits1.da1.dest_reg_type = dest->reg_type;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002849 instr->bits1.da1.dest_subreg_nr = get_subreg_address(dest->reg_file, dest->reg_type, dest->subreg_nr, dest->address_mode);
Eric Anholt2dac0a12006-08-29 15:29:31 -07002850 instr->bits1.da1.dest_reg_nr = dest->reg_nr;
2851 instr->bits1.da1.dest_horiz_stride = dest->horiz_stride;
2852 instr->bits1.da1.dest_address_mode = dest->address_mode;
2853 if (dest->writemask_set) {
2854 fprintf(stderr, "error: write mask set in align1 "
2855 "instruction\n");
2856 return 1;
2857 }
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002858 } else if (dest->address_mode == BRW_ADDRESS_DIRECT) {
Eric Anholt2dac0a12006-08-29 15:29:31 -07002859 instr->bits1.da16.dest_reg_file = dest->reg_file;
2860 instr->bits1.da16.dest_reg_type = dest->reg_type;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002861 instr->bits1.da16.dest_subreg_nr = get_subreg_address(dest->reg_file, dest->reg_type, dest->subreg_nr, dest->address_mode);
Eric Anholt2dac0a12006-08-29 15:29:31 -07002862 instr->bits1.da16.dest_reg_nr = dest->reg_nr;
2863 instr->bits1.da16.dest_address_mode = dest->address_mode;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002864 instr->bits1.da16.dest_horiz_stride = ffs(1);
Eric Anholt2dac0a12006-08-29 15:29:31 -07002865 instr->bits1.da16.dest_writemask = dest->writemask;
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002866 } else if (instr->header.access_mode == BRW_ALIGN_1) {
2867 instr->bits1.ia1.dest_reg_file = dest->reg_file;
2868 instr->bits1.ia1.dest_reg_type = dest->reg_type;
Homer Hsinge221b0a2012-10-18 12:37:31 +08002869 instr->bits1.ia1.dest_subreg_nr = get_indirect_subreg_address(dest->address_subreg_nr);
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002870 instr->bits1.ia1.dest_horiz_stride = dest->horiz_stride;
2871 instr->bits1.ia1.dest_indirect_offset = dest->indirect_offset;
2872 instr->bits1.ia1.dest_address_mode = dest->address_mode;
2873 if (dest->writemask_set) {
2874 fprintf(stderr, "error: write mask set in align1 "
2875 "instruction\n");
2876 return 1;
2877 }
2878 } else {
2879 instr->bits1.ia16.dest_reg_file = dest->reg_file;
2880 instr->bits1.ia16.dest_reg_type = dest->reg_type;
Homer Hsinge221b0a2012-10-18 12:37:31 +08002881 instr->bits1.ia16.dest_subreg_nr = get_indirect_subreg_address(dest->address_subreg_nr);
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002882 instr->bits1.ia16.dest_writemask = dest->writemask;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002883 instr->bits1.ia16.dest_horiz_stride = ffs(1);
2884 instr->bits1.ia16.dest_indirect_offset = (dest->indirect_offset >> 4); /* half register aligned */
Eric Anholt3bcf6b22006-08-29 18:31:34 -07002885 instr->bits1.ia16.dest_address_mode = dest->address_mode;
Eric Anholt2dac0a12006-08-29 15:29:31 -07002886 }
2887
2888 return 0;
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002889}
2890
Eric Anholt6a88ada2006-08-28 22:11:18 -07002891/* Sets the first source operand for the instruction. Returns 0 on success. */
2892int set_instruction_src0(struct brw_instruction *instr,
2893 struct src_operand *src)
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002894{
Xiang, Haihao27b43032010-12-13 16:07:16 +08002895 if (advanced_flag) {
2896 reset_instruction_src_region(instr, src);
2897 }
Eric Anholt6a88ada2006-08-28 22:11:18 -07002898 instr->bits1.da1.src0_reg_file = src->reg_file;
2899 instr->bits1.da1.src0_reg_type = src->reg_type;
2900 if (src->reg_file == BRW_IMMEDIATE_VALUE) {
2901 instr->bits3.ud = src->imm32;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002902 } else if (src->address_mode == BRW_ADDRESS_DIRECT) {
2903 if (instr->header.access_mode == BRW_ALIGN_1) {
2904 instr->bits2.da1.src0_subreg_nr = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode);
Eric Anholt6a88ada2006-08-28 22:11:18 -07002905 instr->bits2.da1.src0_reg_nr = src->reg_nr;
2906 instr->bits2.da1.src0_vert_stride = src->vert_stride;
2907 instr->bits2.da1.src0_width = src->width;
2908 instr->bits2.da1.src0_horiz_stride = src->horiz_stride;
2909 instr->bits2.da1.src0_negate = src->negate;
2910 instr->bits2.da1.src0_abs = src->abs;
2911 instr->bits2.da1.src0_address_mode = src->address_mode;
2912 if (src->swizzle_set) {
2913 fprintf(stderr, "error: swizzle bits set in align1 "
2914 "instruction\n");
2915 return 1;
2916 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08002917 } else {
2918 instr->bits2.da16.src0_subreg_nr = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode);
Eric Anholt6a88ada2006-08-28 22:11:18 -07002919 instr->bits2.da16.src0_reg_nr = src->reg_nr;
2920 instr->bits2.da16.src0_vert_stride = src->vert_stride;
2921 instr->bits2.da16.src0_negate = src->negate;
2922 instr->bits2.da16.src0_abs = src->abs;
2923 instr->bits2.da16.src0_swz_x = src->swizzle_x;
2924 instr->bits2.da16.src0_swz_y = src->swizzle_y;
2925 instr->bits2.da16.src0_swz_z = src->swizzle_z;
2926 instr->bits2.da16.src0_swz_w = src->swizzle_w;
2927 instr->bits2.da16.src0_address_mode = src->address_mode;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002928 }
2929 } else {
2930 if (instr->header.access_mode == BRW_ALIGN_1) {
2931 instr->bits2.ia1.src0_indirect_offset = src->indirect_offset;
Homer Hsinge221b0a2012-10-18 12:37:31 +08002932 instr->bits2.ia1.src0_subreg_nr = get_indirect_subreg_address(src->address_subreg_nr);
Xiang, Haihao27b43032010-12-13 16:07:16 +08002933 instr->bits2.ia1.src0_abs = src->abs;
2934 instr->bits2.ia1.src0_negate = src->negate;
2935 instr->bits2.ia1.src0_address_mode = src->address_mode;
2936 instr->bits2.ia1.src0_horiz_stride = src->horiz_stride;
2937 instr->bits2.ia1.src0_width = src->width;
2938 instr->bits2.ia1.src0_vert_stride = src->vert_stride;
2939 if (src->swizzle_set) {
2940 fprintf(stderr, "error: swizzle bits set in align1 "
2941 "instruction\n");
2942 return 1;
2943 }
2944 } else {
2945 instr->bits2.ia16.src0_swz_x = src->swizzle_x;
2946 instr->bits2.ia16.src0_swz_y = src->swizzle_y;
2947 instr->bits2.ia16.src0_indirect_offset = (src->indirect_offset >> 4); /* half register aligned */
Homer Hsinge221b0a2012-10-18 12:37:31 +08002948 instr->bits2.ia16.src0_subreg_nr = get_indirect_subreg_address(src->address_subreg_nr);
Xiang, Haihao27b43032010-12-13 16:07:16 +08002949 instr->bits2.ia16.src0_abs = src->abs;
2950 instr->bits2.ia16.src0_negate = src->negate;
2951 instr->bits2.ia16.src0_address_mode = src->address_mode;
2952 instr->bits2.ia16.src0_swz_z = src->swizzle_z;
2953 instr->bits2.ia16.src0_swz_w = src->swizzle_w;
2954 instr->bits2.ia16.src0_vert_stride = src->vert_stride;
2955 }
2956 }
Eric Anholt6a88ada2006-08-28 22:11:18 -07002957
2958 return 0;
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002959}
2960
Eric Anholt6a88ada2006-08-28 22:11:18 -07002961/* Sets the second source operand for the instruction. Returns 0 on success.
2962 */
2963int set_instruction_src1(struct brw_instruction *instr,
2964 struct src_operand *src)
Eric Anholt19f1c1c2006-08-22 12:41:09 -07002965{
Xiang, Haihao27b43032010-12-13 16:07:16 +08002966 if (advanced_flag) {
2967 reset_instruction_src_region(instr, src);
2968 }
Eric Anholt6a88ada2006-08-28 22:11:18 -07002969 instr->bits1.da1.src1_reg_file = src->reg_file;
2970 instr->bits1.da1.src1_reg_type = src->reg_type;
2971 if (src->reg_file == BRW_IMMEDIATE_VALUE) {
2972 instr->bits3.ud = src->imm32;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002973 } else if (src->address_mode == BRW_ADDRESS_DIRECT) {
2974 if (instr->header.access_mode == BRW_ALIGN_1) {
2975 instr->bits3.da1.src1_subreg_nr = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode);
Eric Anholt6a88ada2006-08-28 22:11:18 -07002976 instr->bits3.da1.src1_reg_nr = src->reg_nr;
2977 instr->bits3.da1.src1_vert_stride = src->vert_stride;
2978 instr->bits3.da1.src1_width = src->width;
2979 instr->bits3.da1.src1_horiz_stride = src->horiz_stride;
2980 instr->bits3.da1.src1_negate = src->negate;
2981 instr->bits3.da1.src1_abs = src->abs;
Xiang, Haihao27b43032010-12-13 16:07:16 +08002982 instr->bits3.da1.src1_address_mode = src->address_mode;
2983 /* XXX why?
Eric Anholt6a88ada2006-08-28 22:11:18 -07002984 if (src->address_mode != BRW_ADDRESS_DIRECT) {
2985 fprintf(stderr, "error: swizzle bits set in align1 "
2986 "instruction\n");
2987 return 1;
2988 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08002989 */
Eric Anholt6a88ada2006-08-28 22:11:18 -07002990 if (src->swizzle_set) {
2991 fprintf(stderr, "error: swizzle bits set in align1 "
2992 "instruction\n");
2993 return 1;
2994 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08002995 } else {
2996 instr->bits3.da16.src1_subreg_nr = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode);
Eric Anholt6a88ada2006-08-28 22:11:18 -07002997 instr->bits3.da16.src1_reg_nr = src->reg_nr;
2998 instr->bits3.da16.src1_vert_stride = src->vert_stride;
2999 instr->bits3.da16.src1_negate = src->negate;
3000 instr->bits3.da16.src1_abs = src->abs;
3001 instr->bits3.da16.src1_swz_x = src->swizzle_x;
3002 instr->bits3.da16.src1_swz_y = src->swizzle_y;
3003 instr->bits3.da16.src1_swz_z = src->swizzle_z;
3004 instr->bits3.da16.src1_swz_w = src->swizzle_w;
Xiang, Haihao27b43032010-12-13 16:07:16 +08003005 instr->bits3.da16.src1_address_mode = src->address_mode;
Eric Anholt6a88ada2006-08-28 22:11:18 -07003006 if (src->address_mode != BRW_ADDRESS_DIRECT) {
3007 fprintf(stderr, "error: swizzle bits set in align1 "
3008 "instruction\n");
3009 return 1;
3010 }
Xiang, Haihao27b43032010-12-13 16:07:16 +08003011 }
3012 } else {
3013 if (instr->header.access_mode == BRW_ALIGN_1) {
3014 instr->bits3.ia1.src1_indirect_offset = src->indirect_offset;
Homer Hsinge221b0a2012-10-18 12:37:31 +08003015 instr->bits3.ia1.src1_subreg_nr = get_indirect_subreg_address(src->address_subreg_nr);
Xiang, Haihao27b43032010-12-13 16:07:16 +08003016 instr->bits3.ia1.src1_abs = src->abs;
3017 instr->bits3.ia1.src1_negate = src->negate;
3018 instr->bits3.ia1.src1_address_mode = src->address_mode;
3019 instr->bits3.ia1.src1_horiz_stride = src->horiz_stride;
3020 instr->bits3.ia1.src1_width = src->width;
3021 instr->bits3.ia1.src1_vert_stride = src->vert_stride;
3022 if (src->swizzle_set) {
3023 fprintf(stderr, "error: swizzle bits set in align1 "
3024 "instruction\n");
3025 return 1;
3026 }
3027 } else {
3028 instr->bits3.ia16.src1_swz_x = src->swizzle_x;
3029 instr->bits3.ia16.src1_swz_y = src->swizzle_y;
3030 instr->bits3.ia16.src1_indirect_offset = (src->indirect_offset >> 4); /* half register aligned */
Homer Hsinge221b0a2012-10-18 12:37:31 +08003031 instr->bits3.ia16.src1_subreg_nr = get_indirect_subreg_address(src->address_subreg_nr);
Xiang, Haihao27b43032010-12-13 16:07:16 +08003032 instr->bits3.ia16.src1_abs = src->abs;
3033 instr->bits3.ia16.src1_negate = src->negate;
3034 instr->bits3.ia16.src1_address_mode = src->address_mode;
3035 instr->bits3.ia16.src1_swz_z = src->swizzle_z;
3036 instr->bits3.ia16.src1_swz_w = src->swizzle_w;
3037 instr->bits3.ia16.src1_vert_stride = src->vert_stride;
3038 }
3039 }
Eric Anholt6a88ada2006-08-28 22:11:18 -07003040
3041 return 0;
Eric Anholt19f1c1c2006-08-22 12:41:09 -07003042}
3043
Homer Hsinga034bcb2012-09-07 14:38:13 +08003044/* convert 2-src reg type to 3-src reg type
3045 *
3046 * 2-src reg type:
3047 * 000=UD 001=D 010=UW 011=W 100=UB 101=B 110=DF 111=F
3048 *
3049 * 3-src reg type:
3050 * 00=F 01=D 10=UD 11=DF
3051 */
3052static int reg_type_2_to_3(int reg_type)
3053{
3054 int r = 0;
3055 switch(reg_type) {
3056 case 7: r = 0; break;
3057 case 1: r = 1; break;
3058 case 0: r = 2; break;
3059 // TODO: supporting DF
3060 }
3061 return r;
3062}
3063
3064int set_instruction_dest_three_src(struct brw_instruction *instr,
3065 struct dst_operand *dest)
3066{
Damien Lespiau31259c52013-01-15 14:05:23 +00003067 instr->bits1.da3src.dest_reg_file = dest->reg_file;
3068 instr->bits1.da3src.dest_reg_nr = dest->reg_nr;
3069 instr->bits1.da3src.dest_subreg_nr = get_subreg_address(dest->reg_file, dest->reg_type, dest->subreg_nr, dest->address_mode) / 4; // in DWORD
3070 instr->bits1.da3src.dest_writemask = dest->writemask;
3071 instr->bits1.da3src.dest_reg_type = reg_type_2_to_3(dest->reg_type);
Homer Hsinga034bcb2012-09-07 14:38:13 +08003072 return 0;
3073}
3074
3075int set_instruction_src0_three_src(struct brw_instruction *instr,
3076 struct src_operand *src)
3077{
3078 if (advanced_flag) {
3079 reset_instruction_src_region(instr, src);
3080 }
3081 // TODO: supporting src0 swizzle, src0 modifier, src0 rep_ctrl
Damien Lespiau31259c52013-01-15 14:05:23 +00003082 instr->bits1.da3src.src_reg_type = reg_type_2_to_3(src->reg_type);
3083 instr->bits2.da3src.src0_subreg_nr = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode) / 4; // in DWORD
3084 instr->bits2.da3src.src0_reg_nr = src->reg_nr;
Homer Hsinga034bcb2012-09-07 14:38:13 +08003085 return 0;
3086}
3087
3088int set_instruction_src1_three_src(struct brw_instruction *instr,
3089 struct src_operand *src)
3090{
3091 if (advanced_flag) {
3092 reset_instruction_src_region(instr, src);
3093 }
3094 // TODO: supporting src1 swizzle, src1 modifier, src1 rep_ctrl
3095 int v = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode) / 4; // in DWORD
Damien Lespiau31259c52013-01-15 14:05:23 +00003096 instr->bits2.da3src.src1_subreg_nr_low = v % 4; // lower 2 bits
3097 instr->bits3.da3src.src1_subreg_nr_high = v / 4; // highest bit
3098 instr->bits3.da3src.src1_reg_nr = src->reg_nr;
Homer Hsinga034bcb2012-09-07 14:38:13 +08003099 return 0;
3100}
3101
3102int set_instruction_src2_three_src(struct brw_instruction *instr,
3103 struct src_operand *src)
3104{
3105 if (advanced_flag) {
3106 reset_instruction_src_region(instr, src);
3107 }
3108 // TODO: supporting src2 swizzle, src2 modifier, src2 rep_ctrl
Damien Lespiau31259c52013-01-15 14:05:23 +00003109 instr->bits3.da3src.src2_subreg_nr = get_subreg_address(src->reg_file, src->reg_type, src->subreg_nr, src->address_mode) / 4; // in DWORD
3110 instr->bits3.da3src.src2_reg_nr = src->reg_nr;
Homer Hsinga034bcb2012-09-07 14:38:13 +08003111 return 0;
3112}
3113
Eric Anholt19f1c1c2006-08-22 12:41:09 -07003114void set_instruction_options(struct brw_instruction *instr,
3115 struct brw_instruction *options)
3116{
Eric Anholt6a88ada2006-08-28 22:11:18 -07003117 /* XXX: more instr options */
Eric Anholt19f1c1c2006-08-22 12:41:09 -07003118 instr->header.access_mode = options->header.access_mode;
3119 instr->header.mask_control = options->header.mask_control;
3120 instr->header.dependency_control = options->header.dependency_control;
3121 instr->header.compression_control =
3122 options->header.compression_control;
3123}
Eric Anholt2c787652006-08-25 13:53:48 -07003124
Eric Anholt0ed5d932006-08-28 23:05:51 -07003125void set_instruction_predicate(struct brw_instruction *instr,
3126 struct brw_instruction *predicate)
3127{
3128 instr->header.predicate_control = predicate->header.predicate_control;
3129 instr->header.predicate_inverse = predicate->header.predicate_inverse;
Xiang, Haihao3ffbe962012-07-17 15:05:31 +08003130 instr->bits2.da1.flag_reg_nr = predicate->bits2.da1.flag_reg_nr;
Xiang, Haihao2f772dd2012-07-17 14:18:54 +08003131 instr->bits2.da1.flag_subreg_nr = predicate->bits2.da1.flag_subreg_nr;
Eric Anholt0ed5d932006-08-28 23:05:51 -07003132}
3133
Eric Anholt1e907c72006-08-31 10:21:15 -07003134void set_direct_dst_operand(struct dst_operand *dst, struct direct_reg *reg,
3135 int type)
3136{
Homer Hsing81859af2012-09-14 09:34:58 +08003137 memset(dst, 0, sizeof(*dst));
Eric Anholt1e907c72006-08-31 10:21:15 -07003138 dst->address_mode = BRW_ADDRESS_DIRECT;
3139 dst->reg_file = reg->reg_file;
3140 dst->reg_nr = reg->reg_nr;
3141 dst->subreg_nr = reg->subreg_nr;
3142 dst->reg_type = type;
3143 dst->horiz_stride = 1;
3144 dst->writemask_set = 0;
3145 dst->writemask = 0xf;
3146}
3147
Eric Anholt3bcf6b22006-08-29 18:31:34 -07003148void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg,
3149 int type)
Eric Anholt2c787652006-08-25 13:53:48 -07003150{
Homer Hsing81859af2012-09-14 09:34:58 +08003151 memset(src, 0, sizeof(*src));
Eric Anholt1e907c72006-08-31 10:21:15 -07003152 src->address_mode = BRW_ADDRESS_DIRECT;
Eric Anholt6a88ada2006-08-28 22:11:18 -07003153 src->reg_file = reg->reg_file;
3154 src->reg_type = type;
3155 src->subreg_nr = reg->subreg_nr;
3156 src->reg_nr = reg->reg_nr;
3157 src->vert_stride = 0;
3158 src->width = 0;
Keith Packard2033aea2008-04-23 23:10:40 -07003159 src->horiz_stride = 0;
Eric Anholt6a88ada2006-08-28 22:11:18 -07003160 src->negate = 0;
3161 src->abs = 0;
Eric Anholt1e907c72006-08-31 10:21:15 -07003162 src->swizzle_set = 0;
3163 src->swizzle_x = BRW_CHANNEL_X;
3164 src->swizzle_y = BRW_CHANNEL_Y;
3165 src->swizzle_z = BRW_CHANNEL_Z;
3166 src->swizzle_w = BRW_CHANNEL_W;
Eric Anholt2c787652006-08-25 13:53:48 -07003167}