intel-gen4asm: modernization
cover intel-gen4asm: modernization
I attempted to merge the assembler into the modern age. Ideally we should be able to push the changes back into mesa since it appears Haihao added some relevant structs.
I've only done very limited testing on this for my usecase. Wondering if this seems acceptable to push? What is the best way to actually test this?
Most of the changes are copy-paste, but only moderate amount of merging occurred in brw_structs.h, and brw_defines.h
Ben
--- src/Makefile.am | 2 +- src/brw_defines.h | 539 ++++++++++++++++++++++---- src/brw_disasm.c | 1089 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/brw_structs.h | 842 +++++++++++++++++++++++++++++------------ src/disasm-main.c | 32 ++- src/disasm.c | 901 -------------------------------------------- src/gen4asm.h | 2 +- src/gram.y | 24 +- 8 files changed, 2185 insertions(+), 1246 deletions(-)
PATCH 1/2 intel-gen4asm: bring structs and defines into the modern age
merged brw_defines and brw_structs from mesa. Ideally, these should be merged back in to mesa as well.
updated dependent code
---
src/Makefile.am | 2 +-
src/brw_defines.h | 539 ++++++++++++++++++++++----
src/{disasm.c => brw_disasm.c} | 274 +++++++++++--
src/brw_structs.h | 842 ++++++++++++++++++++++++++++------------
src/disasm-main.c | 2 +-
src/gen4asm.h | 2 +-
src/gram.y | 24 +-
7 files changed, 1303 insertions(+), 382 deletions(-)
rename src/{disasm.c => brw_disasm.c} (76%)src/Makefile.am +1 -1
@@ -12,7 +12,7 @@ intel_gen4asm_SOURCES = \ main.c intel_gen4disasm_SOURCES = \ - disasm.c disasm-main.c + brw_disasm.c disasm-main.c gram.h: gram.c
src/brw_defines.h +457 -82
692 lines not on this page · raw message
src/brw_disasm.c renamed from src/disasm.c +231 -43
467 lines not on this page · raw message
src/brw_structs.h +600 -242
1,178 lines not on this page · raw message
src/disasm-main.c +1 -1
@@ -153,6 +153,6 @@ int main(int argc, char **argv) }for (inst = program->first; inst; inst = inst->next) -disasm (output, &inst->instruction); +brw_disasm (output, &inst->instruction,5 );exit (0 ); }
src/gen4asm.h +1 -1
@@ -184,4 +184,4 @@ char *lex_text (void);int -disasm (FILE *output,struct brw_instruction *inst); +brw_disasm (FILE *output,struct brw_instruction *inst,int gen);
src/gram.y +12 -12
@@ -378,7 +378,7 @@ unaryinstruction: { bzero(&$$, sizeof($$)); $$.header.opcode = $2; - $$.header.sfid_destreg__conditionalmod = $3.cond; + $$.header.destreg__conditionalmod = $3.cond; $$.header.saturate = $4; $$.header.execution_size = $5; set_instruction_options(&$$, &$8);
@@ -406,7 +406,7 @@ binaryinstruction: { bzero(&$$, sizeof($$)); $$.header.opcode = $2; - $$.header.sfid_destreg__conditionalmod = $3.cond; + $$.header.destreg__conditionalmod = $3.cond; $$.header.saturate = $4; $$.header.execution_size = $5; set_instruction_options(&$$, &$9);
@@ -436,7 +436,7 @@ binaryaccinstruction: { bzero(&$$, sizeof($$)); $$.header.opcode = $2; - $$.header.sfid_destreg__conditionalmod = $3.cond; + $$.header.destreg__conditionalmod = $3.cond; $$.header.saturate = $4; $$.header.execution_size = $5; set_instruction_options(&$$, &$9);
@@ -478,7 +478,7 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget bzero(&$$, sizeof($$)); $$.header.opcode = $2; $$.header.execution_size = $3; - $$.header.sfid_destreg__conditionalmod = $4; /* msg reg index */ + $$.header.destreg__conditionalmod = $4; /* msg reg index */ set_instruction_predicate(&$$, &$1); if (set_instruction_dest(&$$, &$5) != 0) YYERROR;
@@ -503,9 +503,9 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget if (gen_level >= 5) { if (gen_level > 5) { - $$.header.sfid_destreg__conditionalmod = $7.bits2.send_gen5.sfid; + $$.header.destreg__conditionalmod = $7.bits2.send_gen5.sfid; } else { - $$.header.sfid_destreg__conditionalmod = $4; /* msg reg index */ + $$.header.destreg__conditionalmod = $4; /* msg reg index */ $$.bits2.send_gen5.sfid = $7.bits2.send_gen5.sfid; $$.bits2.send_gen5.end_of_thread = $12.bits3.generic_gen5.end_of_thread; }
@@ -516,7 +516,7 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget $$.bits3.generic_gen5.end_of_thread = $12.bits3.generic_gen5.end_of_thread; } else { - $$.header.sfid_destreg__conditionalmod = $4; /* msg reg index */ + $$.header.destreg__conditionalmod = $4; /* msg reg index */ $$.bits3.generic = $7.bits3.generic; $$.bits3.generic.msg_length = $9; $$.bits3.generic.response_length = $11;
@@ -543,7 +543,7 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget bzero(&$$, sizeof($$)); $$.header.opcode = $2; $$.header.execution_size = $3; - $$.header.sfid_destreg__conditionalmod = ($6 & EX_DESC_SFID_MASK); /* SFID */ + $$.header.destreg__conditionalmod = ($6 & EX_DESC_SFID_MASK); /* SFID */ set_instruction_predicate(&$$, &$1); if (set_instruction_dest(&$$, &$4) != 0)
@@ -573,7 +573,7 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget bzero(&$$, sizeof($$)); $$.header.opcode = $2; $$.header.execution_size = $3; - $$.header.sfid_destreg__conditionalmod = $5.reg_nr; /* msg reg index */ + $$.header.destreg__conditionalmod = $5.reg_nr; /* msg reg index */ set_instruction_predicate(&$$, &$1); if (set_instruction_dest(&$$, &$4) != 0)
@@ -595,7 +595,7 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget bzero(&$$, sizeof($$)); $$.header.opcode = $2; $$.header.execution_size = $3; - $$.header.sfid_destreg__conditionalmod = $5.reg_nr; /* msg reg index */ + $$.header.destreg__conditionalmod = $5.reg_nr; /* msg reg index */ set_instruction_predicate(&$$, &$1);
@@ -802,7 +802,7 @@ mathinstruction: predicate MATH_INST execsize dst src srcimm math_function insto { bzero(&$$, sizeof($$)); $$.header.opcode = $2; - $$.header.sfid_destreg__conditionalmod = $7; + $$.header.destreg__conditionalmod = $7; $$.header.execution_size = $3; set_instruction_options(&$$, &$8); set_instruction_predicate(&$$, &$1);
@@ -2227,7 +2227,7 @@ instoption_list:instoption COMMA instoption_list $$.header.debug_control = BRW_DEBUG_BREAKPOINT; break; case ACCWRCTRL: - $$.header.acc_wr_control = BRW_ACCWRCTRL_ACCWRCTRL; + $$.header.acc_wr_control = BRW_WE_ALL; } } | instoption instoption_list
Signature · 6 lines
1.7.3.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/2 intel-gen4asm: take gen<4|5|6> as an argument
In reply to Ben Widawsky--- src/disasm-main.c | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-)
src/disasm-main.c +25 -7
@@ -28,10 +28,24 @@#include "gen4asm.h" +static long int gen_level =5 ; +static const struct option longopts[] = { + {"binary" , no_argument,0 ,'b' }, + {"output" , required_argument,0 ,'o' }, + {"gen" , required_argument,0 ,'g' }, {NULL ,0 ,NULL ,0 } }; +static void usage (void ) +{ +fprintf (stderr,"usage: intel-gen4disasm [options] inputfile\n" ); +fprintf (stderr,"OPTIONS:\n" ); +fprintf (stderr,"\t-b, --binary C style binary output\n" ); +fprintf (stderr,"\t-o, --output {outputfile} Specify output file\n" ); +fprintf (stderr,"\t-g, --gen <4|5|6> Specify GPU generation\n" ); +} +static struct brw_program *read_program (FILE *input) {
@@ -93,11 +107,6 @@ read_program_binary (FILE *input)return program; } -static void usage (void ) -{ -fprintf (stderr,"usage: intel-gen4disasm [-o outputfile] [-b] inputfile\n" ); -} -int main (int argc,char **argv) {struct brw_program *program;
@@ -109,7 +118,7 @@ int main(int argc, char **argv)int o;struct brw_program_instruction *inst; -while ((o =getopt_long (argc, argv,"o:b" , longopts,NULL )) !=-1 ) { +while ((o =getopt_long (argc, argv,"o:bg:" , longopts,NULL )) !=-1 ) {switch (o) {case 'o' :if (strcmp (optarg,"-" ) !=0 )
@@ -118,6 +127,15 @@ int main(int argc, char **argv)case 'b' : byte_array_input =1 ;break ; +case 'g' : + gen_level =strtol (optarg,NULL ,0 ); + +if (gen_level <4 || gen_level >6 ) { +usage (); +exit (1 ); + } + +break ;default :usage ();exit (1 );
@@ -153,6 +171,6 @@ int main(int argc, char **argv) }for (inst = program->first; inst; inst = inst->next) -brw_disasm (output, &inst->instruction,5 ); +brw_disasm (output, &inst->instruction, gen_level);exit (0 ); }
Signature · 1 line
1.7.3.4
Quoted 11 lines · Ben Widawsky
I attempted to merge the assembler into the modern age. Ideally we should be able to push the changes back into mesa since it appears Haihao added some relevant structs.
I've only done very limited testing on this for my usecase. Wondering if this seems acceptable to push? What is the best way to actually test this?
Most of the changes are copy-paste, but only moderate amount of merging occurred in
brw_structs.h, andbrw_defines.h
You should probably test that generation of existing code (2d driver, probably vaapi?) hasn't changed. Also that you've run the newly-changed generated code somehow.
There's a testsuite for round-trip asm-to-disasm, but it looks like that's already pre-broken by some past change.
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx