1 /* 2 * Copyright 2009 Nicolai Haehnle. 3 * Copyright 2010 Tom Stellard <[email protected]> 4 * SPDX-License-Identifier: MIT 5 */ 6 7 #ifndef RADEON_DATAFLOW_H 8 #define RADEON_DATAFLOW_H 9 10 #include "radeon_program_constants.h" 11 12 struct radeon_compiler; 13 struct rc_instruction; 14 struct rc_swizzle_caps; 15 struct rc_src_register; 16 struct rc_pair_instruction_arg; 17 struct rc_pair_instruction_source; 18 struct rc_pair_sub_instruction; 19 struct rc_compiler; 20 21 22 /** 23 * Help analyze and modify the register accesses of instructions. 24 */ 25 /*@{*/ 26 typedef void (*rc_read_write_chan_fn)(void * userdata, struct rc_instruction * inst, 27 rc_register_file file, unsigned int index, unsigned int chan); 28 void rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata); 29 void rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata); 30 31 typedef void (*rc_read_write_mask_fn)(void * userdata, struct rc_instruction * inst, 32 rc_register_file file, unsigned int index, unsigned int mask); 33 void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata); 34 void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata); 35 36 typedef void (*rc_read_src_fn)(void * userdata, struct rc_instruction * inst, 37 struct rc_src_register * src); 38 void rc_for_all_reads_src(struct rc_instruction * inst, rc_read_src_fn cb, 39 void * userdata); 40 41 typedef void (*rc_pair_read_arg_fn)(void * userdata, 42 struct rc_instruction * inst, struct rc_pair_instruction_arg * arg, 43 struct rc_pair_instruction_source * src); 44 void rc_pair_for_all_reads_arg(struct rc_instruction * inst, 45 rc_pair_read_arg_fn cb, void * userdata); 46 47 typedef void (*rc_remap_register_fn)(void * userdata, struct rc_instruction * inst, 48 rc_register_file * pfile, unsigned int * pindex); 49 void rc_remap_registers(struct rc_instruction * inst, rc_remap_register_fn cb, void * userdata); 50 /*@}*/ 51 52 struct rc_reader { 53 struct rc_instruction * Inst; 54 unsigned int WriteMask; 55 union { 56 struct { 57 struct rc_src_register * Src; 58 } I; 59 struct { 60 struct rc_pair_instruction_arg * Arg; 61 struct rc_pair_instruction_source * Src; 62 } P; 63 } U; 64 }; 65 66 struct rc_reader_data { 67 struct radeon_compiler * C; 68 69 unsigned int Abort; 70 unsigned int AbortOnRead; 71 unsigned int AbortOnWrite; 72 unsigned int LoopDepth; 73 unsigned int InElse; 74 struct rc_instruction * Writer; 75 76 unsigned int ReaderCount; 77 unsigned int ReadersReserved; 78 struct rc_reader * Readers; 79 80 /* If this flag is enabled, rc_get_readers will exit as soon possible 81 * after the Abort flag is set.*/ 82 unsigned int ExitOnAbort; 83 void * CbData; 84 }; 85 86 void rc_get_readers( 87 struct radeon_compiler * c, 88 struct rc_instruction * writer, 89 struct rc_reader_data * data, 90 rc_read_src_fn read_normal_cb, 91 rc_pair_read_arg_fn read_pair_cb, 92 rc_read_write_mask_fn write_cb); 93 94 void rc_get_readers_sub( 95 struct radeon_compiler * c, 96 struct rc_instruction * writer, 97 struct rc_pair_sub_instruction * sub_writer, 98 struct rc_reader_data * data, 99 rc_read_src_fn read_normal_cb, 100 rc_pair_read_arg_fn read_pair_cb, 101 rc_read_write_mask_fn write_cb); 102 /** 103 * Compiler passes based on dataflow analysis. 104 */ 105 /*@{*/ 106 typedef void (*rc_dataflow_mark_outputs_fn)(void * userdata, void * data, 107 void (*mark_fn)(void * data, unsigned int index, unsigned int mask)); 108 void rc_dataflow_deadcode(struct radeon_compiler * c, void *user); 109 void rc_dataflow_swizzles(struct radeon_compiler * c, void *user); 110 /*@}*/ 111 112 void rc_optimize(struct radeon_compiler * c, void *user); 113 void rc_inline_literals(struct radeon_compiler *c, void *user); 114 int rc_opt_presubtract(struct radeon_compiler *c, struct rc_instruction *inst, void *data); 115 116 #endif /* RADEON_DATAFLOW_H */ 117