Fix imm32 translation.

This commit is contained in:
Eric Anholt 2006-08-22 13:33:41 -07:00 committed by Damien Lespiau
parent 0edcb2561d
commit 0d929b430b

View File

@ -80,7 +80,7 @@
%type <instruction> binaryaccinstruction triinstruction sendinstruction %type <instruction> binaryaccinstruction triinstruction sendinstruction
%type <instruction> specialinstruction %type <instruction> specialinstruction
%type <instruction> dst dstoperand dstoperandex dstreg %type <instruction> dst dstoperand dstoperandex dstreg
%type <instruction> directsrcaccoperand src directsrcoperand srcimm %type <instruction> directsrcaccoperand src directsrcoperand srcimm imm32reg
%type <instruction> srcacc srcaccimm %type <instruction> srcacc srcaccimm
%type <instruction> instoptions instoption_list %type <instruction> instoptions instoption_list
%type <program> instrseq %type <program> instrseq
@ -270,32 +270,19 @@ dstreg: directgenreg
; ;
/* 1.4.3: Source register */ /* 1.4.3: Source register */
srcaccimm: srcacc srcaccimm: srcacc | imm32reg
| imm32 srcimmtype
{
$$.bits1.da1.src0_reg_file = BRW_IMMEDIATE_VALUE;
switch ($2) {
case BRW_REGISTER_TYPE_UD:
$$.bits3.ud = $1;
break;
case BRW_REGISTER_TYPE_D:
$$.bits3.id = $1;
break;
case BRW_REGISTER_TYPE_F:
$$.bits3.fd = $1;
break;
}
}
; ;
/* XXX: indirectsrcaccoperand */ /* XXX: indirectsrcaccoperand */
srcacc: directsrcaccoperand srcacc: directsrcaccoperand
; ;
srcimm: directsrcoperand srcimm: directsrcoperand | imm32reg
| imm32 srcimmtype
imm32reg: imm32 srcimmtype
{ {
$$.bits1.da1.src0_reg_file = BRW_IMMEDIATE_VALUE; $$.bits1.da1.src0_reg_file = BRW_IMMEDIATE_VALUE;
$$.bits1.da1.src0_reg_type = $2;
switch ($2) { switch ($2) {
case BRW_REGISTER_TYPE_UD: case BRW_REGISTER_TYPE_UD:
$$.bits3.ud = $1; $$.bits3.ud = $1;
@ -303,9 +290,28 @@ srcimm: directsrcoperand
case BRW_REGISTER_TYPE_D: case BRW_REGISTER_TYPE_D:
$$.bits3.id = $1; $$.bits3.id = $1;
break; break;
case BRW_REGISTER_TYPE_UW:
$$.bits3.ud = $1;
break;
case BRW_REGISTER_TYPE_W:
$$.bits3.id = $1;
break;
case BRW_REGISTER_TYPE_UB:
$$.bits3.ud = $1;
/* There is no native byte immediate type */
$$.bits1.da1.src0_reg_type = BRW_REGISTER_TYPE_UD;
break;
case BRW_REGISTER_TYPE_B:
$$.bits3.id = $1;
/* There is no native byte immediate type */
$$.bits1.da1.src0_reg_type = BRW_REGISTER_TYPE_D;
break;
case BRW_REGISTER_TYPE_F: case BRW_REGISTER_TYPE_F:
$$.bits3.fd = $1; $$.bits3.fd = $1;
break; break;
default:
fprintf(stderr, "unknown immediate type %d\n", $2);
YYERROR;
} }
} }
; ;
@ -427,7 +433,7 @@ regtype: TYPE_F { $$ = BRW_REGISTER_TYPE_F; }
| TYPE_UD { $$ = BRW_REGISTER_TYPE_UD; } | TYPE_UD { $$ = BRW_REGISTER_TYPE_UD; }
| TYPE_D { $$ = BRW_REGISTER_TYPE_D; } | TYPE_D { $$ = BRW_REGISTER_TYPE_D; }
| TYPE_UW { $$ = BRW_REGISTER_TYPE_UW; } | TYPE_UW { $$ = BRW_REGISTER_TYPE_UW; }
| TYPE_W { $$ = BRW_REGISTER_TYPE_UW; } | TYPE_W { $$ = BRW_REGISTER_TYPE_W; }
| TYPE_UB { $$ = BRW_REGISTER_TYPE_UB; } | TYPE_UB { $$ = BRW_REGISTER_TYPE_UB; }
| TYPE_B { $$ = BRW_REGISTER_TYPE_B; } | TYPE_B { $$ = BRW_REGISTER_TYPE_B; }
/* XXX: Add TYPE_VF and TYPE_HF */ /* XXX: Add TYPE_VF and TYPE_HF */