2 * Copyright (C) 2009 Nicolai Haehnle.
3 * Copyright 2010 Tom Stellard <tstellar@gmail.com>
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial
17 * portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
23 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 #ifndef RADEON_DATAFLOW_H
30 #define RADEON_DATAFLOW_H
32 #include "radeon_program_constants.h"
34 struct radeon_compiler
;
35 struct rc_instruction
;
36 struct rc_swizzle_caps
;
37 struct rc_src_register
;
38 struct rc_pair_instruction_arg
;
39 struct rc_pair_instruction_source
;
44 * Help analyze and modify the register accesses of instructions.
47 typedef void (*rc_read_write_chan_fn
)(void * userdata
, struct rc_instruction
* inst
,
48 rc_register_file file
, unsigned int index
, unsigned int chan
);
49 void rc_for_all_reads_chan(struct rc_instruction
* inst
, rc_read_write_chan_fn cb
, void * userdata
);
50 void rc_for_all_writes_chan(struct rc_instruction
* inst
, rc_read_write_chan_fn cb
, void * userdata
);
52 typedef void (*rc_read_write_mask_fn
)(void * userdata
, struct rc_instruction
* inst
,
53 rc_register_file file
, unsigned int index
, unsigned int mask
);
54 void rc_for_all_reads_mask(struct rc_instruction
* inst
, rc_read_write_mask_fn cb
, void * userdata
);
55 void rc_for_all_writes_mask(struct rc_instruction
* inst
, rc_read_write_mask_fn cb
, void * userdata
);
57 typedef void (*rc_read_src_fn
)(void * userdata
, struct rc_instruction
* inst
,
58 struct rc_src_register
* src
);
59 void rc_for_all_reads_src(struct rc_instruction
* inst
, rc_read_src_fn cb
,
62 typedef void (*rc_pair_read_arg_fn
)(void * userdata
,
63 struct rc_instruction
* inst
, struct rc_pair_instruction_arg
* arg
,
64 struct rc_pair_instruction_source
* src
);
65 void rc_pair_for_all_reads_arg(struct rc_instruction
* inst
,
66 rc_pair_read_arg_fn cb
, void * userdata
);
68 typedef void (*rc_remap_register_fn
)(void * userdata
, struct rc_instruction
* inst
,
69 rc_register_file
* pfile
, unsigned int * pindex
);
70 void rc_remap_registers(struct rc_instruction
* inst
, rc_remap_register_fn cb
, void * userdata
);
74 struct rc_instruction
* Inst
;
75 unsigned int WriteMask
;
77 struct rc_src_register
* Src
;
78 struct rc_pair_instruction_arg
* Arg
;
82 struct rc_reader_data
{
84 unsigned int AbortOnRead
;
86 struct rc_instruction
* Writer
;
88 unsigned int ReaderCount
;
89 unsigned int ReadersReserved
;
90 struct rc_reader
* Readers
;
96 struct radeon_compiler
* c
,
97 struct rc_instruction
* 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
);
103 * Compiler passes based on dataflow analysis.
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
);
112 void rc_optimize(struct radeon_compiler
* c
, void *user
);
114 #endif /* RADEON_DATAFLOW_H */