• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2009 Nicolai Haehnle.
3  * Copyright 2010 Tom Stellard <tstellar@gmail.com>
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  * Help analyze and modify the register accesses of instructions.
23  */
24 /*@{*/
25 typedef void (*rc_read_write_chan_fn)(void *userdata, struct rc_instruction *inst,
26                                       rc_register_file file, unsigned int index, unsigned int chan);
27 void rc_for_all_reads_chan(struct rc_instruction *inst, rc_read_write_chan_fn cb, void *userdata);
28 void rc_for_all_writes_chan(struct rc_instruction *inst, rc_read_write_chan_fn cb, void *userdata);
29 
30 typedef void (*rc_read_write_mask_fn)(void *userdata, struct rc_instruction *inst,
31                                       rc_register_file file, unsigned int index, unsigned int mask);
32 void rc_for_all_reads_mask(struct rc_instruction *inst, rc_read_write_mask_fn cb, void *userdata);
33 void rc_for_all_writes_mask(struct rc_instruction *inst, rc_read_write_mask_fn cb, void *userdata);
34 
35 typedef void (*rc_read_src_fn)(void *userdata, struct rc_instruction *inst,
36                                struct rc_src_register *src);
37 void rc_for_all_reads_src(struct rc_instruction *inst, rc_read_src_fn cb, void *userdata);
38 
39 typedef void (*rc_pair_read_arg_fn)(void *userdata, struct rc_instruction *inst,
40                                     struct rc_pair_instruction_arg *arg,
41                                     struct rc_pair_instruction_source *src);
42 void rc_pair_for_all_reads_arg(struct rc_instruction *inst, rc_pair_read_arg_fn cb, void *userdata);
43 
44 typedef void (*rc_remap_register_fn)(void *userdata, struct rc_instruction *inst,
45                                      rc_register_file *pfile, unsigned int *pindex);
46 void rc_remap_registers(struct rc_instruction *inst, rc_remap_register_fn cb, void *userdata);
47 /*@}*/
48 
49 struct rc_reader {
50    struct rc_instruction *Inst;
51    unsigned int WriteMask;
52    union {
53       struct {
54          struct rc_src_register *Src;
55       } I;
56       struct {
57          struct rc_pair_instruction_arg *Arg;
58          struct rc_pair_instruction_source *Src;
59       } P;
60    } U;
61 };
62 
63 struct rc_reader_data {
64    struct radeon_compiler *C;
65 
66    unsigned int Abort;
67    unsigned int AbortOnRead;
68    unsigned int AbortOnWrite;
69    unsigned int LoopDepth;
70    unsigned int InElse;
71    struct rc_instruction *Writer;
72 
73    unsigned int ReaderCount;
74    unsigned int ReadersReserved;
75    struct rc_reader *Readers;
76 
77    /* If this flag is enabled, rc_get_readers will exit as soon possible
78     * after the Abort flag is set.*/
79    unsigned int ExitOnAbort;
80    void *CbData;
81 };
82 
83 void rc_get_readers(struct radeon_compiler *c, struct rc_instruction *writer,
84                     struct rc_reader_data *data, rc_read_src_fn read_normal_cb,
85                     rc_pair_read_arg_fn read_pair_cb, rc_read_write_mask_fn write_cb);
86 
87 void rc_get_readers_sub(struct radeon_compiler *c, struct rc_instruction *writer,
88                         struct rc_pair_sub_instruction *sub_writer, struct rc_reader_data *data,
89                         rc_read_src_fn read_normal_cb, rc_pair_read_arg_fn read_pair_cb,
90                         rc_read_write_mask_fn write_cb);
91 /**
92  * Compiler passes based on dataflow analysis.
93  */
94 /*@{*/
95 typedef void (*rc_dataflow_mark_outputs_fn)(void *userdata, void *data,
96                                             void (*mark_fn)(void *data, unsigned int index,
97                                                             unsigned int mask));
98 void rc_dataflow_deadcode(struct radeon_compiler *c, void *user);
99 void rc_dataflow_swizzles(struct radeon_compiler *c, void *user);
100 /*@}*/
101 
102 void rc_optimize(struct radeon_compiler *c, void *user);
103 void rc_inline_literals(struct radeon_compiler *c, void *user);
104 int rc_opt_presubtract(struct radeon_compiler *c, struct rc_instruction *inst, void *data);
105 
106 #endif /* RADEON_DATAFLOW_H */
107