Commit b329f8c7 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜 Committed by Marge Bot
Browse files

pan/bi: Add dummy scheduler



Do the absolute simplest possible thing -- create a clause for every
instruction, and just pick whichever slot we can, nopping the other,
copying whatever constant we have whether it's used or not.

To be clear - this is not to be used in a production compiler. But this
lets actual bundles and clauses show up in the BIR, which unblocks work
on final code generation and packing (which can happen more or less in
parallel to NIR->BIR, optimization, register allocation, and writing an
actual scheduling).
Signed-off-by: Alyssa Rosenzweig's avatarAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <mesa/mesa!4097>
parent 51e537c9
......@@ -3,6 +3,7 @@ bifrost_FILES := \
bifrost/bifrost_compile.c \
bifrost/bifrost_compile.h \
bifrost/bifrost_tables.c \
bifrost/bi_schedule.c \
bifrost/bi_print.c \
bifrost/bi_print.h \
bifrost/bi_quirks.c \
......
/*
* Copyright (C) 2020 Collabora Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Authors (Collabora):
* Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
*/
#include "compiler.h"
/* Eventually, we'll need a proper scheduling, grouping instructions
* into clauses and ordering/assigning grouped instructions to the
* appropriate FMA/ADD slots. Right now we do the dumbest possible
* thing just to have the scheduler stubbed out so we can focus on
* codegen */
void
bi_schedule(bi_context *ctx)
{
unsigned ids = 0;
unsigned last_id = 0;
bool is_first = true;
bi_foreach_block(ctx, block) {
list_inithead(&block->clauses);
bi_foreach_instr_in_block(block, ins) {
unsigned props = bi_class_props[ins->type];
bi_clause *u = rzalloc(ctx, bi_clause);
u->bundle_count = 1;
if (props & BI_SCHED_FMA)
u->bundles[0].fma = ins;
else
u->bundles[0].add = ins;
u->scoreboard_id = ids++;
if (is_first)
is_first = false;
else
u->dependencies |= (1 << last_id);
ids = ids & 1;
last_id = u->scoreboard_id;
u->back_to_back = true;
u->data_register_write_barrier = true;
u->constant_count = 1;
u->constants[0] = ins->constant.u64;
list_addtail(&u->link, &block->clauses);
}
block->scheduled = true;
}
}
......@@ -606,6 +606,8 @@ bifrost_compile_shader_nir(nir_shader *nir, bifrost_program *program, unsigned p
break; /* TODO: Multi-function shaders */
}
bi_print_shader(ctx, stdout);
bi_schedule(ctx);
bi_print_shader(ctx, stdout);
ralloc_free(ctx);
......
......@@ -308,11 +308,8 @@ typedef struct bi_block {
/* If true, uses clauses; if false, uses instructions */
bool scheduled;
union {
struct list_head instructions; /* pre-schedule, list of bi_instructions */
struct list_head clauses; /* list of bi_clause */
};
struct list_head instructions; /* pre-schedule, list of bi_instructions */
struct list_head clauses; /* list of bi_clause */
/* Control flow graph */
struct set *predecessors;
......@@ -486,4 +483,8 @@ bool bi_has_outmod(bi_instruction *ins);
bool bi_has_source_mods(bi_instruction *ins);
bool bi_is_src_swizzled(bi_instruction *ins, unsigned s);
/* BIR passes */
void bi_schedule(bi_context *ctx);
#endif
......@@ -22,6 +22,7 @@
libpanfrost_bifrost_files = files(
'disassemble.c',
'bi_print.c',
'bi_schedule.c',
'bi_tables.c',
'bir.c',
'bifrost_compile.c',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment