freedreno/ir3: remove tgsi f/e

Also remove ir3_flatten which was only used by tgsi f/e.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
This commit is contained in:
Rob Clark 2015-04-25 10:22:49 -04:00
parent 7273cb4e93
commit 0f6faa8ff3
12 changed files with 25 additions and 3957 deletions

View File

@ -120,12 +120,10 @@ ir3_SOURCES := \
ir3/disasm-a3xx.c \
ir3/instr-a3xx.h \
ir3/ir3.c \
ir3/ir3_compiler.c \
ir3/ir3_compiler_nir.c \
ir3/ir3_compiler.h \
ir3/ir3_cp.c \
ir3/ir3_depth.c \
ir3/ir3_flatten.c \
ir3/ir3_group.c \
ir3/ir3.h \
ir3/ir3_legalize.c \

View File

@ -70,7 +70,6 @@ static const struct debug_named_value debug_options[] = {
{"optmsgs", FD_DBG_OPTMSGS,"Enable optimizer debug messages"},
{"glsl120", FD_DBG_GLSL120,"Temporary flag to force GLSL 120 (rather than 130) on a3xx+"},
{"nocp", FD_DBG_NOCP, "Disable copy-propagation"},
{"nir", FD_DBG_NIR, "Enable experimental NIR compiler"},
DEBUG_NAMED_VALUE_END
};

View File

@ -65,7 +65,6 @@ enum adreno_stencil_op fd_stencil_op(unsigned op);
#define FD_DBG_OPTMSGS 0x0400
#define FD_DBG_GLSL120 0x1000
#define FD_DBG_NOCP 0x2000
#define FD_DBG_NIR 0x4000
extern int fd_mesa_debug;
extern bool fd_binning_enabled;

View File

@ -191,9 +191,9 @@ typedef enum {
OPC_LDLV = 31,
/* meta instructions (category -1): */
/* placeholder instr to mark inputs/outputs: */
/* placeholder instr to mark shader inputs: */
OPC_META_INPUT = 0,
OPC_META_OUTPUT = 1,
OPC_META_PHI = 1,
/* The "fan-in" and "fan-out" instructions are used for keeping
* track of instructions that write to multiple dst registers
* (fan-out) like texture sample instructions, or read multiple
@ -201,9 +201,6 @@ typedef enum {
*/
OPC_META_FO = 2,
OPC_META_FI = 3,
/* branches/flow control */
OPC_META_FLOW = 4,
OPC_META_PHI = 5,
} opc_t;

View File

@ -364,7 +364,6 @@ struct ir3_block {
struct ir3_instruction **outputs;
/* only a single address register: */
struct ir3_instruction *address;
struct ir3_block *parent;
struct list_head instr_list;
};

View File

@ -195,16 +195,6 @@ read_file(const char *filename, void **ptr, size_t *size)
return 0;
}
static void reset_variant(struct ir3_shader_variant *v, const char *msg)
{
printf("; %s\n", msg);
v->inputs_count = 0;
v->outputs_count = 0;
v->total_in = 0;
v->has_samp = false;
v->immediates_count = 0;
}
static void print_usage(void)
{
printf("Usage: ir3_compiler [OPTIONS]... FILE\n");
@ -231,7 +221,6 @@ int main(int argc, char **argv)
const char *info;
void *ptr;
size_t size;
int use_nir = 0;
fd_mesa_debug |= FD_DBG_DISASM;
@ -296,11 +285,6 @@ int main(int argc, char **argv)
n++;
continue;
}
if (!strcmp(argv[n], "--nir")) {
use_nir = true;
n++;
continue;
}
if (!strcmp(argv[n], "--help")) {
print_usage();
@ -341,20 +325,8 @@ int main(int argc, char **argv)
break;
}
if (use_nir) {
info = "NIR compiler";
ret = ir3_compile_shader_nir(&v, toks, key);
} else {
info = "TGSI compiler";
ret = ir3_compile_shader(&v, toks, key, true);
}
if (ret) {
reset_variant(&v, "compiler failed, trying without copy propagation!");
info = "compiler (no copy propagation)";
ret = ir3_compile_shader(&v, toks, key, false);
}
info = "NIR compiler";
ret = ir3_compile_shader_nir(&v, toks, key);
if (ret) {
fprintf(stderr, "compiler failed!\n");
return ret;

File diff suppressed because it is too large Load Diff

View File

@ -31,12 +31,7 @@
#include "ir3_shader.h"
int ir3_compile_shader_nir(struct ir3_shader_variant *so,
const struct tgsi_token *tokens, struct ir3_shader_key key);
int ir3_compile_shader(struct ir3_shader_variant *so,
const struct tgsi_token *tokens,
struct ir3_shader_key key, bool cp);
#endif /* IR3_COMPILER_H_ */

View File

@ -1,152 +0,0 @@
/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
/*
* Copyright (C) 2014 Rob Clark <robclark@freedesktop.org>
*
* 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:
* Rob Clark <robclark@freedesktop.org>
*/
#include <stdarg.h>
#include "ir3.h"
/*
* Flatten: flatten out legs of if/else, etc
*
* TODO probably should use some heuristic to decide to not flatten
* if one side of the other is too large / deeply nested / whatever?
*/
struct ir3_flatten_ctx {
struct ir3_block *block;
unsigned cnt;
};
static struct ir3_register *unwrap(struct ir3_register *reg)
{
if (reg->flags & IR3_REG_SSA) {
struct ir3_instruction *instr = reg->instr;
if (is_meta(instr)) {
switch (instr->opc) {
case OPC_META_OUTPUT:
case OPC_META_FLOW:
if (instr->regs_count > 1)
return instr->regs[1];
return NULL;
default:
break;
}
}
}
return reg;
}
static void ir3_instr_flatten(struct ir3_flatten_ctx *ctx,
struct ir3_instruction *instr)
{
struct ir3_instruction *src;
/* if we've already visited this instruction, bail now: */
if (ir3_instr_check_mark(instr))
return;
instr->block = ctx->block;
/* TODO: maybe some threshold to decide whether to
* flatten or not??
*/
if (is_meta(instr)) {
if (instr->opc == OPC_META_PHI) {
struct ir3_register *cond, *t, *f;
cond = unwrap(instr->regs[1]);
t = unwrap(instr->regs[2]); /* true val */
f = unwrap(instr->regs[3]); /* false val */
/* must have cond, but t or f may be null if only written
* one one side of the if/else (in which case we can just
* convert the PHI to a simple move).
*/
assert(cond);
assert(t || f);
if (t && f) {
/* convert the PHI instruction to sel.{b16,b32} */
instr->category = 3;
/* instruction type based on dst size: */
if (instr->regs[0]->flags & IR3_REG_HALF)
instr->opc = OPC_SEL_B16;
else
instr->opc = OPC_SEL_B32;
instr->regs[1] = t;
instr->regs[2] = cond;
instr->regs[3] = f;
} else {
/* convert to simple mov: */
instr->category = 1;
instr->cat1.dst_type = TYPE_F32;
instr->cat1.src_type = TYPE_F32;
instr->regs_count = 2;
instr->regs[1] = t ? t : f;
}
ctx->cnt++;
} else if ((instr->opc == OPC_META_INPUT) &&
(instr->regs_count == 2)) {
type_t ftype;
if (instr->regs[0]->flags & IR3_REG_HALF)
ftype = TYPE_F16;
else
ftype = TYPE_F32;
/* convert meta:input to mov: */
instr->category = 1;
instr->cat1.src_type = ftype;
instr->cat1.dst_type = ftype;
}
}
/* recursively visit children: */
foreach_ssa_src(src, instr)
ir3_instr_flatten(ctx, src);
}
/* return >= 0 is # of phi's flattened, < 0 is error */
int ir3_block_flatten(struct ir3_block *block)
{
struct ir3_flatten_ctx ctx = {
.block = block,
};
unsigned i;
ir3_clear_mark(block->shader);
for(i = 0; i < block->noutputs; i++)
if (block->outputs[i])
ir3_instr_flatten(&ctx, block->outputs[i]);
return ctx.cnt;
}

View File

@ -218,34 +218,32 @@ static void block_find_neighbors(struct ir3_block *block)
{
unsigned i;
/* shader inputs/outputs themselves must be contiguous as well:
*
* NOTE: group inputs first, since we only insert mov's
* *before* the conflicted instr (and that would go badly
* for inputs). By doing inputs first, we should never
* have a conflict on inputs.. pushing any conflict to
* resolve to the outputs, for stuff like:
*
* MOV OUT[n], IN[m].wzyx
*
* NOTE: we assume here inputs/outputs are grouped in vec4.
* This logic won't quite cut it if we don't align smaller
* on vec4 boundaries
*/
for (i = 0; i < block->ninputs; i += 4)
pad_and_group_input(&block->inputs[i], 4);
for (i = 0; i < block->noutputs; i += 4)
group_n(&arr_ops_out, &block->outputs[i], 4);
for (i = 0; i < block->noutputs; i++) {
if (block->outputs[i]) {
struct ir3_instruction *instr = block->outputs[i];
instr_find_neighbors(instr);
}
}
/* shader inputs/outputs themselves must be contiguous as well:
*/
if (!block->parent) {
/* NOTE: group inputs first, since we only insert mov's
* *before* the conflicted instr (and that would go badly
* for inputs). By doing inputs first, we should never
* have a conflict on inputs.. pushing any conflict to
* resolve to the outputs, for stuff like:
*
* MOV OUT[n], IN[m].wzyx
*
* NOTE: we assume here inputs/outputs are grouped in vec4.
* This logic won't quite cut it if we don't align smaller
* on vec4 boundaries
*/
for (i = 0; i < block->ninputs; i += 4)
pad_and_group_input(&block->inputs[i], 4);
for (i = 0; i < block->noutputs; i += 4)
group_n(&arr_ops_out, &block->outputs[i], 4);
}
}
void ir3_block_group(struct ir3_block *block)

View File

@ -54,10 +54,8 @@ static void print_instr_name(struct ir3_instruction *instr)
/* shouldn't hit here.. just for debugging: */
switch (instr->opc) {
case OPC_META_INPUT: printf("_meta:in"); break;
case OPC_META_OUTPUT: printf("_meta:out"); break;
case OPC_META_FO: printf("_meta:fo"); break;
case OPC_META_FI: printf("_meta:fi"); break;
case OPC_META_FLOW: printf("_meta:flow"); break;
default: printf("_meta:%d", instr->opc); break;
}

View File

@ -146,17 +146,6 @@ assemble_variant(struct ir3_shader_variant *v)
v->ir = NULL;
}
/* reset before attempting to compile again.. */
static void reset_variant(struct ir3_shader_variant *v, const char *msg)
{
debug_error(msg);
v->inputs_count = 0;
v->outputs_count = 0;
v->total_in = 0;
v->has_samp = false;
v->immediates_count = 0;
}
static struct ir3_shader_variant *
create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
{
@ -177,22 +166,7 @@ create_variant(struct ir3_shader *shader, struct ir3_shader_key key)
tgsi_dump(tokens, 0);
}
if (fd_mesa_debug & FD_DBG_NIR) {
ret = ir3_compile_shader_nir(v, tokens, key);
if (ret)
reset_variant(v, "NIR compiler failed, fallback to TGSI!");
} else {
ret = -1;
}
if (ret) {
ret = ir3_compile_shader(v, tokens, key, true);
if (ret) {
reset_variant(v, "new compiler failed, trying without copy propagation!");
ret = ir3_compile_shader(v, tokens, key, false);
}
}
ret = ir3_compile_shader_nir(v, tokens, key);
if (ret) {
debug_error("compile failed!");
goto fail;