1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (C) 2009 Nicolai Haehnle. 3bf215546Sopenharmony_ci * Copyright 2010 Tom Stellard <tstellar@gmail.com> 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * All Rights Reserved. 6bf215546Sopenharmony_ci * 7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 8bf215546Sopenharmony_ci * a copy of this software and associated documentation files (the 9bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 10bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 11bf215546Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 12bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 13bf215546Sopenharmony_ci * the following conditions: 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 16bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial 17bf215546Sopenharmony_ci * portions of the Software. 18bf215546Sopenharmony_ci * 19bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20bf215546Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22bf215546Sopenharmony_ci * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 23bf215546Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 24bf215546Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25bf215546Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26bf215546Sopenharmony_ci * 27bf215546Sopenharmony_ci */ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef RADEON_DATAFLOW_H 30bf215546Sopenharmony_ci#define RADEON_DATAFLOW_H 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "radeon_program_constants.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include <stdbool.h> 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_cistruct radeon_compiler; 37bf215546Sopenharmony_cistruct rc_instruction; 38bf215546Sopenharmony_cistruct rc_swizzle_caps; 39bf215546Sopenharmony_cistruct rc_src_register; 40bf215546Sopenharmony_cistruct rc_pair_instruction_arg; 41bf215546Sopenharmony_cistruct rc_pair_instruction_source; 42bf215546Sopenharmony_cistruct rc_pair_sub_instruction; 43bf215546Sopenharmony_cistruct rc_compiler; 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci/** 47bf215546Sopenharmony_ci * Help analyze and modify the register accesses of instructions. 48bf215546Sopenharmony_ci */ 49bf215546Sopenharmony_ci/*@{*/ 50bf215546Sopenharmony_citypedef void (*rc_read_write_chan_fn)(void * userdata, struct rc_instruction * inst, 51bf215546Sopenharmony_ci rc_register_file file, unsigned int index, unsigned int chan); 52bf215546Sopenharmony_civoid rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata); 53bf215546Sopenharmony_civoid rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata); 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_citypedef void (*rc_read_write_mask_fn)(void * userdata, struct rc_instruction * inst, 56bf215546Sopenharmony_ci rc_register_file file, unsigned int index, unsigned int mask); 57bf215546Sopenharmony_civoid rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata); 58bf215546Sopenharmony_civoid rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata); 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_citypedef void (*rc_read_src_fn)(void * userdata, struct rc_instruction * inst, 61bf215546Sopenharmony_ci struct rc_src_register * src); 62bf215546Sopenharmony_civoid rc_for_all_reads_src(struct rc_instruction * inst, rc_read_src_fn cb, 63bf215546Sopenharmony_ci void * userdata); 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_citypedef void (*rc_pair_read_arg_fn)(void * userdata, 66bf215546Sopenharmony_ci struct rc_instruction * inst, struct rc_pair_instruction_arg * arg, 67bf215546Sopenharmony_ci struct rc_pair_instruction_source * src); 68bf215546Sopenharmony_civoid rc_pair_for_all_reads_arg(struct rc_instruction * inst, 69bf215546Sopenharmony_ci rc_pair_read_arg_fn cb, void * userdata); 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_citypedef void (*rc_remap_register_fn)(void * userdata, struct rc_instruction * inst, 72bf215546Sopenharmony_ci rc_register_file * pfile, unsigned int * pindex); 73bf215546Sopenharmony_civoid rc_remap_registers(struct rc_instruction * inst, rc_remap_register_fn cb, void * userdata); 74bf215546Sopenharmony_ci/*@}*/ 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_cistruct rc_reader { 77bf215546Sopenharmony_ci struct rc_instruction * Inst; 78bf215546Sopenharmony_ci unsigned int WriteMask; 79bf215546Sopenharmony_ci union { 80bf215546Sopenharmony_ci struct { 81bf215546Sopenharmony_ci struct rc_src_register * Src; 82bf215546Sopenharmony_ci } I; 83bf215546Sopenharmony_ci struct { 84bf215546Sopenharmony_ci struct rc_pair_instruction_arg * Arg; 85bf215546Sopenharmony_ci struct rc_pair_instruction_source * Src; 86bf215546Sopenharmony_ci } P; 87bf215546Sopenharmony_ci } U; 88bf215546Sopenharmony_ci}; 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_cistruct rc_reader_data { 91bf215546Sopenharmony_ci unsigned int Abort; 92bf215546Sopenharmony_ci unsigned int AbortOnRead; 93bf215546Sopenharmony_ci unsigned int AbortOnWrite; 94bf215546Sopenharmony_ci unsigned int LoopDepth; 95bf215546Sopenharmony_ci unsigned int InElse; 96bf215546Sopenharmony_ci bool ReadersAfterEndloop; 97bf215546Sopenharmony_ci struct rc_instruction * Writer; 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_ci unsigned int ReaderCount; 100bf215546Sopenharmony_ci unsigned int ReadersReserved; 101bf215546Sopenharmony_ci struct rc_reader * Readers; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci /* If this flag is enabled, rc_get_readers will exit as soon possbile 104bf215546Sopenharmony_ci * after the Abort flag is set.*/ 105bf215546Sopenharmony_ci unsigned int ExitOnAbort; 106bf215546Sopenharmony_ci void * CbData; 107bf215546Sopenharmony_ci}; 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_civoid rc_get_readers( 110bf215546Sopenharmony_ci struct radeon_compiler * c, 111bf215546Sopenharmony_ci struct rc_instruction * writer, 112bf215546Sopenharmony_ci struct rc_reader_data * data, 113bf215546Sopenharmony_ci rc_read_src_fn read_normal_cb, 114bf215546Sopenharmony_ci rc_pair_read_arg_fn read_pair_cb, 115bf215546Sopenharmony_ci rc_read_write_mask_fn write_cb); 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_civoid rc_get_readers_sub( 118bf215546Sopenharmony_ci struct radeon_compiler * c, 119bf215546Sopenharmony_ci struct rc_instruction * writer, 120bf215546Sopenharmony_ci struct rc_pair_sub_instruction * sub_writer, 121bf215546Sopenharmony_ci struct rc_reader_data * data, 122bf215546Sopenharmony_ci rc_read_src_fn read_normal_cb, 123bf215546Sopenharmony_ci rc_pair_read_arg_fn read_pair_cb, 124bf215546Sopenharmony_ci rc_read_write_mask_fn write_cb); 125bf215546Sopenharmony_ci/** 126bf215546Sopenharmony_ci * Compiler passes based on dataflow analysis. 127bf215546Sopenharmony_ci */ 128bf215546Sopenharmony_ci/*@{*/ 129bf215546Sopenharmony_citypedef void (*rc_dataflow_mark_outputs_fn)(void * userdata, void * data, 130bf215546Sopenharmony_ci void (*mark_fn)(void * data, unsigned int index, unsigned int mask)); 131bf215546Sopenharmony_civoid rc_dataflow_deadcode(struct radeon_compiler * c, void *user); 132bf215546Sopenharmony_civoid rc_dataflow_swizzles(struct radeon_compiler * c, void *user); 133bf215546Sopenharmony_ci/*@}*/ 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_civoid rc_optimize(struct radeon_compiler * c, void *user); 136bf215546Sopenharmony_civoid rc_inline_literals(struct radeon_compiler *c, void *user); 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_ci#endif /* RADEON_DATAFLOW_H */ 139