Add syntax for extended math send functions, and adjust packed_yuv_sf for it.

This commit is contained in:
Eric Anholt 2006-08-25 09:36:28 -07:00 committed by Damien Lespiau
parent e865196a9d
commit 3d36079ae3
3 changed files with 59 additions and 3 deletions

View File

@ -78,6 +78,10 @@
%token <integer> INTEGER
%token <number> NUMBER
%token <integer> INV LOG EXP SQRT RSQ POW SIN COS SINCOS INTDIV INTMOD
%token <integer> INTDIVMOD
%token SIGNED SCALAR
%type <instruction> instruction unaryinstruction binaryinstruction
%type <instruction> binaryaccinstruction triinstruction sendinstruction
%type <instruction> specialinstruction
@ -92,6 +96,7 @@
%type <integer> regtype srcimmtype execsize dstregion
%type <integer> subregnum sampler_datatype
%type <integer> urb_swizzle urb_allocate urb_used urb_complete
%type <integer> math_function math_signed math_scalar
%type <region> region
%type <direct_gen_reg> directgenreg directmsgreg addrreg accreg flagreg maskreg
%type <direct_gen_reg> nullreg
@ -263,9 +268,17 @@ msgtarget: NULL_TOKEN
break;
}
}
| MATH
| MATH math_function saturate math_signed math_scalar
{
$$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_MATH;
$$.bits3.math.function = $2;
if ($3 == BRW_INSTRUCTION_SATURATE)
$$.bits3.math.saturate = 1;
else
$$.bits3.math.saturate = 0;
$$.bits3.math.int_type = $4;
$$.bits3.math.precision = BRW_MATH_PRECISION_FULL;
$$.bits3.math.data_type = $5;
}
| GATEWAY
{
@ -311,25 +324,41 @@ msgtarget: NULL_TOKEN
urb_allocate: ALLOCATE { $$ = 1; }
| /* empty */ { $$ = 0; }
;
urb_used: USED { $$ = 1; }
| /* empty */ { $$ = 0; }
;
urb_complete: COMPLETE { $$ = 1; }
| /* empty */ { $$ = 0; }
;
urb_swizzle: TRANSPOSE { $$ = BRW_URB_SWIZZLE_TRANSPOSE; }
| INTERLEAVE { $$ = BRW_URB_SWIZZLE_INTERLEAVE; }
| /* empty */ { $$ = BRW_URB_SWIZZLE_NONE; }
;
sampler_datatype:
TYPE_F
| TYPE_UD
| TYPE_D
;
math_function: INV | LOG | EXP | SQRT | POW | SIN | COS | SINCOS | INTDIV
| INTMOD | INTDIVMOD
;
math_signed: /* empty */ { $$ = 0; }
| SIGNED { $$ = 1; }
math_scalar: /* empty */ { $$ = 0; }
| SCALAR { $$ = 1; }
/* 1.4.2: Destination register */
dst: dstoperand | dstoperandex
;
/* XXX: dstregion writemask */
dstoperand: dstreg dstregion regtype

View File

@ -2,6 +2,7 @@
%{
#include "gen4asm.h"
#include "y.tab.h"
#include "brw_defines.h"
int saved_state = INITIAL;
@ -121,6 +122,32 @@ int saved_state = INITIAL;
"mask_disable" { return MASK_DISABLE; }
"EOT" { return EOT; }
/* extended math functions */
"inv" { yylval.integer = BRW_MATH_FUNCTION_INV; return SIN; }
"log" { yylval.integer = BRW_MATH_FUNCTION_LOG; return LOG; }
"exp" { yylval.integer = BRW_MATH_FUNCTION_EXP; return EXP; }
"sqrt" { yylval.integer = BRW_MATH_FUNCTION_SQRT; return SQRT; }
"rsq" { yylval.integer = BRW_MATH_FUNCTION_RSQ; return RSQ; }
"pow" { yylval.integer = BRW_MATH_FUNCTION_POW; return POW; }
"sin" { yylval.integer = BRW_MATH_FUNCTION_SIN; return SIN; }
"cos" { yylval.integer = BRW_MATH_FUNCTION_COS; return COS; }
"sincos" { yylval.integer = BRW_MATH_FUNCTION_SINCOS; return SINCOS; }
"intdiv" {
yylval.integer = BRW_MATH_FUNCTION_INT_DIV_QUOTIENT;
return INTDIV;
}
"intmod" {
yylval.integer = BRW_MATH_FUNCTION_INT_DIV_REMAINDER;
return INTMOD;
}
"intdivmod" {
yylval.integer = BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER;
return INTDIVMOD;
}
"signed" { return SIGNED; }
"scalar" { return SCALAR; }
[0-9]* {
yylval.integer = atoi(yytext);
return INTEGER;

View File

@ -1,5 +1,5 @@
send (1) 0 g6<1>F g1.12<0,1,0>F math mlen 1 rlen 1 { align1 };
send (1) 0 g6.4<1>F g1.20<0,1,0>F math mlen 1 rlen 1 { align1 };
send (1) 0 g6<1>F g1.12<0,1,0>F math inv scalar mlen 1 rlen 1 { align1 };
send (1) 0 g6.4<1>F g1.20<0,1,0>F math inv scalar mlen 1 rlen 1 { align1 };
add (8) g7<1>F g4<8,8,1>F g3<8,8,1>F { align1 };
mul (1) g7<1>F g7<0,1,0>F g6<0,1,0>F { align1 };
mul (1) g7.4<1>F g7.4<0,1,0>F g6.4<0,1,0>F { align1 };