1 /* 2 * Copyright 2008 Nicolai Haehnle. 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #ifndef __RADEON_PROGRAM_PAIR_H_ 7 #define __RADEON_PROGRAM_PAIR_H_ 8 9 #include "radeon_code.h" 10 #include "radeon_opcodes.h" 11 #include "radeon_program_constants.h" 12 13 struct radeon_compiler; 14 15 16 /** 17 * \file 18 * Represents a paired ALU instruction, as found in R300 and R500 19 * fragment programs. 20 * 21 * Note that this representation is taking some liberties as far 22 * as register files are concerned, to allow separate register 23 * allocation. 24 * 25 * Also note that there are some subtleties in that the semantics 26 * of certain opcodes are implicitly changed in this representation; 27 * see \ref rc_pair_translate 28 */ 29 30 /* For rgb and alpha instructions when arg[n].Source = RC_PAIR_PRESUB_SRC, then 31 * the presubtract value will be used, and 32 * {RGB,Alpha}.Src[RC_PAIR_PRESUB_SRC].File will be set to RC_FILE_PRESUB. 33 */ 34 #define RC_PAIR_PRESUB_SRC 3 35 36 struct rc_pair_instruction_source { 37 unsigned int Used:1; 38 unsigned int File:4; 39 unsigned int Index:RC_REGISTER_INDEX_BITS; 40 }; 41 42 struct rc_pair_instruction_arg { 43 unsigned int Source:2; 44 unsigned int Swizzle:12; 45 unsigned int Abs:1; 46 unsigned int Negate:1; 47 }; 48 49 struct rc_pair_sub_instruction { 50 unsigned int Opcode:8; 51 unsigned int DestIndex:RC_REGISTER_INDEX_BITS; 52 unsigned int WriteMask:4; 53 unsigned int Target:2; 54 unsigned int OutputWriteMask:3; 55 unsigned int DepthWriteMask:1; 56 unsigned int Saturate:1; 57 unsigned int Omod:3; 58 59 struct rc_pair_instruction_source Src[4]; 60 struct rc_pair_instruction_arg Arg[3]; 61 }; 62 63 struct rc_pair_instruction { 64 struct rc_pair_sub_instruction RGB; 65 struct rc_pair_sub_instruction Alpha; 66 67 unsigned int WriteALUResult:2; 68 unsigned int ALUResultCompare:3; 69 unsigned int Nop:1; 70 unsigned int SemWait:1; 71 }; 72 73 typedef void (*rc_pair_foreach_src_fn) 74 (void *, struct rc_pair_instruction_source *); 75 76 /** 77 * General helper functions for dealing with the paired instruction format. 78 */ 79 /*@{*/ 80 int rc_pair_alloc_source(struct rc_pair_instruction *pair, 81 unsigned int rgb, unsigned int alpha, 82 rc_register_file file, unsigned int index); 83 84 void rc_pair_foreach_source_that_alpha_reads( 85 struct rc_pair_instruction * pair, 86 void * data, 87 rc_pair_foreach_src_fn cb); 88 89 void rc_pair_foreach_source_that_rgb_reads( 90 struct rc_pair_instruction * pair, 91 void * data, 92 rc_pair_foreach_src_fn cb); 93 94 struct rc_pair_instruction_source * rc_pair_get_src( 95 struct rc_pair_instruction * pair_inst, 96 struct rc_pair_instruction_arg * arg); 97 98 int rc_pair_get_src_index( 99 struct rc_pair_instruction * pair_inst, 100 struct rc_pair_instruction_source * src); 101 /*@}*/ 102 103 104 /** 105 * Compiler passes that operate with the paired format. 106 */ 107 /*@{*/ 108 struct radeon_pair_handler; 109 110 void rc_pair_translate(struct radeon_compiler *cc, void *user); 111 void rc_pair_schedule(struct radeon_compiler *cc, void *user); 112 void rc_pair_regalloc(struct radeon_compiler *cc, void *user); 113 void rc_pair_remove_dead_sources(struct radeon_compiler *c, void *user); 114 /*@}*/ 115 116 #endif /* __RADEON_PROGRAM_PAIR_H_ */ 117