diff --git a/assembler/TODO b/assembler/TODO index 4e2a4dab..99fe77b2 100644 --- a/assembler/TODO +++ b/assembler/TODO @@ -8,3 +8,4 @@ - boolean types - replace GL* with non-GL? - labels for branch/jump instruction destinations +- break/cont syntax should be better. diff --git a/assembler/src/gram.y b/assembler/src/gram.y index 05a85a8a..d39fbac9 100644 --- a/assembler/src/gram.y +++ b/assembler/src/gram.y @@ -116,12 +116,12 @@ void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg, %type instruction unaryinstruction binaryinstruction %type binaryaccinstruction triinstruction sendinstruction %type jumpinstruction branchloopinstruction elseinstruction -%type syncinstruction specialinstruction +%type breakinstruction syncinstruction specialinstruction %type msgtarget %type instoptions instoption_list predicate %type instrseq %type instoption -%type unaryop binaryop binaryaccop branchloopop +%type unaryop binaryop binaryaccop branchloopop breakop %type conditionalmodifier saturate negate abs chansel %type writemask_x writemask_y writemask_z writemask_w %type regtype srcimmtype execsize dstregion immaddroffset @@ -141,7 +141,7 @@ void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg, %type directsrcoperand srcarchoperandex directsrcaccoperand %type indirectsrcoperand %type src srcimm imm32reg payload srcacc srcaccimm swizzle -%type relativelocation relativelocation2 +%type relativelocation relativelocation2 locationstackcontrol %% ROOT: instrseq @@ -185,6 +185,7 @@ instruction: unaryinstruction | jumpinstruction | branchloopinstruction | elseinstruction + | breakinstruction | syncinstruction | specialinstruction ; @@ -376,7 +377,32 @@ elseinstruction: ELSE relativelocation } ; -breakop: BREAK | CONT | WAIT +breakinstruction: breakop locationstackcontrol + { + struct direct_reg dst; + struct dst_operand ip_dst; + struct src_operand ip_src; + + /* The jump instruction requires that the IP register + * be the destination and first source operand, while the + * offset is the second source operand. The offset is added + * to the IP pre-increment. + */ + dst.reg_file = BRW_ARCHITECTURE_REGISTER_FILE; + dst.reg_nr = BRW_ARF_IP; + dst.subreg_nr = 0; + + bzero(&$$, sizeof($$)); + $$.header.opcode = $1; + set_direct_dst_operand(&ip_dst, &dst, BRW_REGISTER_TYPE_UD); + set_instruction_dest(&$$, &ip_dst); + set_direct_src_operand(&ip_src, &dst, BRW_REGISTER_TYPE_UD); + set_instruction_src0(&$$, &ip_src); + set_instruction_src1(&$$, &$2); + } +; + +breakop: BREAK | CONT | HALT ; maskpushop: MSAVE | PUSH @@ -1031,7 +1057,7 @@ relativelocation: imm32 { if ($1 > 32767 || $1 < -32768) { fprintf(stderr, - "error: relative offset %d out of range\n"); + "error: relative offset %d out of range\n", $1); YYERROR; } @@ -1057,6 +1083,15 @@ relativelocation2: } ; +locationstackcontrol: + imm32 + { + $$.reg_file = BRW_IMMEDIATE_VALUE; + $$.reg_type = BRW_REGISTER_TYPE_D; + $$.imm32 = $1; + } +; + /* 1.4.7: Regions */ dstregion: LANGLE INTEGER RANGLE {