pan/bi: Add dummy scheduler
[mesa.git] / src / panfrost / bifrost / bi_schedule.c
1 /*
2 * Copyright (C) 2020 Collabora Ltd.
3 *
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:
10 *
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
13 * Software.
14 *
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
21 * SOFTWARE.
22 *
23 * Authors (Collabora):
24 * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
25 */
26
27 #include "compiler.h"
28
29 /* Eventually, we'll need a proper scheduling, grouping instructions
30 * into clauses and ordering/assigning grouped instructions to the
31 * appropriate FMA/ADD slots. Right now we do the dumbest possible
32 * thing just to have the scheduler stubbed out so we can focus on
33 * codegen */
34
35 void
36 bi_schedule(bi_context *ctx)
37 {
38 unsigned ids = 0;
39 unsigned last_id = 0;
40 bool is_first = true;
41
42 bi_foreach_block(ctx, block) {
43 list_inithead(&block->clauses);
44
45 bi_foreach_instr_in_block(block, ins) {
46 unsigned props = bi_class_props[ins->type];
47
48 bi_clause *u = rzalloc(ctx, bi_clause);
49 u->bundle_count = 1;
50
51 if (props & BI_SCHED_FMA)
52 u->bundles[0].fma = ins;
53 else
54 u->bundles[0].add = ins;
55
56 u->scoreboard_id = ids++;
57
58 if (is_first)
59 is_first = false;
60 else
61 u->dependencies |= (1 << last_id);
62
63 ids = ids & 1;
64 last_id = u->scoreboard_id;
65 u->back_to_back = true;
66 u->data_register_write_barrier = true;
67
68 u->constant_count = 1;
69 u->constants[0] = ins->constant.u64;
70
71 list_addtail(&u->link, &block->clauses);
72 }
73
74 block->scheduled = true;
75 }
76 }