[PATCH 42/90] assembler: Make struct declared_register use struct brw_reg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It's time to start converting the emission code in gram.y to use libbrw
infrastructure. Let's start with using brw_reg for declared register.

Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 assembler/gen4asm.h |    4 +++-
 assembler/gram.y    |   46 +++++++++++++++++++++++-----------------------
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/assembler/gen4asm.h b/assembler/gen4asm.h
index 8dd08b7..d81f597 100644
--- a/assembler/gen4asm.h
+++ b/assembler/gen4asm.h
@@ -33,6 +33,8 @@
 #include <stdbool.h>
 #include <assert.h>
 
+#include "brw_reg.h"
+
 typedef unsigned char GLubyte;
 typedef short GLshort;
 typedef unsigned int GLuint;
@@ -226,7 +228,7 @@ extern struct program_defaults program_defaults;
 
 struct declared_register {
     char *name;
-    struct direct_reg base;
+    struct brw_reg reg;
     int element_size;
     struct region src_region;
     int dst_region;
diff --git a/assembler/gram.y b/assembler/gram.y
index 342c66d..7b4cdee 100644
--- a/assembler/gram.y
+++ b/assembler/gram.y
@@ -353,9 +353,9 @@ declare_pragma:	DECLARE_PRAGMA STRING declare_base declare_elementsize declare_s
 			reg = calloc(sizeof(struct declared_register), 1);
 			reg->name = $2;
 		    }
-		    reg->base.reg_file = $3.reg_file;
-		    reg->base.reg_nr = $3.reg_nr;
-		    reg->base.subreg_nr = $3.subreg_nr;
+		    reg->reg.file = $3.reg_file;
+		    reg->reg.nr = $3.reg_nr;
+		    reg->reg.subnr = $3.subreg_nr;
 		    reg->element_size = $4;
 		    reg->src_region = $5;
 		    reg->dst_region = $6;
@@ -1548,9 +1548,9 @@ dst:		dstoperand | dstoperandex
 dstoperand:	symbol_reg dstregion
 		{
 		  memset (&$$, '\0', sizeof ($$));
-		  $$.reg_file = $1.base.reg_file;
-		  $$.reg_nr = $1.base.reg_nr;
-		  $$.subreg_nr = $1.base.subreg_nr;
+		  $$.reg_file = $1.reg.file;
+		  $$.reg_nr = $1.reg.nr;
+		  $$.subreg_nr = $1.reg.subnr;
 		  if ($2 == DEFAULT_DSTREGION) {
 		      $$.horiz_stride = $1.dst_region;
 		  } else {
@@ -1657,7 +1657,7 @@ symbol_reg_p: STRING LPAREN exp RPAREN
 		    }
 
 		    memcpy(&$$, dcl_reg, sizeof(*dcl_reg));
-		    $$.base.reg_nr += $3;
+		    $$.reg.nr += $3;
 		    free($1);
 		}
 		| STRING LPAREN exp COMMA exp RPAREN
@@ -1670,15 +1670,15 @@ symbol_reg_p: STRING LPAREN exp RPAREN
 		    }
 
 		    memcpy(&$$, dcl_reg, sizeof(*dcl_reg));
-		    $$.base.reg_nr += $3;
-		    $$.base.subreg_nr += $5;
+		    $$.reg.nr += $3;
 		    if(advanced_flag) {
-		        $$.base.reg_nr += $$.base.subreg_nr / (32 / get_type_size(dcl_reg->type));
-		        $$.base.subreg_nr = $$.base.subreg_nr % (32 / get_type_size(dcl_reg->type));
+			int size = get_type_size(dcl_reg->type);
+		        $$.reg.nr += ($$.reg.subnr + $5) / (32 / size);
+		        $$.reg.subnr = ($$.reg.subnr + $5) % (32 / size);
 		    } else {
-		        $$.base.reg_nr += $$.base.subreg_nr / 32;
-		        $$.base.subreg_nr = $$.base.subreg_nr % 32;
-			}
+		        $$.reg.nr += ($$.reg.subnr + $5) / 32;
+		        $$.reg.subnr = ($$.reg.subnr + $5) % 32;
+		    }
 		    free($1);
 		}
 ;
@@ -1857,9 +1857,9 @@ srcarchoperandex_typed: flagreg | addrreg | maskreg
 sendleadreg: symbol_reg
              {
 		  memset (&$$, '\0', sizeof ($$));
-		  $$.reg_file = $1.base.reg_file;
-		  $$.reg_nr = $1.base.reg_nr;
-		  $$.subreg_nr = $1.base.subreg_nr;
+		  $$.reg_file = $1.reg.file;
+		  $$.reg_nr = $1.reg.nr;
+		  $$.subreg_nr = $1.reg.subnr;
              }
              | directgenreg | directmsgreg
 ;
@@ -1871,9 +1871,9 @@ directsrcoperand:	negate abs symbol_reg region regtype
 		{
 		  memset (&$$, '\0', sizeof ($$));
 		  $$.address_mode = BRW_ADDRESS_DIRECT;
-		  $$.reg_file = $3.base.reg_file;
-		  $$.reg_nr = $3.base.reg_nr;
-		  $$.subreg_nr = $3.base.subreg_nr;
+		  $$.reg_file = $3.reg.file;
+		  $$.reg_nr = $3.reg.nr;
+		  $$.subreg_nr = $3.reg.subnr;
 		  if ($5.is_default) {
 		    $$.reg_type = $3.type;
 		  } else {
@@ -2303,9 +2303,9 @@ relativelocation2:
 		{
 		  memset (&$$, '\0', sizeof ($$));
 		  $$.address_mode = BRW_ADDRESS_DIRECT;
-		  $$.reg_file = $1.base.reg_file;
-		  $$.reg_nr = $1.base.reg_nr;
-		  $$.subreg_nr = $1.base.subreg_nr;
+		  $$.reg_file = $1.reg.file;
+		  $$.reg_nr = $1.reg.nr;
+		  $$.subreg_nr = $1.reg.subnr;
 		  $$.reg_type = $1.type;
 		  $$.vert_stride = $1.src_region.vert_stride;
 		  $$.width = $1.src_region.width;
-- 
1.7.7.5



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux