regs->uniform_constant = f;
ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_CONST_LO;
assigned = true;
+ } else if (ins->src[s] & BIR_INDEX_ZERO && fast_zero) {
+ ins->src[s] = BIR_INDEX_PASS | BIFROST_SRC_STAGE;
} else if (s & BIR_INDEX_UNIFORM) {
unreachable("Push uniforms not implemented yet");
}
}
static enum bifrost_packed_src
-bi_get_src(bi_instruction *ins, struct bi_registers *regs, unsigned s, bool is_fma)
+bi_get_src(bi_instruction *ins, struct bi_registers *regs, unsigned s)
{
unsigned src = ins->src[s];
if (src & BIR_INDEX_REGISTER)
return bi_get_src_reg_port(regs, src);
- else if (src & BIR_INDEX_ZERO && is_fma)
- return BIFROST_SRC_STAGE;
else if (src & BIR_INDEX_PASS)
return src & ~BIR_INDEX_PASS;
else {
bool flip_ab = ins->src_abs[1];
struct bifrost_fma_mscale pack = {
- .src0 = bi_get_src(ins, regs, flip_ab ? 1 : 0, true),
- .src1 = bi_get_src(ins, regs, flip_ab ? 0 : 1, true),
- .src2 = bi_get_src(ins, regs, 2, true),
- .src3 = bi_get_src(ins, regs, 3, true),
+ .src0 = bi_get_src(ins, regs, flip_ab ? 1 : 0),
+ .src1 = bi_get_src(ins, regs, flip_ab ? 0 : 1),
+ .src2 = bi_get_src(ins, regs, 2),
+ .src3 = bi_get_src(ins, regs, 3),
.mscale_mode = 0,
.mode = ins->outmod,
.src0_abs = ins->src_abs[0] || ins->src_abs[1],
RETURN_PACKED(pack);
} else if (ins->dest_type == nir_type_float32) {
struct bifrost_fma_fma pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
- .src2 = bi_get_src(ins, regs, 2, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
+ .src2 = bi_get_src(ins, regs, 2),
.src0_abs = ins->src_abs[0],
.src1_abs = ins->src_abs[1],
.src2_abs = ins->src_abs[2],
RETURN_PACKED(pack);
} else if (ins->dest_type == nir_type_float16) {
struct bifrost_fma_fma16 pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
- .src2 = bi_get_src(ins, regs, 2, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
+ .src2 = bi_get_src(ins, regs, 2),
.swizzle_0 = bi_swiz16(ins, 0),
.swizzle_1 = bi_swiz16(ins, 1),
.swizzle_2 = bi_swiz16(ins, 2),
BIFROST_FMA_OP_FMAX32;
struct bifrost_fma_add pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.src0_abs = ins->src_abs[0],
.src1_abs = ins->src_abs[1],
.src0_neg = ins->src_neg[0],
*/
unsigned abs_0 = ins->src_abs[0], abs_1 = ins->src_abs[1];
- unsigned src_0 = bi_get_src(ins, regs, 0, true);
- unsigned src_1 = bi_get_src(ins, regs, 1, true);
+ unsigned src_0 = bi_get_src(ins, regs, 0);
+ unsigned src_1 = bi_get_src(ins, regs, 1);
assert(!(abs_0 && abs_1 && src_0 == src_1));
bool flip = false;
bool l = bi_pack_fp16_abs(ins, regs, &flip);
- unsigned src_0 = bi_get_src(ins, regs, 0, true);
- unsigned src_1 = bi_get_src(ins, regs, 1, true);
+ unsigned src_0 = bi_get_src(ins, regs, 0);
+ unsigned src_1 = bi_get_src(ins, regs, 1);
if (FMA) {
struct bifrost_fma_add_minmax16 pack = {
bi_pack_fma_1src(bi_instruction *ins, struct bi_registers *regs, unsigned op)
{
struct bifrost_fma_inst pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
+ .src0 = bi_get_src(ins, regs, 0),
.op = op
};
bi_pack_fma_2src(bi_instruction *ins, struct bi_registers *regs, unsigned op)
{
struct bifrost_fma_2src pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.op = op
};
bi_pack_add_1src(bi_instruction *ins, struct bi_registers *regs, unsigned op)
{
struct bifrost_add_inst pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
+ .src0 = bi_get_src(ins, regs, 0),
.op = op
};
unsigned res_1 = (invert ? 2 : 3);
struct bifrost_csel4 pack = {
- .src0 = bi_get_src(ins, regs, cmp_0, true),
- .src1 = bi_get_src(ins, regs, cmp_1, true),
- .src2 = bi_get_src(ins, regs, res_0, true),
- .src3 = bi_get_src(ins, regs, res_1, true),
+ .src0 = bi_get_src(ins, regs, cmp_0),
+ .src1 = bi_get_src(ins, regs, cmp_1),
+ .src2 = bi_get_src(ins, regs, res_0),
+ .src3 = bi_get_src(ins, regs, res_1),
.cond = cond,
.op = (size == 16) ? BIFROST_FMA_OP_CSEL4_V16 :
BIFROST_FMA_OP_CSEL4
if (from_size == 32 && to_size == 16 && from_base == nir_type_float && to_base == from_base) {
/* TODO: second vectorized source? */
struct bifrost_fma_2src pfma = {
- .src0 = bi_get_src(ins, regs, 0, true),
+ .src0 = bi_get_src(ins, regs, 0),
.src1 = BIFROST_SRC_STAGE, /* 0 */
.op = BIFROST_FMA_FLOAT32_TO_16
};
struct bifrost_add_2src padd = {
- .src0 = bi_get_src(ins, regs, 0, true),
+ .src0 = bi_get_src(ins, regs, 0),
.src1 = BIFROST_SRC_STAGE, /* 0 */
.op = BIFROST_ADD_FLOAT32_TO_16
};
}
struct bifrost_fma_sel8 pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
- .src2 = bi_get_src(ins, regs, 2, true),
- .src3 = bi_get_src(ins, regs, 3, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
+ .src2 = bi_get_src(ins, regs, 2),
+ .src3 = bi_get_src(ins, regs, 3),
.swizzle = swiz,
.op = BIFROST_FMA_OP_SEL8
};
cond = bi_flip_fcmp(cond);
struct bifrost_fma_fcmp pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.src0_abs = ins->src_abs[0],
.src1_abs = ins->src_abs[1],
.src1_neg = neg,
cond = bi_flip_fcmp(cond);
struct bifrost_fma_fcmp16 pack = {
- .src0 = bi_get_src(ins, regs, flip ? 1 : 0, true),
- .src1 = bi_get_src(ins, regs, flip ? 0 : 1, true),
+ .src0 = bi_get_src(ins, regs, flip ? 1 : 0),
+ .src1 = bi_get_src(ins, regs, flip ? 0 : 1),
.src0_swizzle = bi_swiz16(ins, flip ? 1 : 0),
.src1_swizzle = bi_swiz16(ins, flip ? 0 : 1),
.abs1 = l,
}
struct bifrost_shift_fma pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
- .src2 = bi_get_src(ins, regs, 2, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
+ .src2 = bi_get_src(ins, regs, 2),
.half = (size == 32) ? 0 : (size == 16) ? 0x7 : (size == 8) ? 0x4 : 0,
.unk = 1, /* XXX */
.invert_1 = invert_0,
packed_addr = bi_get_immediate(ins, 0);
} else {
/* Indirect gets an extra source */
- packed_addr = bi_get_src(ins, regs, 0, false) | 0b11000;
+ packed_addr = bi_get_src(ins, regs, 0) | 0b11000;
}
/* The destination is thrown in the data register */
assert(channels >= 1 && channels <= 4);
struct bifrost_ld_var pack = {
- .src0 = bi_get_src(ins, regs, 1, false),
+ .src0 = bi_get_src(ins, regs, 1),
.addr = packed_addr,
.channels = MALI_POSITIVE(channels),
.interp_mode = ins->load_vary.interp_mode,
bi_pack_add_2src(bi_instruction *ins, struct bi_registers *regs, unsigned op)
{
struct bifrost_add_2src pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.op = op
};
BIFROST_ADD_OP_FMAX32;
struct bifrost_add_faddmin pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.src0_abs = ins->src_abs[0],
.src1_abs = ins->src_abs[1],
.src0_neg = ins->src_neg[0],
assert(ins->outmod == BIFROST_NONE);
struct bifrost_add_faddmin pack = {
- .src0 = bi_get_src(ins, regs, 0, true),
- .src1 = bi_get_src(ins, regs, 1, true),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.src0_abs = ins->src_abs[0],
.src1_abs = ins->src_abs[1],
.src0_neg = ins->src_neg[0],
bi_pack_add_ld_var_addr(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs)
{
struct bifrost_ld_var_addr pack = {
- .src0 = bi_get_src(ins, regs, 1, false),
- .src1 = bi_get_src(ins, regs, 2, false),
+ .src0 = bi_get_src(ins, regs, 1),
+ .src1 = bi_get_src(ins, regs, 2),
.location = bi_get_immediate(ins, 0),
.type = bi_pack_ldst_type(ins->src_types[3]),
.op = BIFROST_ADD_OP_LD_VAR_ADDR
assert(ins->vector_channels >= 0 && ins->vector_channels <= 4);
struct bifrost_ld_attr pack = {
- .src0 = bi_get_src(ins, regs, 1, false),
- .src1 = bi_get_src(ins, regs, 2, false),
+ .src0 = bi_get_src(ins, regs, 1),
+ .src1 = bi_get_src(ins, regs, 2),
.location = bi_get_immediate(ins, 0),
.channels = MALI_POSITIVE(ins->vector_channels),
.type = bi_pack_ldst_type(ins->dest_type),
assert(ins->vector_channels >= 1 && ins->vector_channels <= 4);
struct bifrost_st_vary pack = {
- .src0 = bi_get_src(ins, regs, 1, false),
- .src1 = bi_get_src(ins, regs, 2, false),
- .src2 = bi_get_src(ins, regs, 3, false),
+ .src0 = bi_get_src(ins, regs, 1),
+ .src1 = bi_get_src(ins, regs, 2),
+ .src2 = bi_get_src(ins, regs, 3),
.channels = MALI_POSITIVE(ins->vector_channels),
.op = BIFROST_ADD_OP_ST_VAR
};
bool fp16 = (ins->src_types[1] == nir_type_float16);
struct bifrost_add_atest pack = {
- .src0 = bi_get_src(ins, regs, 0, false),
- .src1 = bi_get_src(ins, regs, 1, false),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.half = fp16,
.component = fp16 ? ins->swizzle[1][0] : 1, /* Set for fp32 */
.op = BIFROST_ADD_OP_ATEST,
bi_pack_add_blend(bi_clause *clause, bi_instruction *ins, struct bi_registers *regs)
{
struct bifrost_add_inst pack = {
- .src0 = bi_get_src(ins, regs, 1, false),
+ .src0 = bi_get_src(ins, regs, 1),
.op = BIFROST_ADD_OP_BLEND
};
bool vtx = stage != MESA_SHADER_FRAGMENT;
struct bifrost_tex_compact pack = {
- .src0 = bi_get_src(ins, regs, 0, false),
- .src1 = bi_get_src(ins, regs, 1, false),
+ .src0 = bi_get_src(ins, regs, 0),
+ .src1 = bi_get_src(ins, regs, 1),
.op = f16 ? BIFROST_ADD_OP_TEX_COMPACT_F16(vtx) :
BIFROST_ADD_OP_TEX_COMPACT_F32(vtx),
.compute_lod = !vtx,
enum bifrost_discard_cond cond = bi_cond_to_discard(ins->cond, &flip);
struct bifrost_add_discard pack = {
- .src0 = bi_get_src(ins, regs, flip ? 1 : 0, false),
- .src1 = bi_get_src(ins, regs, flip ? 0 : 1, false),
+ .src0 = bi_get_src(ins, regs, flip ? 1 : 0),
+ .src1 = bi_get_src(ins, regs, flip ? 0 : 1),
.cond = cond,
.src0_select = fp16 ? ins->swizzle[0][0] : 0,
.src1_select = fp16 ? ins->swizzle[1][0] : 0,
enum bifrost_icmp_cond cond)
{
struct bifrost_add_icmp pack = {
- .src0 = bi_get_src(ins, regs, flip ? 1 : 0, true),
- .src1 = bi_get_src(ins, regs, flip ? 0 : 1, true),
+ .src0 = bi_get_src(ins, regs, flip ? 1 : 0),
+ .src1 = bi_get_src(ins, regs, flip ? 0 : 1),
.cond = cond,
.sz = 1,
.d3d = false,
enum bifrost_icmp_cond cond)
{
struct bifrost_add_icmp16 pack = {
- .src0 = bi_get_src(ins, regs, flip ? 1 : 0, false),
- .src1 = bi_get_src(ins, regs, flip ? 0 : 1, false),
+ .src0 = bi_get_src(ins, regs, flip ? 1 : 0),
+ .src1 = bi_get_src(ins, regs, flip ? 0 : 1),
.src0_swizzle = bi_swiz16(ins, flip ? 1 : 0),
.src1_swizzle = bi_swiz16(ins, flip ? 0 : 1),
.cond = cond,