panfrost/midgard: Helpers for pipeline
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Ryan Houdek <Sonicadvance1@gmail.com>
This commit is contained in:

committed by
Alyssa Rosenzweig

parent
3c7abbfbe8
commit
2a79afc5f0
@@ -27,6 +27,7 @@ files_panfrost = files(
|
||||
'pan_resource.h',
|
||||
|
||||
'midgard/midgard_compile.c',
|
||||
'midgard/mir.c',
|
||||
'midgard/midgard_print.c',
|
||||
'midgard/midgard_schedule.c',
|
||||
'midgard/midgard_emit.c',
|
||||
|
@@ -312,8 +312,6 @@ mir_next_op(struct midgard_instruction *ins)
|
||||
#define mir_foreach_block_from(ctx, from, v) \
|
||||
list_for_each_entry_from(struct midgard_block, v, from, &ctx->blocks, link)
|
||||
|
||||
/* The following routines are for use before the scheduler has run */
|
||||
|
||||
#define mir_foreach_instr(ctx, v) \
|
||||
list_for_each_entry(struct midgard_instruction, v, &ctx->current_block->instructions, link)
|
||||
|
||||
@@ -338,6 +336,11 @@ mir_next_op(struct midgard_instruction *ins)
|
||||
#define mir_foreach_bundle_in_block(block, v) \
|
||||
util_dynarray_foreach(&block->bundles, midgard_bundle, v)
|
||||
|
||||
#define mir_foreach_instr_global(ctx, v) \
|
||||
mir_foreach_block(ctx, v_block) \
|
||||
mir_foreach_instr_in_block(v_block, v)
|
||||
|
||||
|
||||
static inline midgard_instruction *
|
||||
mir_last_in_block(struct midgard_block *block)
|
||||
{
|
||||
@@ -355,6 +358,18 @@ mir_get_block(compiler_context *ctx, int idx)
|
||||
return (struct midgard_block *) lst;
|
||||
}
|
||||
|
||||
static inline bool
|
||||
mir_is_alu_bundle(midgard_bundle *bundle)
|
||||
{
|
||||
return IS_ALU(bundle->tag);
|
||||
}
|
||||
|
||||
/* MIR manipulation */
|
||||
|
||||
void mir_rewrite_index(compiler_context *ctx, unsigned old, unsigned new);
|
||||
void mir_rewrite_index_src(compiler_context *ctx, unsigned old, unsigned new);
|
||||
void mir_rewrite_index_dst(compiler_context *ctx, unsigned old, unsigned new);
|
||||
|
||||
/* MIR printing */
|
||||
|
||||
void mir_print_instruction(midgard_instruction *ins);
|
||||
|
@@ -112,6 +112,9 @@ quadword_size(int tag)
|
||||
}
|
||||
}
|
||||
|
||||
#define IS_ALU(tag) (tag == TAG_ALU_4 || tag == TAG_ALU_8 || \
|
||||
tag == TAG_ALU_12 || tag == TAG_ALU_16)
|
||||
|
||||
/* Special register aliases */
|
||||
|
||||
#define MAX_WORK_REGISTERS 16
|
||||
|
@@ -1484,13 +1484,6 @@ emit_instr(compiler_context *ctx, struct nir_instr *instr)
|
||||
}
|
||||
}
|
||||
|
||||
/* Midgard prefetches instruction types, so during emission we need to
|
||||
* lookahead too. Unless this is the last instruction, in which we return 1. Or
|
||||
* if this is the second to last and the last is an ALU, then it's also 1... */
|
||||
|
||||
#define IS_ALU(tag) (tag == TAG_ALU_4 || tag == TAG_ALU_8 || \
|
||||
tag == TAG_ALU_12 || tag == TAG_ALU_16)
|
||||
|
||||
|
||||
/* ALU instructions can inline or embed constants, which decreases register
|
||||
* pressure and saves space. */
|
||||
@@ -2544,6 +2537,11 @@ midgard_compile_shader_nir(nir_shader *nir, midgard_program *program, bool is_bl
|
||||
|
||||
int current_bundle = 0;
|
||||
|
||||
/* Midgard prefetches instruction types, so during emission we
|
||||
* need to lookahead. Unless this is the last instruction, in
|
||||
* which we return 1. Or if this is the second to last and the
|
||||
* last is an ALU, then it's also 1... */
|
||||
|
||||
mir_foreach_block(ctx, block) {
|
||||
util_dynarray_foreach(&block->bundles, midgard_bundle, bundle) {
|
||||
int lookahead = 1;
|
||||
|
53
src/gallium/drivers/panfrost/midgard/mir.c
Normal file
53
src/gallium/drivers/panfrost/midgard/mir.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Alyssa Rosenzweig <alyssa@rosenzweig.io>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "compiler.h"
|
||||
|
||||
void
|
||||
mir_rewrite_index_src(compiler_context *ctx, unsigned old, unsigned new)
|
||||
{
|
||||
mir_foreach_instr_global(ctx, ins) {
|
||||
if (ins->ssa_args.src0 == old)
|
||||
ins->ssa_args.src0 = new;
|
||||
|
||||
if (ins->ssa_args.src1 == old &&
|
||||
!ins->ssa_args.inline_constant)
|
||||
ins->ssa_args.src1 = new;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mir_rewrite_index_dst(compiler_context *ctx, unsigned old, unsigned new)
|
||||
{
|
||||
mir_foreach_instr_global(ctx, ins) {
|
||||
if (ins->ssa_args.dest == old)
|
||||
ins->ssa_args.dest = new;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mir_rewrite_index(compiler_context *ctx, unsigned old, unsigned new)
|
||||
{
|
||||
mir_rewrite_index_src(ctx, old, new);
|
||||
mir_rewrite_index_dst(ctx, old, new);
|
||||
}
|
Reference in New Issue
Block a user