diff options
author | Eric Anholt <eric@anholt.net> | 2006-08-22 11:54:19 -0700 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2013-03-04 15:54:20 +0000 |
commit | 6c98c8d578ab5feb65a9f6827a7e1bad11468575 (patch) | |
tree | a49707d31d95ef2e5d2d804fc8f9c9417acf2141 /assembler | |
parent | 22a1063cc014437bee07bdaff2c38c2e843d12d2 (diff) |
Get the wm program to parse.
Diffstat (limited to 'assembler')
-rw-r--r-- | assembler/Makefile | 1 | ||||
-rw-r--r-- | assembler/brw_structs.h | 2 | ||||
-rw-r--r-- | assembler/gram.c | 539 | ||||
-rw-r--r-- | assembler/gram.y | 143 | ||||
-rw-r--r-- | assembler/lex.c | 585 | ||||
-rw-r--r-- | assembler/lex.l | 58 | ||||
-rw-r--r-- | assembler/packed_yuv_wm.g4a | 120 |
7 files changed, 947 insertions, 501 deletions
diff --git a/assembler/Makefile b/assembler/Makefile index f9dd8d86..dae1e46d 100644 --- a/assembler/Makefile +++ b/assembler/Makefile @@ -8,4 +8,5 @@ lextest: ${SOURCES} cc -o lextest ${SOURCES} clean: + rm -f gram.c lex.c rm -f *.o lextest
\ No newline at end of file diff --git a/assembler/brw_structs.h b/assembler/brw_structs.h index b9e3059a..a5acbe3d 100644 --- a/assembler/brw_structs.h +++ b/assembler/brw_structs.h @@ -1053,7 +1053,7 @@ struct brw_instruction GLuint predicate_control:4; GLuint predicate_inverse:1; GLuint execution_size:3; - GLuint destreg__conditonalmod:4; /* destreg - send, conditionalmod - others */ + GLuint destreg__conditionalmod:4; /* destreg - send, conditionalmod - others */ GLuint pad0:2; GLuint debug_control:1; GLuint saturate:1; diff --git a/assembler/gram.c b/assembler/gram.c index c59548e2..a216b69c 100644 --- a/assembler/gram.c +++ b/assembler/gram.c @@ -89,114 +89,140 @@ typedef union { #define TYPE_V 274 #define TYPE_F 275 #define ALIGN1 276 -#define GENREGFILE 277 -#define MSGREGFILE 278 -#define MOV 279 -#define MUL 280 -#define MAC 281 -#define MACH 282 -#define LINE 283 -#define SAD2 284 -#define SADA2 285 -#define DP4 286 -#define DPH 287 -#define DP3 288 -#define DP2 289 -#define ADD 290 -#define SEND 291 -#define NULL_TOKEN 292 -#define MATH 293 -#define SAMPLER 294 -#define GATEWAY 295 -#define READ 296 -#define WRITE 297 -#define URB 298 -#define THREAD_SPAWNER 299 -#define MSGLEN 300 -#define RETURNLEN 301 -#define INTEGER 302 -#define NUMBER 303 -#define accreg 304 -#define triop 305 +#define ALIGN16 277 +#define MASK_DISABLE 278 +#define EOT 279 +#define GENREG 280 +#define MSGREG 281 +#define ACCREG 282 +#define ADDRESSREG 283 +#define FLAGREG 284 +#define CONTROLREG 285 +#define IPREG 286 +#define MOV 287 +#define MUL 288 +#define MAC 289 +#define MACH 290 +#define LINE 291 +#define SAD2 292 +#define SADA2 293 +#define DP4 294 +#define DPH 295 +#define DP3 296 +#define DP2 297 +#define ADD 298 +#define SEND 299 +#define NULL_TOKEN 300 +#define MATH 301 +#define SAMPLER 302 +#define GATEWAY 303 +#define READ 304 +#define WRITE 305 +#define URB 306 +#define THREAD_SPAWNER 307 +#define MSGLEN 308 +#define RETURNLEN 309 +#define SATURATE 310 +#define INTEGER 311 +#define NUMBER 312 +#define flagreg 313 +#define maskreg 314 +#define NOP 315 const short yylhs[] = { -1, - 0, 16, 16, 16, 1, 1, 1, 1, 2, 17, - 3, 18, 4, 19, 5, 6, 34, 35, 26, 26, - 26, 26, 26, 26, 26, 26, 32, 7, 8, 9, - 9, 15, 15, 14, 13, 13, 10, 11, 12, 28, - 24, 24, 29, 25, 23, 27, 20, 20, 20, 20, - 20, 20, 20, 21, 30, 30, 31, 22, 33, 36, + 0, 21, 21, 21, 1, 1, 1, 1, 1, 2, + 22, 3, 23, 23, 4, 24, 5, 6, 7, 41, + 32, 32, 32, 32, 32, 32, 32, 32, 40, 40, + 8, 9, 9, 10, 10, 17, 17, 16, 15, 15, + 12, 13, 14, 31, 31, 34, 35, 11, 36, 37, + 30, 33, 27, 27, 27, 27, 27, 27, 27, 28, + 38, 38, 39, 29, 26, 26, 25, 18, 19, 19, + 20, 20, 20, 20, }; const short yylen[] = { 2, - 1, 3, 2, 3, 1, 1, 1, 1, 6, 1, - 7, 1, 7, 1, 1, 12, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, - 1, 1, 2, 1, 1, 2, 1, 1, 3, 3, - 2, 0, 3, 1, 3, 7, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 0, 3, 3, 1, + 1, 3, 2, 3, 1, 1, 1, 1, 1, 8, + 1, 9, 1, 1, 9, 1, 1, 12, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 3, 3, 1, 1, 1, 1, 2, 1, 1, 2, + 1, 1, 3, 2, 0, 3, 3, 3, 3, 1, + 3, 7, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 3, 0, 2, 0, 3, 2, 0, + 1, 1, 1, 1, }; const short yydefred[] = { 0, - 0, 0, 0, 5, 6, 7, 8, 15, 1, 0, - 0, 0, 10, 12, 14, 0, 0, 0, 0, 4, - 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 27, 0, 30, 31, 0, 0, 0, 17, 0, 58, - 0, 0, 0, 0, 55, 56, 34, 37, 32, 0, - 0, 0, 0, 38, 0, 18, 0, 0, 40, 44, - 43, 0, 48, 49, 50, 51, 52, 53, 47, 28, - 0, 9, 0, 0, 54, 33, 35, 0, 0, 0, - 19, 21, 20, 22, 23, 24, 25, 26, 0, 41, - 45, 60, 0, 0, 39, 11, 36, 13, 0, 59, - 0, 0, 0, 0, 0, 0, 0, 16, 46, + 0, 19, 0, 0, 5, 6, 7, 8, 17, 9, + 1, 0, 0, 0, 11, 13, 14, 16, 0, 67, + 67, 67, 4, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 50, 29, + 30, 0, 0, 34, 35, 33, 0, 66, 0, 0, + 0, 64, 0, 0, 0, 0, 0, 0, 20, 0, + 0, 0, 0, 0, 0, 46, 47, 48, 0, 54, + 55, 56, 57, 58, 59, 53, 31, 32, 0, 0, + 21, 23, 22, 24, 25, 26, 27, 28, 0, 61, + 62, 38, 41, 36, 0, 0, 0, 42, 0, 44, + 51, 0, 43, 0, 0, 10, 60, 37, 39, 0, + 0, 0, 0, 0, 71, 72, 73, 74, 0, 0, + 12, 40, 15, 0, 0, 68, 69, 0, 0, 0, + 18, 52, }; -const short yydgoto[] = { 2, - 3, 4, 5, 6, 7, 8, 31, 0, 32, 47, - 53, 48, 78, 49, 50, 9, 17, 18, 19, 75, - 76, 24, 44, 59, 61, 89, 74, 51, 34, 79, - 10, 35, 72, 39, 57, 93, +const short yydgoto[] = { 3, + 4, 5, 6, 7, 8, 9, 10, 40, 41, 42, + 43, 92, 97, 93, 110, 94, 95, 106, 119, 120, + 11, 20, 21, 22, 26, 32, 107, 108, 30, 57, + 66, 89, 80, 60, 45, 0, 46, 111, 12, 47, + 61, }; -const short yysindex[] = { -246, - -251, 0, -239, 0, 0, 0, 0, 0, 0, -271, - -246, -246, 0, 0, 0, -280, -232, -232, -232, 0, - 0, -232, -273, -261, -261, -261, -261, -219, -245, -244, - 0, -204, 0, 0, -275, -218, -218, 0, -218, 0, - -205, -205, -241, -234, 0, 0, 0, 0, 0, -200, - -197, -234, -275, 0, -275, 0, -250, -238, 0, 0, - 0, -196, 0, 0, 0, 0, 0, 0, 0, 0, - -210, 0, -235, -234, 0, 0, 0, -200, -234, -200, - 0, 0, 0, 0, 0, 0, 0, 0, -231, 0, - 0, 0, -195, -194, 0, 0, 0, 0, -230, 0, - -229, -227, -193, -226, -225, -200, -186, 0, 0, +const short yysindex[] = { -256, + -244, 0, 0, -218, 0, 0, 0, 0, 0, 0, + 0, -266, -256, -256, 0, 0, 0, 0, -265, 0, + 0, 0, 0, 0, -205, -194, -194, -194, -239, -274, + -237, -205, -205, -205, -185, -236, -235, -234, 0, 0, + 0, -182, -182, 0, 0, 0, -201, 0, -274, -274, + -274, 0, -184, -184, -184, -231, -226, -226, 0, -178, + -240, -277, -201, -201, -228, 0, 0, 0, -177, 0, + 0, 0, 0, 0, 0, 0, 0, 0, -225, -226, + 0, 0, 0, 0, 0, 0, 0, 0, -223, 0, + 0, 0, 0, 0, -175, -226, -277, 0, -277, 0, + 0, -176, 0, -222, -221, 0, 0, 0, 0, -175, + -226, -175, -220, -219, 0, 0, 0, 0, -171, -221, + 0, 0, 0, -170, -216, 0, 0, -215, -175, -168, + 0, 0, }; -const short yyrindex[] = { -266, +const short yyrindex[] = { -251, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -266, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -251, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, -161, -161, -161, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - -182, -182, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, -162, -162, -162, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, -164, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, -164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, }; const short yygindex[] = { 0, - 0, 0, 0, 0, 0, 0, 52, 0, 0, 0, - 0, -32, 25, 44, 0, 27, 0, 0, 0, -44, - 3, -7, 0, 41, 0, 0, 0, 26, 0, 49, - 0, 29, -75, 0, 0, 0, -}; -#define YYTABLESIZE 292 -const short yytable[] = { 70, - 3, 29, 96, 54, 98, 11, 56, 13, 14, 1, - 25, 26, 57, 57, 27, 29, 30, 12, 15, 16, - 77, 22, 77, 57, 57, 23, 45, 46, 28, 95, - 108, 63, 64, 65, 66, 67, 68, 20, 21, 40, - 69, 81, 82, 83, 84, 85, 86, 87, 88, 33, - 33, 33, 33, 36, 37, 43, 41, 42, 29, 58, - 62, 71, 73, 90, 91, 92, 94, 100, 99, 101, - 105, 102, 103, 104, 109, 106, 107, 42, 38, 80, - 55, 97, 60, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, -45, 2, 36, 0, -98, -18, 0, + -3, 0, 0, 0, -2, 23, -53, -8, -17, 61, + -30, 0, 0, -21, 0, 0, 0, 43, 0, 19, + 0, +}; +#define YYTABLESIZE 300 +const short yytable[] = { 1, + 3, 59, 36, 77, 78, 36, 37, 38, 44, 23, + 24, 121, 13, 123, 49, 50, 51, 98, 27, 28, + 15, 16, 17, 67, 68, 39, 103, 44, 44, 44, + 131, 18, 19, 90, 91, 63, 63, 63, 14, 70, + 71, 72, 73, 74, 75, 25, 63, 63, 76, 33, + 34, 109, 29, 109, 115, 116, 117, 118, 2, 81, + 82, 83, 84, 85, 86, 87, 88, 62, 63, 64, + 31, 35, 48, 52, 53, 54, 55, 56, 36, 69, + 65, 79, 100, 101, 104, 102, 105, 113, 114, 125, + 124, 126, 132, 128, 129, 130, 65, 45, 70, 99, + 112, 127, 122, 58, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -214,20 +240,21 @@ const short yytable[] = { 70, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, - 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 57, 57, + 0, 0, 0, 0, 0, 0, 0, 63, 63, 63, + 0, 0, 0, 0, 0, 0, 0, 0, 63, 63, }; -const short yycheck[] = { 44, - 0, 277, 78, 36, 80, 257, 39, 279, 280, 256, - 18, 19, 279, 280, 22, 277, 278, 257, 290, 291, - 53, 302, 55, 290, 291, 258, 302, 303, 302, 74, - 106, 266, 267, 268, 269, 270, 271, 11, 12, 259, - 275, 292, 293, 294, 295, 296, 297, 298, 299, 24, - 25, 26, 27, 25, 26, 260, 302, 302, 277, 265, - 302, 262, 260, 302, 261, 276, 302, 263, 300, 264, - 264, 302, 302, 301, 261, 302, 302, 260, 27, 55, - 37, 79, 42, 35, -1, -1, -1, -1, -1, -1, +const short yycheck[] = { 256, + 0, 47, 280, 57, 58, 280, 281, 282, 30, 13, + 14, 110, 257, 112, 32, 33, 34, 63, 21, 22, + 287, 288, 289, 54, 55, 300, 80, 49, 50, 51, + 129, 298, 299, 311, 312, 287, 288, 289, 257, 266, + 267, 268, 269, 270, 271, 311, 298, 299, 275, 27, + 28, 97, 258, 99, 276, 277, 278, 279, 315, 300, + 301, 302, 303, 304, 305, 306, 307, 49, 50, 51, + 265, 311, 310, 259, 311, 311, 311, 260, 280, 311, + 265, 260, 311, 261, 308, 311, 262, 264, 311, 309, + 311, 263, 261, 264, 311, 311, 258, 260, 263, 64, + 99, 120, 111, 43, 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -245,16 +272,14 @@ const short yycheck[] = { 44, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, 279, - 280, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 290, 291, + -1, -1, -1, -1, -1, -1, -1, 287, 288, 289, + -1, -1, -1, -1, -1, -1, -1, -1, 298, 299, }; -#define YYFINAL 2 +#define YYFINAL 3 #ifndef YYDEBUG #define YYDEBUG 0 #endif -#define YYMAXTOKEN 305 +#define YYMAXTOKEN 315 #if YYDEBUG const char * const yyname[] = { "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -266,10 +291,11 @@ const char * const yyname[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"SEMICOLON","LPAREN","RPAREN", "LANGLE","RANGLE","LCURLY","RCURLY","COMMA","DOT","TYPE_UD","TYPE_D","TYPE_UW", "TYPE_W","TYPE_UB","TYPE_B","TYPE_VF","TYPE_HF","TYPE_V","TYPE_F","ALIGN1", -"GENREGFILE","MSGREGFILE","MOV","MUL","MAC","MACH","LINE","SAD2","SADA2","DP4", -"DPH","DP3","DP2","ADD","SEND","NULL_TOKEN","MATH","SAMPLER","GATEWAY","READ", -"WRITE","URB","THREAD_SPAWNER","MSGLEN","RETURNLEN","INTEGER","NUMBER","accreg", -"triop", +"ALIGN16","MASK_DISABLE","EOT","GENREG","MSGREG","ACCREG","ADDRESSREG", +"FLAGREG","CONTROLREG","IPREG","MOV","MUL","MAC","MACH","LINE","SAD2","SADA2", +"DP4","DPH","DP3","DP2","ADD","SEND","NULL_TOKEN","MATH","SAMPLER","GATEWAY", +"READ","WRITE","URB","THREAD_SPAWNER","MSGLEN","RETURNLEN","SATURATE","INTEGER", +"NUMBER","flagreg","maskreg","NOP", }; const char * const yyrule[] = { "$accept : ROOT", @@ -281,16 +307,18 @@ const char * const yyrule[] = { "instruction : binaryinstruction", "instruction : binaryaccinstruction", "instruction : triinstruction", -"unaryinstruction : predicate unaryop execsize dst srcaccimm instoptions", +"instruction : specialinstruction", +"unaryinstruction : predicate unaryop conditionalmodifier saturate execsize dst srcaccimm instoptions", "unaryop : MOV", -"binaryinstruction : predicate binaryop execsize dst src srcimm instoptions", +"binaryinstruction : predicate binaryop conditionalmodifier saturate execsize dst src srcimm instoptions", "binaryop : MUL", -"binaryaccinstruction : predicate binaryaccop execsize dst srcacc srcimm instoptions", +"binaryop : MAC", +"binaryaccinstruction : predicate binaryaccop conditionalmodifier saturate execsize dst srcacc srcimm instoptions", "binaryaccop : ADD", "triinstruction : sendinstruction", -"sendinstruction : predicate SEND INTEGER execsize postdst curdst msgtarget MSGLEN INTEGER RETURNLEN INTEGER instoptions", -"postdst : dstoperand", -"curdst : directsrcoperand", +"sendinstruction : predicate SEND INTEGER execsize dst payload msgtarget MSGLEN INTEGER RETURNLEN INTEGER instoptions", +"specialinstruction : NOP", +"payload : directsrcoperand", "msgtarget : NULL_TOKEN", "msgtarget : SAMPLER", "msgtarget : MATH", @@ -300,8 +328,10 @@ const char * const yyrule[] = { "msgtarget : URB", "msgtarget : THREAD_SPAWNER", "dst : dstoperand", +"dst : dstoperandex", "dstoperand : dstreg dstregion regtype", "dstoperandex : accreg dstregion regtype", +"dstoperandex : nullreg", "dstreg : directgenreg", "dstreg : directmsgreg", "srcaccimm : srcacc", @@ -312,11 +342,13 @@ const char * const yyrule[] = { "directsrcaccoperand : directsrcoperand", "src : directsrcoperand", "directsrcoperand : directgenreg region regtype", -"directgenreg : GENREGFILE INTEGER gensubregnum", -"gensubregnum : DOT INTEGER", -"gensubregnum :", -"directmsgreg : MSGREGFILE INTEGER msgsubregnum", -"msgsubregnum : gensubregnum", +"subregnum : DOT INTEGER", +"subregnum :", +"directgenreg : GENREG INTEGER subregnum", +"directmsgreg : MSGREG INTEGER subregnum", +"accreg : ACCREG INTEGER subregnum", +"addrreg : ADDRESSREG INTEGER subregnum", +"nullreg : NULL_TOKEN", "dstregion : LANGLE INTEGER RANGLE", "region : LANGLE INTEGER COMMA INTEGER COMMA INTEGER RANGLE", "regtype : TYPE_F", @@ -331,8 +363,16 @@ const char * const yyrule[] = { "imm32 : NUMBER", "predicate :", "execsize : LPAREN INTEGER RPAREN", -"instoptions : LCURLY instoption RCURLY", +"saturate :", +"saturate : DOT SATURATE", +"conditionalmodifier :", +"instoptions : LCURLY instoption_list RCURLY", +"instoption_list : instoption instoption_list", +"instoption_list :", "instoption : ALIGN1", +"instoption : ALIGN16", +"instoption : MASK_DISABLE", +"instoption : EOT", }; #endif #if YYDEBUG @@ -362,7 +402,7 @@ short *yyss; short *yysslim; YYSTYPE *yyvs; int yystacksize; -#line 395 "gram.y" +#line 470 "gram.y" extern int yylineno; void yyerror (char *msg) @@ -371,7 +411,7 @@ void yyerror (char *msg) msg, yylineno, lex_text()); } -#line 375 "y.tab.c" +#line 415 "y.tab.c" /* allocate initial stack or double stack size, up to YYMAXDEPTH */ static int yygrowstack() { @@ -567,13 +607,13 @@ yyreduce: switch (yyn) { case 1: -#line 92 "gram.y" +#line 97 "gram.y" { compiled_program = yyvsp[0].program; } break; case 2: -#line 98 "gram.y" +#line 103 "gram.y" { struct brw_program_instruction *list_entry = calloc(sizeof(struct brw_program_instruction), 1); @@ -586,7 +626,7 @@ case 2: } break; case 3: -#line 109 "gram.y" +#line 114 "gram.y" { struct brw_program_instruction *list_entry = calloc(sizeof(struct brw_program_instruction), 1); @@ -598,114 +638,147 @@ case 3: } break; case 4: -#line 119 "gram.y" +#line 124 "gram.y" { yyval.program = yyvsp[0].program; } break; -case 9: -#line 132 "gram.y" +case 10: +#line 140 "gram.y" { - yyval.instruction.header.opcode = yyvsp[-4].integer; + yyval.instruction.header.opcode = yyvsp[-6].integer; + yyval.instruction.header.saturate = yyvsp[-5].integer; + yyval.instruction.header.destreg__conditionalmod = yyvsp[-4].integer; yyval.instruction.header.execution_size = yyvsp[-3].integer; + yyval.instruction.bits1 = yyvsp[-1].instruction.bits1; + /* XXX: more */ } break; -case 10: -#line 138 "gram.y" +case 11: +#line 150 "gram.y" { yyval.integer = BRW_OPCODE_MOV; } break; -case 11: -#line 143 "gram.y" +case 12: +#line 156 "gram.y" { - yyval.instruction.header.opcode = yyvsp[-5].integer; + yyval.instruction.header.opcode = yyvsp[-7].integer; + yyval.instruction.header.saturate = yyvsp[-6].integer; + yyval.instruction.header.destreg__conditionalmod = yyvsp[-5].integer; yyval.instruction.header.execution_size = yyvsp[-4].integer; + /* XXX: more */ } break; -case 12: -#line 149 "gram.y" +case 13: +#line 165 "gram.y" { yyval.integer = BRW_OPCODE_MUL; } break; -case 13: -#line 153 "gram.y" +case 14: +#line 166 "gram.y" +{ yyval.integer = BRW_OPCODE_MAC; } +break; +case 15: +#line 171 "gram.y" { - yyval.instruction.header.opcode = yyvsp[-5].integer; + yyval.instruction.header.opcode = yyvsp[-7].integer; + yyval.instruction.header.saturate = yyvsp[-6].integer; + yyval.instruction.header.destreg__conditionalmod = yyvsp[-5].integer; yyval.instruction.header.execution_size = yyvsp[-4].integer; } break; -case 14: -#line 159 "gram.y" +case 16: +#line 179 "gram.y" { yyval.integer = BRW_OPCODE_ADD; } break; -case 16: -#line 167 "gram.y" +case 18: +#line 187 "gram.y" { yyval.instruction.header.opcode = BRW_OPCODE_SEND; yyval.instruction.header.execution_size = yyvsp[-8].integer; - yyval.instruction.header.destreg__conditonalmod = yyvsp[-9].integer; + yyval.instruction.header.destreg__conditionalmod = yyvsp[-9].integer; } break; case 19: -#line 181 "gram.y" +#line 194 "gram.y" +{ + yyval.instruction.header.opcode = BRW_OPCODE_NOP; + } +break; +case 21: +#line 202 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_NULL; } break; -case 20: -#line 182 "gram.y" +case 22: +#line 203 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_SAMPLER; } break; -case 21: -#line 183 "gram.y" +case 23: +#line 204 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_MATH; } break; -case 22: -#line 184 "gram.y" +case 24: +#line 205 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_GATEWAY; } break; -case 23: -#line 185 "gram.y" +case 25: +#line 206 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_DATAPORT_READ; } break; -case 24: -#line 186 "gram.y" +case 26: +#line 207 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_DATAPORT_WRITE; } break; -case 25: -#line 187 "gram.y" +case 27: +#line 208 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_URB; } break; -case 26: -#line 188 "gram.y" +case 28: +#line 209 "gram.y" { yyval.integer = BRW_MESSAGE_TARGET_THREAD_SPAWNER; } break; -case 28: -#line 198 "gram.y" +case 31: +#line 218 "gram.y" { /* Returns an instruction with just the destination register * filled in. */ yyval.instruction.bits1 = yyvsp[-2].instruction.bits1; - yyval.instruction.bits1.da1.dest_reg_type = yyvsp[-1].integer; + yyval.instruction.bits1.da1.dest_reg_type = yyvsp[-1].integer; /* XXX */ + /* XXX: $3 */ } break; -case 29: -#line 207 "gram.y" +case 32: +#line 229 "gram.y" { /* Returns an instruction with just the destination register * filled in. */ - yyval.instruction.bits1 = yyvsp[-2].instruction.bits1; - yyval.instruction.bits1.da1.dest_reg_type = yyvsp[-1].integer; + yyval.instruction.bits1.da1.dest_reg_file = yyvsp[-2].direct_gen_reg.reg_file; + yyval.instruction.bits1.da1.dest_reg_nr = yyvsp[-2].direct_gen_reg.reg_nr; + yyval.instruction.bits1.da1.dest_subreg_nr = yyvsp[-2].direct_gen_reg.subreg_nr; + /* XXX: $2 $3 */ } break; -case 30: -#line 217 "gram.y" +case 33: +#line 239 "gram.y" { + /* Returns an instruction with just the destination register + * filled in. + */ yyval.instruction.bits1.da1.dest_reg_file = yyvsp[0].direct_gen_reg.reg_file; yyval.instruction.bits1.da1.dest_reg_nr = yyvsp[0].direct_gen_reg.reg_nr; yyval.instruction.bits1.da1.dest_subreg_nr = yyvsp[0].direct_gen_reg.subreg_nr; } break; -case 33: -#line 229 "gram.y" +case 34: +#line 251 "gram.y" +{ + yyval.instruction.bits1.da1.dest_reg_file = yyvsp[0].direct_gen_reg.reg_file; + yyval.instruction.bits1.da1.dest_reg_nr = yyvsp[0].direct_gen_reg.reg_nr; + yyval.instruction.bits1.da1.dest_subreg_nr = yyvsp[0].direct_gen_reg.subreg_nr; + } +break; +case 37: +#line 263 "gram.y" { yyval.instruction.bits1.da1.src0_reg_file = BRW_IMMEDIATE_VALUE; switch (yyvsp[0].integer) { @@ -721,8 +794,8 @@ case 33: } } break; -case 36: -#line 251 "gram.y" +case 40: +#line 285 "gram.y" { yyval.instruction.bits1.da1.src0_reg_file = BRW_IMMEDIATE_VALUE; switch (yyvsp[0].integer) { @@ -738,8 +811,8 @@ case 36: } } break; -case 39: -#line 277 "gram.y" +case 43: +#line 311 "gram.y" { /* Returns a source operand in the src0 fields of an * instruction. @@ -753,8 +826,21 @@ case 39: yyval.instruction.bits2.da1.src0_horiz_stride = yyvsp[-1].region.horiz_stride; } break; -case 40: -#line 293 "gram.y" +case 44: +#line 326 "gram.y" +{ + yyval.integer = yyvsp[0].integer; + } +break; +case 45: +#line 330 "gram.y" +{ + /* Default to subreg 0 if unspecified. */ + yyval.integer = 0; + } +break; +case 46: +#line 338 "gram.y" { /* Returns an instruction with just the destination register * fields filled in. @@ -764,32 +850,49 @@ case 40: yyval.direct_gen_reg.subreg_nr = yyvsp[0].integer; } break; -case 41: -#line 303 "gram.y" +case 47: +#line 348 "gram.y" { - yyval.integer = yyvsp[0].integer; + /* Returns an instruction with just the destination register + * fields filled in. + */ + yyval.direct_gen_reg.reg_file = BRW_GENERAL_REGISTER_FILE; + yyval.direct_gen_reg.reg_nr = yyvsp[-1].integer; + yyval.direct_gen_reg.subreg_nr = yyvsp[0].integer; } break; -case 42: -#line 307 "gram.y" +case 48: +#line 359 "gram.y" { - /* Default to subreg 0 if unspecified. */ - yyval.integer = 0; + /* Returns an instruction with just the destination register + * fields filled in. + */ + yyval.direct_gen_reg.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + yyval.direct_gen_reg.reg_nr = BRW_ARF_ACCUMULATOR | yyvsp[-1].integer; + yyval.direct_gen_reg.subreg_nr = yyvsp[0].integer; } break; -case 43: -#line 314 "gram.y" +case 49: +#line 370 "gram.y" { /* Returns an instruction with just the destination register * fields filled in. */ - yyval.direct_gen_reg.reg_file = BRW_GENERAL_REGISTER_FILE; - yyval.direct_gen_reg.reg_nr = yyvsp[-1].integer; + yyval.direct_gen_reg.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + yyval.direct_gen_reg.reg_nr = BRW_ARF_ADDRESS | yyvsp[-1].integer; yyval.direct_gen_reg.subreg_nr = yyvsp[0].integer; } break; -case 45: -#line 329 "gram.y" +case 50: +#line 381 "gram.y" +{ + yyval.direct_gen_reg.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + yyval.direct_gen_reg.reg_nr = BRW_ARF_NULL; + yyval.direct_gen_reg.subreg_nr = 0; + } +break; +case 51: +#line 390 "gram.y" { /* Returns a value for a horiz_stride field of an * instruction. @@ -800,44 +903,44 @@ case 45: yyval.integer = ffs(yyvsp[-1].integer); } break; -case 46: -#line 341 "gram.y" +case 52: +#line 402 "gram.y" { yyval.region.vert_stride = yyvsp[-5].integer; yyval.region.width = yyvsp[-3].integer; yyval.region.horiz_stride = yyvsp[-1].integer; } break; -case 47: -#line 353 "gram.y" +case 53: +#line 414 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_F; } break; -case 48: -#line 354 "gram.y" +case 54: +#line 415 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_UD; } break; -case 49: -#line 355 "gram.y" +case 55: +#line 416 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_D; } break; -case 50: -#line 356 "gram.y" +case 56: +#line 417 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_UW; } break; -case 51: -#line 357 "gram.y" +case 57: +#line 418 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_UW; } break; -case 52: -#line 358 "gram.y" +case 58: +#line 419 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_UB; } break; -case 53: -#line 359 "gram.y" +case 59: +#line 420 "gram.y" { yyval.integer = BRW_REGISTER_TYPE_B; } break; -case 58: -#line 372 "gram.y" +case 64: +#line 433 "gram.y" { /* Returns a value for the execution_size field of an * instruction. @@ -850,7 +953,19 @@ case 58: yyval.integer = ffs(yyvsp[-1].integer); } break; -#line 854 "y.tab.c" +case 65: +#line 446 "gram.y" +{ yyval.integer = 0; } +break; +case 66: +#line 447 "gram.y" +{ yyval.integer = 1; } +break; +case 68: +#line 456 "gram.y" +{ yyval.instruction = yyvsp[-1].instruction; } +break; +#line 969 "y.tab.c" } yyssp -= yym; yystate = *yyssp; diff --git a/assembler/gram.y b/assembler/gram.y index 5ef46b1e..6e4b1b5a 100644 --- a/assembler/gram.y +++ b/assembler/gram.y @@ -59,9 +59,9 @@ %token TYPE_UD, TYPE_D, TYPE_UW, TYPE_W, TYPE_UB, TYPE_B, %token TYPE_VF, TYPE_HF, TYPE_V, TYPE_F -%token ALIGN1 +%token ALIGN1 ALIGN16 MASK_DISABLE EOT -%token GENREGFILE MSGREGFILE +%token GENREG MSGREG ACCREG ADDRESSREG FLAGREG CONTROLREG IPREG %token MOV %token MUL MAC MACH LINE SAD2 SADA2 DP4 DPH DP3 DP2 @@ -69,21 +69,26 @@ %token SEND NULL_TOKEN MATH SAMPLER GATEWAY READ WRITE URB THREAD_SPAWNER %token MSGLEN RETURNLEN +%token SATURATE %token <integer> INTEGER %token <number> NUMBER %type <instruction> instruction unaryinstruction binaryinstruction %type <instruction> binaryaccinstruction triinstruction sendinstruction +%type <instruction> specialinstruction %type <instruction> dstoperand dstoperandex dstreg accreg %type <instruction> directsrcaccoperand src directsrcoperand srcimm %type <instruction> srcacc srcaccimm +%type <instruction> instoptions instoption_list instoption %type <program> instrseq -%type <integer> unaryop binaryop binaryaccop triop +%type <integer> unaryop binaryop binaryaccop +%type <integer> conditionalmodifier saturate %type <integer> regtype srcimmtype execsize dstregion -%type <integer> gensubregnum msgsubregnum msgtarget +%type <integer> subregnum msgtarget %type <region> region -%type <direct_gen_reg> directgenreg directmsgreg +%type <direct_gen_reg> directgenreg directmsgreg addrreg accreg flagreg maskreg +%type <direct_gen_reg> nullreg %type <imm32> imm32 %% @@ -126,12 +131,19 @@ instruction: unaryinstruction | binaryinstruction | binaryaccinstruction | triinstruction + | specialinstruction ; -unaryinstruction: predicate unaryop execsize dst srcaccimm instoptions +unaryinstruction: + predicate unaryop conditionalmodifier saturate execsize + dst srcaccimm instoptions { $$.header.opcode = $2; - $$.header.execution_size = $3; + $$.header.saturate = $3; + $$.header.destreg__conditionalmod = $4; + $$.header.execution_size = $5; + $$.bits1 = $7.bits1; + /* XXX: more */ } ; @@ -139,20 +151,28 @@ unaryop: MOV { $$ = BRW_OPCODE_MOV; } ; binaryinstruction: - predicate binaryop execsize dst src srcimm instoptions + predicate binaryop conditionalmodifier saturate execsize + dst src srcimm instoptions { $$.header.opcode = $2; - $$.header.execution_size = $3; + $$.header.saturate = $3; + $$.header.destreg__conditionalmod = $4; + $$.header.execution_size = $5; + /* XXX: more */ } ; binaryop: MUL { $$ = BRW_OPCODE_MUL; } + | MAC { $$ = BRW_OPCODE_MAC; } binaryaccinstruction: - predicate binaryaccop execsize dst srcacc srcimm instoptions + predicate binaryaccop conditionalmodifier saturate execsize + dst srcacc srcimm instoptions { $$.header.opcode = $2; - $$.header.execution_size = $3; + $$.header.saturate = $3; + $$.header.destreg__conditionalmod = $4; + $$.header.execution_size = $5; } ; @@ -162,20 +182,21 @@ binaryaccop: ADD { $$ = BRW_OPCODE_ADD; } triinstruction: sendinstruction /* XXX formatting of this instruction */ -sendinstruction: predicate SEND INTEGER execsize postdst curdst msgtarget +sendinstruction: predicate SEND INTEGER execsize dst payload msgtarget MSGLEN INTEGER RETURNLEN INTEGER instoptions { $$.header.opcode = BRW_OPCODE_SEND; $$.header.execution_size = $4; - $$.header.destreg__conditonalmod = $3; + $$.header.destreg__conditionalmod = $3; } -/* XXX! */ -postdst: dstoperand -; +specialinstruction: NOP + { + $$.header.opcode = BRW_OPCODE_NOP; + } /* XXX! */ -curdst: directsrcoperand +payload: directsrcoperand ; msgtarget: NULL_TOKEN { $$ = BRW_MESSAGE_TARGET_NULL; } @@ -190,8 +211,7 @@ msgtarget: NULL_TOKEN { $$ = BRW_MESSAGE_TARGET_NULL; } /* 1.4.2: Destination register */ -/** XXX: dstoperandex */ -dst: dstoperand +dst: dstoperand | dstoperandex /* XXX: dstregion writemask */ dstoperand: dstreg dstregion regtype @@ -200,17 +220,31 @@ dstoperand: dstreg dstregion regtype * filled in. */ $$.bits1 = $1.bits1; - $$.bits1.da1.dest_reg_type = $2; + $$.bits1.da1.dest_reg_type = $2; /* XXX */ + /* XXX: $3 */ } +; dstoperandex: accreg dstregion regtype { /* Returns an instruction with just the destination register * filled in. */ - $$.bits1 = $1.bits1; - $$.bits1.da1.dest_reg_type = $2; + $$.bits1.da1.dest_reg_file = $1.reg_file; + $$.bits1.da1.dest_reg_nr = $1.reg_nr; + $$.bits1.da1.dest_subreg_nr = $1.subreg_nr; + /* XXX: $2 $3 */ } + | nullreg + { + /* Returns an instruction with just the destination register + * filled in. + */ + $$.bits1.da1.dest_reg_file = $1.reg_file; + $$.bits1.da1.dest_reg_nr = $1.reg_nr; + $$.bits1.da1.dest_subreg_nr = $1.subreg_nr; + } +; /* XXX: indirectgenreg, directmsgreg, indirectmsgreg */ dstreg: directgenreg @@ -288,8 +322,19 @@ directsrcoperand: directgenreg region regtype } ; +subregnum: DOT INTEGER + { + $$ = $2; + } + | + { + /* Default to subreg 0 if unspecified. */ + $$ = 0; + } +; + /* 1.4.5: Register files and register numbers */ -directgenreg: GENREGFILE INTEGER gensubregnum +directgenreg: GENREG INTEGER subregnum { /* Returns an instruction with just the destination register * fields filled in. @@ -299,29 +344,45 @@ directgenreg: GENREGFILE INTEGER gensubregnum $$.subreg_nr = $3; } -gensubregnum: DOT INTEGER +directmsgreg: MSGREG INTEGER subregnum { - $$ = $2; + /* Returns an instruction with just the destination register + * fields filled in. + */ + $$.reg_file = BRW_GENERAL_REGISTER_FILE; + $$.reg_nr = $2; + $$.subreg_nr = $3; } - | +; + +accreg: ACCREG INTEGER subregnum { - /* Default to subreg 0 if unspecified. */ - $$ = 0; + /* Returns an instruction with just the destination register + * fields filled in. + */ + $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + $$.reg_nr = BRW_ARF_ACCUMULATOR | $2; + $$.subreg_nr = $3; } ; -directmsgreg: MSGREGFILE INTEGER msgsubregnum +addrreg: ADDRESSREG INTEGER subregnum { /* Returns an instruction with just the destination register * fields filled in. */ - $$.reg_file = BRW_GENERAL_REGISTER_FILE; - $$.reg_nr = $2; + $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + $$.reg_nr = BRW_ARF_ADDRESS | $2; $$.subreg_nr = $3; } ; -msgsubregnum: gensubregnum +nullreg: NULL_TOKEN + { + $$.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + $$.reg_nr = BRW_ARF_NULL; + $$.subreg_nr = 0; + } ; /* 1.4.7: Regions */ @@ -382,14 +443,28 @@ execsize: LPAREN INTEGER RPAREN } ; +saturate: /* empty */ { $$ = 0; } + | DOT SATURATE { $$ = 1; } +; + +conditionalmodifier: +; + /* 1.4.13: Instruction options */ /* XXX: this is a comma-separated list, really. */ -instoptions: LCURLY instoption RCURLY +instoptions: LCURLY instoption_list RCURLY + { $$ = $2; } +; + +instoption_list: instoption instoption_list + | +; /* XXX: fill me in. alignctrl, comprctrl, threadctrl, depctrl, maskctrl, * debugctrl, sendctrl */ -instoption: ALIGN1 +instoption: ALIGN1 | ALIGN16 | MASK_DISABLE | EOT +; %% extern int yylineno; diff --git a/assembler/lex.c b/assembler/lex.c index 1957d106..5c05e21d 100644 --- a/assembler/lex.c +++ b/assembler/lex.c @@ -293,42 +293,47 @@ static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); *yy_cp = '\0'; \ yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 48 -#define YY_END_OF_BUFFER 49 -static yyconst short int yy_acclist[122] = +#define YY_NUM_RULES 62 +#define YY_END_OF_BUFFER 63 +static yyconst short int yy_acclist[151] = { 0, - 44, 44, 44, 44, 49, 47, 48, 46, 47, 48, - 46, 48, 26, 47, 48, 27, 47, 48, 32, 47, - 48, 47, 48, 33, 47, 48, 47, 48, 44, 47, - 48, 25, 47, 48, 28, 47, 48, 29, 47, 48, - 41, 47, 48, 37, 47, 48, 42, 47, 48, 47, - 48, 39, 47, 48, 47, 48, 47, 48, 35, 47, - 48, 47, 48, 34, 47, 48, 47, 48, 35, 47, - 48, 47, 48, 47, 48, 47, 48, 47, 48, 30, - 47, 48, 31, 47, 48, 44, 47, 48, 46, 44, - 40, 36, 38, 44, 1, 1, 45, 13, 12, 11, - - 9, 10, 4, 2, 3, 23, 6, 5, 18, 15, - 17, 21, 16, 7, 14, 8, 22, 43, 20, 19, - 24 + 58, 58, 58, 58, 63, 61, 62, 60, 61, 62, + 60, 62, 31, 61, 62, 32, 61, 62, 37, 61, + 62, 61, 62, 38, 61, 62, 61, 62, 58, 61, + 62, 30, 61, 62, 33, 61, 62, 34, 61, 62, + 51, 61, 62, 47, 61, 62, 61, 62, 52, 61, + 62, 61, 62, 49, 61, 62, 40, 61, 62, 61, + 62, 61, 62, 42, 61, 62, 43, 61, 62, 61, + 62, 61, 62, 41, 61, 62, 61, 62, 43, 61, + 62, 61, 62, 61, 62, 61, 62, 61, 62, 35, + 61, 62, 36, 61, 62, 58, 61, 62, 4, 62, + + 5, 62, 4, 5, 62, 4, 62, 60, 2, 58, + 50, 46, 48, 44, 45, 58, 3, 1, 1, 59, + 57, 39, 18, 17, 16, 14, 15, 9, 7, 8, + 19, 53, 28, 11, 10, 23, 21, 6, 26, 22, + 12, 20, 13, 27, 54, 55, 25, 24, 56, 29 } ; -static yyconst short int yy_accept[127] = +static yyconst short int yy_accept[159] = { 0, - 1, 2, 3, 4, 5, 6, 8, 11, 13, 16, - 19, 22, 24, 27, 29, 32, 35, 38, 41, 44, - 47, 50, 52, 55, 57, 59, 62, 64, 67, 69, - 72, 74, 76, 78, 80, 83, 86, 89, 90, 90, - 90, 90, 91, 92, 93, 94, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, - 94, 94, 94, 95, 95, 96, 97, 98, 99, 99, - 100, 101, 102, 103, 103, 103, 104, 104, 104, 105, - 106, 106, 106, 106, 106, 106, 106, 106, 107, 107, - 107, 107, 108, 109, 110, 111, 112, 113, 114, 115, - - 115, 115, 116, 116, 116, 116, 116, 117, 117, 117, - 118, 119, 119, 119, 119, 120, 121, 121, 121, 121, - 121, 121, 121, 121, 122, 122 + 1, 2, 3, 4, 5, 5, 5, 6, 8, 11, + 13, 16, 19, 22, 24, 27, 29, 32, 35, 38, + 41, 44, 47, 49, 52, 54, 57, 60, 62, 64, + 67, 70, 72, 74, 77, 79, 82, 84, 86, 88, + 90, 93, 96, 99, 101, 103, 106, 108, 109, 109, + 110, 110, 110, 111, 111, 112, 113, 114, 114, 114, + 114, 115, 115, 115, 116, 116, 116, 116, 116, 116, + 116, 116, 116, 116, 116, 116, 116, 116, 116, 117, + 118, 118, 119, 120, 121, 122, 123, 124, 124, 125, + 126, 127, 128, 128, 128, 129, 129, 129, 129, 130, + + 131, 132, 132, 132, 132, 132, 132, 133, 133, 133, + 134, 134, 134, 134, 135, 136, 136, 137, 138, 139, + 140, 141, 142, 142, 142, 143, 143, 143, 143, 143, + 143, 144, 144, 144, 145, 146, 146, 146, 146, 146, + 147, 148, 148, 149, 149, 149, 149, 149, 149, 149, + 149, 149, 149, 150, 150, 150, 151, 151 } ; static yyconst int yy_ec[256] = @@ -337,16 +342,16 @@ static yyconst int yy_ec[256] = 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 5, - 6, 1, 1, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 11, 11, 11, 11, 11, 1, 16, 17, - 1, 18, 1, 1, 1, 19, 1, 20, 1, 21, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 22, 1, 23, 1, 1, 1, - 1, 1, 1, 1, 24, 1, 25, 26, 27, 28, - - 29, 1, 30, 31, 32, 1, 1, 33, 34, 35, - 36, 37, 1, 38, 39, 40, 41, 42, 43, 1, - 44, 1, 45, 1, 46, 1, 1, 1, 1, 1, + 6, 7, 1, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 12, 17, 12, 12, 12, 1, 18, 19, + 1, 20, 1, 1, 1, 21, 1, 22, 23, 24, + 1, 1, 1, 1, 1, 1, 1, 1, 25, 1, + 1, 1, 1, 26, 27, 1, 28, 1, 1, 1, + 1, 1, 1, 1, 29, 1, 30, 31, 32, 33, + + 34, 35, 36, 37, 38, 1, 39, 40, 41, 42, + 43, 44, 1, 45, 46, 47, 48, 49, 50, 1, + 51, 1, 52, 1, 53, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -363,109 +368,130 @@ static yyconst int yy_ec[256] = 1, 1, 1, 1, 1 } ; -static yyconst int yy_meta[47] = +static yyconst int yy_meta[54] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1 } ; -static yyconst short int yy_base[127] = +static yyconst short int yy_base[160] = { 0, - 0, 0, 39, 47, 193, 194, 46, 54, 194, 194, - 194, 52, 194, 182, 59, 194, 194, 194, 194, 194, - 194, 56, 194, 49, 154, 165, 157, 53, 147, 51, - 56, 156, 148, 147, 194, 194, 84, 85, 91, 87, - 96, 103, 194, 194, 194, 156, 151, 106, 142, 146, - 86, 151, 137, 145, 144, 151, 146, 94, 139, 135, - 146, 139, 118, 89, 194, 120, 127, 194, 140, 194, - 194, 194, 194, 140, 139, 136, 135, 130, 194, 194, - 131, 135, 127, 121, 124, 132, 130, 194, 118, 122, - 113, 194, 194, 194, 194, 194, 194, 194, 194, 142, - - 121, 194, 128, 123, 139, 125, 194, 120, 120, 194, - 194, 103, 107, 120, 194, 194, 104, 99, 110, 84, - 90, 72, 45, 194, 194, 68 + 0, 0, 45, 54, 69, 71, 239, 240, 53, 62, + 240, 240, 240, 67, 240, 78, 78, 240, 240, 240, + 240, 240, 213, 240, 75, 240, 66, 192, 192, 240, + 205, 190, 195, 70, 59, 71, 74, 195, 186, 185, + 240, 240, 107, 240, 240, 240, 218, 84, 115, 240, + 111, 121, 129, 202, 240, 240, 240, 195, 193, 187, + 240, 133, 177, 240, 181, 108, 188, 172, 180, 175, + 178, 187, 182, 117, 173, 169, 182, 174, 159, 240, + 113, 240, 148, 165, 240, 240, 240, 175, 240, 240, + 240, 240, 176, 175, 171, 168, 169, 163, 240, 240, + + 240, 164, 170, 160, 139, 157, 240, 167, 165, 240, + 151, 155, 146, 240, 240, 166, 240, 240, 240, 240, + 240, 240, 180, 153, 240, 162, 157, 177, 159, 155, + 240, 153, 153, 240, 168, 133, 145, 123, 138, 240, + 240, 120, 240, 119, 133, 118, 130, 130, 119, 107, + 122, 84, 240, 78, 64, 240, 240, 100, 76 } ; -static yyconst short int yy_def[127] = +static yyconst short int yy_def[160] = { 0, - 125, 1, 1, 1, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 126, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 126, 125, 126, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 0, 125 + 157, 1, 1, 1, 158, 158, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 159, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 159, 157, 159, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 0, 157, 157 } ; -static yyconst short int yy_nxt[241] = +static yyconst short int yy_nxt[294] = { 0, - 6, 7, 8, 6, 9, 10, 11, 12, 13, 14, - 15, 15, 15, 15, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 6, 24, 6, 6, 25, 6, 26, - 6, 6, 27, 28, 29, 6, 6, 30, 31, 32, - 33, 6, 34, 6, 35, 36, 6, 38, 38, 37, - 37, 37, 37, 37, 6, 38, 38, 37, 37, 37, - 37, 37, 39, 39, 39, 39, 39, 41, 64, 42, - 42, 42, 42, 42, 43, 44, 46, 51, 45, 56, - 58, 47, 124, 57, 59, 52, 38, 38, 53, 65, - 66, 65, 66, 54, 63, 63, 63, 63, 63, 41, - - 123, 39, 39, 39, 39, 39, 67, 67, 67, 67, - 67, 41, 76, 42, 42, 42, 42, 42, 70, 71, - 72, 84, 65, 66, 122, 77, 121, 85, 63, 63, - 63, 63, 63, 99, 120, 119, 73, 67, 67, 67, - 67, 67, 118, 117, 116, 100, 115, 114, 113, 112, - 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, - 101, 98, 97, 96, 95, 94, 93, 92, 91, 90, - 89, 88, 87, 86, 83, 82, 81, 80, 79, 78, - 75, 74, 69, 68, 62, 61, 60, 55, 50, 49, - 48, 40, 125, 5, 125, 125, 125, 125, 125, 125, - - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125 + 8, 9, 10, 8, 11, 12, 8, 13, 14, 15, + 16, 17, 17, 17, 17, 17, 17, 18, 19, 20, + 21, 22, 23, 24, 8, 8, 25, 26, 8, 27, + 8, 28, 29, 8, 30, 31, 8, 32, 8, 33, + 34, 35, 8, 8, 36, 37, 38, 39, 8, 40, + 8, 41, 42, 8, 48, 48, 43, 43, 43, 43, + 43, 43, 8, 48, 48, 43, 43, 43, 43, 43, + 43, 45, 46, 45, 46, 47, 81, 47, 49, 49, + 49, 49, 49, 49, 50, 48, 48, 52, 51, 53, + 53, 53, 53, 53, 53, 55, 56, 58, 59, 66, + + 44, 70, 57, 74, 72, 60, 71, 75, 156, 67, + 73, 155, 68, 82, 83, 82, 83, 69, 79, 79, + 79, 79, 79, 79, 52, 154, 49, 49, 49, 49, + 49, 49, 84, 84, 84, 84, 84, 84, 52, 95, + 53, 53, 53, 53, 53, 53, 89, 90, 91, 105, + 82, 83, 122, 96, 97, 153, 152, 106, 151, 150, + 149, 148, 147, 107, 146, 145, 144, 143, 123, 92, + 79, 79, 79, 79, 79, 79, 84, 84, 84, 84, + 84, 84, 142, 141, 140, 139, 138, 137, 136, 135, + 134, 133, 132, 131, 130, 129, 128, 127, 126, 125, + + 124, 121, 120, 119, 118, 117, 116, 115, 114, 113, + 112, 111, 110, 109, 108, 104, 103, 102, 101, 100, + 99, 98, 94, 93, 88, 87, 86, 85, 80, 78, + 77, 76, 65, 64, 63, 62, 61, 54, 157, 7, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157 + } ; -static yyconst short int yy_chk[241] = +static yyconst short int yy_chk[294] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 7, 7, 3, - 3, 3, 3, 3, 4, 8, 8, 4, 4, 4, - 4, 4, 12, 12, 12, 12, 12, 15, 126, 15, - 15, 15, 15, 15, 22, 22, 24, 28, 22, 30, - 31, 24, 123, 30, 31, 28, 38, 38, 28, 40, - 40, 64, 64, 28, 37, 37, 37, 37, 37, 39, - - 122, 39, 39, 39, 39, 39, 41, 41, 41, 41, - 41, 42, 51, 42, 42, 42, 42, 42, 48, 48, - 48, 58, 66, 66, 121, 51, 120, 58, 63, 63, - 63, 63, 63, 84, 119, 118, 48, 67, 67, 67, - 67, 67, 117, 114, 113, 84, 112, 109, 108, 106, - 105, 104, 103, 101, 100, 91, 90, 89, 87, 86, - 85, 83, 82, 81, 78, 77, 76, 75, 74, 69, - 62, 61, 60, 59, 57, 56, 55, 54, 53, 52, - 50, 49, 47, 46, 34, 33, 32, 29, 27, 26, - 25, 14, 5, 125, 125, 125, 125, 125, 125, 125, - - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, - 125, 125, 125, 125, 125, 125, 125, 125, 125, 125 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 3, 9, 9, 3, 3, 3, 3, + 3, 3, 4, 10, 10, 4, 4, 4, 4, 4, + 4, 5, 5, 6, 6, 5, 159, 6, 14, 14, + 14, 14, 14, 14, 16, 48, 48, 17, 16, 17, + 17, 17, 17, 17, 17, 25, 25, 27, 27, 34, + + 158, 35, 25, 37, 36, 27, 35, 37, 155, 34, + 36, 154, 34, 51, 51, 81, 81, 34, 43, 43, + 43, 43, 43, 43, 49, 152, 49, 49, 49, 49, + 49, 49, 52, 52, 52, 52, 52, 52, 53, 66, + 53, 53, 53, 53, 53, 53, 62, 62, 62, 74, + 83, 83, 105, 66, 66, 151, 150, 74, 149, 148, + 147, 146, 145, 74, 144, 142, 139, 138, 105, 62, + 79, 79, 79, 79, 79, 79, 84, 84, 84, 84, + 84, 84, 137, 136, 135, 133, 132, 130, 129, 128, + 127, 126, 124, 123, 116, 113, 112, 111, 109, 108, + + 106, 104, 103, 102, 98, 97, 96, 95, 94, 93, + 88, 78, 77, 76, 75, 73, 72, 71, 70, 69, + 68, 67, 65, 63, 60, 59, 58, 54, 47, 40, + 39, 38, 33, 32, 31, 29, 28, 23, 7, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, + 157, 157, 157 + } ; static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; @@ -487,8 +513,13 @@ char *yytext; #line 3 "lex.l" #include "gen4asm.h" #include "y.tab.h" + +int saved_state = INITIAL; + #define IN_REG 1 +#define BLOCK_COMMENT 2 + /* Macros after this point can all be overridden by user definitions in * section 1. @@ -639,7 +670,7 @@ YY_DECL register char *yy_cp, *yy_bp; register int yy_act; -#line 8 "lex.l" +#line 12 "lex.l" if ( yy_init ) @@ -688,14 +719,14 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 126 ) + if ( yy_current_state >= 158 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; *yy_state_ptr++ = yy_current_state; ++yy_cp; } - while ( yy_base[yy_current_state] != 194 ); + while ( yy_base[yy_current_state] != 240 ); yy_find_action: yy_current_state = *--yy_state_ptr; @@ -734,261 +765,361 @@ do_action: /* This label is used only to access EOF actions. */ { /* beginning of action switch */ case 1: YY_RULE_SETUP -#line 9 "lex.l" +#line 13 "lex.l" { } /* eat up single-line comments */ YY_BREAK +/* eat up multi-line comments, non-nesting. */ case 2: YY_RULE_SETUP -#line 11 "lex.l" -{ return MOV; } +#line 16 "lex.l" +{ + saved_state = YYSTATE; + BEGIN(BLOCK_COMMENT); +} YY_BREAK case 3: YY_RULE_SETUP -#line 13 "lex.l" -{ return MUL; } +#line 20 "lex.l" +{ + BEGIN(saved_state); +} YY_BREAK case 4: YY_RULE_SETUP -#line 14 "lex.l" -{ return MAC; } +#line 23 "lex.l" +{ } YY_BREAK case 5: YY_RULE_SETUP -#line 15 "lex.l" -{ return MACH; } +#line 24 "lex.l" +{ } YY_BREAK +/* used for both null send and null register. */ case 6: YY_RULE_SETUP -#line 16 "lex.l" -{ return LINE; } +#line 27 "lex.l" +{ return NULL_TOKEN; } YY_BREAK +/* opcodes */ case 7: YY_RULE_SETUP -#line 17 "lex.l" -{ return SAD2; } +#line 30 "lex.l" +{ return MOV; } YY_BREAK case 8: YY_RULE_SETUP -#line 18 "lex.l" -{ return SADA2; } +#line 32 "lex.l" +{ return MUL; } YY_BREAK case 9: YY_RULE_SETUP -#line 19 "lex.l" -{ return DP4; } +#line 33 "lex.l" +{ return MAC; } YY_BREAK case 10: YY_RULE_SETUP -#line 20 "lex.l" -{ return DPH; } +#line 34 "lex.l" +{ return MACH; } YY_BREAK case 11: YY_RULE_SETUP -#line 21 "lex.l" -{ return DP3; } +#line 35 "lex.l" +{ return LINE; } YY_BREAK case 12: YY_RULE_SETUP -#line 22 "lex.l" -{ return DP2; } +#line 36 "lex.l" +{ return SAD2; } YY_BREAK case 13: YY_RULE_SETUP -#line 24 "lex.l" -{ return ADD; } +#line 37 "lex.l" +{ return SADA2; } YY_BREAK case 14: YY_RULE_SETUP -#line 26 "lex.l" -{ return SEND; } +#line 38 "lex.l" +{ return DP4; } YY_BREAK case 15: YY_RULE_SETUP -#line 27 "lex.l" -{ return MSGLEN; } +#line 39 "lex.l" +{ return DPH; } YY_BREAK case 16: YY_RULE_SETUP -#line 28 "lex.l" -{ return RETURNLEN; } +#line 40 "lex.l" +{ return DP3; } YY_BREAK case 17: YY_RULE_SETUP -#line 29 "lex.l" -{ return NULL_TOKEN; } +#line 41 "lex.l" +{ return DP2; } YY_BREAK case 18: YY_RULE_SETUP -#line 30 "lex.l" -{ return MATH; } +#line 43 "lex.l" +{ return ADD; } YY_BREAK case 19: YY_RULE_SETUP -#line 31 "lex.l" -{ return SAMPLER; } +#line 45 "lex.l" +{ return NOP; } YY_BREAK case 20: YY_RULE_SETUP -#line 32 "lex.l" -{ return GATEWAY; } +#line 47 "lex.l" +{ return SEND; } YY_BREAK case 21: YY_RULE_SETUP -#line 33 "lex.l" -{ return READ; } +#line 48 "lex.l" +{ return MSGLEN; } YY_BREAK case 22: YY_RULE_SETUP -#line 34 "lex.l" -{ return WRITE; } +#line 49 "lex.l" +{ return RETURNLEN; } YY_BREAK case 23: YY_RULE_SETUP -#line 35 "lex.l" -{ return URB; } +#line 50 "lex.l" +{ return MATH; } YY_BREAK case 24: YY_RULE_SETUP -#line 36 "lex.l" -{ return THREAD_SPAWNER; } +#line 51 "lex.l" +{ return SAMPLER; } YY_BREAK case 25: YY_RULE_SETUP -#line 38 "lex.l" -{ return SEMICOLON; } +#line 52 "lex.l" +{ return GATEWAY; } YY_BREAK case 26: YY_RULE_SETUP -#line 39 "lex.l" -{ return LPAREN; } +#line 53 "lex.l" +{ return READ; } YY_BREAK case 27: YY_RULE_SETUP -#line 40 "lex.l" -{ return RPAREN; } +#line 54 "lex.l" +{ return WRITE; } YY_BREAK case 28: YY_RULE_SETUP -#line 41 "lex.l" -{ return LANGLE; } +#line 55 "lex.l" +{ return URB; } YY_BREAK case 29: YY_RULE_SETUP -#line 42 "lex.l" -{ return RANGLE; } +#line 56 "lex.l" +{ return THREAD_SPAWNER; } YY_BREAK case 30: YY_RULE_SETUP -#line 43 "lex.l" -{ return LCURLY; } +#line 58 "lex.l" +{ return SEMICOLON; } YY_BREAK case 31: YY_RULE_SETUP -#line 44 "lex.l" -{ return RCURLY; } +#line 59 "lex.l" +{ return LPAREN; } YY_BREAK case 32: YY_RULE_SETUP -#line 45 "lex.l" -{ return COMMA; } +#line 60 "lex.l" +{ return RPAREN; } YY_BREAK case 33: YY_RULE_SETUP -#line 46 "lex.l" -{ return DOT; } +#line 61 "lex.l" +{ return LANGLE; } YY_BREAK -/* XXX: this lexing of register files is shady */ case 34: YY_RULE_SETUP -#line 49 "lex.l" -{ BEGIN(IN_REG); return MSGREGFILE; } +#line 62 "lex.l" +{ return RANGLE; } YY_BREAK case 35: YY_RULE_SETUP -#line 50 "lex.l" -{ BEGIN(IN_REG); return GENREGFILE; } +#line 63 "lex.l" +{ return LCURLY; } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 64 "lex.l" +{ return RCURLY; } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 65 "lex.l" +{ return COMMA; } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 66 "lex.l" +{ return DOT; } + YY_BREAK +/* XXX: this lexing of register files is shady */ +case 39: +YY_RULE_SETUP +#line 69 "lex.l" +{ + BEGIN(IN_REG); + return ACCREG; +} + YY_BREAK +case 40: +YY_RULE_SETUP +#line 73 "lex.l" +{ + BEGIN(IN_REG); + return ADDRESSREG; +} + YY_BREAK +case 41: +YY_RULE_SETUP +#line 77 "lex.l" +{ + BEGIN(IN_REG); + return MSGREG; +} + YY_BREAK +case 42: +YY_RULE_SETUP +#line 81 "lex.l" +{ + BEGIN(IN_REG); + return FLAGREG; +} + YY_BREAK +case 43: +YY_RULE_SETUP +#line 85 "lex.l" +{ + BEGIN(IN_REG); + return GENREG; +} + YY_BREAK +case 44: +YY_RULE_SETUP +#line 89 "lex.l" +{ + BEGIN(IN_REG); + return CONTROLREG; +} + YY_BREAK +case 45: +YY_RULE_SETUP +#line 93 "lex.l" +{ + BEGIN(IN_REG); + return IPREG; +} YY_BREAK /* * Lexing of register types should probably require the ":" symbol specified * in the BNF of the assembly, but our existing source didn't use that syntax. */ -case 36: +case 46: YY_RULE_SETUP -#line 56 "lex.l" +#line 102 "lex.l" { BEGIN(INITIAL); return TYPE_UD; } YY_BREAK -case 37: +case 47: YY_RULE_SETUP -#line 57 "lex.l" +#line 103 "lex.l" { BEGIN(INITIAL); return TYPE_D; } YY_BREAK -case 38: +case 48: YY_RULE_SETUP -#line 58 "lex.l" +#line 104 "lex.l" { BEGIN(INITIAL); return TYPE_UW; } YY_BREAK -case 39: +case 49: YY_RULE_SETUP -#line 59 "lex.l" +#line 105 "lex.l" { BEGIN(INITIAL); return TYPE_W; } YY_BREAK -case 40: +case 50: YY_RULE_SETUP -#line 60 "lex.l" +#line 106 "lex.l" { BEGIN(INITIAL); return TYPE_UB; } YY_BREAK -case 41: +case 51: YY_RULE_SETUP -#line 61 "lex.l" +#line 107 "lex.l" { BEGIN(INITIAL); return TYPE_B; } YY_BREAK -case 42: +case 52: YY_RULE_SETUP -#line 62 "lex.l" +#line 108 "lex.l" { BEGIN(INITIAL); return TYPE_F; } YY_BREAK -case 43: +case 53: YY_RULE_SETUP -#line 64 "lex.l" +#line 110 "lex.l" +{ return SATURATE; } + YY_BREAK +case 54: +YY_RULE_SETUP +#line 111 "lex.l" { return ALIGN1; } YY_BREAK -case 44: +case 55: YY_RULE_SETUP -#line 66 "lex.l" +#line 112 "lex.l" +{ return ALIGN16; } + YY_BREAK +case 56: +YY_RULE_SETUP +#line 113 "lex.l" +{ return MASK_DISABLE; } + YY_BREAK +case 57: +YY_RULE_SETUP +#line 114 "lex.l" +{ return EOT; } + YY_BREAK +case 58: +YY_RULE_SETUP +#line 116 "lex.l" { yylval.integer = atoi(yytext); return INTEGER; } YY_BREAK -case 45: +case 59: YY_RULE_SETUP -#line 71 "lex.l" +#line 121 "lex.l" { yylval.number = strtod(yytext, NULL); return NUMBER; } YY_BREAK -case 46: +case 60: YY_RULE_SETUP -#line 76 "lex.l" +#line 126 "lex.l" { } /* eat up whitespace */ YY_BREAK -case 47: +case 61: YY_RULE_SETUP -#line 78 "lex.l" +#line 128 "lex.l" { printf("parse error at line %d: unexpected \"%s\"\n", yylineno, yytext); exit(1); } YY_BREAK -case 48: +case 62: YY_RULE_SETUP -#line 83 "lex.l" +#line 133 "lex.l" ECHO; YY_BREAK case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(IN_REG): + case YY_STATE_EOF(BLOCK_COMMENT): yyterminate(); case YY_END_OF_BUFFER: @@ -1276,7 +1407,7 @@ static yy_state_type yy_get_previous_state() while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 126 ) + if ( yy_current_state >= 158 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; @@ -1306,11 +1437,11 @@ yy_state_type yy_current_state; while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 126 ) + if ( yy_current_state >= 158 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 125); + yy_is_jam = (yy_current_state == 157); if ( ! yy_is_jam ) *yy_state_ptr++ = yy_current_state; @@ -1871,7 +2002,7 @@ int main() return 0; } #endif -#line 83 "lex.l" +#line 133 "lex.l" char * diff --git a/assembler/lex.l b/assembler/lex.l index f835f377..c08cdbdb 100644 --- a/assembler/lex.l +++ b/assembler/lex.l @@ -2,12 +2,31 @@ %{ #include "gen4asm.h" #include "y.tab.h" + +int saved_state = INITIAL; + %} -%start IN_REG +%s IN_REG +%x BLOCK_COMMENT %% \/\/.*[\r\n] { } /* eat up single-line comments */ + /* eat up multi-line comments, non-nesting. */ +\/\* { + saved_state = YYSTATE; + BEGIN(BLOCK_COMMENT); +} +<BLOCK_COMMENT>\*\/ { + BEGIN(saved_state); +} +<BLOCK_COMMENT>. { } +<BLOCK_COMMENT>[\r\n] { } + + /* used for both null send and null register. */ +"null" { return NULL_TOKEN; } + + /* opcodes */ "mov" { return MOV; } "mul" { return MUL; } @@ -23,10 +42,11 @@ "add" { return ADD; } +"nop" { return NOP; } + "send" { return SEND; } "mlen" { return MSGLEN; } "rlen" { return RETURNLEN; } -"null" { return NULL_TOKEN; } "math" { return MATH; } "sampler" { return SAMPLER; } "gateway" { return GATEWAY; } @@ -46,8 +66,34 @@ "." { return DOT; } /* XXX: this lexing of register files is shady */ -"m" { BEGIN(IN_REG); return MSGREGFILE; } -[gr] { BEGIN(IN_REG); return GENREGFILE; } +"acc" { + BEGIN(IN_REG); + return ACCREG; +} +"a" { + BEGIN(IN_REG); + return ADDRESSREG; +} +"m" { + BEGIN(IN_REG); + return MSGREG; +} +"f" { + BEGIN(IN_REG); + return FLAGREG; +} +[gr] { + BEGIN(IN_REG); + return GENREG; +} +"cr" { + BEGIN(IN_REG); + return CONTROLREG; +} +"ip" { + BEGIN(IN_REG); + return IPREG; +} /* * Lexing of register types should probably require the ":" symbol specified @@ -61,7 +107,11 @@ "B" { BEGIN(INITIAL); return TYPE_B; } "F" { BEGIN(INITIAL); return TYPE_F; } +"sat" { return SATURATE; } "align1" { return ALIGN1; } +"align16" { return ALIGN16; } +"mask_disable" { return MASK_DISABLE; } +"EOT" { return EOT; } [0-9]* { yylval.integer = atoi(yytext); diff --git a/assembler/packed_yuv_wm.g4a b/assembler/packed_yuv_wm.g4a index 8a1003d7..d6f1ba54 100644 --- a/assembler/packed_yuv_wm.g4a +++ b/assembler/packed_yuv_wm.g4a @@ -1,82 +1,156 @@ +/* The initial payload of the thread is always g0. + * WM_URB (incoming URB entries) is g3 + * X0_R is g4 + * X1_R is g5 + * Y0_R is g6 + * Y1_R is g7 + */ + + /* Set up the X/Y screen coordinates of the pixels in our 4 subspans. Each + * subspan is a 2x2 rectangle, and the screen x/y of the upper left of each + * subspan are given in GRF register 1.2 through 1.5 (which, with the word + * addressing below, are 1.4 through 1.11). + * + * The result is WM_X*_R and WM_Y*R being: + * + * X0: {ss0.x, ss0.x+1, ss0.x, ss0.x+1, ss1.x, ss1.x+1, ss1.x, ss1.x+y} + * Y0: {ss0.y, ss0.y, ss0.y+1, ss0.y+1, ss1.y, ss1.y, ss1.y+1, ss1.y+1} + * X1: {ss2.x, ss2.x+1, ss2.x, ss2.x+1, ss3.x, ss3.x+1, ss3.x, ss3.x+y} + * Y1: {ss2.y, ss2.y, ss2.y+1, ss2.y+1, ss3.y, ss3.y, ss3.y+1, ss3.y+1} + */ + + /* Set up ss0.x coordinates*/ mov (1) g4<1>F g1.8<0,1,0>UW { align1 }; add (1) g4.4<1>F g1.8<0,1,0>UW 1UB { align1 }; mov (1) g4.8<1>F g1.8<0,1,0>UW { align1 }; add (1) g4.12<1>F g1.8<0,1,0>UW 1UB { align1 }; + /* Set up ss0.y coordinates */ mov (1) g6<1>F g1.10<0,1,0>UW { align1 }; mov (1) g6.4<1>F g1.10<0,1,0>UW { align1 }; add (1) g6.8<1>F g1.10<0,1,0>UW 1UB { align1 }; add (1) g6.12<1>F g1.10<0,1,0>UW 1UB { align1 }; + /* set up ss1.x coordinates */ mov (1) g4.16<1>F g1.12<0,1,0>UW { align1 }; add (1) g4.20<1>F g1.12<0,1,0>UW 1UB { align1 }; mov (1) g4.24<1>F g1.12<0,1,0>UW { align1 }; add (1) g4.28<1>F g1.12<0,1,0>UW 1UB { align1 }; + /* set up ss1.y coordinates */ mov (1) g6.16<1>F g1.14<0,1,0>UW { align1 }; mov (1) g6.20<1>F g1.14<0,1,0>UW { align1 }; add (1) g6.24<1>F g1.14<0,1,0>UW 1UB { align1 }; add (1) g6.28<1>F g1.14<0,1,0>UW 1UB { align1 }; + /* Set up ss2.x coordinates */ mov (1) g5<1>F g1.16<0,1,0>UW { align1 }; add (1) g5.4<1>F g1.16<0,1,0>UW 1UB { align1 }; mov (1) g5.8<1>F g1.16<0,1,0>UW { align1 }; add (1) g5.12<1>F g1.16<0,1,0>UW 1UB { align1 }; + /* Set up ss2.y coordinates */ mov (1) g7<1>F g1.18<0,1,0>UW { align1 }; mov (1) g7.4<1>F g1.18<0,1,0>UW { align1 }; add (1) g7.8<1>F g1.18<0,1,0>UW 1UB { align1 }; add (1) g7.12<1>F g1.18<0,1,0>UW 1UB { align1 }; + /* Set up ss3.x coordinates */ mov (1) g5.16<1>F g1.20<0,1,0>UW { align1 }; add (1) g5.20<1>F g1.20<0,1,0>UW 1UB { align1 }; mov (1) g5.24<1>F g1.20<0,1,0>UW { align1 }; add (1) g5.28<1>F g1.20<0,1,0>UW 1UB { align1 }; + /* Set up ss3.y coordinates */ mov (1) g7.16<1>F g1.22<0,1,0>UW { align1 }; mov (1) g7.20<1>F g1.22<0,1,0>UW { align1 }; add (1) g7.24<1>F g1.22<0,1,0>UW 1UB { align1 }; add (1) g7.28<1>F g1.22<0,1,0>UW 1UB { align1 }; + + /* Now, map these screen space coordinates into texture coordinates. */ + /* subtract screen-space X origin of vertex 0. */ add (8) g4<1>F g4<8,8,1>F g1<0,1,0>F { align1 }; add (8) g5<1>F g5<8,8,1>F g1<0,1,0>F { align1 }; + /* scale by texture X increment */ mul (8) g4<1>F g4<8,8,1>F g3<0,1,0>F { align1 }; mul (8) g5<1>F g5<8,8,1>F g3<0,1,0>F { align1 }; + /* add in texture X offset */ add (8) g4<1>F g4<8,8,1>F g3.12<0,1,0>F { align1 }; add (8) g5<1>F g5<8,8,1>F g3.12<0,1,0>F { align1 }; + /* subtract screen-space Y origin of vertex 0. */ add (8) g6<1>F g6<8,8,1>F g1.4<0,1,0>F { align1 }; add (8) g7<1>F g7<8,8,1>F g1.4<0,1,0>F { align1 }; + /* scale by texture Y increment */ mul (8) g6<1>F g6<8,8,1>F g3.20<0,1,0>F { align1 }; mul (8) g7<1>F g7<8,8,1>F g3.20<0,1,0>F { align1 }; + /* add in texture Y offset */ add (8) g6<1>F g6<8,8,1>F g3.28<0,1,0>F { align1 }; add (8) g7<1>F g7<8,8,1>F g3.28<0,1,0>F { align1 }; + /* sampler */ mov (8) m1<1>F g4<8,8,1>F { align1 }; mov (8) m2<1>F g5<8,8,1>F { align1 }; mov (8) m3<1>F g6<8,8,1>F { align1 }; mov (8) m4<1>F g7<8,8,1>F { align1 }; + + /* + * g0 holds the PS thread payload, which (oddly) contains + * precisely what the sampler wants to see in m0 + */ send 0 (16) g12<1>UW g0<8,8,1>UW sampler mlen 5 rlen 8 { align1 }; mov (8) g19<1>UW g19<8,8,1>UW { align1 }; + + /* color space conversion function: + * R = Clamp ( 1.164(Y-16/255) + 1.596(Cr-128/255), 0, 1) + * G = Clamp ( 1.164(Y-16/255) - 0.813(Cr-128/255) - 0.392(Cb-128/255), 0, 1) + * B = Clamp ( 1.164(Y-16/255) + 2.017(Cb-128/255), 0, 1) + * + * Y is g14, g15. + * Cr is g12, g13. + * Cb is g16, g17. + * + * R is g2, g6. + * G is g3, g7. + * B is g4, g8. + */ + /* Y = Y - 16/255 */ add (8) g14<1>F g14<8,8,1>F -0.0627451F { align1 }; + /* Cr = Cr - 128/255 */ add (8) g12<1>F g12<8,8,1>F -0.501961F { align1 }; + /* Cb = Cb - 128 / 255 */ add (8) g16<1>F g16<8,8,1>F -0.501961F { align1 }; + /* Y = Y * 1.164 */ mul (8) g14<1>F g14<8,8,1>F 1.164F { align1 }; -mul (8) a0<1>F g12<8,8,1>F 1.596F { align1 }; -mac (8) m2<1>F g14<8,8,1>F 1F { align1Saturate }; -mul (8) a0<1>F g12<8,8,1>F -0.813F { align1 }; -mac (8) a0<1>F g16<8,8,1>F -0.392F { align1 }; -mac (8) m3<1>F g14<8,8,1>F 1F { align1Saturate }; -mul (8) a0<1>F g16<8,8,1>F 2.017F { align1 }; -mac (8) m4<1>F g14<8,8,1>F 1F { align1Saturate }; + /* acc = 1.596 * Cr */ +mul (8) acc0<1>F g12<8,8,1>F 1.596F { align1 }; + /* R = acc + Y */ +mac.sat (8) m2<1>F g14<8,8,1>F 1F { align1 }; + /* acc = Cr * -0.813 */ +mul (8) acc0<1>F g12<8,8,1>F -0.813F { align1 }; + /* acc += Cb * -0.392 */ +mac (8) acc0<1>F g16<8,8,1>F -0.392F { align1 }; + /* G = acc + Y */ +mac.sat (8) m3<1>F g14<8,8,1>F 1F { align1 }; + /* acc = Cb * 2.017 */ +mul (8) acc0<1>F g16<8,8,1>F 2.017F { align1 }; + /* B = acc + Y */ +mac.sat (8) m4<1>F g14<8,8,1>F 1F { align1 }; + /* and do it again */ add (8) g15<1>F g15<8,8,1>F -0.0627451F { align1 }; add (8) g13<1>F g13<8,8,1>F -0.501961F { align1 }; add (8) g17<1>F g17<8,8,1>F -0.501961F { align1 }; mul (8) g15<1>F g15<8,8,1>F 1.164F { align1 }; -mul (8) a0<1>F g13<8,8,1>F 1.596F { align1 }; -mac (8) m6<1>F g15<8,8,1>F 1F { align1Saturate }; -mul (8) a0<1>F g13<8,8,1>F -0.813F { align1 }; -mac (8) a0<1>F g17<8,8,1>F -0.392F { align1 }; -mac (8) m7<1>F g15<8,8,1>F 1F { align1Saturate }; -mul (8) a0<1>F g17<8,8,1>F 2.017F { align1 }; -mac (8) m8<1>F g15<8,8,1>F 1F { align1Saturate }; +mul (8) acc0<1>F g13<8,8,1>F 1.596F { align1 }; +mac.sat (8) m6<1>F g15<8,8,1>F 1F { align1 }; +mul (8) acc0<1>F g13<8,8,1>F -0.813F { align1 }; +mac (8) acc0<1>F g17<8,8,1>F -0.392F { align1 }; +mac.sat (8) m7<1>F g15<8,8,1>F 1F { align1 }; +mul (8) acc0<1>F g17<8,8,1>F 2.017F { align1 }; +mac.sat (8) m8<1>F g15<8,8,1>F 1F { align1 }; + + /* Pass through control information: + */ mov (8) m1<1>UD g1<8,8,1>UD { align1 mask_disable }; -send 0 (16) a0<1>UW g0<8,8,1>UW write mlen 10 rlen 0 EOT{ align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; -nop (4) g0<1>UD { align1 }; + /* Send framebuffer write message: XXX: acc0? */ +send 0 (16) null g0<8,8,1>UW write mlen 10 rlen 0 { align1 EOT }; + /* padding */ +nop; +nop; +nop; +nop; +nop; +nop; +nop; +nop; |