void mir_insert_instruction_before_scheduled(compiler_context *ctx, midgard_block *block, midgard_instruction *tag, midgard_instruction ins);
void mir_insert_instruction_after_scheduled(compiler_context *ctx, midgard_block *block, midgard_instruction *tag, midgard_instruction ins);
+void mir_flip(midgard_instruction *ins);
/* MIR goodies */
if (both) {
ins->alu.op = mir_demorgan_op(ins->alu.op);
} else if (right || (left && !ins->has_inline_constant)) {
- if (left) {
- /* Commute */
- unsigned temp = ins->src[0];
- ins->src[0] = ins->src[1];
- ins->src[1] = temp;
-
- temp = ins->alu.src1;
- ins->alu.src1 = ins->alu.src2;
- ins->alu.src2 = temp;
- }
+ /* Commute arguments */
+ if (left)
+ mir_flip(ins);
ins->alu.op = mir_notright_op(ins->alu.op);
} else if (left && ins->has_inline_constant) {
memcpy(bundles + after + 1, &new, sizeof(new));
list_addtail(&new.instructions[0]->link, &after_bundle_1->instructions[0]->link);
}
+
+/* Flip the first-two arguments of a (binary) op. Currently ALU
+ * only, no known uses for ldst/tex */
+
+void
+mir_flip(midgard_instruction *ins)
+{
+ unsigned temp = ins->src[0];
+ ins->src[0] = ins->src[1];
+ ins->src[1] = temp;
+
+ assert(ins->type == TAG_ALU_4);
+
+ temp = ins->alu.src1;
+ ins->alu.src1 = ins->alu.src2;
+ ins->alu.src2 = temp;
+}