r300/compiler: Refactor the pair instruction data structures

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.
This commit is contained in:
Tom Stellard 2010-09-16 10:31:19 -07:00
parent 84997cd566
commit 610aed81db
4 changed files with 21 additions and 38 deletions

View file

@ -74,7 +74,7 @@ static void use_temporary(struct r300_fragment_program_code *code, unsigned int
code->pixsize = index; 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) { if (src.File == RC_FILE_CONSTANT) {
return src.Index | (1 << 5); return src.Index | (1 << 5);

View file

@ -198,7 +198,7 @@ static void use_temporary(struct r500_fragment_program_code* code, unsigned int
code->max_temp_idx = index; 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) { if (src.File == RC_FILE_CONSTANT) {
return src.Index | 0x100; return src.Index | 0x100;

View file

@ -301,9 +301,9 @@ static int destructive_merge_instructions(
unsigned int arg; unsigned int arg;
int free_source; int free_source;
unsigned int one_way = 0; unsigned int one_way = 0;
struct radeon_pair_instruction_source srcp = struct rc_pair_instruction_source srcp =
alpha->RGB.Src[srcp_src]; 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. /* 2nd arg of 1 means this is an rgb source.
* 3rd arg of 0 means this is not an alpha source. */ * 3rd arg of 0 means this is not an alpha source. */
free_source = rc_pair_alloc_source(rgb, 1, 0, free_source = rc_pair_alloc_source(rgb, 1, 0,
@ -366,9 +366,9 @@ static int destructive_merge_instructions(
unsigned int arg; unsigned int arg;
int free_source; int free_source;
unsigned int one_way = 0; unsigned int one_way = 0;
struct radeon_pair_instruction_source srcp = struct rc_pair_instruction_source srcp =
alpha->Alpha.Src[srcp_src]; 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. /* 2nd arg of 0 means this is not an rgb source.
* 3rd arg of 1 means this is an alpha source. */ * 3rd arg of 1 means this is an alpha source. */
free_source = rc_pair_alloc_source(rgb, 0, 1, free_source = rc_pair_alloc_source(rgb, 0, 1,

View file

@ -55,52 +55,35 @@ struct radeon_compiler;
*/ */
#define RC_PAIR_PRESUB_SRC 3 #define RC_PAIR_PRESUB_SRC 3
struct radeon_pair_instruction_source { struct rc_pair_instruction_source {
unsigned int Used:1; unsigned int Used:1;
unsigned int File:3; unsigned int File:3;
unsigned int Index:RC_REGISTER_INDEX_BITS; unsigned int Index:RC_REGISTER_INDEX_BITS;
}; };
struct radeon_pair_instruction_rgb { struct rc_pair_instruction_arg {
unsigned int Source:2;
unsigned int Swizzle:9;
unsigned int Abs:1;
unsigned int Negate:1;
};
struct rc_pair_sub_instruction {
unsigned int Opcode:8; unsigned int Opcode:8;
unsigned int DestIndex:RC_REGISTER_INDEX_BITS; unsigned int DestIndex:RC_REGISTER_INDEX_BITS;
unsigned int WriteMask:3; unsigned int WriteMask:3;
unsigned int Target:2; unsigned int Target:2;
unsigned int OutputWriteMask:3; 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 radeon_pair_instruction_alpha {
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 DepthWriteMask:1; unsigned int DepthWriteMask:1;
unsigned int Saturate:1; unsigned int Saturate:1;
struct radeon_pair_instruction_source Src[4]; struct rc_pair_instruction_source Src[4];
struct rc_pair_instruction_arg Arg[3];
struct {
unsigned int Source:2;
unsigned int Swizzle:3;
unsigned int Abs:1;
unsigned int Negate:1;
} Arg[3];
}; };
struct rc_pair_instruction { struct rc_pair_instruction {
struct radeon_pair_instruction_rgb RGB; struct rc_pair_sub_instruction RGB;
struct radeon_pair_instruction_alpha Alpha; struct rc_pair_sub_instruction Alpha;
unsigned int WriteALUResult:2; unsigned int WriteALUResult:2;
unsigned int ALUResultCompare:3; unsigned int ALUResultCompare:3;
@ -108,7 +91,7 @@ struct rc_pair_instruction {
}; };
typedef void (*rc_pair_foreach_src_fn) typedef void (*rc_pair_foreach_src_fn)
(void *, struct radeon_pair_instruction_source *); (void *, struct rc_pair_instruction_source *);
typedef enum { typedef enum {
RC_PAIR_SOURCE_NONE = 0, RC_PAIR_SOURCE_NONE = 0,