Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1 | %{ |
| 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 Anholt | f2f1856 | 2006-08-22 12:46:37 -0700 | [diff] [blame] | 30 | #include <string.h> |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 31 | #include <stdlib.h> |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 32 | #include "gen4asm.h" |
| 33 | #include "brw_defines.h" |
| 34 | |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 35 | extern long int gen_level; |
| 36 | |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 37 | int set_instruction_dest(struct brw_instruction *instr, |
| 38 | struct dst_operand *dest); |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 39 | int set_instruction_src0(struct brw_instruction *instr, |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 40 | struct src_operand *src); |
| 41 | int set_instruction_src1(struct brw_instruction *instr, |
| 42 | struct src_operand *src); |
| 43 | void set_instruction_options(struct brw_instruction *instr, |
| 44 | struct brw_instruction *options); |
| 45 | void set_instruction_predicate(struct brw_instruction *instr, |
| 46 | struct brw_instruction *predicate); |
| 47 | void set_instruction_predicate(struct brw_instruction *instr, |
| 48 | struct brw_instruction *predicate); |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 49 | void set_direct_dst_operand(struct dst_operand *dst, struct direct_reg *reg, |
| 50 | int type); |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 51 | void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg, |
| 52 | int type); |
| 53 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 54 | %} |
| 55 | |
| 56 | %start ROOT |
| 57 | |
| 58 | %union { |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 59 | char *string; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 60 | int integer; |
| 61 | double number; |
| 62 | struct brw_instruction instruction; |
| 63 | struct brw_program program; |
| 64 | struct region { |
| 65 | int vert_stride, width, horiz_stride; |
| 66 | } region; |
Eric Anholt | 74c81af | 2006-08-30 11:10:45 -0700 | [diff] [blame] | 67 | struct direct_reg direct_reg; |
| 68 | struct indirect_reg indirect_reg; |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 69 | |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 70 | imm32_t imm32; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 71 | |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 72 | struct dst_operand dst_operand; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 73 | struct src_operand src_operand; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 74 | } |
| 75 | |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 76 | %token COLON |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 77 | %token SEMICOLON |
| 78 | %token LPAREN RPAREN |
| 79 | %token LANGLE RANGLE |
| 80 | %token LCURLY RCURLY |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 81 | %token LSQUARE RSQUARE |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 82 | %token COMMA |
| 83 | %token DOT |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 84 | %token PLUS MINUS ABS |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 85 | |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 86 | %token <integer> TYPE_UD TYPE_D TYPE_UW TYPE_W TYPE_UB TYPE_B |
| 87 | %token <integer> TYPE_VF TYPE_HF TYPE_V TYPE_F |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 88 | |
Eric Anholt | 908f37d | 2006-08-25 17:33:02 -0700 | [diff] [blame] | 89 | %token ALIGN1 ALIGN16 SECHALF COMPR SWITCH ATOMIC NODDCHK NODDCLR |
| 90 | %token MASK_DISABLE BREAKPOINT EOT |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 91 | |
Keith Packard | 2033aea | 2008-04-23 23:10:40 -0700 | [diff] [blame] | 92 | %token SEQ ANY2H ALL2H ANY4H ALL4H ANY8H ALL8H ANY16H ALL16H ANYV ALLV |
| 93 | %token <integer> ZERO EQUAL NOT_ZERO NOT_EQUAL GREATER GREATER_EQUAL LESS LESS_EQUAL |
| 94 | %token <integer> ROUND_INCREMENT OVERFLOW UNORDERED |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 95 | %token <integer> GENREG MSGREG ADDRESSREG ACCREG FLAGREG |
| 96 | %token <integer> MASKREG AMASK IMASK LMASK CMASK |
| 97 | %token <integer> MASKSTACKREG LMS IMS MASKSTACKDEPTHREG IMSD LMSD |
| 98 | %token <integer> NOTIFYREG STATEREG CONTROLREG IPREG |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 99 | %token GENREGFILE MSGREGFILE |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 100 | |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 101 | %token <integer> MOV FRC RNDU RNDD RNDE RNDZ NOT LZD |
| 102 | %token <integer> MUL MAC MACH LINE SAD2 SADA2 DP4 DPH DP3 DP2 |
| 103 | %token <integer> AVG ADD SEL AND OR XOR SHR SHL ASR CMP CMPN |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 104 | %token <integer> SEND NOP JMPI IF IFF WHILE ELSE BREAK CONT HALT MSAVE |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 105 | %token <integer> PUSH MREST POP WAIT DO ENDIF ILLEGAL |
| 106 | |
| 107 | %token NULL_TOKEN MATH SAMPLER GATEWAY READ WRITE URB THREAD_SPAWNER |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 108 | |
| 109 | %token MSGLEN RETURNLEN |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 110 | %token <integer> ALLOCATE USED COMPLETE TRANSPOSE INTERLEAVE |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 111 | %token SATURATE |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 112 | |
| 113 | %token <integer> INTEGER |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 114 | %token <string> STRING |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 115 | %token <number> NUMBER |
| 116 | |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 117 | %token <integer> INV LOG EXP SQRT RSQ POW SIN COS SINCOS INTDIV INTMOD |
| 118 | %token <integer> INTDIVMOD |
| 119 | %token SIGNED SCALAR |
| 120 | |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 121 | %token <integer> X Y Z W |
| 122 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 123 | %type <instruction> instruction unaryinstruction binaryinstruction |
| 124 | %type <instruction> binaryaccinstruction triinstruction sendinstruction |
Eric Anholt | 356ce76 | 2006-08-31 10:27:48 -0700 | [diff] [blame] | 125 | %type <instruction> jumpinstruction branchloopinstruction elseinstruction |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 126 | %type <instruction> breakinstruction syncinstruction specialinstruction |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 127 | %type <instruction> msgtarget |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 128 | %type <instruction> instoptions instoption_list predicate |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 129 | %type <string> label |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 130 | %type <program> instrseq |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 131 | %type <integer> instoption |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 132 | %type <integer> unaryop binaryop binaryaccop branchloopop breakop |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 133 | %type <integer> conditionalmodifier saturate negate abs chansel |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 134 | %type <integer> writemask_x writemask_y writemask_z writemask_w |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 135 | %type <integer> regtype srcimmtype execsize dstregion immaddroffset |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 136 | %type <integer> subregnum sampler_datatype |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 137 | %type <integer> urb_swizzle urb_allocate urb_used urb_complete |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 138 | %type <integer> math_function math_signed math_scalar |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 139 | %type <integer> predctrl predstate |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 140 | %type <region> region region_wh indirectregion |
Eric Anholt | 1d7d042 | 2006-08-25 16:52:09 -0700 | [diff] [blame] | 141 | %type <direct_reg> directgenreg directmsgreg addrreg accreg flagreg maskreg |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 142 | %type <direct_reg> maskstackreg notifyreg |
| 143 | /* %type <direct_reg> maskstackdepthreg */ |
Eric Anholt | 1d7d042 | 2006-08-25 16:52:09 -0700 | [diff] [blame] | 144 | %type <direct_reg> statereg controlreg ipreg nullreg |
| 145 | %type <direct_reg> dstoperandex_typed srcarchoperandex_typed |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 146 | %type <indirect_reg> indirectgenreg indirectmsgreg addrparam |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 147 | %type <integer> mask_subreg maskstack_subreg |
| 148 | /* %type <intger> maskstackdepth_subreg */ |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 149 | %type <imm32> imm32 |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 150 | %type <dst_operand> dst dstoperand dstoperandex dstreg post_dst writemask |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 151 | %type <src_operand> directsrcoperand srcarchoperandex directsrcaccoperand |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 152 | %type <src_operand> indirectsrcoperand |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 153 | %type <src_operand> src srcimm imm32reg payload srcacc srcaccimm swizzle |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 154 | %type <src_operand> relativelocation relativelocation2 locationstackcontrol |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 155 | %% |
| 156 | |
| 157 | ROOT: instrseq |
| 158 | { |
| 159 | compiled_program = $1; |
| 160 | } |
| 161 | ; |
| 162 | |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 163 | |
| 164 | label: STRING COLON |
| 165 | { |
| 166 | $$ = $1; |
| 167 | } |
| 168 | ; |
| 169 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 170 | instrseq: instruction SEMICOLON instrseq |
| 171 | { |
| 172 | struct brw_program_instruction *list_entry = |
| 173 | calloc(sizeof(struct brw_program_instruction), 1); |
| 174 | list_entry->instruction = $1; |
| 175 | |
| 176 | list_entry->next = $3.first; |
| 177 | $3.first = list_entry; |
| 178 | |
| 179 | $$ = $3; |
| 180 | } |
| 181 | | instruction SEMICOLON |
| 182 | { |
| 183 | struct brw_program_instruction *list_entry = |
| 184 | calloc(sizeof(struct brw_program_instruction), 1); |
| 185 | list_entry->instruction = $1; |
| 186 | |
| 187 | list_entry->next = NULL; |
| 188 | |
| 189 | $$.first = list_entry; |
| 190 | } |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 191 | | label instrseq |
| 192 | { |
| 193 | struct brw_program_instruction *list_entry = |
| 194 | calloc(sizeof(struct brw_program_instruction), 1); |
| 195 | list_entry->string = $1; |
| 196 | list_entry->islabel = 1; |
| 197 | list_entry->next = $2.first; |
| 198 | $2.first = list_entry; |
| 199 | $$ = $2; |
| 200 | } |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 201 | | error SEMICOLON instrseq |
| 202 | { |
| 203 | $$ = $3; |
| 204 | } |
| 205 | ; |
| 206 | |
| 207 | /* 1.4.1: Instruction groups */ |
| 208 | instruction: unaryinstruction |
| 209 | | binaryinstruction |
| 210 | | binaryaccinstruction |
| 211 | | triinstruction |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 212 | | jumpinstruction |
| 213 | | branchloopinstruction |
Eric Anholt | 356ce76 | 2006-08-31 10:27:48 -0700 | [diff] [blame] | 214 | | elseinstruction |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 215 | | breakinstruction |
Eric Anholt | 1f58efa | 2006-09-01 11:56:12 -0700 | [diff] [blame] | 216 | | syncinstruction |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 217 | | specialinstruction |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 218 | ; |
| 219 | |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 220 | unaryinstruction: |
| 221 | predicate unaryop conditionalmodifier saturate execsize |
| 222 | dst srcaccimm instoptions |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 223 | { |
Eric Anholt | 56b50b6 | 2006-08-24 10:51:48 -0700 | [diff] [blame] | 224 | bzero(&$$, sizeof($$)); |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 225 | $$.header.opcode = $2; |
Eric Anholt | 90aea51 | 2006-08-22 14:46:39 -0700 | [diff] [blame] | 226 | $$.header.destreg__conditionalmod = $3; |
| 227 | $$.header.saturate = $4; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 228 | $$.header.execution_size = $5; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 229 | set_instruction_options(&$$, &$8); |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 230 | set_instruction_predicate(&$$, &$1); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 231 | if (set_instruction_dest(&$$, &$6) != 0) |
| 232 | YYERROR; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 233 | if (set_instruction_src0(&$$, &$7) != 0) |
| 234 | YYERROR; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 235 | } |
| 236 | ; |
| 237 | |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 238 | unaryop: MOV | FRC | RNDU | RNDD | RNDE | RNDZ | NOT | LZD |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 239 | ; |
| 240 | |
| 241 | binaryinstruction: |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 242 | predicate binaryop conditionalmodifier saturate execsize |
| 243 | dst src srcimm instoptions |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 244 | { |
Eric Anholt | 56b50b6 | 2006-08-24 10:51:48 -0700 | [diff] [blame] | 245 | bzero(&$$, sizeof($$)); |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 246 | $$.header.opcode = $2; |
Eric Anholt | 90aea51 | 2006-08-22 14:46:39 -0700 | [diff] [blame] | 247 | $$.header.destreg__conditionalmod = $3; |
| 248 | $$.header.saturate = $4; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 249 | $$.header.execution_size = $5; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 250 | set_instruction_options(&$$, &$9); |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 251 | set_instruction_predicate(&$$, &$1); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 252 | if (set_instruction_dest(&$$, &$6) != 0) |
| 253 | YYERROR; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 254 | if (set_instruction_src0(&$$, &$7) != 0) |
| 255 | YYERROR; |
| 256 | if (set_instruction_src1(&$$, &$8) != 0) |
| 257 | YYERROR; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 258 | } |
| 259 | ; |
| 260 | |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 261 | binaryop: MUL | MAC | MACH | LINE | SAD2 | SADA2 | DP4 | DPH | DP3 | DP2 |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 262 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 263 | |
| 264 | binaryaccinstruction: |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 265 | predicate binaryaccop conditionalmodifier saturate execsize |
| 266 | dst srcacc srcimm instoptions |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 267 | { |
Eric Anholt | 56b50b6 | 2006-08-24 10:51:48 -0700 | [diff] [blame] | 268 | bzero(&$$, sizeof($$)); |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 269 | $$.header.opcode = $2; |
Eric Anholt | 90aea51 | 2006-08-22 14:46:39 -0700 | [diff] [blame] | 270 | $$.header.destreg__conditionalmod = $3; |
| 271 | $$.header.saturate = $4; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 272 | $$.header.execution_size = $5; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 273 | set_instruction_options(&$$, &$9); |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 274 | set_instruction_predicate(&$$, &$1); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 275 | if (set_instruction_dest(&$$, &$6) != 0) |
| 276 | YYERROR; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 277 | if (set_instruction_src0(&$$, &$7) != 0) |
| 278 | YYERROR; |
| 279 | if (set_instruction_src1(&$$, &$8) != 0) |
| 280 | YYERROR; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 281 | } |
| 282 | ; |
| 283 | |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 284 | binaryaccop: AVG | ADD | SEL | AND | OR | XOR | SHR | SHL | ASR | CMP | CMPN |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 285 | ; |
| 286 | |
| 287 | triinstruction: sendinstruction |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 288 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 289 | |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 290 | sendinstruction: predicate SEND execsize INTEGER post_dst payload msgtarget |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 291 | MSGLEN INTEGER RETURNLEN INTEGER instoptions |
| 292 | { |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 293 | /* Send instructions are messy. The first argument is the |
| 294 | * post destination -- the grf register that the response |
| 295 | * starts from. The second argument is the current |
| 296 | * destination, which is the start of the message arguments |
| 297 | * to the shared function, and where src0 payload is loaded |
| 298 | * to if not null. The payload is typically based on the |
| 299 | * grf 0 thread payload of your current thread, and is |
| 300 | * implicitly loaded if non-null. |
| 301 | */ |
Eric Anholt | 56b50b6 | 2006-08-24 10:51:48 -0700 | [diff] [blame] | 302 | bzero(&$$, sizeof($$)); |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 303 | $$.header.opcode = $2; |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 304 | $$.header.execution_size = $3; |
| 305 | $$.header.destreg__conditionalmod = $4; /* msg reg index */ |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 306 | set_instruction_predicate(&$$, &$1); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 307 | if (set_instruction_dest(&$$, &$5) != 0) |
| 308 | YYERROR; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 309 | if (set_instruction_src0(&$$, &$6) != 0) |
| 310 | YYERROR; |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 311 | $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE; |
| 312 | $$.bits1.da1.src1_reg_type = BRW_REGISTER_TYPE_D; |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 313 | |
| 314 | if (gen_level == 5) { |
| 315 | $$.bits2.send_gen5.sfid = $7.bits2.send_gen5.sfid; |
| 316 | $$.bits2.send_gen5.end_of_thread = $12.bits3.generic_gen5.end_of_thread; |
| 317 | $$.bits3.generic_gen5 = $7.bits3.generic_gen5; |
| 318 | $$.bits3.generic_gen5.msg_length = $9; |
| 319 | $$.bits3.generic_gen5.response_length = $11; |
| 320 | $$.bits3.generic_gen5.end_of_thread = |
| 321 | $12.bits3.generic_gen5.end_of_thread; |
| 322 | } else { |
| 323 | $$.bits3.generic = $7.bits3.generic; |
| 324 | $$.bits3.generic.msg_length = $9; |
| 325 | $$.bits3.generic.response_length = $11; |
| 326 | $$.bits3.generic.end_of_thread = |
| 327 | $12.bits3.generic.end_of_thread; |
| 328 | } |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 329 | } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 330 | ; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 331 | |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 332 | jumpinstruction: predicate JMPI relativelocation2 |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 333 | { |
| 334 | struct direct_reg dst; |
| 335 | struct dst_operand ip_dst; |
| 336 | struct src_operand ip_src; |
| 337 | |
| 338 | /* The jump instruction requires that the IP register |
| 339 | * be the destination and first source operand, while the |
| 340 | * offset is the second source operand. The next instruction |
| 341 | * is the post-incremented IP plus the offset. |
| 342 | */ |
Eric Anholt | 56cdee4 | 2006-08-31 15:28:10 -0700 | [diff] [blame] | 343 | dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 344 | dst.reg_nr = BRW_ARF_IP; |
| 345 | dst.subreg_nr = 0; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 346 | |
| 347 | bzero(&$$, sizeof($$)); |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 348 | $$.header.opcode = $2; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 349 | set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 350 | set_instruction_predicate(&$$, &$1); |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 351 | set_instruction_dest(&$$, &ip_dst); |
| 352 | set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); |
| 353 | set_instruction_src0(&$$, &ip_src); |
Zou Nanhai | be9bcee | 2008-12-09 18:38:54 -0800 | [diff] [blame] | 354 | set_instruction_src1(&$$, &$3); |
| 355 | } |
| 356 | | predicate JMPI STRING |
| 357 | { |
| 358 | struct direct_reg dst; |
| 359 | struct dst_operand ip_dst; |
| 360 | struct src_operand ip_src; |
| 361 | struct src_operand imm; |
| 362 | |
| 363 | /* The jump instruction requires that the IP register |
| 364 | * be the destination and first source operand, while the |
| 365 | * offset is the second source operand. The next instruction |
| 366 | is the post-incremented IP plus the offset. |
| 367 | */ |
| 368 | dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 369 | dst.reg_nr = BRW_ARF_IP; |
| 370 | dst.subreg_nr = 0; |
| 371 | memset (&imm, '\0', sizeof (imm)); |
| 372 | imm.reg_file = BRW_IMMEDIATE_VALUE; |
| 373 | imm.reg_type = BRW_REGISTER_TYPE_D; |
| 374 | imm.imm32 = 0; |
| 375 | |
| 376 | bzero(&$$, sizeof($$)); |
| 377 | $$.header.opcode = $2; |
| 378 | set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); |
| 379 | set_instruction_dest(&$$, &ip_dst); |
| 380 | set_instruction_predicate(&$$, &$1); |
| 381 | set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); |
| 382 | set_instruction_src0(&$$, &ip_src); |
| 383 | set_instruction_src1(&$$, &imm); |
| 384 | $$.reloc_target = $3; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 385 | } |
| 386 | ; |
| 387 | |
| 388 | branchloopinstruction: |
| 389 | predicate branchloopop relativelocation |
| 390 | { |
| 391 | struct direct_reg dst; |
| 392 | struct dst_operand ip_dst; |
| 393 | struct src_operand ip_src; |
| 394 | |
| 395 | /* The branch instructions require that the IP register |
| 396 | * be the destination and first source operand, while the |
| 397 | * offset is the second source operand. The offset is added |
| 398 | * to the pre-incremented IP. |
| 399 | */ |
Eric Anholt | 56cdee4 | 2006-08-31 15:28:10 -0700 | [diff] [blame] | 400 | dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 401 | dst.reg_nr = BRW_ARF_IP; |
| 402 | dst.subreg_nr = 0; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 403 | |
| 404 | bzero(&$$, sizeof($$)); |
| 405 | $$.header.opcode = $2; |
| 406 | set_instruction_predicate(&$$, &$1); |
| 407 | set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); |
| 408 | set_instruction_dest(&$$, &ip_dst); |
| 409 | set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); |
| 410 | set_instruction_src0(&$$, &ip_src); |
| 411 | set_instruction_src1(&$$, &$3); |
| 412 | } |
| 413 | ; |
| 414 | |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 415 | branchloopop: IF | IFF | WHILE |
| 416 | ; |
| 417 | |
Eric Anholt | 356ce76 | 2006-08-31 10:27:48 -0700 | [diff] [blame] | 418 | elseinstruction: ELSE relativelocation |
| 419 | { |
| 420 | struct direct_reg dst; |
| 421 | struct dst_operand ip_dst; |
| 422 | struct src_operand ip_src; |
| 423 | |
| 424 | /* The jump instruction requires that the IP register |
| 425 | * be the destination and first source operand, while the |
| 426 | * offset is the second source operand. The offset is added |
| 427 | * to the IP pre-increment. |
| 428 | */ |
Eric Anholt | 960ca00 | 2006-09-01 12:11:55 -0700 | [diff] [blame] | 429 | dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 430 | dst.reg_nr = BRW_ARF_IP; |
| 431 | dst.subreg_nr = 0; |
| 432 | |
| 433 | /* Set the istack pop count, which must always be 1. */ |
| 434 | $2.imm32 |= (1 << 16); |
Eric Anholt | 356ce76 | 2006-08-31 10:27:48 -0700 | [diff] [blame] | 435 | |
| 436 | bzero(&$$, sizeof($$)); |
| 437 | $$.header.opcode = $1; |
| 438 | set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); |
| 439 | set_instruction_dest(&$$, &ip_dst); |
| 440 | set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); |
| 441 | set_instruction_src0(&$$, &ip_src); |
| 442 | set_instruction_src1(&$$, &$2); |
| 443 | } |
| 444 | ; |
| 445 | |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 446 | breakinstruction: breakop locationstackcontrol |
| 447 | { |
| 448 | struct direct_reg dst; |
| 449 | struct dst_operand ip_dst; |
| 450 | struct src_operand ip_src; |
| 451 | |
| 452 | /* The jump instruction requires that the IP register |
| 453 | * be the destination and first source operand, while the |
| 454 | * offset is the second source operand. The offset is added |
| 455 | * to the IP pre-increment. |
| 456 | */ |
| 457 | dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 458 | dst.reg_nr = BRW_ARF_IP; |
| 459 | dst.subreg_nr = 0; |
| 460 | |
| 461 | bzero(&$$, sizeof($$)); |
| 462 | $$.header.opcode = $1; |
| 463 | set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); |
| 464 | set_instruction_dest(&$$, &ip_dst); |
| 465 | set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); |
| 466 | set_instruction_src0(&$$, &ip_src); |
| 467 | set_instruction_src1(&$$, &$2); |
| 468 | } |
| 469 | ; |
| 470 | |
| 471 | breakop: BREAK | CONT | HALT |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 472 | ; |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 473 | |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 474 | /* |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 475 | maskpushop: MSAVE | PUSH |
| 476 | ; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 477 | */ |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 478 | |
Eric Anholt | 1f58efa | 2006-09-01 11:56:12 -0700 | [diff] [blame] | 479 | syncinstruction: predicate WAIT notifyreg |
| 480 | { |
| 481 | struct direct_reg null; |
| 482 | struct dst_operand null_dst; |
| 483 | struct src_operand null_src; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 484 | struct src_operand notify_src; |
Eric Anholt | 1f58efa | 2006-09-01 11:56:12 -0700 | [diff] [blame] | 485 | |
| 486 | null.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 487 | null.reg_nr = BRW_ARF_NULL; |
| 488 | null.subreg_nr = 0; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 489 | |
| 490 | notify_src.reg_file = $3.reg_file; |
| 491 | notify_src.reg_nr = $3.reg_nr; |
| 492 | notify_src.subreg_nr = $3.subreg_nr; |
| 493 | notify_src.reg_type = BRW_REGISTER_TYPE_UD; |
Eric Anholt | 1f58efa | 2006-09-01 11:56:12 -0700 | [diff] [blame] | 494 | |
| 495 | bzero(&$$, sizeof($$)); |
| 496 | $$.header.opcode = $2; |
| 497 | set_direct_dst_operand(&null_dst, &null, BRW_REGISTER_TYPE_UD); |
| 498 | set_instruction_dest(&$$, &null_dst); |
| 499 | set_direct_src_operand(&null_src, &null, BRW_REGISTER_TYPE_UD); |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 500 | set_instruction_src0(&$$, ¬ify_src); |
Eric Anholt | 1f58efa | 2006-09-01 11:56:12 -0700 | [diff] [blame] | 501 | set_instruction_src1(&$$, &null_src); |
| 502 | } |
| 503 | ; |
| 504 | |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 505 | specialinstruction: NOP |
| 506 | { |
Eric Anholt | 56b50b6 | 2006-08-24 10:51:48 -0700 | [diff] [blame] | 507 | bzero(&$$, sizeof($$)); |
Eric Anholt | f914c6a | 2006-08-25 11:05:10 -0700 | [diff] [blame] | 508 | $$.header.opcode = $1; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 509 | } |
Eric Anholt | d777129 | 2006-08-30 11:40:05 -0700 | [diff] [blame] | 510 | | DO |
| 511 | { |
| 512 | bzero(&$$, sizeof($$)); |
| 513 | $$.header.opcode = $1; |
| 514 | } |
| 515 | | ENDIF |
| 516 | { |
| 517 | bzero(&$$, sizeof($$)); |
| 518 | $$.header.opcode = $1; |
| 519 | $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE; |
Eric Anholt | f45ac8b | 2006-09-01 12:29:23 -0700 | [diff] [blame] | 520 | $$.bits1.da1.src1_reg_type = BRW_REGISTER_TYPE_D; |
Eric Anholt | d777129 | 2006-08-30 11:40:05 -0700 | [diff] [blame] | 521 | $$.bits3.if_else.pop_count = 1; |
| 522 | } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 523 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 524 | |
| 525 | /* XXX! */ |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 526 | payload: directsrcoperand |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 527 | ; |
| 528 | |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 529 | post_dst: dst |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 530 | ; |
| 531 | |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 532 | msgtarget: NULL_TOKEN |
| 533 | { |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 534 | if (gen_level == 5) { |
| 535 | $$.bits2.send_gen5.sfid= BRW_MESSAGE_TARGET_NULL; |
| 536 | $$.bits3.generic_gen5.header_present = 0; /* ??? */ |
| 537 | } else { |
| 538 | $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_NULL; |
| 539 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 540 | } |
| 541 | | SAMPLER LPAREN INTEGER COMMA INTEGER COMMA |
| 542 | sampler_datatype RPAREN |
| 543 | { |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 544 | if (gen_level == 5) { |
| 545 | $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_SAMPLER; |
| 546 | $$.bits3.generic_gen5.header_present = 1; /* ??? */ |
| 547 | $$.bits3.sampler_gen5.binding_table_index = $3; |
| 548 | $$.bits3.sampler_gen5.sampler = $5; |
| 549 | $$.bits3.sampler_gen5.simd_mode = 2; /* SIMD16, maybe we should add a new parameter */ |
| 550 | } else { |
| 551 | $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_SAMPLER; |
| 552 | $$.bits3.sampler.binding_table_index = $3; |
| 553 | $$.bits3.sampler.sampler = $5; |
| 554 | switch ($7) { |
| 555 | case TYPE_F: |
| 556 | $$.bits3.sampler.return_format = |
| 557 | BRW_SAMPLER_RETURN_FORMAT_FLOAT32; |
| 558 | break; |
| 559 | case TYPE_UD: |
| 560 | $$.bits3.sampler.return_format = |
| 561 | BRW_SAMPLER_RETURN_FORMAT_UINT32; |
| 562 | break; |
| 563 | case TYPE_D: |
| 564 | $$.bits3.sampler.return_format = |
| 565 | BRW_SAMPLER_RETURN_FORMAT_SINT32; |
| 566 | break; |
| 567 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 568 | } |
| 569 | } |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 570 | | MATH math_function saturate math_signed math_scalar |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 571 | { |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 572 | if (gen_level == 5) { |
| 573 | $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_MATH; |
| 574 | $$.bits3.generic_gen5.header_present = 0; |
| 575 | $$.bits3.math_gen5.function = $2; |
| 576 | if ($3 == BRW_INSTRUCTION_SATURATE) |
| 577 | $$.bits3.math_gen5.saturate = 1; |
| 578 | else |
| 579 | $$.bits3.math_gen5.saturate = 0; |
| 580 | $$.bits3.math_gen5.int_type = $4; |
| 581 | $$.bits3.math_gen5.precision = BRW_MATH_PRECISION_FULL; |
| 582 | $$.bits3.math_gen5.data_type = $5; |
| 583 | } else { |
| 584 | $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_MATH; |
| 585 | $$.bits3.math.function = $2; |
| 586 | if ($3 == BRW_INSTRUCTION_SATURATE) |
| 587 | $$.bits3.math.saturate = 1; |
| 588 | else |
| 589 | $$.bits3.math.saturate = 0; |
| 590 | $$.bits3.math.int_type = $4; |
| 591 | $$.bits3.math.precision = BRW_MATH_PRECISION_FULL; |
| 592 | $$.bits3.math.data_type = $5; |
| 593 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 594 | } |
| 595 | | GATEWAY |
| 596 | { |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 597 | if (gen_level == 5) { |
| 598 | $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_GATEWAY; |
| 599 | $$.bits3.generic_gen5.header_present = 0; /* ??? */ |
| 600 | } else { |
| 601 | $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_GATEWAY; |
| 602 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 603 | } |
Zou Nan hai | 807f876 | 2008-06-18 15:05:19 -0700 | [diff] [blame] | 604 | | READ LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA |
| 605 | INTEGER RPAREN |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 606 | { |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 607 | if (gen_level == 5) { |
| 608 | $$.bits2.send_gen5.sfid = |
| 609 | BRW_MESSAGE_TARGET_DATAPORT_READ; |
| 610 | $$.bits3.generic_gen5.header_present = 1; |
| 611 | $$.bits3.dp_read_gen5.binding_table_index = $3; |
| 612 | $$.bits3.dp_read_gen5.target_cache = $5; |
| 613 | $$.bits3.dp_read_gen5.msg_control = $7; |
| 614 | $$.bits3.dp_read_gen5.msg_type = $9; |
| 615 | } else { |
| 616 | $$.bits3.generic.msg_target = |
| 617 | BRW_MESSAGE_TARGET_DATAPORT_READ; |
| 618 | $$.bits3.dp_read.binding_table_index = $3; |
| 619 | $$.bits3.dp_read.target_cache = $5; |
| 620 | $$.bits3.dp_read.msg_control = $7; |
| 621 | $$.bits3.dp_read.msg_type = $9; |
| 622 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 623 | } |
Eric Anholt | 4331394 | 2006-08-24 15:26:10 -0700 | [diff] [blame] | 624 | | WRITE LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA |
| 625 | INTEGER RPAREN |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 626 | { |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 627 | if (gen_level == 5) { |
| 628 | $$.bits2.send_gen5.sfid = |
| 629 | BRW_MESSAGE_TARGET_DATAPORT_WRITE; |
| 630 | $$.bits3.generic_gen5.header_present = 1; |
| 631 | $$.bits3.dp_write_gen5.binding_table_index = $3; |
| 632 | $$.bits3.dp_write_gen5.pixel_scoreboard_clear = ($5 & 0x8) >> 3; |
| 633 | $$.bits3.dp_write_gen5.msg_control = $5 & 0x7; |
| 634 | $$.bits3.dp_write_gen5.msg_type = $7; |
| 635 | $$.bits3.dp_write_gen5.send_commit_msg = $9; |
| 636 | } else { |
| 637 | $$.bits3.generic.msg_target = |
| 638 | BRW_MESSAGE_TARGET_DATAPORT_WRITE; |
| 639 | $$.bits3.dp_write.binding_table_index = $3; |
| 640 | /* The msg control field of brw_struct.h is split into |
| 641 | * msg control and pixel_scoreboard_clear, even though |
| 642 | * pixel_scoreboard_clear isn't common to all write messages. |
| 643 | */ |
| 644 | $$.bits3.dp_write.pixel_scoreboard_clear = ($5 & 0x8) >> 3; |
| 645 | $$.bits3.dp_write.msg_control = $5 & 0x7; |
| 646 | $$.bits3.dp_write.msg_type = $7; |
| 647 | $$.bits3.dp_write.send_commit_msg = $9; |
| 648 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 649 | } |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 650 | | URB INTEGER urb_swizzle urb_allocate urb_used urb_complete |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 651 | { |
| 652 | $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_URB; |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 653 | if (gen_level == 5) { |
| 654 | $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_URB; |
| 655 | $$.bits3.generic_gen5.header_present = 1; |
| 656 | $$.bits3.urb_gen5.opcode = BRW_URB_OPCODE_WRITE; |
| 657 | $$.bits3.urb_gen5.offset = $2; |
| 658 | $$.bits3.urb_gen5.swizzle_control = $3; |
| 659 | $$.bits3.urb_gen5.pad = 0; |
| 660 | $$.bits3.urb_gen5.allocate = $4; |
| 661 | $$.bits3.urb_gen5.used = $5; |
| 662 | $$.bits3.urb_gen5.complete = $6; |
| 663 | } else { |
| 664 | $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_URB; |
| 665 | $$.bits3.urb.opcode = BRW_URB_OPCODE_WRITE; |
| 666 | $$.bits3.urb.offset = $2; |
| 667 | $$.bits3.urb.swizzle_control = $3; |
| 668 | $$.bits3.urb.pad = 0; |
| 669 | $$.bits3.urb.allocate = $4; |
| 670 | $$.bits3.urb.used = $5; |
| 671 | $$.bits3.urb.complete = $6; |
| 672 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 673 | } |
Zou Nan hai | 26afe90 | 2008-06-18 15:04:11 -0700 | [diff] [blame] | 674 | | THREAD_SPAWNER LPAREN INTEGER COMMA INTEGER COMMA |
| 675 | INTEGER RPAREN |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 676 | { |
| 677 | $$.bits3.generic.msg_target = |
| 678 | BRW_MESSAGE_TARGET_THREAD_SPAWNER; |
Xiang Haihao | 549b751 | 2009-06-30 10:02:33 +0800 | [diff] [blame^] | 679 | if (gen_level == 5) { |
| 680 | $$.bits2.send_gen5.sfid = |
| 681 | BRW_MESSAGE_TARGET_THREAD_SPAWNER; |
| 682 | $$.bits3.generic_gen5.header_present = 0; |
| 683 | $$.bits3.thread_spawner_gen5.opcode = $3; |
| 684 | $$.bits3.thread_spawner_gen5.requester_type = $5; |
| 685 | $$.bits3.thread_spawner_gen5.resource_select = $7; |
| 686 | } else { |
| 687 | $$.bits3.generic.msg_target = |
| 688 | BRW_MESSAGE_TARGET_THREAD_SPAWNER; |
| 689 | $$.bits3.thread_spawner.opcode = $3; |
| 690 | $$.bits3.thread_spawner.requester_type = $5; |
| 691 | $$.bits3.thread_spawner.resource_select = $7; |
| 692 | } |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 693 | } |
| 694 | ; |
| 695 | |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 696 | urb_allocate: ALLOCATE { $$ = 1; } |
| 697 | | /* empty */ { $$ = 0; } |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 698 | ; |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 699 | |
| 700 | urb_used: USED { $$ = 1; } |
| 701 | | /* empty */ { $$ = 0; } |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 702 | ; |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 703 | |
| 704 | urb_complete: COMPLETE { $$ = 1; } |
| 705 | | /* empty */ { $$ = 0; } |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 706 | ; |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 707 | |
| 708 | urb_swizzle: TRANSPOSE { $$ = BRW_URB_SWIZZLE_TRANSPOSE; } |
| 709 | | INTERLEAVE { $$ = BRW_URB_SWIZZLE_INTERLEAVE; } |
| 710 | | /* empty */ { $$ = BRW_URB_SWIZZLE_NONE; } |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 711 | ; |
Eric Anholt | e865196 | 2006-08-24 16:37:04 -0700 | [diff] [blame] | 712 | |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 713 | sampler_datatype: |
| 714 | TYPE_F |
| 715 | | TYPE_UD |
| 716 | | TYPE_D |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 717 | ; |
| 718 | |
| 719 | math_function: INV | LOG | EXP | SQRT | POW | SIN | COS | SINCOS | INTDIV |
| 720 | | INTMOD | INTDIVMOD |
| 721 | ; |
| 722 | |
| 723 | math_signed: /* empty */ { $$ = 0; } |
| 724 | | SIGNED { $$ = 1; } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 725 | ; |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 726 | |
| 727 | math_scalar: /* empty */ { $$ = 0; } |
| 728 | | SCALAR { $$ = 1; } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 729 | ; |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 730 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 731 | /* 1.4.2: Destination register */ |
| 732 | |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 733 | dst: dstoperand | dstoperandex |
Eric Anholt | 3d36079 | 2006-08-25 09:36:28 -0700 | [diff] [blame] | 734 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 735 | |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 736 | dstoperand: dstreg dstregion writemask regtype |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 737 | { |
| 738 | /* Returns an instruction with just the destination register |
| 739 | * filled in. |
| 740 | */ |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 741 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 742 | $$.reg_file = $1.reg_file; |
| 743 | $$.reg_nr = $1.reg_nr; |
| 744 | $$.subreg_nr = $1.subreg_nr; |
| 745 | $$.horiz_stride = $2; |
| 746 | $$.writemask_set = $3.writemask_set; |
| 747 | $$.writemask = $3.writemask; |
| 748 | $$.reg_type = $4; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 749 | } |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 750 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 751 | |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 752 | /* The dstoperandex returns an instruction with just the destination register |
| 753 | * filled in. |
| 754 | */ |
| 755 | dstoperandex: dstoperandex_typed dstregion regtype |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 756 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 757 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 758 | $$.reg_file = $1.reg_file; |
| 759 | $$.reg_nr = $1.reg_nr; |
| 760 | $$.subreg_nr = $1.subreg_nr; |
| 761 | $$.horiz_stride = $2; |
| 762 | $$.reg_type = $3; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 763 | } |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 764 | | maskstackreg |
| 765 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 766 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 767 | $$.reg_file = $1.reg_file; |
| 768 | $$.reg_nr = $1.reg_nr; |
| 769 | $$.subreg_nr = $1.subreg_nr; |
| 770 | $$.horiz_stride = 1; |
| 771 | $$.reg_type = BRW_REGISTER_TYPE_UW; |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 772 | } |
| 773 | | controlreg |
| 774 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 775 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 776 | $$.reg_file = $1.reg_file; |
| 777 | $$.reg_nr = $1.reg_nr; |
| 778 | $$.subreg_nr = $1.subreg_nr; |
| 779 | $$.horiz_stride = 1; |
| 780 | $$.reg_type = BRW_REGISTER_TYPE_UD; |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 781 | } |
| 782 | | ipreg |
| 783 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 784 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 785 | $$.reg_file = $1.reg_file; |
| 786 | $$.reg_nr = $1.reg_nr; |
| 787 | $$.subreg_nr = $1.subreg_nr; |
| 788 | $$.horiz_stride = 1; |
| 789 | $$.reg_type = BRW_REGISTER_TYPE_UD; |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 790 | } |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 791 | | nullreg |
| 792 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 793 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 794 | $$.reg_file = $1.reg_file; |
| 795 | $$.reg_nr = $1.reg_nr; |
| 796 | $$.subreg_nr = $1.subreg_nr; |
| 797 | $$.horiz_stride = 1; |
| 798 | $$.reg_type = BRW_REGISTER_TYPE_F; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 799 | } |
| 800 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 801 | |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 802 | dstoperandex_typed: accreg | flagreg | addrreg | maskreg |
| 803 | ; |
| 804 | |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 805 | /* Returns a partially complete destination register consisting of the |
| 806 | * direct or indirect register addressing fields, but not stride or writemask. |
| 807 | */ |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 808 | dstreg: directgenreg |
| 809 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 810 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 811 | $$.address_mode = BRW_ADDRESS_DIRECT; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 812 | $$.reg_file = $1.reg_file; |
| 813 | $$.reg_nr = $1.reg_nr; |
| 814 | $$.subreg_nr = $1.subreg_nr; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 815 | } |
| 816 | | directmsgreg |
Eric Anholt | a34d1e0 | 2006-08-22 14:52:14 -0700 | [diff] [blame] | 817 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 818 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 819 | $$.address_mode = BRW_ADDRESS_DIRECT; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 820 | $$.reg_file = $1.reg_file; |
| 821 | $$.reg_nr = $1.reg_nr; |
| 822 | $$.subreg_nr = $1.subreg_nr; |
Eric Anholt | a34d1e0 | 2006-08-22 14:52:14 -0700 | [diff] [blame] | 823 | } |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 824 | | indirectgenreg |
| 825 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 826 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 827 | $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER; |
| 828 | $$.reg_file = $1.reg_file; |
| 829 | $$.address_subreg_nr = $1.address_subreg_nr; |
| 830 | $$.indirect_offset = $1.indirect_offset; |
| 831 | } |
| 832 | | indirectmsgreg |
| 833 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 834 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 835 | $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER; |
| 836 | $$.reg_file = $1.reg_file; |
| 837 | $$.address_subreg_nr = $1.address_subreg_nr; |
| 838 | $$.indirect_offset = $1.indirect_offset; |
| 839 | } |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 840 | ; |
| 841 | |
| 842 | /* 1.4.3: Source register */ |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 843 | srcaccimm: srcacc | imm32reg |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 844 | ; |
| 845 | |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 846 | srcacc: directsrcaccoperand | indirectsrcoperand |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 847 | ; |
| 848 | |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 849 | srcimm: directsrcoperand | imm32reg |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 850 | ; |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 851 | |
| 852 | imm32reg: imm32 srcimmtype |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 853 | { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 854 | union { |
| 855 | int i; |
| 856 | float f; |
| 857 | } intfloat; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 858 | uint32_t d; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 859 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 860 | switch ($2) { |
| 861 | case BRW_REGISTER_TYPE_UD: |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 862 | case BRW_REGISTER_TYPE_D: |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 863 | case BRW_REGISTER_TYPE_V: |
| 864 | switch ($1.r) { |
| 865 | case imm32_d: |
| 866 | d = $1.u.d; |
| 867 | break; |
| 868 | default: |
| 869 | fprintf (stderr, "non-int D/UD/V representation\n"); |
| 870 | YYERROR; |
| 871 | } |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 872 | break; |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 873 | case BRW_REGISTER_TYPE_UW: |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 874 | case BRW_REGISTER_TYPE_W: |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 875 | switch ($1.r) { |
| 876 | case imm32_d: |
| 877 | d = $1.u.d; |
| 878 | break; |
| 879 | default: |
| 880 | fprintf (stderr, "non-int W/UW representation\n"); |
| 881 | YYERROR; |
| 882 | } |
| 883 | d &= 0xffff; |
| 884 | d |= d << 16; |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 885 | break; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 886 | case BRW_REGISTER_TYPE_F: |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 887 | switch ($1.r) { |
| 888 | case imm32_f: |
| 889 | intfloat.f = $1.u.f; |
| 890 | break; |
| 891 | case imm32_d: |
| 892 | intfloat.f = (float) $1.u.d; |
| 893 | break; |
| 894 | default: |
| 895 | fprintf (stderr, "non-float F representation\n"); |
| 896 | YYERROR; |
| 897 | } |
| 898 | d = intfloat.i; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 899 | break; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 900 | case BRW_REGISTER_TYPE_VF: |
| 901 | fprintf (stderr, "Immediate type VF not supported yet\n"); |
| 902 | YYERROR; |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 903 | default: |
| 904 | fprintf(stderr, "unknown immediate type %d\n", $2); |
| 905 | YYERROR; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 906 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 907 | memset (&$$, '\0', sizeof ($$)); |
| 908 | $$.reg_file = BRW_IMMEDIATE_VALUE; |
| 909 | $$.reg_type = $2; |
| 910 | $$.imm32 = d; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 911 | } |
| 912 | ; |
| 913 | |
Eric Anholt | 5297b2a | 2006-08-25 16:50:17 -0700 | [diff] [blame] | 914 | directsrcaccoperand: directsrcoperand |
Eric Anholt | 2a0f135 | 2006-08-25 17:44:55 -0700 | [diff] [blame] | 915 | | accreg regtype |
| 916 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 917 | set_direct_src_operand(&$$, &$1, $2); |
Eric Anholt | 2a0f135 | 2006-08-25 17:44:55 -0700 | [diff] [blame] | 918 | } |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 919 | ; |
| 920 | |
| 921 | /* Returns a source operand in the src0 fields of an instruction. */ |
Eric Anholt | 5297b2a | 2006-08-25 16:50:17 -0700 | [diff] [blame] | 922 | srcarchoperandex: srcarchoperandex_typed region regtype |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 923 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 924 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 925 | $$.reg_file = $1.reg_file; |
| 926 | $$.reg_type = $3; |
| 927 | $$.subreg_nr = $1.subreg_nr; |
| 928 | $$.reg_nr = $1.reg_nr; |
| 929 | $$.vert_stride = $2.vert_stride; |
| 930 | $$.width = $2.width; |
| 931 | $$.horiz_stride = $2.horiz_stride; |
| 932 | $$.negate = 0; |
| 933 | $$.abs = 0; |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 934 | } |
| 935 | | maskstackreg |
| 936 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 937 | set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UB); |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 938 | } |
| 939 | | controlreg |
| 940 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 941 | set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD); |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 942 | } |
| 943 | | statereg |
| 944 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 945 | set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD); |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 946 | } |
| 947 | | notifyreg |
| 948 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 949 | set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD); |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 950 | } |
| 951 | | ipreg |
| 952 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 953 | set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD); |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 954 | } |
| 955 | | nullreg |
| 956 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 957 | set_direct_src_operand(&$$, &$1, BRW_REGISTER_TYPE_UD); |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 958 | } |
| 959 | ; |
| 960 | |
Eric Anholt | 5297b2a | 2006-08-25 16:50:17 -0700 | [diff] [blame] | 961 | srcarchoperandex_typed: flagreg | addrreg | maskreg |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 962 | ; |
| 963 | |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 964 | src: directsrcoperand | indirectsrcoperand |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 965 | ; |
| 966 | |
Eric Anholt | dc96c56 | 2006-08-22 14:42:45 -0700 | [diff] [blame] | 967 | directsrcoperand: |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 968 | negate abs directgenreg region regtype swizzle |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 969 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 970 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 971 | $$.address_mode = BRW_ADDRESS_DIRECT; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 972 | $$.reg_file = $3.reg_file; |
| 973 | $$.reg_nr = $3.reg_nr; |
| 974 | $$.subreg_nr = $3.subreg_nr; |
| 975 | $$.reg_type = $5; |
| 976 | $$.vert_stride = $4.vert_stride; |
| 977 | $$.width = $4.width; |
| 978 | $$.horiz_stride = $4.horiz_stride; |
| 979 | $$.negate = $1; |
| 980 | $$.abs = $2; |
| 981 | $$.swizzle_set = $6.swizzle_set; |
| 982 | $$.swizzle_x = $6.swizzle_x; |
| 983 | $$.swizzle_y = $6.swizzle_y; |
| 984 | $$.swizzle_z = $6.swizzle_z; |
| 985 | $$.swizzle_w = $6.swizzle_w; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 986 | } |
Eric Anholt | 5297b2a | 2006-08-25 16:50:17 -0700 | [diff] [blame] | 987 | | srcarchoperandex |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 988 | ; |
| 989 | |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 990 | indirectsrcoperand: |
| 991 | negate abs indirectgenreg indirectregion regtype swizzle |
| 992 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 993 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 994 | $$.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER; |
| 995 | $$.reg_file = $3.reg_file; |
| 996 | $$.address_subreg_nr = $3.address_subreg_nr; |
| 997 | $$.indirect_offset = $3.indirect_offset; |
| 998 | $$.reg_type = $5; |
| 999 | $$.vert_stride = $4.vert_stride; |
| 1000 | $$.width = $4.width; |
| 1001 | $$.horiz_stride = $4.horiz_stride; |
| 1002 | $$.negate = $1; |
| 1003 | $$.abs = $2; |
| 1004 | $$.swizzle_set = $6.swizzle_set; |
| 1005 | $$.swizzle_x = $6.swizzle_x; |
| 1006 | $$.swizzle_y = $6.swizzle_y; |
| 1007 | $$.swizzle_z = $6.swizzle_z; |
| 1008 | $$.swizzle_w = $6.swizzle_w; |
| 1009 | } |
| 1010 | ; |
| 1011 | |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1012 | /* 1.4.4: Address Registers */ |
| 1013 | /* Returns a partially-completed indirect_reg consisting of the address |
| 1014 | * register fields for register-indirect access. |
| 1015 | */ |
| 1016 | addrparam: addrreg immaddroffset |
| 1017 | { |
| 1018 | if ($2 < -512 || $2 > 511) { |
| 1019 | fprintf(stderr, "Address immediate offset %d out of" |
| 1020 | "range\n", $2); |
| 1021 | YYERROR; |
| 1022 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1023 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1024 | $$.address_subreg_nr = $1.subreg_nr; |
| 1025 | $$.indirect_offset = $2; |
| 1026 | } |
| 1027 | ; |
| 1028 | |
| 1029 | /* The immaddroffset provides an immediate offset value added to the addresses |
| 1030 | * from the address register in register-indirect register access. |
| 1031 | */ |
| 1032 | immaddroffset: /* empty */ { $$ = 0; } |
| 1033 | | INTEGER |
| 1034 | ; |
| 1035 | |
| 1036 | |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1037 | /* 1.4.5: Register files and register numbers */ |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1038 | subregnum: DOT INTEGER |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1039 | { |
| 1040 | $$ = $2; |
| 1041 | } |
| 1042 | | |
| 1043 | { |
| 1044 | /* Default to subreg 0 if unspecified. */ |
| 1045 | $$ = 0; |
| 1046 | } |
| 1047 | ; |
| 1048 | |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1049 | directgenreg: GENREG subregnum |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1050 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1051 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1052 | $$.reg_file = BRW_GENERAL_REGISTER_FILE; |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1053 | $$.reg_nr = $1; |
| 1054 | $$.subreg_nr = $2; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1055 | } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1056 | ; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1057 | |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1058 | indirectgenreg: GENREGFILE LSQUARE addrparam RSQUARE |
| 1059 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1060 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1061 | $$.reg_file = BRW_GENERAL_REGISTER_FILE; |
| 1062 | $$.address_subreg_nr = $3.address_subreg_nr; |
| 1063 | $$.indirect_offset = $3.indirect_offset; |
| 1064 | } |
| 1065 | ; |
| 1066 | |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1067 | directmsgreg: MSGREG subregnum |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1068 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1069 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | a34d1e0 | 2006-08-22 14:52:14 -0700 | [diff] [blame] | 1070 | $$.reg_file = BRW_MESSAGE_REGISTER_FILE; |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1071 | $$.reg_nr = $1; |
| 1072 | $$.subreg_nr = $2; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1073 | } |
| 1074 | ; |
| 1075 | |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1076 | indirectmsgreg: MSGREGFILE LSQUARE addrparam RSQUARE |
| 1077 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1078 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1079 | $$.reg_file = BRW_MESSAGE_REGISTER_FILE; |
| 1080 | $$.address_subreg_nr = $3.address_subreg_nr; |
| 1081 | $$.indirect_offset = $3.indirect_offset; |
| 1082 | } |
| 1083 | ; |
| 1084 | |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1085 | addrreg: ADDRESSREG subregnum |
| 1086 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1087 | if ($1 != 0) { |
| 1088 | fprintf(stderr, |
| 1089 | "address register number %d out of range", $1); |
| 1090 | YYERROR; |
| 1091 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1092 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1093 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1094 | $$.reg_nr = BRW_ARF_ADDRESS | $1; |
| 1095 | $$.subreg_nr = $2; |
| 1096 | } |
| 1097 | ; |
| 1098 | |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1099 | accreg: ACCREG subregnum |
| 1100 | { |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1101 | if ($1 > 1) { |
| 1102 | fprintf(stderr, |
| 1103 | "accumulator register number %d out of range", $1); |
| 1104 | YYERROR; |
| 1105 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1106 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 569990b | 2006-08-25 09:46:18 -0700 | [diff] [blame] | 1107 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1108 | $$.reg_nr = BRW_ARF_ACCUMULATOR | $1; |
| 1109 | $$.subreg_nr = $2; |
| 1110 | } |
| 1111 | ; |
| 1112 | |
Eric Anholt | de1a889 | 2006-08-29 09:30:32 -0700 | [diff] [blame] | 1113 | flagreg: FLAGREG |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1114 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1115 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1116 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
Eric Anholt | de1a889 | 2006-08-29 09:30:32 -0700 | [diff] [blame] | 1117 | $$.reg_nr = BRW_ARF_FLAG | 0; |
| 1118 | $$.subreg_nr = $1; |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1119 | } |
| 1120 | ; |
| 1121 | |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1122 | maskreg: MASKREG subregnum |
| 1123 | { |
| 1124 | if ($1 > 0) { |
| 1125 | fprintf(stderr, |
| 1126 | "mask register number %d out of range", $1); |
| 1127 | YYERROR; |
| 1128 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1129 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1130 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1131 | $$.reg_nr = BRW_ARF_MASK; |
| 1132 | $$.subreg_nr = $2; |
| 1133 | } |
| 1134 | | mask_subreg |
| 1135 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1136 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1137 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1138 | $$.reg_nr = BRW_ARF_MASK; |
| 1139 | $$.subreg_nr = $1; |
| 1140 | } |
| 1141 | ; |
| 1142 | |
| 1143 | mask_subreg: AMASK | IMASK | LMASK | CMASK |
| 1144 | ; |
| 1145 | |
| 1146 | maskstackreg: MASKSTACKREG subregnum |
| 1147 | { |
| 1148 | if ($1 > 0) { |
| 1149 | fprintf(stderr, |
| 1150 | "mask stack register number %d out of range", $1); |
| 1151 | YYERROR; |
| 1152 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1153 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1154 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1155 | $$.reg_nr = BRW_ARF_MASK_STACK; |
| 1156 | $$.subreg_nr = $2; |
| 1157 | } |
| 1158 | | maskstack_subreg |
| 1159 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1160 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1161 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1162 | $$.reg_nr = BRW_ARF_MASK_STACK; |
| 1163 | $$.subreg_nr = $1; |
| 1164 | } |
| 1165 | ; |
| 1166 | |
| 1167 | maskstack_subreg: IMS | LMS |
| 1168 | ; |
| 1169 | |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1170 | /* |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1171 | maskstackdepthreg: MASKSTACKDEPTHREG subregnum |
| 1172 | { |
| 1173 | if ($1 > 0) { |
| 1174 | fprintf(stderr, |
| 1175 | "mask stack register number %d out of range", $1); |
| 1176 | YYERROR; |
| 1177 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1178 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1179 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1180 | $$.reg_nr = BRW_ARF_MASK_STACK_DEPTH; |
| 1181 | $$.subreg_nr = $2; |
| 1182 | } |
| 1183 | | maskstackdepth_subreg |
| 1184 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1185 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1186 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1187 | $$.reg_nr = BRW_ARF_MASK_STACK_DEPTH; |
| 1188 | $$.subreg_nr = $1; |
| 1189 | } |
| 1190 | ; |
| 1191 | |
| 1192 | maskstackdepth_subreg: IMSD | LMSD |
| 1193 | ; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1194 | */ |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1195 | |
| 1196 | notifyreg: NOTIFYREG |
| 1197 | { |
| 1198 | if ($1 > 1) { |
| 1199 | fprintf(stderr, |
| 1200 | "notification register number %d out of range", |
| 1201 | $1); |
| 1202 | YYERROR; |
| 1203 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1204 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1205 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1206 | $$.reg_nr = BRW_ARF_NOTIFICATION_COUNT; |
| 1207 | $$.subreg_nr = 0; |
| 1208 | } |
| 1209 | ; |
| 1210 | |
| 1211 | statereg: STATEREG subregnum |
| 1212 | { |
| 1213 | if ($1 > 0) { |
| 1214 | fprintf(stderr, |
| 1215 | "state register number %d out of range", $1); |
| 1216 | YYERROR; |
| 1217 | } |
| 1218 | if ($2 > 1) { |
| 1219 | fprintf(stderr, |
| 1220 | "state subregister number %d out of range", $1); |
| 1221 | YYERROR; |
| 1222 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1223 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1224 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1225 | $$.reg_nr = BRW_ARF_STATE | $1; |
| 1226 | $$.subreg_nr = $2; |
| 1227 | } |
| 1228 | ; |
| 1229 | |
| 1230 | controlreg: CONTROLREG subregnum |
| 1231 | { |
| 1232 | if ($1 > 0) { |
| 1233 | fprintf(stderr, |
| 1234 | "control register number %d out of range", $1); |
| 1235 | YYERROR; |
| 1236 | } |
| 1237 | if ($2 > 2) { |
| 1238 | fprintf(stderr, |
| 1239 | "control subregister number %d out of range", $1); |
| 1240 | YYERROR; |
| 1241 | } |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1242 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1243 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1244 | $$.reg_nr = BRW_ARF_CONTROL | $1; |
| 1245 | $$.subreg_nr = $2; |
| 1246 | } |
| 1247 | ; |
| 1248 | |
| 1249 | ipreg: IPREG |
| 1250 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1251 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 883408e | 2006-08-25 13:38:03 -0700 | [diff] [blame] | 1252 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1253 | $$.reg_nr = BRW_ARF_IP; |
| 1254 | $$.subreg_nr = 0; |
| 1255 | } |
| 1256 | ; |
| 1257 | |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1258 | nullreg: NULL_TOKEN |
| 1259 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1260 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1261 | $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; |
| 1262 | $$.reg_nr = BRW_ARF_NULL; |
| 1263 | $$.subreg_nr = 0; |
| 1264 | } |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1265 | ; |
| 1266 | |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1267 | /* 1.4.6: Relative locations */ |
| 1268 | relativelocation: imm32 |
| 1269 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1270 | if ($1.r != imm32_d) { |
| 1271 | fprintf (stderr, |
| 1272 | "error: non-int offset representation\n"); |
| 1273 | YYERROR; |
| 1274 | } |
| 1275 | |
| 1276 | if ($1.u.d > 32767 || $1.u.d < -32768) { |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1277 | fprintf(stderr, |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1278 | "error: relative offset %d out of range\n", $1.u.d); |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1279 | YYERROR; |
| 1280 | } |
| 1281 | |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1282 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1283 | $$.reg_file = BRW_IMMEDIATE_VALUE; |
| 1284 | $$.reg_type = BRW_REGISTER_TYPE_D; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1285 | $$.imm32 = $1.u.d & 0x0000ffff; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1286 | } |
| 1287 | ; |
| 1288 | |
| 1289 | relativelocation2: |
| 1290 | imm32 |
| 1291 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1292 | if ($1.r != imm32_d) { |
| 1293 | fprintf (stderr, |
| 1294 | "error: non-int location representation\n"); |
| 1295 | YYERROR; |
| 1296 | } |
| 1297 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1298 | $$.reg_file = BRW_IMMEDIATE_VALUE; |
| 1299 | $$.reg_type = BRW_REGISTER_TYPE_D; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1300 | $$.imm32 = $1.u.d; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1301 | } |
| 1302 | | directgenreg region regtype |
| 1303 | { |
| 1304 | set_direct_src_operand(&$$, &$1, $3); |
| 1305 | $$.vert_stride = $2.vert_stride; |
| 1306 | $$.width = $2.width; |
| 1307 | $$.horiz_stride = $2.horiz_stride; |
| 1308 | } |
| 1309 | ; |
| 1310 | |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 1311 | locationstackcontrol: |
| 1312 | imm32 |
| 1313 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1314 | if ($1.r != imm32_d) { |
| 1315 | fprintf (stderr, |
| 1316 | "error: non-int stack control representation\n"); |
| 1317 | YYERROR; |
| 1318 | } |
| 1319 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 1320 | $$.reg_file = BRW_IMMEDIATE_VALUE; |
| 1321 | $$.reg_type = BRW_REGISTER_TYPE_D; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1322 | $$.imm32 = $1.u.d; |
Eric Anholt | 4ee9c3d | 2006-09-01 13:37:51 -0700 | [diff] [blame] | 1323 | } |
| 1324 | ; |
| 1325 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1326 | /* 1.4.7: Regions */ |
| 1327 | dstregion: LANGLE INTEGER RANGLE |
| 1328 | { |
| 1329 | /* Returns a value for a horiz_stride field of an |
| 1330 | * instruction. |
| 1331 | */ |
| 1332 | if ($2 != 1 && $2 != 2 && $2 != 4) { |
| 1333 | fprintf(stderr, "Invalid horiz size %d\n", $2); |
| 1334 | } |
Eric Anholt | 0edcb25 | 2006-08-22 13:15:38 -0700 | [diff] [blame] | 1335 | $$ = ffs($2); |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1336 | } |
| 1337 | ; |
| 1338 | |
| 1339 | region: LANGLE INTEGER COMMA INTEGER COMMA INTEGER RANGLE |
| 1340 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1341 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1342 | $$.vert_stride = ffs($2); |
| 1343 | $$.width = ffs($4) - 1; |
Eric Anholt | d4c82e8 | 2006-08-22 13:08:26 -0700 | [diff] [blame] | 1344 | $$.horiz_stride = ffs($6); |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1345 | } |
| 1346 | ; |
| 1347 | |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1348 | /* region_wh is used in specifying indirect operands where rather than having |
| 1349 | * a vertical stride, you use subsequent address registers to get a new base |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 1350 | * offset for the next row. |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1351 | */ |
| 1352 | region_wh: LANGLE INTEGER COMMA INTEGER RANGLE |
| 1353 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1354 | memset (&$$, '\0', sizeof ($$)); |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1355 | $$.vert_stride = BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL; |
| 1356 | $$.width = ffs($2) - 1; |
| 1357 | $$.horiz_stride = ffs($4); |
| 1358 | } |
| 1359 | ; |
| 1360 | |
Eric Anholt | 2d29874 | 2006-08-30 09:57:20 -0700 | [diff] [blame] | 1361 | indirectregion: region | region_wh |
| 1362 | ; |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1363 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1364 | /* 1.4.8: Types */ |
| 1365 | |
| 1366 | /* regtype returns an integer register type suitable for inserting into an |
| 1367 | * instruction. |
| 1368 | */ |
| 1369 | regtype: TYPE_F { $$ = BRW_REGISTER_TYPE_F; } |
| 1370 | | TYPE_UD { $$ = BRW_REGISTER_TYPE_UD; } |
| 1371 | | TYPE_D { $$ = BRW_REGISTER_TYPE_D; } |
| 1372 | | TYPE_UW { $$ = BRW_REGISTER_TYPE_UW; } |
Eric Anholt | 0d929b4 | 2006-08-22 13:33:41 -0700 | [diff] [blame] | 1373 | | TYPE_W { $$ = BRW_REGISTER_TYPE_W; } |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1374 | | TYPE_UB { $$ = BRW_REGISTER_TYPE_UB; } |
| 1375 | | TYPE_B { $$ = BRW_REGISTER_TYPE_B; } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1376 | ; |
| 1377 | |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1378 | srcimmtype: TYPE_F { $$ = BRW_REGISTER_TYPE_F; } |
| 1379 | | TYPE_UD { $$ = BRW_REGISTER_TYPE_UD; } |
| 1380 | | TYPE_D { $$ = BRW_REGISTER_TYPE_D; } |
| 1381 | | TYPE_UW { $$ = BRW_REGISTER_TYPE_UW; } |
| 1382 | | TYPE_W { $$ = BRW_REGISTER_TYPE_W; } |
| 1383 | | TYPE_V { $$ = BRW_REGISTER_TYPE_V; } |
| 1384 | | TYPE_VF { $$ = BRW_REGISTER_TYPE_VF; } |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1385 | ; |
| 1386 | |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1387 | /* 1.4.10: Swizzle control */ |
| 1388 | /* Returns the swizzle control for an align16 instruction's source operand |
| 1389 | * in the src0 fields. |
| 1390 | */ |
| 1391 | swizzle: /* empty */ |
| 1392 | { |
| 1393 | $$.swizzle_set = 0; |
| 1394 | $$.swizzle_x = BRW_CHANNEL_X; |
| 1395 | $$.swizzle_y = BRW_CHANNEL_Y; |
| 1396 | $$.swizzle_z = BRW_CHANNEL_Z; |
| 1397 | $$.swizzle_w = BRW_CHANNEL_W; |
| 1398 | } |
| 1399 | | DOT chansel |
| 1400 | { |
| 1401 | $$.swizzle_set = 1; |
| 1402 | $$.swizzle_x = $2; |
| 1403 | $$.swizzle_y = $2; |
| 1404 | $$.swizzle_z = $2; |
| 1405 | $$.swizzle_w = $2; |
| 1406 | } |
| 1407 | | DOT chansel chansel chansel chansel |
| 1408 | { |
| 1409 | $$.swizzle_set = 1; |
| 1410 | $$.swizzle_x = $2; |
| 1411 | $$.swizzle_y = $3; |
| 1412 | $$.swizzle_z = $4; |
| 1413 | $$.swizzle_w = $5; |
| 1414 | } |
| 1415 | ; |
| 1416 | |
| 1417 | chansel: X | Y | Z | W |
| 1418 | ; |
| 1419 | |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1420 | /* 1.4.9: Write mask */ |
| 1421 | /* Returns a partially completed dst_operand, with just the writemask bits |
| 1422 | * filled out. |
| 1423 | */ |
| 1424 | writemask: /* empty */ |
| 1425 | { |
| 1426 | $$.writemask_set = 0; |
| 1427 | $$.writemask = 0xf; |
| 1428 | } |
| 1429 | | DOT writemask_x writemask_y writemask_z writemask_w |
| 1430 | { |
| 1431 | $$.writemask_set = 1; |
| 1432 | $$.writemask = $2 | $3 | $4 | $5; |
| 1433 | } |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 1434 | ; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1435 | |
| 1436 | writemask_x: /* empty */ { $$ = 0; } |
| 1437 | | X { $$ = 1 << BRW_CHANNEL_X; } |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 1438 | ; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1439 | |
| 1440 | writemask_y: /* empty */ { $$ = 0; } |
| 1441 | | Y { $$ = 1 << BRW_CHANNEL_Y; } |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 1442 | ; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1443 | |
| 1444 | writemask_z: /* empty */ { $$ = 0; } |
| 1445 | | Z { $$ = 1 << BRW_CHANNEL_Z; } |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 1446 | ; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1447 | |
| 1448 | writemask_w: /* empty */ { $$ = 0; } |
| 1449 | | W { $$ = 1 << BRW_CHANNEL_W; } |
Eric Anholt | c8939ed | 2006-08-30 10:50:56 -0700 | [diff] [blame] | 1450 | ; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1451 | |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1452 | /* 1.4.11: Immediate values */ |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1453 | imm32: INTEGER { $$.r = imm32_d; $$.u.d = $1; } |
| 1454 | | MINUS INTEGER { $$.r = imm32_d; $$.u.d = -$2; } |
| 1455 | | NUMBER { $$.r = imm32_f; $$.u.f = $1; } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1456 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1457 | |
| 1458 | /* 1.4.12: Predication and modifiers */ |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 1459 | predicate: /* empty */ |
| 1460 | { |
| 1461 | $$.header.predicate_control = BRW_PREDICATE_NONE; |
| 1462 | $$.bits2.da1.flag_reg_nr = 0; |
| 1463 | $$.header.predicate_inverse = 0; |
| 1464 | } |
| 1465 | | LPAREN predstate flagreg predctrl RPAREN |
| 1466 | { |
| 1467 | $$.header.predicate_control = $4; |
| 1468 | /* XXX: Should deal with erroring when the user tries to |
| 1469 | * set a predicate for one flag register and conditional |
| 1470 | * modification on the other flag register. |
| 1471 | */ |
| 1472 | $$.bits2.da1.flag_reg_nr = $3.subreg_nr; |
| 1473 | $$.header.predicate_inverse = $2; |
| 1474 | } |
| 1475 | ; |
| 1476 | |
| 1477 | predstate: /* empty */ { $$ = 0; } |
| 1478 | | PLUS { $$ = 0; } |
| 1479 | | MINUS { $$ = 1; } |
| 1480 | ; |
| 1481 | |
Keith Packard | 2033aea | 2008-04-23 23:10:40 -0700 | [diff] [blame] | 1482 | predctrl: /* empty */ { $$ = BRW_PREDICATE_NORMAL; } |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 1483 | | DOT X { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_X; } |
| 1484 | | DOT Y { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Y; } |
| 1485 | | DOT Z { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_Z; } |
| 1486 | | DOT W { $$ = BRW_PREDICATE_ALIGN16_REPLICATE_W; } |
Keith Packard | 2033aea | 2008-04-23 23:10:40 -0700 | [diff] [blame] | 1487 | | ANYV { $$ = BRW_PREDICATE_ALIGN1_ANYV; } |
| 1488 | | ALLV { $$ = BRW_PREDICATE_ALIGN1_ALLV; } |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 1489 | | ANY2H { $$ = BRW_PREDICATE_ALIGN1_ANY2H; } |
| 1490 | | ALL2H { $$ = BRW_PREDICATE_ALIGN1_ALL2H; } |
| 1491 | | ANY4H { $$ = BRW_PREDICATE_ALIGN1_ANY4H; } |
| 1492 | | ALL4H { $$ = BRW_PREDICATE_ALIGN1_ALL4H; } |
| 1493 | | ANY8H { $$ = BRW_PREDICATE_ALIGN1_ANY8H; } |
| 1494 | | ALL8H { $$ = BRW_PREDICATE_ALIGN1_ALL8H; } |
| 1495 | | ANY16H { $$ = BRW_PREDICATE_ALIGN1_ANY16H; } |
| 1496 | | ALL16H { $$ = BRW_PREDICATE_ALIGN1_ALL16H; } |
Eric Anholt | dc96c56 | 2006-08-22 14:42:45 -0700 | [diff] [blame] | 1497 | ; |
| 1498 | |
| 1499 | negate: /* empty */ { $$ = 0; } |
| 1500 | | MINUS { $$ = 1; } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1501 | ; |
Eric Anholt | dc96c56 | 2006-08-22 14:42:45 -0700 | [diff] [blame] | 1502 | |
| 1503 | abs: /* empty */ { $$ = 0; } |
| 1504 | | ABS { $$ = 1; } |
Eric Anholt | edc82a0 | 2006-08-25 17:42:05 -0700 | [diff] [blame] | 1505 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1506 | |
| 1507 | execsize: LPAREN INTEGER RPAREN |
| 1508 | { |
| 1509 | /* Returns a value for the execution_size field of an |
| 1510 | * instruction. |
| 1511 | */ |
| 1512 | if ($2 != 1 && $2 != 2 && $2 != 4 && $2 != 8 && $2 != 16 && |
| 1513 | $2 != 32) { |
| 1514 | fprintf(stderr, "Invalid execution size %d\n", $2); |
| 1515 | YYERROR; |
| 1516 | } |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1517 | $$ = ffs($2) - 1; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1518 | } |
| 1519 | ; |
| 1520 | |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1521 | saturate: /* empty */ { $$ = BRW_INSTRUCTION_NORMAL; } |
| 1522 | | DOT SATURATE { $$ = BRW_INSTRUCTION_SATURATE; } |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1523 | ; |
| 1524 | |
Keith Packard | 2033aea | 2008-04-23 23:10:40 -0700 | [diff] [blame] | 1525 | conditionalmodifier: /* empty */ { $$ = BRW_CONDITIONAL_NONE; } |
| 1526 | | ZERO |
| 1527 | | EQUAL |
| 1528 | | NOT_ZERO |
| 1529 | | NOT_EQUAL |
| 1530 | | GREATER |
| 1531 | | GREATER_EQUAL |
| 1532 | | LESS |
| 1533 | | LESS_EQUAL |
| 1534 | | ROUND_INCREMENT |
| 1535 | | OVERFLOW |
| 1536 | | UNORDERED |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1537 | ; |
| 1538 | |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1539 | /* 1.4.13: Instruction options */ |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1540 | instoptions: LCURLY instoption_list RCURLY |
| 1541 | { $$ = $2; } |
| 1542 | ; |
| 1543 | |
| 1544 | instoption_list: instoption instoption_list |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1545 | { |
| 1546 | $$ = $2; |
| 1547 | switch ($1) { |
| 1548 | case ALIGN1: |
| 1549 | $$.header.access_mode = BRW_ALIGN_1; |
| 1550 | break; |
| 1551 | case ALIGN16: |
| 1552 | $$.header.access_mode = BRW_ALIGN_16; |
| 1553 | break; |
Eric Anholt | 908f37d | 2006-08-25 17:33:02 -0700 | [diff] [blame] | 1554 | case SECHALF: |
| 1555 | $$.header.compression_control |= BRW_COMPRESSION_2NDHALF; |
| 1556 | break; |
| 1557 | case COMPR: |
| 1558 | $$.header.compression_control |= |
| 1559 | BRW_COMPRESSION_COMPRESSED; |
| 1560 | break; |
| 1561 | case SWITCH: |
| 1562 | $$.header.thread_control |= BRW_THREAD_SWITCH; |
| 1563 | break; |
| 1564 | case ATOMIC: |
| 1565 | $$.header.thread_control |= BRW_THREAD_ATOMIC; |
| 1566 | break; |
| 1567 | case NODDCHK: |
| 1568 | $$.header.dependency_control |= BRW_DEPENDENCY_NOTCHECKED; |
| 1569 | break; |
| 1570 | case NODDCLR: |
| 1571 | $$.header.dependency_control |= BRW_DEPENDENCY_NOTCLEARED; |
| 1572 | break; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1573 | case MASK_DISABLE: |
| 1574 | $$.header.mask_control = BRW_MASK_DISABLE; |
| 1575 | break; |
Eric Anholt | 908f37d | 2006-08-25 17:33:02 -0700 | [diff] [blame] | 1576 | case BREAKPOINT: |
| 1577 | $$.header.debug_control = BRW_DEBUG_BREAKPOINT; |
| 1578 | break; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1579 | case EOT: |
Eric Anholt | 56c4ccf | 2006-08-24 14:35:10 -0700 | [diff] [blame] | 1580 | /* XXX: EOT shouldn't be an instoption, I don't think */ |
| 1581 | $$.bits3.generic.end_of_thread = 1; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1582 | break; |
| 1583 | } |
| 1584 | } |
| 1585 | | /* empty, header defaults to zeroes. */ |
Eric Anholt | e609d6b | 2006-08-24 12:36:56 -0700 | [diff] [blame] | 1586 | { |
| 1587 | bzero(&$$, sizeof($$)); |
| 1588 | } |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1589 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1590 | |
Eric Anholt | 1632421 | 2006-08-24 14:47:21 -0700 | [diff] [blame] | 1591 | instoption: ALIGN1 { $$ = ALIGN1; } |
| 1592 | | ALIGN16 { $$ = ALIGN16; } |
Eric Anholt | 908f37d | 2006-08-25 17:33:02 -0700 | [diff] [blame] | 1593 | | SECHALF { $$ = SECHALF; } |
| 1594 | | COMPR { $$ = COMPR; } |
| 1595 | | SWITCH { $$ = SWITCH; } |
| 1596 | | ATOMIC { $$ = ATOMIC; } |
| 1597 | | NODDCHK { $$ = NODDCHK; } |
| 1598 | | NODDCLR { $$ = NODDCLR; } |
Eric Anholt | 1632421 | 2006-08-24 14:47:21 -0700 | [diff] [blame] | 1599 | | MASK_DISABLE { $$ = MASK_DISABLE; } |
Eric Anholt | 908f37d | 2006-08-25 17:33:02 -0700 | [diff] [blame] | 1600 | | BREAKPOINT { $$ = BREAKPOINT; } |
Eric Anholt | 1632421 | 2006-08-24 14:47:21 -0700 | [diff] [blame] | 1601 | | EOT { $$ = EOT; } |
Eric Anholt | 6c98c8d | 2006-08-22 11:54:19 -0700 | [diff] [blame] | 1602 | ; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1603 | |
| 1604 | %% |
| 1605 | extern int yylineno; |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1606 | extern char *input_filename; |
| 1607 | |
| 1608 | int errors; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1609 | |
| 1610 | void yyerror (char *msg) |
| 1611 | { |
Keith Packard | 2d4d401 | 2008-03-30 00:58:28 -0700 | [diff] [blame] | 1612 | fprintf(stderr, "%s: %d: %s at \"%s\"\n", |
| 1613 | input_filename, yylineno, msg, lex_text()); |
| 1614 | ++errors; |
Eric Anholt | 22a1063 | 2006-08-22 10:15:33 -0700 | [diff] [blame] | 1615 | } |
| 1616 | |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1617 | /** |
| 1618 | * Fills in the destination register information in instr from the bits in dst. |
| 1619 | */ |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1620 | int set_instruction_dest(struct brw_instruction *instr, |
| 1621 | struct dst_operand *dest) |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1622 | { |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1623 | if (dest->address_mode == BRW_ADDRESS_DIRECT && |
| 1624 | instr->header.access_mode == BRW_ALIGN_1) { |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1625 | instr->bits1.da1.dest_reg_file = dest->reg_file; |
| 1626 | instr->bits1.da1.dest_reg_type = dest->reg_type; |
| 1627 | instr->bits1.da1.dest_subreg_nr = dest->subreg_nr; |
| 1628 | instr->bits1.da1.dest_reg_nr = dest->reg_nr; |
| 1629 | instr->bits1.da1.dest_horiz_stride = dest->horiz_stride; |
| 1630 | instr->bits1.da1.dest_address_mode = dest->address_mode; |
| 1631 | if (dest->writemask_set) { |
| 1632 | fprintf(stderr, "error: write mask set in align1 " |
| 1633 | "instruction\n"); |
| 1634 | return 1; |
| 1635 | } |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1636 | } else if (dest->address_mode == BRW_ADDRESS_DIRECT) { |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1637 | instr->bits1.da16.dest_reg_file = dest->reg_file; |
| 1638 | instr->bits1.da16.dest_reg_type = dest->reg_type; |
| 1639 | instr->bits1.da16.dest_subreg_nr = dest->subreg_nr; |
| 1640 | instr->bits1.da16.dest_reg_nr = dest->reg_nr; |
| 1641 | instr->bits1.da16.dest_address_mode = dest->address_mode; |
| 1642 | instr->bits1.da16.dest_writemask = dest->writemask; |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1643 | } else if (instr->header.access_mode == BRW_ALIGN_1) { |
| 1644 | instr->bits1.ia1.dest_reg_file = dest->reg_file; |
| 1645 | instr->bits1.ia1.dest_reg_type = dest->reg_type; |
| 1646 | instr->bits1.ia1.dest_subreg_nr = dest->address_subreg_nr; |
| 1647 | instr->bits1.ia1.dest_horiz_stride = dest->horiz_stride; |
| 1648 | instr->bits1.ia1.dest_indirect_offset = dest->indirect_offset; |
| 1649 | instr->bits1.ia1.dest_address_mode = dest->address_mode; |
| 1650 | if (dest->writemask_set) { |
| 1651 | fprintf(stderr, "error: write mask set in align1 " |
| 1652 | "instruction\n"); |
| 1653 | return 1; |
| 1654 | } |
| 1655 | } else { |
| 1656 | instr->bits1.ia16.dest_reg_file = dest->reg_file; |
| 1657 | instr->bits1.ia16.dest_reg_type = dest->reg_type; |
| 1658 | instr->bits1.ia16.dest_subreg_nr = dest->address_subreg_nr; |
| 1659 | instr->bits1.ia16.dest_writemask = dest->writemask; |
| 1660 | instr->bits1.ia16.dest_indirect_offset = dest->indirect_offset; |
| 1661 | instr->bits1.ia16.dest_address_mode = dest->address_mode; |
Eric Anholt | 2dac0a1 | 2006-08-29 15:29:31 -0700 | [diff] [blame] | 1662 | } |
| 1663 | |
| 1664 | return 0; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1665 | } |
| 1666 | |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1667 | /* Sets the first source operand for the instruction. Returns 0 on success. */ |
| 1668 | int set_instruction_src0(struct brw_instruction *instr, |
| 1669 | struct src_operand *src) |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1670 | { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1671 | instr->bits1.da1.src0_reg_file = src->reg_file; |
| 1672 | instr->bits1.da1.src0_reg_type = src->reg_type; |
| 1673 | if (src->reg_file == BRW_IMMEDIATE_VALUE) { |
| 1674 | instr->bits3.ud = src->imm32; |
| 1675 | } else if (instr->header.access_mode == BRW_ALIGN_1) { |
| 1676 | instr->bits2.da1.src0_subreg_nr = src->subreg_nr; |
| 1677 | instr->bits2.da1.src0_reg_nr = src->reg_nr; |
| 1678 | instr->bits2.da1.src0_vert_stride = src->vert_stride; |
| 1679 | instr->bits2.da1.src0_width = src->width; |
| 1680 | instr->bits2.da1.src0_horiz_stride = src->horiz_stride; |
| 1681 | instr->bits2.da1.src0_negate = src->negate; |
| 1682 | instr->bits2.da1.src0_abs = src->abs; |
| 1683 | instr->bits2.da1.src0_address_mode = src->address_mode; |
| 1684 | if (src->swizzle_set) { |
| 1685 | fprintf(stderr, "error: swizzle bits set in align1 " |
| 1686 | "instruction\n"); |
| 1687 | return 1; |
| 1688 | } |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1689 | } else { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1690 | instr->bits2.da16.src0_subreg_nr = src->subreg_nr; |
| 1691 | instr->bits2.da16.src0_reg_nr = src->reg_nr; |
| 1692 | instr->bits2.da16.src0_vert_stride = src->vert_stride; |
| 1693 | instr->bits2.da16.src0_negate = src->negate; |
| 1694 | instr->bits2.da16.src0_abs = src->abs; |
| 1695 | instr->bits2.da16.src0_swz_x = src->swizzle_x; |
| 1696 | instr->bits2.da16.src0_swz_y = src->swizzle_y; |
| 1697 | instr->bits2.da16.src0_swz_z = src->swizzle_z; |
| 1698 | instr->bits2.da16.src0_swz_w = src->swizzle_w; |
| 1699 | instr->bits2.da16.src0_address_mode = src->address_mode; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1700 | } |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1701 | |
| 1702 | return 0; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1703 | } |
| 1704 | |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1705 | /* Sets the second source operand for the instruction. Returns 0 on success. |
| 1706 | */ |
| 1707 | int set_instruction_src1(struct brw_instruction *instr, |
| 1708 | struct src_operand *src) |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1709 | { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1710 | instr->bits1.da1.src1_reg_file = src->reg_file; |
| 1711 | instr->bits1.da1.src1_reg_type = src->reg_type; |
| 1712 | if (src->reg_file == BRW_IMMEDIATE_VALUE) { |
| 1713 | instr->bits3.ud = src->imm32; |
| 1714 | } else if (instr->header.access_mode == BRW_ALIGN_1) { |
| 1715 | instr->bits3.da1.src1_subreg_nr = src->subreg_nr; |
| 1716 | instr->bits3.da1.src1_reg_nr = src->reg_nr; |
| 1717 | instr->bits3.da1.src1_vert_stride = src->vert_stride; |
| 1718 | instr->bits3.da1.src1_width = src->width; |
| 1719 | instr->bits3.da1.src1_horiz_stride = src->horiz_stride; |
| 1720 | instr->bits3.da1.src1_negate = src->negate; |
| 1721 | instr->bits3.da1.src1_abs = src->abs; |
| 1722 | if (src->address_mode != BRW_ADDRESS_DIRECT) { |
| 1723 | fprintf(stderr, "error: swizzle bits set in align1 " |
| 1724 | "instruction\n"); |
| 1725 | return 1; |
| 1726 | } |
| 1727 | if (src->swizzle_set) { |
| 1728 | fprintf(stderr, "error: swizzle bits set in align1 " |
| 1729 | "instruction\n"); |
| 1730 | return 1; |
| 1731 | } |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1732 | } else { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1733 | instr->bits3.da16.src1_subreg_nr = src->subreg_nr; |
| 1734 | instr->bits3.da16.src1_reg_nr = src->reg_nr; |
| 1735 | instr->bits3.da16.src1_vert_stride = src->vert_stride; |
| 1736 | instr->bits3.da16.src1_negate = src->negate; |
| 1737 | instr->bits3.da16.src1_abs = src->abs; |
| 1738 | instr->bits3.da16.src1_swz_x = src->swizzle_x; |
| 1739 | instr->bits3.da16.src1_swz_y = src->swizzle_y; |
| 1740 | instr->bits3.da16.src1_swz_z = src->swizzle_z; |
| 1741 | instr->bits3.da16.src1_swz_w = src->swizzle_w; |
| 1742 | if (src->address_mode != BRW_ADDRESS_DIRECT) { |
| 1743 | fprintf(stderr, "error: swizzle bits set in align1 " |
| 1744 | "instruction\n"); |
| 1745 | return 1; |
| 1746 | } |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1747 | } |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1748 | |
| 1749 | return 0; |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1750 | } |
| 1751 | |
| 1752 | void set_instruction_options(struct brw_instruction *instr, |
| 1753 | struct brw_instruction *options) |
| 1754 | { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1755 | /* XXX: more instr options */ |
Eric Anholt | 19f1c1c | 2006-08-22 12:41:09 -0700 | [diff] [blame] | 1756 | instr->header.access_mode = options->header.access_mode; |
| 1757 | instr->header.mask_control = options->header.mask_control; |
| 1758 | instr->header.dependency_control = options->header.dependency_control; |
| 1759 | instr->header.compression_control = |
| 1760 | options->header.compression_control; |
| 1761 | } |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 1762 | |
Eric Anholt | 0ed5d93 | 2006-08-28 23:05:51 -0700 | [diff] [blame] | 1763 | void set_instruction_predicate(struct brw_instruction *instr, |
| 1764 | struct brw_instruction *predicate) |
| 1765 | { |
| 1766 | instr->header.predicate_control = predicate->header.predicate_control; |
| 1767 | instr->header.predicate_inverse = predicate->header.predicate_inverse; |
| 1768 | instr->bits2.da1.flag_reg_nr = predicate->bits2.da1.flag_reg_nr; |
| 1769 | } |
| 1770 | |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1771 | void set_direct_dst_operand(struct dst_operand *dst, struct direct_reg *reg, |
| 1772 | int type) |
| 1773 | { |
| 1774 | bzero(dst, sizeof(*dst)); |
| 1775 | dst->address_mode = BRW_ADDRESS_DIRECT; |
| 1776 | dst->reg_file = reg->reg_file; |
| 1777 | dst->reg_nr = reg->reg_nr; |
| 1778 | dst->subreg_nr = reg->subreg_nr; |
| 1779 | dst->reg_type = type; |
| 1780 | dst->horiz_stride = 1; |
| 1781 | dst->writemask_set = 0; |
| 1782 | dst->writemask = 0xf; |
| 1783 | } |
| 1784 | |
Eric Anholt | 3bcf6b2 | 2006-08-29 18:31:34 -0700 | [diff] [blame] | 1785 | void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg, |
| 1786 | int type) |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 1787 | { |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1788 | bzero(src, sizeof(*src)); |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1789 | src->address_mode = BRW_ADDRESS_DIRECT; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1790 | src->reg_file = reg->reg_file; |
| 1791 | src->reg_type = type; |
| 1792 | src->subreg_nr = reg->subreg_nr; |
| 1793 | src->reg_nr = reg->reg_nr; |
| 1794 | src->vert_stride = 0; |
| 1795 | src->width = 0; |
Keith Packard | 2033aea | 2008-04-23 23:10:40 -0700 | [diff] [blame] | 1796 | src->horiz_stride = 0; |
Eric Anholt | 6a88ada | 2006-08-28 22:11:18 -0700 | [diff] [blame] | 1797 | src->negate = 0; |
| 1798 | src->abs = 0; |
Eric Anholt | 1e907c7 | 2006-08-31 10:21:15 -0700 | [diff] [blame] | 1799 | src->swizzle_set = 0; |
| 1800 | src->swizzle_x = BRW_CHANNEL_X; |
| 1801 | src->swizzle_y = BRW_CHANNEL_Y; |
| 1802 | src->swizzle_z = BRW_CHANNEL_Z; |
| 1803 | src->swizzle_w = BRW_CHANNEL_W; |
Eric Anholt | 2c78765 | 2006-08-25 13:53:48 -0700 | [diff] [blame] | 1804 | } |