2 * Copyright (C) 2009 Nicolai Haehnle.
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial
16 * portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #ifndef RADEON_DATAFLOW_H
29 #define RADEON_DATAFLOW_H
31 #include "radeon_program_constants.h"
33 struct radeon_compiler
;
34 struct rc_instruction
;
35 struct rc_swizzle_caps
;
37 struct rc_dataflow_vector
;
39 struct rc_dataflow_ref
{
40 struct rc_dataflow_vector
* Vector
;
43 * Linked list of references to the above-mentioned vector.
44 * The linked list is \em not sorted.
47 struct rc_dataflow_ref
* Prev
;
48 struct rc_dataflow_ref
* Next
;
51 unsigned int UseMask
:4;
52 struct rc_instruction
* ReadInstruction
;
55 struct rc_dataflow_vector
{
56 rc_register_file File
:3;
57 unsigned int Index
:RC_REGISTER_INDEX_BITS
;
59 /** For private use in compiler passes. MUST BE RESET TO 0 by the end of each pass.
60 * The annotate pass uses this bit to track whether a vector is in the
63 unsigned int PassBit
:1;
64 /** Which of the components have been written with useful values */
65 unsigned int ValidMask
:4;
66 /** Which of the components are used downstream */
67 unsigned int UseMask
:4;
68 /** The instruction that produced this vector */
69 struct rc_instruction
* WriteInstruction
;
71 /** Linked list of references to this vector */
72 struct rc_dataflow_ref Refs
;
75 struct rc_instruction_dataflow
{
76 struct rc_dataflow_ref
* SrcReg
[3];
77 struct rc_dataflow_ref
* SrcRegAddress
[3];
79 /** Reference the components of the destination register
80 * that are carried over without being overwritten */
81 struct rc_dataflow_ref
* DstRegPrev
;
82 /** Indicates whether the destination register was in use
83 * before this instruction */
84 unsigned int DstRegAliased
:1;
85 struct rc_dataflow_vector
* DstReg
;
89 * General functions for manipulating the dataflow structures.
92 struct rc_dataflow_ref
* rc_dataflow_create_ref(struct radeon_compiler
* c
,
93 struct rc_dataflow_vector
* vector
, struct rc_instruction
* inst
);
94 struct rc_dataflow_vector
* rc_dataflow_create_vector(struct radeon_compiler
* c
,
95 rc_register_file file
, unsigned int index
, struct rc_instruction
* inst
);
96 void rc_dataflow_remove_ref(struct rc_dataflow_ref
* ref
);
98 void rc_dataflow_remove_instruction(struct rc_instruction
* inst
);
103 * Compiler passes based on dataflow structures.
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_annotate(struct radeon_compiler
* c
, rc_dataflow_mark_outputs_fn dce
, void * userdata
);
109 void rc_dataflow_dealias(struct radeon_compiler
* c
);
110 void rc_dataflow_swizzles(struct radeon_compiler
* c
);
113 #endif /* RADEON_DATAFLOW_H */