Skip to contentSkip to conversation

support for Sandybridge in GFX assembler

PATCH New Xiang, Haihao 1 participant 11 messages Oct 9, 2010

lore
Share & tools
lore
#0 lore raw

Here is a set of patches for GFX assembler to support Sandybridge. We will try to re-use all existing render shaders with these fixes. Note these patches don't support for some Sandybridge ISA changes such as math instructions, IF/ELSE/ENDIF etc.

#1 lore raw

PATCH 1/10 add -g 6 for Sandybridge

---
 src/main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
src/main.c +2 -2
index 2757e96..7c0b579 100644
@@ -49,7 +49,7 @@ static const struct option longopts[] = {
 
 static void usage(void)
 {
-	fprintf(stderr, "usage: intel-gen4asm [-o outputfile] [-g <4|5>] inputfile\n");
+	fprintf(stderr, "usage: intel-gen4asm [-o outputfile] [-g <4|5|6>] inputfile\n");
 }
 
 int main(int argc, char **argv)
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
 		case 'g':
 			gen_level = strtol(optarg, NULL, 0);
 
-			if (gen_level < 4 || gen_level > 5) {
+			if (gen_level < 4 || gen_level > 6) {
 				usage();
 				exit(1);
 			}
Signature · 1 line
1.7.0.4
#2 lore raw

PATCH 2/10 fix jump count for Sandybridge.

In reply to Xiang, Haihao

It is same as Ironlake.

---
 src/main.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
src/main.c +1 -1
index 7c0b579..12901a7 100644
@@ -130,7 +130,7 @@ int main(int argc, char **argv)
 			    int offset = 
 				entry1->inst_offset - entry->inst_offset;
 
-                            if (gen_level == 5)
+                            if (gen_level >= 5)
                                     entry->instruction.bits3.ud = 2 * (offset - 1);
                             else
                                     entry->instruction.bits3.ud = offset - 1;
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 3/10 always set destination horiz stride for Align16 to 1 on Sandybridge.

In reply to Xiang, Haihao
---
 src/brw_structs.h |    4 ++--
 src/gram.y        |    2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)
src/brw_structs.h +2 -2
index ba20547..32a52df 100644
@@ -1102,7 +1102,7 @@ struct brw_instruction
 	 GLuint dest_writemask:4;
 	 GLuint dest_subreg_nr:1;
 	 GLuint dest_reg_nr:8;
-	 GLuint pad1:2;
+	 GLuint dest_horiz_stride:2;
 	 GLuint dest_address_mode:1;
       } da16;
 
@@ -1116,7 +1116,7 @@ struct brw_instruction
 	 GLuint dest_writemask:4;
 	 GLint dest_indirect_offset:6;
 	 GLuint dest_subreg_nr:3;
-	 GLuint pad1:2;
+	 GLuint dest_horiz_stride:2;
 	 GLuint dest_address_mode:1;
       } ia16;
    } bits1;
src/gram.y +2 -0
index 438559a..f57e97c 100644
@@ -1668,6 +1668,7 @@ int set_instruction_dest(struct brw_instruction *instr,
 		instr->bits1.da16.dest_subreg_nr = dest->subreg_nr;
 		instr->bits1.da16.dest_reg_nr = dest->reg_nr;
 		instr->bits1.da16.dest_address_mode = dest->address_mode;
+		instr->bits1.da16.dest_horiz_stride = 1;
 		instr->bits1.da16.dest_writemask = dest->writemask;
 	} else if (instr->header.access_mode == BRW_ALIGN_1) {
 		instr->bits1.ia1.dest_reg_file = dest->reg_file;
@@ -1687,6 +1688,7 @@ int set_instruction_dest(struct brw_instruction *instr,
 		instr->bits1.ia16.dest_subreg_nr = dest->address_subreg_nr;
 		instr->bits1.ia16.dest_writemask = dest->writemask;
 		instr->bits1.ia16.dest_indirect_offset = dest->indirect_offset;
+		instr->bits1.ia16.dest_horiz_stride = 1;
 		instr->bits1.ia16.dest_address_mode = dest->address_mode;
 	}
 
Signature · 1 line
1.7.0.4
#4 lore raw

PATCH 4/10 add AccWrCtrl flag on Sandybridge

In reply to Xiang, Haihao
---
 src/brw_defines.h |    3 +++
 src/brw_structs.h |    3 ++-
 src/gram.y        |    6 +++++-
 src/lex.l         |    1 +
 4 files changed, 11 insertions(+), 2 deletions(-)
src/brw_defines.h +3 -0
index 7812d72..4921d34 100644
@@ -552,6 +552,9 @@
 #define BRW_MASK_ENABLE   0
 #define BRW_MASK_DISABLE  1
 
+#define BRW_ACCWRCTRL_NONE      0
+#define BRW_ACCWRCTRL_ACCWRCTRL 1
+
 #define BRW_OPCODE_MOV        1
 #define BRW_OPCODE_SEL        2
 #define BRW_OPCODE_NOT        4
src/brw_structs.h +2 -1
index 32a52df..515d2aa 100644
@@ -1054,7 +1054,8 @@ struct brw_instruction
       GLuint predicate_inverse:1;	/* 0x00100000 */
       GLuint execution_size:3;		/* 0x00e00000 */
       GLuint destreg__conditionalmod:4; /* destreg - send, conditionalmod - others */
-      GLuint pad0:2;			/* 0x30000000 */
+      GLuint acc_wr_control:1;          /* 0x10000000 */
+      GLuint pad0:1;                    /* 0x20000000 */
       GLuint debug_control:1;		/* 0x40000000 */
       GLuint saturate:1;		/* 0x80000000 */
    } header;
src/gram.y +5 -1
index f57e97c..fcbbd81 100644
@@ -88,7 +88,7 @@ void set_direct_src_operand(struct src_operand *src, struct direct_reg *reg,
 %token <integer> TYPE_VF TYPE_HF TYPE_V TYPE_F
 
 %token ALIGN1 ALIGN16 SECHALF COMPR SWITCH ATOMIC NODDCHK NODDCLR
-%token MASK_DISABLE BREAKPOINT EOT
+%token MASK_DISABLE BREAKPOINT ACCWRCTRL EOT
 
 %token SEQ ANY2H ALL2H ANY4H ALL4H ANY8H ALL8H ANY16H ALL16H ANYV ALLV
 %token <integer> ZERO EQUAL NOT_ZERO NOT_EQUAL GREATER GREATER_EQUAL LESS LESS_EQUAL
@@ -1605,6 +1605,9 @@ instoption_list:
 		  case BREAKPOINT:
 		    $$.header.debug_control = BRW_DEBUG_BREAKPOINT;
 		    break;
+		  case ACCWRCTRL:
+		    $$.header.acc_wr_control = BRW_ACCWRCTRL_ACCWRCTRL;
+		    break;
 		  case EOT:
 		    /* XXX: EOT shouldn't be an instoption, I don't think */
 		    $$.bits3.generic.end_of_thread = 1;
@@ -1627,6 +1630,7 @@ instoption:	ALIGN1 { $$ = ALIGN1; }
 		| NODDCLR { $$ = NODDCLR; }
 		| MASK_DISABLE { $$ = MASK_DISABLE; }
 		| BREAKPOINT { $$ = BREAKPOINT; }
+		| ACCWRCTRL { $$ = ACCWRCTRL; }
 		| EOT { $$ = EOT; }
 ;
 
src/lex.l +1 -0
index 8d7a4f0..ead12af 100644
@@ -269,6 +269,7 @@ extern char *input_filename;
 "mask_disable" { return MASK_DISABLE; }
 "nomask" { return MASK_DISABLE; }
 "breakpoint" { return BREAKPOINT; }
+"accwrctrl" { return ACCWRCTRL; }
 "EOT" { return EOT; }
 
  /* extended math functions */
Signature · 1 line
1.7.0.4
#5 lore raw

PATCH 5/10 fix send instruction on Sandybridge

In reply to Xiang, Haihao

Send doesn't have implied move on Sandybridge, the SFID moves to bits[24,27] which is used as the destination of the implied move on Prev GEN6.

---
 src/brw_structs.h |    2 +-
 src/disasm.c      |    4 ++--
 src/gram.y        |   20 +++++++++++++-------
 3 files changed, 16 insertions(+), 10 deletions(-)
src/brw_structs.h +1 -1
index 515d2aa..92a398e 100644
@@ -1053,7 +1053,7 @@ struct brw_instruction
       GLuint predicate_control:4;	/* 0x000f0000 */
       GLuint predicate_inverse:1;	/* 0x00100000 */
       GLuint execution_size:3;		/* 0x00e00000 */
-      GLuint destreg__conditionalmod:4; /* destreg - send, conditionalmod - others */
+      GLuint sfid_destreg__conditionalmod:4; /* sfid - send on GEN6+, destreg - send on Prev GEN6, conditionalmod - others */
       GLuint acc_wr_control:1;          /* 0x10000000 */
       GLuint pad0:1;                    /* 0x20000000 */
       GLuint debug_control:1;		/* 0x40000000 */
src/disasm.c +2 -2
index 37e8b51..8180149 100644
@@ -795,7 +795,7 @@ int disasm (FILE *file, struct brw_instruction *inst)
 
     if (inst->header.opcode != BRW_OPCODE_SEND)
 	err |= control (file, "conditional modifier", conditional_modifier,
-			inst->header.destreg__conditionalmod, NULL);
+			inst->header.sfid_destreg__conditionalmod, NULL);
 
     if (inst->header.opcode != BRW_OPCODE_NOP) {
 	string (file, "(");
@@ -804,7 +804,7 @@ int disasm (FILE *file, struct brw_instruction *inst)
     }
 
     if (inst->header.opcode == BRW_OPCODE_SEND)
-	format (file, " %d", inst->header.destreg__conditionalmod);
+	format (file, " %d", inst->header.sfid_destreg__conditionalmod);
 
     if (opcode[inst->header.opcode].ndst > 0) {
 	pad (file, 16);
src/gram.y +13 -7
index fcbbd81..2dab7a2 100644
@@ -243,7 +243,7 @@ unaryinstruction:
 		{
 		  bzero(&$$, sizeof($$));
 		  $$.header.opcode = $2;
-		  $$.header.destreg__conditionalmod = $3;
+		  $$.header.sfid_destreg__conditionalmod = $3;
 		  $$.header.saturate = $4;
 		  $$.header.execution_size = $5;
 		  set_instruction_options(&$$, &$8);
@@ -264,7 +264,7 @@ binaryinstruction:
 		{
 		  bzero(&$$, sizeof($$));
 		  $$.header.opcode = $2;
-		  $$.header.destreg__conditionalmod = $3;
+		  $$.header.sfid_destreg__conditionalmod = $3;
 		  $$.header.saturate = $4;
 		  $$.header.execution_size = $5;
 		  set_instruction_options(&$$, &$9);
@@ -287,7 +287,7 @@ binaryaccinstruction:
 		{
 		  bzero(&$$, sizeof($$));
 		  $$.header.opcode = $2;
-		  $$.header.destreg__conditionalmod = $3;
+		  $$.header.sfid_destreg__conditionalmod = $3;
 		  $$.header.saturate = $4;
 		  $$.header.execution_size = $5;
 		  set_instruction_options(&$$, &$9);
@@ -322,7 +322,6 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget
 		  bzero(&$$, sizeof($$));
 		  $$.header.opcode = $2;
 		  $$.header.execution_size = $3;
-		  $$.header.destreg__conditionalmod = $4; /* msg reg index */
 		  set_instruction_predicate(&$$, &$1);
 		  if (set_instruction_dest(&$$, &$5) != 0)
 		    YYERROR;
@@ -331,15 +330,22 @@ sendinstruction: predicate SEND execsize exp post_dst payload msgtarget
 		  $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE;
 		  $$.bits1.da1.src1_reg_type = BRW_REGISTER_TYPE_D;
 
-		  if (gen_level == 5) {
-                      $$.bits2.send_gen5.sfid = $7.bits2.send_gen5.sfid;
-                      $$.bits2.send_gen5.end_of_thread = $12.bits3.generic_gen5.end_of_thread;
+		  if (gen_level >= 5) {
+                      if (gen_level > 5) {
+                          $$.header.sfid_destreg__conditionalmod = $7.bits2.send_gen5.sfid;
+                      } else {
+                          $$.header.sfid_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;
+                      }
+
                       $$.bits3.generic_gen5 = $7.bits3.generic_gen5;
                       $$.bits3.generic_gen5.msg_length = $9;
                       $$.bits3.generic_gen5.response_length = $11;
                       $$.bits3.generic_gen5.end_of_thread =
                           $12.bits3.generic_gen5.end_of_thread;
 		  } else {
+                      $$.header.sfid_destreg__conditionalmod = $4; /* msg reg index */
                       $$.bits3.generic = $7.bits3.generic;
                       $$.bits3.generic.msg_length = $9;
                       $$.bits3.generic.response_length = $11;
Signature · 1 line
1.7.0.4
#6 lore raw

PATCH 6/10 add support for data port write on Sandybridge.

In reply to Xiang, Haihao
---
 src/brw_structs.h |   13 +++++++++++++
 src/gram.y        |   14 +++++++++++++-
 2 files changed, 26 insertions(+), 1 deletions(-)
src/brw_structs.h +13 -0
index 92a398e..6a29f37 100644
@@ -1413,6 +1413,19 @@ struct brw_instruction
        } dp_write_gen5;
 
        struct {
+           GLuint binding_table_index:8;
+           GLuint msg_control:5;
+           GLuint msg_type:4;    
+           GLuint send_commit_msg:1;
+           GLuint pad0:1;
+           GLuint header_present:1;
+           GLuint response_length:5;
+           GLuint msg_length:4;
+           GLuint pad1:2;
+           GLuint end_of_thread:1;
+       } dp_write_gen6;
+
+       struct {
            GLuint opcode:1;
            GLuint requester_type:1;
            GLuint pad0:2;
src/gram.y +13 -1
index 2dab7a2..d536625 100644
@@ -650,7 +650,19 @@ msgtarget:	NULL_TOKEN
 		| WRITE LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA
 		INTEGER RPAREN
 		{
-		  if (gen_level == 5) {
+		  if (gen_level == 6) {
+                      $$.bits2.send_gen5.sfid =
+                          BRW_MESSAGE_TARGET_DATAPORT_WRITE;
+                      /* Sandybridge supports headerlesss message for render target write.
+                       * Currently the GFX assembler doesn't support it. so the program must provide 
+                       * message header
+                       */
+                      $$.bits3.generic_gen5.header_present = 1;
+                      $$.bits3.dp_write_gen6.binding_table_index = $3;
+                      $$.bits3.dp_write_gen6.msg_control = $5;
+                      $$.bits3.dp_write_gen6.msg_type = $7;
+                      $$.bits3.dp_write_gen6.send_commit_msg = $9;
+		  } else if (gen_level == 5) {
                       $$.bits2.send_gen5.sfid =
                           BRW_MESSAGE_TARGET_DATAPORT_WRITE;
                       $$.bits3.generic_gen5.header_present = 1;
Signature · 1 line
1.7.0.4
#7 lore raw

PATCH 7/10 add support for data port read on Sandybridge

In reply to Xiang, Haihao
---
 src/brw_structs.h |   12 ++++++++++++
 src/gram.y        |    9 ++++++++-
 2 files changed, 20 insertions(+), 1 deletions(-)
src/brw_structs.h +12 -0
index 6a29f37..9b1cd92 100644
@@ -1400,6 +1400,18 @@ struct brw_instruction
 
        struct {
            GLuint binding_table_index:8;
+           GLuint msg_control:5;  
+           GLuint msg_type:3;  
+           GLuint pad0:3;
+           GLuint header_present:1;
+           GLuint response_length:5;
+           GLuint msg_length:4;
+           GLuint pad1:2;
+           GLuint end_of_thread:1;
+       } dp_read_gen6;
+
+       struct {
+           GLuint binding_table_index:8;
            GLuint msg_control:3;
            GLuint pixel_scoreboard_clear:1;
            GLuint msg_type:3;    
src/gram.y +8 -1
index d536625..ffb0851 100644
@@ -630,7 +630,14 @@ msgtarget:	NULL_TOKEN
 		| READ  LPAREN INTEGER COMMA INTEGER COMMA INTEGER COMMA
                 INTEGER RPAREN
 		{
-		  if (gen_level == 5) {
+		  if (gen_level == 6) {
+                      $$.bits2.send_gen5.sfid = 
+                          BRW_MESSAGE_TARGET_DATAPORT_READ;
+                      $$.bits3.generic_gen5.header_present = 1;
+                      $$.bits3.dp_read_gen6.binding_table_index = $3;
+                      $$.bits3.dp_read_gen6.msg_control = $7;
+                      $$.bits3.dp_read_gen6.msg_type = $9;
+		  } else if (gen_level == 5) {
                       $$.bits2.send_gen5.sfid = 
                           BRW_MESSAGE_TARGET_DATAPORT_READ;
                       $$.bits3.generic_gen5.header_present = 1;
Signature · 1 line
1.7.0.4
#8 lore raw

PATCH 8/10 sampler, urb write, null and gateway on Sandybridge are same as Ironlake.

In reply to Xiang, Haihao
---
 src/gram.y |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
src/gram.y +5 -5
index ffb0851..9258ac7 100644
@@ -557,7 +557,7 @@ post_dst:	dst
 
 msgtarget:	NULL_TOKEN
 		{
-		  if (gen_level == 5) {
+		  if (gen_level >= 5) {
                       $$.bits2.send_gen5.sfid= BRW_MESSAGE_TARGET_NULL;
                       $$.bits3.generic_gen5.header_present = 0;  /* ??? */
 		  } else {
@@ -567,7 +567,7 @@ msgtarget:	NULL_TOKEN
 		| SAMPLER LPAREN INTEGER COMMA INTEGER COMMA
 		sampler_datatype RPAREN
 		{
-		  if (gen_level == 5) {
+		  if (gen_level >= 5) {
                       $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_SAMPLER;
                       $$.bits3.generic_gen5.header_present = 1;   /* ??? */
                       $$.bits3.sampler_gen5.binding_table_index = $3;
@@ -620,7 +620,7 @@ msgtarget:	NULL_TOKEN
 		}
 		| GATEWAY
 		{
-		  if (gen_level == 5) {
+		  if (gen_level >= 5) {
                       $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_GATEWAY;
                       $$.bits3.generic_gen5.header_present = 0;  /* ??? */
 		  } else {
@@ -695,7 +695,7 @@ msgtarget:	NULL_TOKEN
 		| URB INTEGER urb_swizzle urb_allocate urb_used urb_complete
 		{
 		  $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_URB;
-		  if (gen_level == 5) {
+		  if (gen_level >= 5) {
                       $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_URB;
                       $$.bits3.generic_gen5.header_present = 1;
                       $$.bits3.urb_gen5.opcode = BRW_URB_OPCODE_WRITE;
@@ -721,7 +721,7 @@ msgtarget:	NULL_TOKEN
 		{
 		  $$.bits3.generic.msg_target =
 		    BRW_MESSAGE_TARGET_THREAD_SPAWNER;
-		  if (gen_level == 5) {
+		  if (gen_level >= 5) {
                       $$.bits2.send_gen5.sfid = 
                           BRW_MESSAGE_TARGET_THREAD_SPAWNER;
                       $$.bits3.generic_gen5.header_present = 0;
Signature · 1 line
1.7.0.4
#9 lore raw

PATCH 9/10 print error message when using math function on Sandybridge.

In reply to Xiang, Haihao

Sandybridge doesn't have math funtion, instead it supports a set of math instructions. The support for math instructions will be added later.

---
 src/gram.y |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
src/gram.y +4 -1
index 9258ac7..e61e9db 100644
@@ -595,7 +595,10 @@ msgtarget:	NULL_TOKEN
 		}
 		| MATH math_function saturate math_signed math_scalar
 		{
-		  if (gen_level == 5) {
+		  if (gen_level == 6) {
+                      fprintf (stderr, "Gen6+ donesn't have math function\n");
+                      YYERROR;
+		  } else if (gen_level == 5) {
                       $$.bits2.send_gen5.sfid = BRW_MESSAGE_TARGET_MATH;
                       $$.bits3.generic_gen5.header_present = 0;
                       $$.bits3.math_gen5.function = $2;
Signature · 1 line
1.7.0.4
#10 lore raw

PATCH 10/10 no compression flag on Sandybridge

In reply to Xiang, Haihao
---
 src/gram.y |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
src/gram.y +4 -2
index e61e9db..a57e4e9 100644
@@ -1612,8 +1612,10 @@ instoption_list:
 		    $$.header.compression_control |= BRW_COMPRESSION_2NDHALF;
 		    break;
 		  case COMPR:
-		    $$.header.compression_control |=
-		      BRW_COMPRESSION_COMPRESSED;
+		    if (gen_level < 6) {
+                        $$.header.compression_control |=
+                            BRW_COMPRESSION_COMPRESSED;
+		    }
 		    break;
 		  case SWITCH:
 		    $$.header.thread_control |= BRW_THREAD_SWITCH;
Signature · 1 line
1.7.0.4