summaryrefslogtreecommitdiffstats
path: root/src/panfrost
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <[email protected]>2019-08-23 16:02:49 -0700
committerAlyssa Rosenzweig <[email protected]>2019-08-26 11:42:32 -0700
commit0acb5c1774d8759ca5ee4c61a13ee745768b4d2d (patch)
tree7ffd10281c5e18bc29a6f0e00978c8e7759cd328 /src/panfrost
parent2e1be771e47adf1d06901283ffb8df0d83f28b3c (diff)
pan/midgard: Switch constants to uint32
Storing constants as float doesn't make sense when we have integer instructions; better to switch to be integer natively and coerce to/from float rather than the opposite. Signed-off-by: Alyssa Rosenzweig <[email protected]>
Diffstat (limited to 'src/panfrost')
-rw-r--r--src/panfrost/midgard/compiler.h2
-rw-r--r--src/panfrost/midgard/midgard_compile.c14
-rw-r--r--src/panfrost/midgard/midgard_print.c11
3 files changed, 17 insertions, 10 deletions
diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h
index 75f9e4a93fc..a64bb55203d 100644
--- a/src/panfrost/midgard/compiler.h
+++ b/src/panfrost/midgard/compiler.h
@@ -109,7 +109,7 @@ typedef struct midgard_instruction {
bool precede_break;
bool has_constants;
- float constants[4];
+ uint32_t constants[4];
uint16_t inline_constant;
bool has_blend_constant;
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 8000f72c9cf..be4318d371a 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -1096,11 +1096,10 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
ins.has_constants = true;
if (instr->op == nir_op_b2f32) {
- ins.constants[0] = 1.0f;
+ float f = 1.0f;
+ memcpy(&ins.constants, &f, sizeof(float));
} else {
- /* Type pun it into place */
- uint32_t one = 0x1;
- memcpy(&ins.constants[0], &one, sizeof(uint32_t));
+ ins.constants[0] = 1;
}
ins.alu.src2 = vector_alu_srco_unsigned(blank_alu_src_xxxx);
@@ -1109,7 +1108,7 @@ emit_alu(compiler_context *ctx, nir_alu_instr *instr)
ins.ssa_args.inline_constant = false;
ins.ssa_args.src[1] = SSA_FIXED_REGISTER(REGISTER_CONSTANT);
ins.has_constants = true;
- ins.constants[0] = 0.0f;
+ ins.constants[0] = 0;
ins.alu.src2 = vector_alu_srco_unsigned(blank_alu_src_xxxx);
} else if (instr->op == nir_op_inot) {
ins.invert = true;
@@ -2108,7 +2107,8 @@ embedded_to_inline_constant(compiler_context *ctx)
if (scaled_constant != iconstants[component])
continue;
} else {
- float original = (float) ins->constants[component];
+ float *f = (float *) ins->constants;
+ float original = f[component];
scaled_constant = _mesa_float_to_half(original);
/* Check for loss of precision. If this is
@@ -2135,7 +2135,7 @@ embedded_to_inline_constant(compiler_context *ctx)
* vector by checking if all accessed values
* (by the swizzle) are the same. */
- uint32_t *cons = (uint32_t *) ins->constants;
+ uint32_t *cons = ins->constants;
uint32_t value = cons[component];
bool is_vector = false;
diff --git a/src/panfrost/midgard/midgard_print.c b/src/panfrost/midgard/midgard_print.c
index add40511d2f..871d1c5a6de 100644
--- a/src/panfrost/midgard/midgard_print.c
+++ b/src/panfrost/midgard/midgard_print.c
@@ -148,8 +148,15 @@ mir_print_instruction(midgard_instruction *ins)
printf(", ");
mir_print_index(args->src[2]);
- if (ins->has_constants)
- printf(" <%f, %f, %f, %f>", ins->constants[0], ins->constants[1], ins->constants[2], ins->constants[3]);
+ if (ins->has_constants) {
+ uint32_t *uc = ins->constants;
+ float *fc = (float *) uc;
+
+ if (midgard_is_integer_op(ins->alu.op))
+ printf(" <0x%X, 0x%X, 0x%X, 0x%x>", uc[0], uc[1], uc[2], uc[3]);
+ else
+ printf(" <%f, %f, %f, %f>", fc[0], fc[1], fc[2], fc[3]);
+ }
if (ins->no_spill)
printf(" /* no spill */");