r300/compiler: Refactor the pair instruction data structures
authorTom Stellard <tstellar@gmail.com>
Thu, 16 Sep 2010 17:31:19 +0000 (10:31 -0700)
committerTom Stellard <tstellar@gmail.com>
Tue, 21 Sep 2010 01:48:47 +0000 (18:48 -0700)
Use rc_pair_ prefix for all pair instruction structs

Create a named struct for pair instruction args

Replace structs radeon_pair_instruction_{rgb,alpha} with struct
radeon_pair_sub_instruction.  These two structs were nearly identical
and were creating a lot of cut and paste code.  These changes are the
first step towards removing some of that code.

src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
src/mesa/drivers/dri/r300/compiler/radeon_program_pair.h

index 3b2b06fc2bd0e1ce2922a78744d4265140c15132..4f13e51bccd82c1aa5d6550bf8ab1b40d5920613 100644 (file)
@@ -74,7 +74,7 @@ static void use_temporary(struct r300_fragment_program_code *code, unsigned int
                code->pixsize = index;
 }
 
-static unsigned int use_source(struct r300_fragment_program_code* code, struct radeon_pair_instruction_source src)
+static unsigned int use_source(struct r300_fragment_program_code* code, struct rc_pair_instruction_source src)
 {
        if (src.File == RC_FILE_CONSTANT) {
                return src.Index | (1 << 5);
index 54cff9169a4d87de732056d46cb71ec36bd102c2..bad168469649d84446eb4b4144a1d80462b11e3f 100644 (file)
@@ -198,7 +198,7 @@ static void use_temporary(struct r500_fragment_program_code* code, unsigned int
                code->max_temp_idx = index;
 }
 
-static unsigned int use_source(struct r500_fragment_program_code* code, struct radeon_pair_instruction_source src)
+static unsigned int use_source(struct r500_fragment_program_code* code, struct rc_pair_instruction_source src)
 {
        if (src.File == RC_FILE_CONSTANT) {
                return src.Index | 0x100;
index 5269d65985138a267162587312ceedc1a14257d2..a33b2fde7b587cc44828d9ae189db2a2e61dcc79 100644 (file)
@@ -301,9 +301,9 @@ static int destructive_merge_instructions(
                        unsigned int arg;
                        int free_source;
                        unsigned int one_way = 0;
-                       struct radeon_pair_instruction_source srcp =
+                       struct rc_pair_instruction_source srcp =
                                                alpha->RGB.Src[srcp_src];
-                       struct radeon_pair_instruction_source temp;
+                       struct rc_pair_instruction_source temp;
                        /* 2nd arg of 1 means this is an rgb source.
                         * 3rd arg of 0 means this is not an alpha source. */
                        free_source = rc_pair_alloc_source(rgb, 1, 0,
@@ -366,9 +366,9 @@ static int destructive_merge_instructions(
                        unsigned int arg;
                        int free_source;
                        unsigned int one_way = 0;
-                       struct radeon_pair_instruction_source srcp =
+                       struct rc_pair_instruction_source srcp =
                                                alpha->Alpha.Src[srcp_src];
-                       struct radeon_pair_instruction_source temp;
+                       struct rc_pair_instruction_source temp;
                        /* 2nd arg of 0 means this is not an rgb source.
                         * 3rd arg of 1 means this is an alpha source. */
                        free_source = rc_pair_alloc_source(rgb, 0, 1,
index e0061e454bfde420878f11379cb2e4a341d3dd55..01cdb154240f14cd96669ef11678fc673dbd6cf5 100644 (file)
@@ -55,52 +55,35 @@ struct radeon_compiler;
  */
 #define RC_PAIR_PRESUB_SRC 3
 
-struct radeon_pair_instruction_source {
+struct rc_pair_instruction_source {
        unsigned int Used:1;
        unsigned int File:3;
        unsigned int Index:RC_REGISTER_INDEX_BITS;
 };
 
-struct radeon_pair_instruction_rgb {
-       unsigned int Opcode:8;
-       unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
-       unsigned int WriteMask:3;
-    unsigned int Target:2;
-       unsigned int OutputWriteMask:3;
-       unsigned int Saturate:1;
-
-       struct radeon_pair_instruction_source Src[4];
-
-       struct {
-               unsigned int Source:2;
-               unsigned int Swizzle:9;
-               unsigned int Abs:1;
-               unsigned int Negate:1;
-       } Arg[3];
+struct rc_pair_instruction_arg {
+       unsigned int Source:2;
+       unsigned int Swizzle:9;
+       unsigned int Abs:1;
+       unsigned int Negate:1;
 };
 
-struct radeon_pair_instruction_alpha {
+struct rc_pair_sub_instruction {
        unsigned int Opcode:8;
        unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
-       unsigned int WriteMask:1;
-    unsigned int Target:2;
-       unsigned int OutputWriteMask:1;
+       unsigned int WriteMask:3;
+       unsigned int Target:2;
+       unsigned int OutputWriteMask:3;
        unsigned int DepthWriteMask:1;
        unsigned int Saturate:1;
 
-       struct radeon_pair_instruction_source Src[4];
-
-       struct {
-               unsigned int Source:2;
-               unsigned int Swizzle:3;
-               unsigned int Abs:1;
-               unsigned int Negate:1;
-       } Arg[3];
+       struct rc_pair_instruction_source Src[4];
+       struct rc_pair_instruction_arg Arg[3];
 };
 
 struct rc_pair_instruction {
-       struct radeon_pair_instruction_rgb RGB;
-       struct radeon_pair_instruction_alpha Alpha;
+       struct rc_pair_sub_instruction RGB;
+       struct rc_pair_sub_instruction Alpha;
 
        unsigned int WriteALUResult:2;
        unsigned int ALUResultCompare:3;
@@ -108,7 +91,7 @@ struct rc_pair_instruction {
 };
 
 typedef void (*rc_pair_foreach_src_fn)
-                       (void *, struct radeon_pair_instruction_source *);
+                       (void *, struct rc_pair_instruction_source *);
 
 typedef enum {
        RC_PAIR_SOURCE_NONE = 0,