%token LCURLY RCURLY
%token LSQUARE RSQUARE
%token COMMA
-%token DOT
-%token PLUS MINUS ABS
+%token DOT ABS
+%left PLUS MINUS
+%left MULTIPLY DIVIDE
%token <integer> TYPE_UD TYPE_D TYPE_UW TYPE_W TYPE_UB TYPE_B
%token <integer> TYPE_VF TYPE_HF TYPE_V TYPE_F
%token <integer> X Y Z W
+%type <integer> exp
%type <instruction> instruction unaryinstruction binaryinstruction
%type <instruction> binaryaccinstruction triinstruction sendinstruction
%type <instruction> jumpinstruction branchloopinstruction elseinstruction
%type <src_operand> indirectsrcoperand
%type <src_operand> src srcimm imm32reg payload srcacc srcaccimm swizzle
%type <src_operand> relativelocation relativelocation2 locationstackcontrol
+
%%
+exp: INTEGER { $$ = $1; }
+ | exp MULTIPLY exp { $$ = $1 * $3; }
+ | exp DIVIDE exp { if ($3) $$ = $1 / $3; else YYERROR;}
+ | exp PLUS exp { $$ = $1 + $3; }
+ | exp MINUS exp { $$ = $1 - $3; }
+ | MINUS exp { $$ = -$2;}
+ | LPAREN exp RPAREN { $$ = $2; }
ROOT: instrseq
{
triinstruction: sendinstruction
;
-sendinstruction: predicate SEND execsize INTEGER post_dst payload msgtarget
- MSGLEN INTEGER RETURNLEN INTEGER instoptions
+sendinstruction: predicate SEND execsize exp post_dst payload msgtarget
+ MSGLEN exp RETURNLEN exp instoptions
{
/* Send instructions are messy. The first argument is the
* post destination -- the grf register that the response
* from the address register in register-indirect register access.
*/
immaddroffset: /* empty */ { $$ = 0; }
- | INTEGER
+ | exp
;
/* 1.4.5: Register files and register numbers */
-subregnum: DOT INTEGER
+subregnum: DOT exp
{
$$ = $2;
}
;
/* 1.4.7: Regions */
-dstregion: LANGLE INTEGER RANGLE
+dstregion: LANGLE exp RANGLE
{
/* Returns a value for a horiz_stride field of an
* instruction.
}
;
-region: LANGLE INTEGER COMMA INTEGER COMMA INTEGER RANGLE
+region: LANGLE exp COMMA exp COMMA exp RANGLE
{
memset (&$$, '\0', sizeof ($$));
$$.vert_stride = ffs($2);
* a vertical stride, you use subsequent address registers to get a new base
* offset for the next row.
*/
-region_wh: LANGLE INTEGER COMMA INTEGER RANGLE
+region_wh: LANGLE exp COMMA exp RANGLE
{
memset (&$$, '\0', sizeof ($$));
$$.vert_stride = BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL;
;
/* 1.4.11: Immediate values */
-imm32: INTEGER { $$.r = imm32_d; $$.u.d = $1; }
- | MINUS INTEGER { $$.r = imm32_d; $$.u.d = -$2; }
+imm32: exp { $$.r = imm32_d; $$.u.d = $1; }
+ | MINUS exp { $$.r = imm32_d; $$.u.d = -$2; }
| NUMBER { $$.r = imm32_f; $$.u.f = $1; }
;
| ABS { $$ = 1; }
;
-execsize: LPAREN INTEGER RPAREN
+execsize: LPAREN exp RPAREN
{
/* Returns a value for the execution_size field of an
* instruction.