2 * Copyright (C) 2020 Collabora Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
29 /* Finds the clause type required or return none */
31 static enum bifrost_clause_type
32 bi_clause_type_for_ins(bi_instruction
*ins
)
34 unsigned T
= ins
->type
;
36 /* Only high latency ops impose clause types */
37 if (!(bi_class_props
[T
] & BI_SCHED_HI_LATENCY
))
38 return BIFROST_CLAUSE_NONE
;
43 return BIFROST_CLAUSE_NONE
;
46 return BIFROST_CLAUSE_LOAD_VARY
;
50 case BI_LOAD_VAR_ADDRESS
:
51 return BIFROST_CLAUSE_UBO
;
54 return BIFROST_CLAUSE_TEX
;
57 return BIFROST_CLAUSE_SSBO_LOAD
;
61 return BIFROST_CLAUSE_SSBO_STORE
;
64 return BIFROST_CLAUSE_BLEND
;
67 return BIFROST_CLAUSE_ATEST
;
70 unreachable("Invalid high-latency class");
74 /* Eventually, we'll need a proper scheduling, grouping instructions
75 * into clauses and ordering/assigning grouped instructions to the
76 * appropriate FMA/ADD slots. Right now we do the dumbest possible
77 * thing just to have the scheduler stubbed out so we can focus on
81 bi_schedule(bi_context
*ctx
)
87 bi_foreach_block(ctx
, block
) {
88 bi_block
*bblock
= (bi_block
*) block
;
90 list_inithead(&bblock
->clauses
);
92 bi_foreach_instr_in_block(bblock
, ins
) {
93 unsigned props
= bi_class_props
[ins
->type
];
95 bi_clause
*u
= rzalloc(ctx
, bi_clause
);
98 if (props
& BI_SCHED_FMA
)
99 u
->bundles
[0].fma
= ins
;
101 u
->bundles
[0].add
= ins
;
103 u
->scoreboard_id
= ids
++;
108 u
->dependencies
|= (1 << last_id
);
111 last_id
= u
->scoreboard_id
;
112 u
->back_to_back
= true;
114 /* Rule: first instructions cannot have write barriers */
116 u
->data_register_write_barrier
= true;
118 u
->constant_count
= 1;
119 u
->constants
[0] = ins
->constant
.u64
;
121 u
->clause_type
= bi_clause_type_for_ins(ins
);
123 list_addtail(&u
->link
, &bblock
->clauses
);
126 bblock
->scheduled
= true;