Commit df0a8d89 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Begin emitting ALU ops

parent 0555a74e
......@@ -151,6 +151,28 @@ __attribute__((__packed__))
unsigned output_component : 3;
} midgard_scalar_alu_t;
/* ALU control words are single bit fields with a lot of space */
#define ALU_ENAB_VEC_MUL (1 << 17)
#define ALU_ENAB_SCAL_ADD (1 << 19)
#define ALU_ENAB_VEC_ADD (1 << 21)
#define ALU_ENAB_SCAL_MUL (1 << 23)
#define ALU_ENAB_LUT (1 << 25)
#define ALU_ENAB_MUL_2 (1 << 25)
#define ALU_ENAB_WRITE (1 << 26)
#define ALU_ENAB_BRANCH (1 << 27)
/* ALU register fields are weird because of inline constants */
typedef struct
__attribute__((__packed__))
{
unsigned input1_reg : 5;
unsigned input2_reg : 5;
unsigned output_reg : 5;
unsigned inline_2 : 1;
} alu_register_word;
typedef struct
__attribute__((__packed__))
{
......
......@@ -47,6 +47,7 @@
typedef struct midgard_instruction {
midgard_word_type type; /* ALU, load/store, texture */
bool vector; /* If it's an ALU instruction */
union {
midgard_load_store_word_t load_store;
midgard_scalar_alu_t scalar_alu;
......@@ -126,7 +127,12 @@ emit_load_const(compiler_context *ctx, nir_load_const_instr *instr)
instr->value.f32[3]);
midgard_instruction ins = { .type = TAG_ALU_4 };
ins.vector = true;
ins.vector_alu.op = midgard_alu_op_fmov;
ins.vector_alu.reg_mode = midgard_reg_mode_full;
ins.vector_alu.dest_override = midgard_dest_override_none;
ins.vector_alu.outmod = midgard_outmod_none;
ins.vector_alu.mask = 0xFF;
util_dynarray_append(&ctx->current_block, midgard_instruction, ins);
} else {
printf("Unknown configuration in load_const %d x %d\n", def.num_components, def.bit_size);
......@@ -251,9 +257,31 @@ emit_binary_instruction(compiler_context *ctx, midgard_instruction *ins, struct
case TAG_ALU_4:
case TAG_ALU_8:
case TAG_ALU_12:
case TAG_ALU_16:
case TAG_ALU_16: {
uint32_t control = tag;
/* TODO: Determine which units need to be enabled */
if (ins->vector) {
control |= ALU_ENAB_VEC_ADD;
/* TODO */
alu_register_word word = {
.input1_reg = 0,
.input2_reg = 0,
.output_reg = 0
};
util_dynarray_append(emission, uint32_t, control);
util_dynarray_append(emission, alu_register_word, word);
util_dynarray_append(emission, midgard_vector_alu_t, ins->vector_alu);
} else {
control |= ALU_ENAB_SCAL_ADD;
}
printf("ALU instruction\n");
break;
}
case TAG_LOAD_STORE_4: {
printf("Load store\n");
......
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