3 * Copyright © 2018 Intel Corporation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
31 #define YYLTYPE YYLTYPE
32 typedef struct YYLTYPE
48 message(enum message_level level, YYLTYPE *location,
51 static const char *level_str[] = { "warning", "error" };
55 fprintf(stderr, "%s:%d:%d: %s: ", input_filename,
57 location->first_column, level_str[level]);
59 fprintf(stderr, "%s:%s: ", input_filename, level_str[level]);
62 vfprintf(stderr, fmt, args);
66 #define warn(flag, l, fmt, ...) \
68 if (warning_flags & WARN_ ## flag) \
69 message(WARN, l, fmt, ## __VA_ARGS__); \
72 #define error(l, fmt, ...) \
74 message(ERROR, l, fmt, ## __VA_ARGS__); \
78 isPowerofTwo(unsigned int x)
80 return x && (!(x & (x - 1)));
84 set_direct_src_operand(struct brw_reg *reg, int type)
86 return brw_reg(reg->file,
100 i965_asm_unary_instruction(int opcode, struct brw_codegen *p,
101 struct brw_reg dest, struct brw_reg src0)
104 case BRW_OPCODE_BFREV:
105 brw_BFREV(p, dest, src0);
107 case BRW_OPCODE_CBIT:
108 brw_CBIT(p, dest, src0);
110 case BRW_OPCODE_F32TO16:
111 brw_F32TO16(p, dest, src0);
113 case BRW_OPCODE_F16TO32:
114 brw_F16TO32(p, dest, src0);
117 brw_MOV(p, dest, src0);
120 brw_FBL(p, dest, src0);
123 brw_FRC(p, dest, src0);
126 brw_FBH(p, dest, src0);
129 brw_NOT(p, dest, src0);
131 case BRW_OPCODE_RNDE:
132 brw_RNDE(p, dest, src0);
134 case BRW_OPCODE_RNDZ:
135 brw_RNDZ(p, dest, src0);
137 case BRW_OPCODE_RNDD:
138 brw_RNDD(p, dest, src0);
141 brw_LZD(p, dest, src0);
144 brw_DIM(p, dest, src0);
146 case BRW_OPCODE_RNDU:
147 fprintf(stderr, "Opcode BRW_OPCODE_RNDU unhandled\n");
150 fprintf(stderr, "Unsupported unary opcode\n");
155 i965_asm_binary_instruction(int opcode,
156 struct brw_codegen *p,
162 case BRW_OPCODE_ADDC:
163 brw_ADDC(p, dest, src0, src1);
165 case BRW_OPCODE_BFI1:
166 brw_BFI1(p, dest, src0, src1);
169 brw_DP2(p, dest, src0, src1);
172 brw_DP3(p, dest, src0, src1);
175 brw_DP4(p, dest, src0, src1);
178 brw_DPH(p, dest, src0, src1);
180 case BRW_OPCODE_LINE:
181 brw_LINE(p, dest, src0, src1);
184 brw_MAC(p, dest, src0, src1);
186 case BRW_OPCODE_MACH:
187 brw_MACH(p, dest, src0, src1);
190 brw_PLN(p, dest, src0, src1);
193 brw_ROL(p, dest, src0, src1);
196 brw_ROR(p, dest, src0, src1);
198 case BRW_OPCODE_SAD2:
199 fprintf(stderr, "Opcode BRW_OPCODE_SAD2 unhandled\n");
201 case BRW_OPCODE_SADA2:
202 fprintf(stderr, "Opcode BRW_OPCODE_SADA2 unhandled\n");
204 case BRW_OPCODE_SUBB:
205 brw_SUBB(p, dest, src0, src1);
208 brw_ADD(p, dest, src0, src1);
211 /* Third parameter is conditional modifier
212 * which gets updated later
214 brw_CMP(p, dest, 0, src0, src1);
217 brw_AND(p, dest, src0, src1);
220 brw_ASR(p, dest, src0, src1);
223 brw_AVG(p, dest, src0, src1);
226 brw_OR(p, dest, src0, src1);
229 brw_SEL(p, dest, src0, src1);
232 brw_SHL(p, dest, src0, src1);
235 brw_SHR(p, dest, src0, src1);
238 brw_XOR(p, dest, src0, src1);
241 brw_MUL(p, dest, src0, src1);
244 fprintf(stderr, "Unsupported binary opcode\n");
249 i965_asm_ternary_instruction(int opcode,
250 struct brw_codegen *p,
258 brw_MAD(p, dest, src0, src1, src2);
260 case BRW_OPCODE_CSEL:
261 brw_CSEL(p, dest, src0, src1, src2);
264 brw_LRP(p, dest, src0, src1, src2);
267 brw_BFE(p, dest, src0, src1, src2);
269 case BRW_OPCODE_BFI2:
270 brw_BFI2(p, dest, src0, src1, src2);
273 fprintf(stderr, "Unsupported ternary opcode\n");
278 i965_asm_set_instruction_options(struct brw_codegen *p,
279 struct options options)
281 brw_inst_set_access_mode(p->devinfo, brw_last_inst,
282 options.access_mode);
283 brw_inst_set_mask_control(p->devinfo, brw_last_inst,
284 options.mask_control);
285 brw_inst_set_thread_control(p->devinfo, brw_last_inst,
286 options.thread_control);
287 brw_inst_set_no_dd_check(p->devinfo, brw_last_inst,
288 options.no_dd_check);
289 brw_inst_set_no_dd_clear(p->devinfo, brw_last_inst,
290 options.no_dd_clear);
291 brw_inst_set_debug_control(p->devinfo, brw_last_inst,
292 options.debug_control);
293 if (p->devinfo->gen >= 6)
294 brw_inst_set_acc_wr_control(p->devinfo, brw_last_inst,
295 options.acc_wr_control);
296 brw_inst_set_cmpt_control(p->devinfo, brw_last_inst,
301 i965_asm_set_dst_nr(struct brw_codegen *p,
303 struct options options)
305 if (p->devinfo->gen <= 6) {
306 if (reg->file == BRW_MESSAGE_REGISTER_FILE &&
307 options.qtr_ctrl == BRW_COMPRESSION_COMPRESSED &&
309 reg->nr |= BRW_MRF_COMPR4;
322 unsigned long long int llint;
324 struct brw_codegen *program;
325 struct predicate predicate;
326 struct condition condition;
327 struct options options;
328 brw_inst *instruction;
338 %token LSQUARE RSQUARE
343 %token <integer> TYPE_B TYPE_UB
344 %token <integer> TYPE_W TYPE_UW
345 %token <integer> TYPE_D TYPE_UD
346 %token <integer> TYPE_Q TYPE_UQ
347 %token <integer> TYPE_V TYPE_UV
348 %token <integer> TYPE_F TYPE_HF
349 %token <integer> TYPE_DF TYPE_NF
350 %token <integer> TYPE_VF
353 %token <integer> ADD ADD3 ADDC AND ASR AVG
354 %token <integer> BFE BFI1 BFI2 BFB BFREV BRC BRD BREAK
355 %token <integer> CALL CALLA CASE CBIT CMP CMPN CONT CSEL
356 %token <integer> DIM DO DPAS DPASW DP2 DP3 DP4 DP4A DPH
357 %token <integer> ELSE ENDIF F16TO32 F32TO16 FBH FBL FORK FRC
358 %token <integer> GOTO
359 %token <integer> HALT
360 %token <integer> IF IFF ILLEGAL
361 %token <integer> JMPI JOIN
362 %token <integer> LINE LRP LZD
363 %token <integer> MAC MACH MAD MADM MOV MOVI MUL MREST MSAVE
364 %token <integer> NENOP NOP NOT
366 %token <integer> PLN POP PUSH
367 %token <integer> RET RNDD RNDE RNDU RNDZ ROL ROR
368 %token <integer> SAD2 SADA2 SEL SEND SENDC SENDS SENDSC SHL SHR SMOV SUBB SYNC
369 %token <integer> WAIT WHILE
372 /* extended math functions */
373 %token <integer> COS EXP FDIV INV INVM INTDIV INTDIVMOD INTMOD LOG POW RSQ
374 %token <integer> RSQRTM SIN SINCOS SQRT
376 /* shared functions for send */
377 %token CONST CRE DATA DP_DATA_1 GATEWAY MATH PIXEL_INTERP READ RENDER SAMPLER
378 %token THREAD_SPAWNER URB VME WRITE DP_SAMPLER
380 /* Conditional modifiers */
381 %token <integer> EQUAL GREATER GREATER_EQUAL LESS LESS_EQUAL NOT_EQUAL
382 %token <integer> NOT_ZERO OVERFLOW UNORDERED ZERO
384 /* register Access Modes */
385 %token ALIGN1 ALIGN16
387 /* accumulator write control */
390 /* compaction control */
393 /* compression control */
394 %token COMPR COMPR4 SECHALF
396 /* mask control (WeCtrl) */
402 /* dependency control */
403 %token NODDCLR NODDCHK
411 /* predicate control */
412 %token <integer> ANYV ALLV ANY2H ALL2H ANY4H ALL4H ANY8H ALL8H ANY16H ALL16H
413 %token <integer> ANY32H ALL32H
415 /* round instructions */
416 %token <integer> ROUND_INCREMENT
425 %token QTR_2Q QTR_3Q QTR_4Q QTR_2H QTR_2N QTR_3N QTR_4N QTR_5N
426 %token QTR_6N QTR_7N QTR_8N
429 %token <integer> X Y Z W
432 %token GENREGFILE MSGREGFILE
434 /* vertical stride in register region */
438 %token <integer> GENREG MSGREG ADDRREG ACCREG FLAGREG NOTIFYREG STATEREG
439 %token <integer> CONTROLREG IPREG PERFORMANCEREG THREADREG CHANNELENABLEREG
440 %token <integer> MASKREG
442 %token <integer> INTEGER
446 %precedence SUBREGNUM
449 %precedence EMPTYEXECSIZE
452 %type <integer> execsize simple_int exp
455 /* predicate control */
456 %type <integer> predctrl predstate
457 %type <predicate> predicate
459 /* conditional modifier */
460 %type <condition> cond_mod
461 %type <integer> condModifiers
463 /* instruction options */
464 %type <options> instoptions instoption_list
465 %type <integer> instoption
468 %type <integer> writemask_x writemask_y writemask_z writemask_w
469 %type <reg> writemask
472 %type <reg> dst dstoperand dstoperandex dstoperandex_typed dstreg dsttype
473 %type <integer> dstregion
475 %type <integer> saturate relativelocation rellocation
476 %type <reg> relativelocation2
479 %type <reg> directsrcoperand directsrcaccoperand indirectsrcoperand srcacc
480 %type <reg> srcarcoperandex srcaccimm srcarcoperandex_typed srctype srcimm
481 %type <reg> srcimmtype indirectgenreg indirectregion
482 %type <reg> immreg src reg32 payload directgenreg_list addrparam region
483 %type <reg> region_wh swizzle directgenreg directmsgreg indirectmsgreg
486 %type <reg> accreg addrreg channelenablereg controlreg flagreg ipreg
487 %type <reg> notifyreg nullreg performancereg threadcontrolreg statereg maskreg
488 %type <integer> subregnum
490 /* immediate values */
493 /* instruction opcodes */
494 %type <integer> unaryopcodes binaryopcodes binaryaccopcodes ternaryopcodes
495 %type <integer> sendop
496 %type <instruction> sendopcode
498 %type <integer> negate abs chansel math_function sharedfunction
503 add_instruction_option(struct options *options, int option)
507 options->access_mode = BRW_ALIGN_1;
510 options->access_mode = BRW_ALIGN_16;
513 options->qtr_ctrl |= BRW_COMPRESSION_2NDHALF;
516 options->qtr_ctrl |= BRW_COMPRESSION_COMPRESSED;
517 options->is_compr = true;
520 options->qtr_ctrl |= BRW_COMPRESSION_COMPRESSED;
523 options->thread_control |= BRW_THREAD_SWITCH;
526 options->thread_control |= BRW_THREAD_ATOMIC;
529 options->no_dd_check = true;
532 options->no_dd_clear = BRW_DEPENDENCY_NOTCLEARED;
535 options->mask_control |= BRW_MASK_DISABLE;
538 options->debug_control = BRW_DEBUG_BREAKPOINT;
541 options->mask_control |= BRW_WE_ALL;
544 options->compaction = true;
547 options->acc_wr_control = true;
550 options->end_of_thread = true;
552 /* TODO : Figure out how to set instruction group and get rid of
556 options->qtr_ctrl = BRW_COMPRESSION_2NDHALF;
559 options->qtr_ctrl = BRW_COMPRESSION_COMPRESSED;
562 options->qtr_ctrl = 3;
565 options->qtr_ctrl = BRW_COMPRESSION_COMPRESSED;
568 options->qtr_ctrl = BRW_COMPRESSION_NONE;
569 options->nib_ctrl = true;
572 options->qtr_ctrl = BRW_COMPRESSION_2NDHALF;
575 options->qtr_ctrl = BRW_COMPRESSION_2NDHALF;
576 options->nib_ctrl = true;
579 options->qtr_ctrl = BRW_COMPRESSION_COMPRESSED;
582 options->qtr_ctrl = BRW_COMPRESSION_COMPRESSED;
583 options->nib_ctrl = true;
586 options->qtr_ctrl = 3;
589 options->qtr_ctrl = 3;
590 options->nib_ctrl = true;
602 instrseq instruction SEMICOLON
603 | instrseq relocatableinstruction SEMICOLON
604 | instruction SEMICOLON
605 | relocatableinstruction SEMICOLON
608 /* Instruction Group */
612 | binaryaccinstruction
621 relocatableinstruction:
629 ILLEGAL execsize instoptions
631 brw_next_insn(p, $1);
632 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $2);
633 i965_asm_set_instruction_options(p, $3);
637 /* Unary instruction */
639 predicate unaryopcodes saturate cond_mod execsize dst srcaccimm instoptions
641 i965_asm_set_dst_nr(p, &$6, $8);
642 brw_set_default_access_mode(p, $8.access_mode);
643 i965_asm_unary_instruction($2, p, $6, $7);
644 brw_pop_insn_state(p);
645 i965_asm_set_instruction_options(p, $8);
646 brw_inst_set_cond_modifier(p->devinfo, brw_last_inst,
649 if (p->devinfo->gen >= 7) {
650 if ($2 != BRW_OPCODE_DIM) {
651 brw_inst_set_flag_reg_nr(p->devinfo,
654 brw_inst_set_flag_subreg_nr(p->devinfo,
660 if ($7.file != BRW_IMMEDIATE_VALUE) {
661 brw_inst_set_src0_vstride(p->devinfo, brw_last_inst,
664 brw_inst_set_saturate(p->devinfo, brw_last_inst, $3);
665 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $5);
666 // TODO: set instruction group instead of qtr and nib ctrl
667 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
670 if (p->devinfo->gen >= 7)
671 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
694 /* Binary instruction */
696 predicate binaryopcodes saturate cond_mod execsize dst srcimm srcimm instoptions
698 i965_asm_set_dst_nr(p, &$6, $9);
699 brw_set_default_access_mode(p, $9.access_mode);
700 i965_asm_binary_instruction($2, p, $6, $7, $8);
701 i965_asm_set_instruction_options(p, $9);
702 brw_inst_set_cond_modifier(p->devinfo, brw_last_inst,
705 if (p->devinfo->gen >= 7) {
706 brw_inst_set_flag_reg_nr(p->devinfo, brw_last_inst,
708 brw_inst_set_flag_subreg_nr(p->devinfo, brw_last_inst,
712 brw_inst_set_saturate(p->devinfo, brw_last_inst, $3);
713 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $5);
714 // TODO: set instruction group instead of qtr and nib ctrl
715 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
718 if (p->devinfo->gen >= 7)
719 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
722 brw_pop_insn_state(p);
745 /* Binary acc instruction */
746 binaryaccinstruction:
747 predicate binaryaccopcodes saturate cond_mod execsize dst srcacc srcimm instoptions
749 i965_asm_set_dst_nr(p, &$6, $9);
750 brw_set_default_access_mode(p, $9.access_mode);
751 i965_asm_binary_instruction($2, p, $6, $7, $8);
752 brw_pop_insn_state(p);
753 i965_asm_set_instruction_options(p, $9);
754 brw_inst_set_cond_modifier(p->devinfo, brw_last_inst,
757 if (p->devinfo->gen >= 7) {
758 if (!brw_inst_flag_reg_nr(p->devinfo, brw_last_inst)) {
759 brw_inst_set_flag_reg_nr(p->devinfo,
762 brw_inst_set_flag_subreg_nr(p->devinfo,
768 brw_inst_set_saturate(p->devinfo, brw_last_inst, $3);
769 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $5);
770 // TODO: set instruction group instead of qtr and nib ctrl
771 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
774 if (p->devinfo->gen >= 7)
775 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
794 /* Math instruction */
796 predicate MATH saturate math_function execsize dst src srcimm instoptions
798 brw_set_default_access_mode(p, $9.access_mode);
799 gen6_math(p, $6, $4, $7, $8);
800 i965_asm_set_instruction_options(p, $9);
801 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $5);
802 brw_inst_set_saturate(p->devinfo, brw_last_inst, $3);
803 // TODO: set instruction group instead
804 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
807 if (p->devinfo->gen >= 7)
808 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
811 brw_pop_insn_state(p);
833 /* NOP instruction */
841 /* Ternary operand instruction */
843 predicate ternaryopcodes saturate cond_mod execsize dst src src src instoptions
845 brw_set_default_access_mode(p, $10.access_mode);
846 i965_asm_ternary_instruction($2, p, $6, $7, $8, $9);
847 brw_pop_insn_state(p);
848 i965_asm_set_instruction_options(p, $10);
849 brw_inst_set_cond_modifier(p->devinfo, brw_last_inst,
852 if (p->devinfo->gen >= 7) {
853 brw_inst_set_3src_a16_flag_reg_nr(p->devinfo, brw_last_inst,
855 brw_inst_set_3src_a16_flag_subreg_nr(p->devinfo, brw_last_inst,
859 brw_inst_set_saturate(p->devinfo, brw_last_inst, $3);
860 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $5);
861 // TODO: set instruction group instead of qtr and nib ctrl
862 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
865 if (p->devinfo->gen >= 7)
866 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
879 /* Sync instruction */
881 WAIT execsize src instoptions
883 brw_next_insn(p, $1);
884 i965_asm_set_instruction_options(p, $4);
885 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $2);
886 brw_set_default_access_mode(p, $4.access_mode);
887 struct brw_reg src = brw_notification_reg();
888 brw_set_dest(p, brw_last_inst, src);
889 brw_set_src0(p, brw_last_inst, src);
890 brw_set_src1(p, brw_last_inst, brw_null_reg());
891 brw_inst_set_mask_control(p->devinfo, brw_last_inst, BRW_MASK_DISABLE);
895 /* Send instruction */
897 predicate sendopcode execsize dst payload exp2 sharedfunction instoptions
899 i965_asm_set_instruction_options(p, $8);
900 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
901 brw_set_dest(p, brw_last_inst, $4);
902 brw_set_src0(p, brw_last_inst, $5);
903 brw_inst_set_bits(brw_last_inst, 127, 96, $6);
904 brw_inst_set_src1_file_type(p->devinfo, brw_last_inst,
906 BRW_REGISTER_TYPE_UD);
907 brw_inst_set_sfid(p->devinfo, brw_last_inst, $7);
908 brw_inst_set_eot(p->devinfo, brw_last_inst, $8.end_of_thread);
909 // TODO: set instruction group instead of qtr and nib ctrl
910 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
913 if (p->devinfo->gen >= 7)
914 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
917 brw_pop_insn_state(p);
919 | predicate sendopcode execsize exp dst payload exp2 sharedfunction instoptions
921 i965_asm_set_instruction_options(p, $9);
922 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
923 brw_inst_set_base_mrf(p->devinfo, brw_last_inst, $4);
924 brw_set_dest(p, brw_last_inst, $5);
925 brw_set_src0(p, brw_last_inst, $6);
926 brw_inst_set_bits(brw_last_inst, 127, 96, $7);
927 brw_inst_set_src1_file_type(p->devinfo, brw_last_inst,
929 BRW_REGISTER_TYPE_UD);
930 brw_inst_set_sfid(p->devinfo, brw_last_inst, $8);
931 brw_inst_set_eot(p->devinfo, brw_last_inst, $9.end_of_thread);
932 // TODO: set instruction group instead of qtr and nib ctrl
933 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
936 if (p->devinfo->gen >= 7)
937 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
940 brw_pop_insn_state(p);
942 | predicate sendopcode execsize dst payload payload exp2 sharedfunction instoptions
944 i965_asm_set_instruction_options(p, $9);
945 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
946 brw_set_dest(p, brw_last_inst, $4);
947 brw_set_src0(p, brw_last_inst, $5);
948 brw_inst_set_bits(brw_last_inst, 127, 96, $7);
949 brw_inst_set_sfid(p->devinfo, brw_last_inst, $8);
950 brw_inst_set_eot(p->devinfo, brw_last_inst, $9.end_of_thread);
951 // TODO: set instruction group instead of qtr and nib ctrl
952 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
955 if (p->devinfo->gen >= 7)
956 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
959 brw_pop_insn_state(p);
961 | predicate SENDS execsize dst payload payload exp2 exp2 sharedfunction instoptions
963 brw_next_insn(p, $2);
964 i965_asm_set_instruction_options(p, $10);
965 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
966 brw_set_dest(p, brw_last_inst, $4);
967 brw_set_src0(p, brw_last_inst, $5);
968 brw_set_src1(p, brw_last_inst, $6);
970 if (brw_inst_send_sel_reg32_ex_desc(p->devinfo, brw_last_inst)) {
971 brw_inst_set_send_ex_desc_ia_subreg_nr(p->devinfo, brw_last_inst, $5.subnr);
973 brw_inst_set_sends_ex_desc(p->devinfo, brw_last_inst, $8);
976 brw_inst_set_bits(brw_last_inst, 127, 96, $7);
977 brw_inst_set_sfid(p->devinfo, brw_last_inst, $9);
978 brw_inst_set_eot(p->devinfo, brw_last_inst, $10.end_of_thread);
979 // TODO: set instruction group instead of qtr and nib ctrl
980 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
983 if (p->devinfo->gen >= 7)
984 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
987 brw_pop_insn_state(p);
989 | predicate SENDS execsize dst payload payload src exp2 sharedfunction instoptions
991 brw_next_insn(p, $2);
992 i965_asm_set_instruction_options(p, $10);
993 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
994 brw_set_dest(p, brw_last_inst, $4);
995 brw_set_src0(p, brw_last_inst, $5);
996 brw_set_src1(p, brw_last_inst, $6);
998 brw_inst_set_send_sel_reg32_desc(p->devinfo, brw_last_inst, 1);
999 brw_inst_set_sends_ex_desc(p->devinfo, brw_last_inst, $8);
1001 brw_inst_set_sfid(p->devinfo, brw_last_inst, $9);
1002 brw_inst_set_eot(p->devinfo, brw_last_inst, $10.end_of_thread);
1003 // TODO: set instruction group instead of qtr and nib ctrl
1004 brw_inst_set_qtr_control(p->devinfo, brw_last_inst,
1007 if (p->devinfo->gen >= 7)
1008 brw_inst_set_nib_control(p->devinfo, brw_last_inst,
1011 brw_pop_insn_state(p);
1021 sendop { $$ = brw_next_insn(p, $1); }
1025 NULL_TOKEN { $$ = BRW_SFID_NULL; }
1026 | MATH { $$ = BRW_SFID_MATH; }
1027 | GATEWAY { $$ = BRW_SFID_MESSAGE_GATEWAY; }
1028 | READ { $$ = BRW_SFID_DATAPORT_READ; }
1029 | WRITE { $$ = BRW_SFID_DATAPORT_WRITE; }
1030 | URB { $$ = BRW_SFID_URB; }
1031 | THREAD_SPAWNER { $$ = BRW_SFID_THREAD_SPAWNER; }
1032 | VME { $$ = BRW_SFID_VME; }
1033 | RENDER { $$ = GEN6_SFID_DATAPORT_RENDER_CACHE; }
1034 | CONST { $$ = GEN6_SFID_DATAPORT_CONSTANT_CACHE; }
1035 | DATA { $$ = GEN7_SFID_DATAPORT_DATA_CACHE; }
1036 | PIXEL_INTERP { $$ = GEN7_SFID_PIXEL_INTERPOLATOR; }
1037 | DP_DATA_1 { $$ = HSW_SFID_DATAPORT_DATA_CACHE_1; }
1038 | CRE { $$ = HSW_SFID_CRE; }
1039 | SAMPLER { $$ = BRW_SFID_SAMPLER; }
1040 | DP_SAMPLER { $$ = GEN6_SFID_DATAPORT_SAMPLER_CACHE; }
1045 | MINUS LONG { $$ = -$2; }
1048 /* Jump instruction */
1050 predicate JMPI execsize relativelocation2 instoptions
1052 brw_next_insn(p, $2);
1053 i965_asm_set_instruction_options(p, $5);
1054 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1055 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1056 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1057 brw_set_src1(p, brw_last_inst, $4);
1058 brw_inst_set_pred_control(p->devinfo, brw_last_inst,
1059 brw_inst_pred_control(p->devinfo,
1061 brw_pop_insn_state(p);
1065 /* branch instruction */
1067 predicate ENDIF execsize relativelocation instoptions
1069 brw_next_insn(p, $2);
1070 i965_asm_set_instruction_options(p, $5);
1071 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1073 if (p->devinfo->gen < 6) {
1074 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1075 BRW_REGISTER_TYPE_D));
1076 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1077 BRW_REGISTER_TYPE_D));
1078 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1079 brw_inst_set_gen4_pop_count(p->devinfo, brw_last_inst,
1081 } else if (p->devinfo->gen == 6) {
1082 brw_set_dest(p, brw_last_inst, brw_imm_w(0x0));
1083 brw_inst_set_gen6_jump_count(p->devinfo, brw_last_inst,
1085 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1086 BRW_REGISTER_TYPE_D));
1087 brw_set_src1(p, brw_last_inst, retype(brw_null_reg(),
1088 BRW_REGISTER_TYPE_D));
1089 } else if (p->devinfo->gen == 7) {
1090 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1091 BRW_REGISTER_TYPE_D));
1092 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1093 BRW_REGISTER_TYPE_D));
1094 brw_set_src1(p, brw_last_inst, brw_imm_w(0x0));
1095 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1097 brw_set_src0(p, brw_last_inst, brw_imm_d($4));
1100 if (p->devinfo->gen < 6)
1101 brw_inst_set_thread_control(p->devinfo, brw_last_inst,
1103 brw_pop_insn_state(p);
1105 | ELSE execsize relativelocation rellocation instoptions
1107 brw_next_insn(p, $1);
1108 i965_asm_set_instruction_options(p, $5);
1109 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $2);
1111 if (p->devinfo->gen < 6) {
1112 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1113 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1114 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1115 brw_inst_set_gen4_jump_count(p->devinfo, brw_last_inst,
1117 brw_inst_set_gen4_pop_count(p->devinfo, brw_last_inst,
1119 } else if (p->devinfo->gen == 6) {
1120 brw_set_dest(p, brw_last_inst, brw_imm_w(0x0));
1121 brw_inst_set_gen6_jump_count(p->devinfo, brw_last_inst,
1123 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1124 BRW_REGISTER_TYPE_D));
1125 brw_set_src1(p, brw_last_inst, retype(brw_null_reg(),
1126 BRW_REGISTER_TYPE_D));
1127 } else if (p->devinfo->gen == 7) {
1128 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1129 BRW_REGISTER_TYPE_D));
1130 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1131 BRW_REGISTER_TYPE_D));
1132 brw_set_src1(p, brw_last_inst, brw_imm_w($3));
1133 brw_inst_set_jip(p->devinfo, brw_last_inst, $3);
1134 brw_inst_set_uip(p->devinfo, brw_last_inst, $4);
1136 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1137 BRW_REGISTER_TYPE_D));
1138 brw_set_src0(p, brw_last_inst, brw_imm_d($3));
1139 brw_inst_set_jip(p->devinfo, brw_last_inst, $3);
1140 brw_inst_set_uip(p->devinfo, brw_last_inst, $4);
1143 if (!p->single_program_flow && p->devinfo->gen < 6)
1144 brw_inst_set_thread_control(p->devinfo, brw_last_inst,
1147 | predicate IF execsize relativelocation rellocation instoptions
1149 brw_next_insn(p, $2);
1150 i965_asm_set_instruction_options(p, $6);
1151 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1153 if (p->devinfo->gen < 6) {
1154 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1155 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1156 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1157 brw_inst_set_gen4_jump_count(p->devinfo, brw_last_inst,
1159 brw_inst_set_gen4_pop_count(p->devinfo, brw_last_inst,
1161 } else if (p->devinfo->gen == 6) {
1162 brw_set_dest(p, brw_last_inst, brw_imm_w(0x0));
1163 brw_inst_set_gen6_jump_count(p->devinfo, brw_last_inst,
1165 brw_set_src0(p, brw_last_inst,
1166 vec1(retype(brw_null_reg(),
1167 BRW_REGISTER_TYPE_D)));
1168 brw_set_src1(p, brw_last_inst,
1169 vec1(retype(brw_null_reg(),
1170 BRW_REGISTER_TYPE_D)));
1171 } else if (p->devinfo->gen == 7) {
1172 brw_set_dest(p, brw_last_inst,
1173 vec1(retype(brw_null_reg(),
1174 BRW_REGISTER_TYPE_D)));
1175 brw_set_src0(p, brw_last_inst,
1176 vec1(retype(brw_null_reg(),
1177 BRW_REGISTER_TYPE_D)));
1178 brw_set_src1(p, brw_last_inst, brw_imm_w($4));
1179 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1180 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1182 brw_set_dest(p, brw_last_inst,
1183 vec1(retype(brw_null_reg(),
1184 BRW_REGISTER_TYPE_D)));
1185 brw_set_src0(p, brw_last_inst, brw_imm_d($4));
1186 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1187 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1190 if (!p->single_program_flow && p->devinfo->gen < 6)
1191 brw_inst_set_thread_control(p->devinfo, brw_last_inst,
1194 brw_pop_insn_state(p);
1196 | predicate IFF execsize relativelocation instoptions
1198 brw_next_insn(p, $2);
1199 i965_asm_set_instruction_options(p, $5);
1200 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1202 if (p->devinfo->gen < 6) {
1203 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1204 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1205 brw_inst_set_gen4_jump_count(p->devinfo, brw_last_inst,
1207 brw_set_src1(p, brw_last_inst, brw_imm_d($4));
1208 } else if (p->devinfo->gen == 6) {
1209 brw_set_dest(p, brw_last_inst, brw_imm_w($4));
1210 brw_inst_set_gen6_jump_count(p->devinfo, brw_last_inst,
1212 brw_set_src0(p, brw_last_inst,
1213 vec1(retype(brw_null_reg(),
1214 BRW_REGISTER_TYPE_D)));
1215 brw_set_src1(p, brw_last_inst,
1216 vec1(retype(brw_null_reg(),
1217 BRW_REGISTER_TYPE_D)));
1218 } else if (p->devinfo->gen == 7) {
1219 brw_set_dest(p, brw_last_inst,
1220 vec1(retype(brw_null_reg(),
1221 BRW_REGISTER_TYPE_D)));
1222 brw_set_src0(p, brw_last_inst,
1223 vec1(retype(brw_null_reg(),
1224 BRW_REGISTER_TYPE_D)));
1225 brw_set_src1(p, brw_last_inst, brw_imm_w($4));
1226 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1228 brw_set_dest(p, brw_last_inst,
1229 vec1(retype(brw_null_reg(),
1230 BRW_REGISTER_TYPE_D)));
1231 brw_set_src0(p, brw_last_inst, brw_imm_d($4));
1232 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1235 if (!p->single_program_flow && p->devinfo->gen < 6)
1236 brw_inst_set_thread_control(p->devinfo, brw_last_inst,
1239 brw_pop_insn_state(p);
1243 /* break instruction */
1245 predicate BREAK execsize relativelocation relativelocation instoptions
1247 brw_next_insn(p, $2);
1248 i965_asm_set_instruction_options(p, $6);
1249 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1251 if (p->devinfo->gen >= 8) {
1252 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1253 BRW_REGISTER_TYPE_D));
1254 brw_set_src0(p, brw_last_inst, brw_imm_d($4));
1255 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1256 } else if (p->devinfo->gen >= 6) {
1257 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1258 BRW_REGISTER_TYPE_D));
1259 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1260 BRW_REGISTER_TYPE_D));
1261 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1262 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1263 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1265 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1266 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1267 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1268 brw_inst_set_gen4_jump_count(p->devinfo, brw_last_inst,
1270 brw_inst_set_gen4_pop_count(p->devinfo, brw_last_inst,
1274 brw_pop_insn_state(p);
1276 | predicate HALT execsize relativelocation relativelocation instoptions
1278 brw_next_insn(p, $2);
1279 i965_asm_set_instruction_options(p, $6);
1280 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1281 brw_set_dest(p, brw_last_inst, retype(brw_null_reg(),
1282 BRW_REGISTER_TYPE_D));
1284 if (p->devinfo->gen >= 8) {
1285 brw_set_src0(p, brw_last_inst, brw_imm_d($4));
1286 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1288 brw_set_src0(p, brw_last_inst, retype(brw_null_reg(),
1289 BRW_REGISTER_TYPE_D));
1290 brw_set_src1(p, brw_last_inst, brw_imm_d($5));
1293 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1294 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1295 brw_pop_insn_state(p);
1297 | predicate CONT execsize relativelocation relativelocation instoptions
1299 brw_next_insn(p, $2);
1300 i965_asm_set_instruction_options(p, $6);
1301 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1302 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1304 if (p->devinfo->gen >= 8) {
1305 brw_set_src0(p, brw_last_inst, brw_imm_d(0x0));
1306 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1307 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1309 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1310 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1311 if (p->devinfo->gen >= 6) {
1312 brw_inst_set_jip(p->devinfo, brw_last_inst, $4);
1313 brw_inst_set_uip(p->devinfo, brw_last_inst, $5);
1315 brw_inst_set_gen4_jump_count(p->devinfo, brw_last_inst,
1317 brw_inst_set_gen4_pop_count(p->devinfo, brw_last_inst,
1322 brw_pop_insn_state(p);
1326 /* loop instruction */
1328 predicate WHILE execsize relativelocation instoptions
1330 brw_next_insn(p, $2);
1331 i965_asm_set_instruction_options(p, $5);
1332 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $3);
1334 if (p->devinfo->gen >= 6) {
1335 if (p->devinfo->gen >= 8) {
1336 brw_set_dest(p, brw_last_inst,
1337 retype(brw_null_reg(),
1338 BRW_REGISTER_TYPE_D));
1339 brw_set_src0(p, brw_last_inst, brw_imm_d($4));
1340 } else if (p->devinfo->gen == 7) {
1341 brw_set_dest(p, brw_last_inst,
1342 retype(brw_null_reg(),
1343 BRW_REGISTER_TYPE_D));
1344 brw_set_src0(p, brw_last_inst,
1345 retype(brw_null_reg(),
1346 BRW_REGISTER_TYPE_D));
1347 brw_set_src1(p, brw_last_inst,
1349 brw_inst_set_jip(p->devinfo, brw_last_inst,
1352 brw_set_dest(p, brw_last_inst, brw_imm_w(0x0));
1353 brw_inst_set_gen6_jump_count(p->devinfo,
1356 brw_set_src0(p, brw_last_inst,
1357 retype(brw_null_reg(),
1358 BRW_REGISTER_TYPE_D));
1359 brw_set_src1(p, brw_last_inst,
1360 retype(brw_null_reg(),
1361 BRW_REGISTER_TYPE_D));
1364 brw_set_dest(p, brw_last_inst, brw_ip_reg());
1365 brw_set_src0(p, brw_last_inst, brw_ip_reg());
1366 brw_set_src1(p, brw_last_inst, brw_imm_d(0x0));
1367 brw_inst_set_gen4_jump_count(p->devinfo, brw_last_inst,
1369 brw_inst_set_gen4_pop_count(p->devinfo, brw_last_inst,
1372 brw_pop_insn_state(p);
1374 | DO execsize instoptions
1376 brw_next_insn(p, $1);
1377 if (p->devinfo->gen < 6) {
1378 brw_inst_set_exec_size(p->devinfo, brw_last_inst, $2);
1379 i965_asm_set_instruction_options(p, $3);
1380 brw_set_dest(p, brw_last_inst, brw_null_reg());
1381 brw_set_src0(p, brw_last_inst, brw_null_reg());
1382 brw_set_src1(p, brw_last_inst, brw_null_reg());
1384 brw_inst_set_qtr_control(p->devinfo, brw_last_inst, BRW_COMPRESSION_NONE);
1389 /* Relative location */
1396 INTEGER { $$ = $1; }
1397 | MINUS INTEGER { $$ = -$2; }
1399 | MINUS LONG { $$ = -$2; }
1404 | %empty { $$ = 0; }
1414 /* Destination register */
1421 dstreg dstregion writemask dsttype
1426 $$.hstride = BRW_HORIZONTAL_STRIDE_1;
1427 $$.vstride = BRW_VERTICAL_STRIDE_1;
1428 $$.width = BRW_WIDTH_1;
1433 $$.writemask = $3.writemask;
1434 $$.swizzle = BRW_SWIZZLE_NOOP;
1435 $$.subnr = $$.subnr * brw_reg_type_to_size($4.type);
1440 dstoperandex_typed dstregion writemask dsttype
1445 $$.writemask = $3.writemask;
1446 $$.subnr = $$.subnr * brw_reg_type_to_size($4.type);
1448 /* BSpec says "When the conditional modifier is present, updates
1449 * to the selected flag register also occur. In this case, the
1450 * register region fields of the ‘null’ operand are valid."
1452 | nullreg dstregion writemask dsttype
1456 $$.hstride = BRW_HORIZONTAL_STRIDE_1;
1457 $$.vstride = BRW_VERTICAL_STRIDE_1;
1458 $$.width = BRW_WIDTH_1;
1462 $$.writemask = $3.writemask;
1469 $$.type = BRW_REGISTER_TYPE_UW;
1489 $$.address_mode = BRW_ADDRESS_DIRECT;
1494 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
1499 $$.address_mode = BRW_ADDRESS_DIRECT;
1504 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
1508 /* Source register */
1520 case BRW_REGISTER_TYPE_UD:
1522 $$ = brw_imm_ud(u32);
1524 case BRW_REGISTER_TYPE_D:
1527 case BRW_REGISTER_TYPE_UW:
1528 u32 = $1 | ($1 << 16);
1529 $$ = brw_imm_uw(u32);
1531 case BRW_REGISTER_TYPE_W:
1533 $$ = brw_imm_w(u32);
1535 case BRW_REGISTER_TYPE_F:
1536 $$ = brw_imm_reg(BRW_REGISTER_TYPE_F);
1540 case BRW_REGISTER_TYPE_V:
1543 case BRW_REGISTER_TYPE_UV:
1544 $$ = brw_imm_uv($1);
1546 case BRW_REGISTER_TYPE_VF:
1547 $$ = brw_imm_reg(BRW_REGISTER_TYPE_VF);
1550 case BRW_REGISTER_TYPE_Q:
1552 $$ = brw_imm_q(u64);
1554 case BRW_REGISTER_TYPE_UQ:
1556 $$ = brw_imm_uq(u64);
1558 case BRW_REGISTER_TYPE_DF:
1559 $$ = brw_imm_reg(BRW_REGISTER_TYPE_DF);
1563 error(&@2, "Unknown immediate type %s\n",
1564 brw_reg_type_to_letters($2.type));
1570 directgenreg region srctype
1572 $$ = set_direct_src_operand(&$1, $3.type);
1573 $$ = stride($$, $2.vstride, $2.width, $2.hstride);
1583 | indirectsrcoperand
1588 | indirectsrcoperand
1593 | indirectsrcoperand
1597 directsrcaccoperand:
1599 | accreg region srctype
1601 $$ = set_direct_src_operand(&$1, $3.type);
1602 $$.vstride = $2.vstride;
1603 $$.width = $2.width;
1604 $$.hstride = $2.hstride;
1609 srcarcoperandex_typed region srctype
1611 $$ = brw_reg($1.file,
1623 | nullreg region srctype
1625 $$ = set_direct_src_operand(&$1, $3.type);
1626 $$.vstride = $2.vstride;
1627 $$.width = $2.width;
1628 $$.hstride = $2.hstride;
1632 $$ = set_direct_src_operand(&$1, BRW_REGISTER_TYPE_UW);
1636 srcarcoperandex_typed:
1646 negate abs indirectgenreg indirectregion swizzle srctype
1648 $$ = brw_reg($3.file,
1660 $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
1661 // brw_reg set indirect_offset to 0 so set it to valid value
1662 $$.indirect_offset = $3.indirect_offset;
1675 negate abs directgenreg_list region swizzle srctype
1677 $$ = brw_reg($3.file,
1692 /* Address register */
1696 memset(&$$, '\0', sizeof($$));
1697 $$.subnr = $1.subnr;
1698 $$.indirect_offset = $2;
1703 /* Register files and register numbers */
1705 INTEGER { $$ = $1; }
1710 DOT exp { $$ = $2; }
1711 | %empty %prec SUBREGNUM { $$ = 0; }
1717 memset(&$$, '\0', sizeof($$));
1718 $$.file = BRW_GENERAL_REGISTER_FILE;
1725 GENREGFILE LSQUARE addrparam RSQUARE
1727 memset(&$$, '\0', sizeof($$));
1728 $$.file = BRW_GENERAL_REGISTER_FILE;
1729 $$.subnr = $3.subnr;
1730 $$.indirect_offset = $3.indirect_offset;
1737 $$ = brw_message_reg($1);
1743 MSGREGFILE LSQUARE addrparam RSQUARE
1745 memset(&$$, '\0', sizeof($$));
1746 $$.file = BRW_MESSAGE_REGISTER_FILE;
1747 $$.subnr = $3.subnr;
1748 $$.indirect_offset = $3.indirect_offset;
1755 int subnr = (p->devinfo->gen >= 8) ? 16 : 8;
1758 error(&@2, "Address sub register number %d"
1759 "out of range\n", $2);
1761 $$.file = BRW_ARCHITECTURE_REGISTER_FILE;
1762 $$.nr = BRW_ARF_ADDRESS;
1771 if (p->devinfo->gen < 8)
1777 error(&@1, "Accumulator register number %d"
1778 " out of range\n", $1);
1780 memset(&$$, '\0', sizeof($$));
1781 $$.file = BRW_ARCHITECTURE_REGISTER_FILE;
1782 $$.nr = BRW_ARF_ACCUMULATOR;
1790 // SNB = 1 flag reg and IVB+ = 2 flag reg
1791 int nr_reg = (p->devinfo->gen >= 7) ? 2 : 1;
1795 error(&@1, "Flag register number %d"
1796 " out of range \n", $1);
1798 error(&@2, "Flag subregister number %d"
1799 " out of range\n", $2);
1801 $$.file = BRW_ARCHITECTURE_REGISTER_FILE;
1802 $$.nr = BRW_ARF_FLAG | $1;
1811 error(&@1, "Mask register number %d"
1812 " out of range\n", $1);
1814 $$ = brw_mask_reg($2);
1822 error(&@1, "Notification register number %d"
1823 " out of range\n", $1);
1825 int subnr = (p->devinfo->gen >= 11) ? 2 : 3;
1827 error(&@2, "Notification sub register number %d"
1828 " out of range\n", $2);
1830 $$ = brw_notification_reg();
1839 error(&@1, "State register number %d"
1840 " out of range\n", $1);
1843 error(&@2, "State sub register number %d"
1844 " out of range\n", $2);
1846 $$.file = BRW_ARCHITECTURE_REGISTER_FILE;
1847 $$.nr = BRW_ARF_STATE;
1853 CONTROLREG subregnum
1856 error(&@2, "control sub register number %d"
1857 " out of range\n", $2);
1859 $$ = brw_cr0_reg($2);
1864 IPREG { $$ = brw_ip_reg(); }
1868 NULL_TOKEN { $$ = brw_null_reg(); }
1875 error(&@1, "Thread control register number %d"
1876 " out of range\n", $1);
1879 error(&@2, "Thread control sub register number %d"
1880 " out of range\n", $2);
1888 PERFORMANCEREG subregnum
1891 if (p->devinfo->gen >= 10)
1893 else if (p->devinfo->gen <= 8)
1899 error(&@2, "Performance sub register number %d"
1900 " out of range\n", $2);
1902 $$.file = BRW_ARCHITECTURE_REGISTER_FILE;
1903 $$.nr = BRW_ARF_TIMESTAMP;
1908 CHANNELENABLEREG subregnum
1911 error(&@1, "Channel enable register number %d"
1912 " out of range\n", $1);
1914 $$ = brw_mask_reg($2);
1918 /* Immediate values */
1924 | LSQUARE exp2 COMMA exp2 COMMA exp2 COMMA exp2 RSQUARE
1926 $$ = ($2 << 0) | ($4 << 8) | ($6 << 16) | ($8 << 24);
1935 if ($2 != 0 && ($2 > 4 || !isPowerofTwo($2)))
1936 error(&@2, "Invalid Horizontal stride %d\n", $2);
1950 $$ = stride($$, BRW_VERTICAL_STRIDE_1, BRW_WIDTH_2, BRW_HORIZONTAL_STRIDE_1);
1954 if ($2 != 0 && ($2 > 32 || !isPowerofTwo($2)))
1955 error(&@2, "Invalid VertStride %d\n", $2);
1957 $$ = stride($$, $2, BRW_WIDTH_1, 0);
1959 | LANGLE exp COMMA exp COMMA exp RANGLE
1962 if ($2 != 0 && ($2 > 32 || !isPowerofTwo($2)))
1963 error(&@2, "Invalid VertStride %d\n", $2);
1965 if ($4 > 16 || !isPowerofTwo($4))
1966 error(&@4, "Invalid width %d\n", $4);
1968 if ($6 != 0 && ($6 > 4 || !isPowerofTwo($6)))
1969 error(&@6, "Invalid Horizontal stride in"
1970 " region_wh %d\n", $6);
1972 $$ = stride($$, $2, $4, $6);
1974 | LANGLE exp SEMICOLON exp COMMA exp RANGLE
1976 if ($2 != 0 && ($2 > 32 || !isPowerofTwo($2)))
1977 error(&@2, "Invalid VertStride %d\n", $2);
1979 if ($4 > 16 || !isPowerofTwo($4))
1980 error(&@4, "Invalid width %d\n", $4);
1982 if ($6 != 0 && ($6 > 4 || !isPowerofTwo($6)))
1983 error(&@6, "Invalid Horizontal stride in"
1984 " region_wh %d\n", $6);
1986 $$ = stride($$, $2, $4, $6);
1988 | LANGLE VxH COMMA exp COMMA exp RANGLE
1990 if ($4 > 16 || !isPowerofTwo($4))
1991 error(&@4, "Invalid width %d\n", $4);
1993 if ($6 != 0 && ($6 > 4 || !isPowerofTwo($6)))
1994 error(&@6, "Invalid Horizontal stride in"
1995 " region_wh %d\n", $6);
1997 $$ = brw_VxH_indirect(0, 0);
2002 LANGLE exp COMMA exp RANGLE
2004 if ($2 > 16 || !isPowerofTwo($2))
2005 error(&@2, "Invalid width %d\n", $2);
2007 if ($4 != 0 && ($4 > 4 || !isPowerofTwo($4)))
2008 error(&@4, "Invalid Horizontal stride in"
2009 " region_wh %d\n", $4);
2011 $$ = stride($$, BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL, $2, $4);
2016 %empty { $$ = retype($$, BRW_REGISTER_TYPE_F); }
2017 | TYPE_F { $$ = retype($$, BRW_REGISTER_TYPE_F); }
2018 | TYPE_UD { $$ = retype($$, BRW_REGISTER_TYPE_UD); }
2019 | TYPE_D { $$ = retype($$, BRW_REGISTER_TYPE_D); }
2020 | TYPE_UW { $$ = retype($$, BRW_REGISTER_TYPE_UW); }
2021 | TYPE_W { $$ = retype($$, BRW_REGISTER_TYPE_W); }
2022 | TYPE_UB { $$ = retype($$, BRW_REGISTER_TYPE_UB); }
2023 | TYPE_B { $$ = retype($$, BRW_REGISTER_TYPE_B); }
2024 | TYPE_DF { $$ = retype($$, BRW_REGISTER_TYPE_DF); }
2025 | TYPE_UQ { $$ = retype($$, BRW_REGISTER_TYPE_UQ); }
2026 | TYPE_Q { $$ = retype($$, BRW_REGISTER_TYPE_Q); }
2027 | TYPE_HF { $$ = retype($$, BRW_REGISTER_TYPE_HF); }
2028 | TYPE_NF { $$ = retype($$, BRW_REGISTER_TYPE_NF); }
2032 srctype { $$ = $1; }
2033 | TYPE_V { $$ = retype($$, BRW_REGISTER_TYPE_V); }
2034 | TYPE_VF { $$ = retype($$, BRW_REGISTER_TYPE_VF); }
2035 | TYPE_UV { $$ = retype($$, BRW_REGISTER_TYPE_UV); }
2039 srctype { $$ = $1; }
2045 $$= brw_set_writemask($$, WRITEMASK_XYZW);
2047 | DOT writemask_x writemask_y writemask_z writemask_w
2049 $$ = brw_set_writemask($$, $2 | $3 | $4 | $5);
2055 | X { $$ = 1 << BRW_CHANNEL_X; }
2060 | Y { $$ = 1 << BRW_CHANNEL_Y; }
2065 | Z { $$ = 1 << BRW_CHANNEL_Z; }
2070 | W { $$ = 1 << BRW_CHANNEL_W; }
2076 $$.swizzle = BRW_SWIZZLE_NOOP;
2080 $$.swizzle = BRW_SWIZZLE4($2, $2, $2, $2);
2082 | DOT chansel chansel chansel chansel
2084 $$.swizzle = BRW_SWIZZLE4($2, $3, $4, $5);
2095 /* Instruction prediction and modifiers */
2099 brw_push_insn_state(p);
2100 brw_set_default_predicate_control(p, BRW_PREDICATE_NONE);
2101 brw_set_default_flag_reg(p, 0, 0);
2102 brw_set_default_predicate_inverse(p, false);
2104 | LPAREN predstate flagreg predctrl RPAREN
2106 brw_push_insn_state(p);
2107 brw_set_default_predicate_inverse(p, $2);
2108 brw_set_default_flag_reg(p, $3.nr, $3.subnr);
2109 brw_set_default_predicate_control(p, $4);
2120 %empty { $$ = BRW_PREDICATE_NORMAL; }
2121 | DOT X { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_X; }
2122 | DOT Y { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Y; }
2123 | DOT Z { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Z; }
2124 | DOT W { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_W; }
2139 /* Source Modification */
2150 /* Flag (Conditional) Modifier */
2154 $$.cond_modifier = $1;
2156 $$.flag_subreg_nr = 0;
2158 | condModifiers DOT flagreg
2160 $$.cond_modifier = $1;
2161 $$.flag_reg_nr = $3.nr;
2162 $$.flag_subreg_nr = $3.subnr;
2167 %empty { $$ = BRW_CONDITIONAL_NONE; }
2182 %empty { $$ = BRW_INSTRUCTION_NORMAL; }
2183 | SATURATE { $$ = BRW_INSTRUCTION_SATURATE; }
2186 /* Execution size */
2188 %empty %prec EMPTYEXECSIZE
2192 | LPAREN exp2 RPAREN
2194 if ($2 > 32 || !isPowerofTwo($2))
2195 error(&@2, "Invalid execution size %d\n", $2);
2201 /* Instruction options */
2205 memset(&$$, 0, sizeof($$));
2207 | LCURLY instoption_list RCURLY
2209 memset(&$$, 0, sizeof($$));
2215 instoption_list COMMA instoption
2217 memset(&$$, 0, sizeof($$));
2219 add_instruction_option(&$$, $3);
2221 | instoption_list instoption
2223 memset(&$$, 0, sizeof($$));
2225 add_instruction_option(&$$, $2);
2229 memset(&$$, 0, sizeof($$));
2234 ALIGN1 { $$ = ALIGN1;}
2235 | ALIGN16 { $$ = ALIGN16; }
2236 | ACCWREN { $$ = ACCWREN; }
2237 | SECHALF { $$ = SECHALF; }
2238 | COMPR { $$ = COMPR; }
2239 | COMPR4 { $$ = COMPR4; }
2240 | BREAKPOINT { $$ = BREAKPOINT; }
2241 | NODDCLR { $$ = NODDCLR; }
2242 | NODDCHK { $$ = NODDCHK; }
2243 | MASK_DISABLE { $$ = MASK_DISABLE; }
2245 | SWITCH { $$ = SWITCH; }
2246 | ATOMIC { $$ = ATOMIC; }
2247 | CMPTCTRL { $$ = CMPTCTRL; }
2248 | WECTRL { $$ = WECTRL; }
2249 | QTR_2Q { $$ = QTR_2Q; }
2250 | QTR_3Q { $$ = QTR_3Q; }
2251 | QTR_4Q { $$ = QTR_4Q; }
2252 | QTR_2H { $$ = QTR_2H; }
2253 | QTR_2N { $$ = QTR_2N; }
2254 | QTR_3N { $$ = QTR_3N; }
2255 | QTR_4N { $$ = QTR_4N; }
2256 | QTR_5N { $$ = QTR_5N; }
2257 | QTR_6N { $$ = QTR_6N; }
2258 | QTR_7N { $$ = QTR_7N; }
2259 | QTR_8N { $$ = QTR_8N; }
2264 extern int yylineno;
2269 fprintf(stderr, "%s: %d: %s at \"%s\"\n",
2270 input_filename, yylineno, msg, lex_text());