r600g: Glue to handle predicate aware output from llvm
authorVincent Lejeune <vljn@ovi.com>
Fri, 3 Aug 2012 22:15:51 +0000 (00:15 +0200)
committerTom Stellard <thomas.stellard@amd.com>
Wed, 15 Aug 2012 21:07:13 +0000 (21:07 +0000)
Signed-off-by: Tom Stellard <thomas.stellard@amd.com>
src/gallium/drivers/r600/r600_shader.c

index dfaff832e764f7cec7f288b103b0602550aa934f..3ca23c59ca25ae41f658643a92ce8b9386ca96d4 100644 (file)
@@ -293,6 +293,7 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
 {
        unsigned src_idx;
        unsigned inst0, inst1;
+       unsigned push_modifier;
        struct r600_bytecode_alu alu;
        memset(&alu, 0, sizeof(alu));
        for(src_idx = 0; src_idx < 3; src_idx++) {
@@ -310,12 +311,32 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
        alu.inst = inst0 | (inst1 << 8);
        alu.last = bytes[bytes_read++];
        alu.is_op3 = bytes[bytes_read++];
+       push_modifier = bytes[bytes_read++];
        alu.pred_sel = bytes[bytes_read++];
        alu.bank_swizzle = bytes[bytes_read++];
        alu.bank_swizzle_force = bytes[bytes_read++];
        alu.omod = bytes[bytes_read++];
        alu.index_mode = bytes[bytes_read++];
-       r600_bytecode_add_alu(ctx->bc, &alu);
+
+
+       if (alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE) ||
+           alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE) ||
+           alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETE_INT) ||
+           alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE_INT)) {
+               alu.update_pred = 1;
+               alu.dst.write = 0;
+               alu.src[1].sel = V_SQ_ALU_SRC_0;
+               alu.src[1].chan = 0;
+               alu.last = 1;
+    }
+
+    if (push_modifier) {
+        alu.pred_sel = 0;
+               alu.execute_mask = 1;
+               r600_bytecode_add_alu_type(ctx->bc, &alu, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE));
+       } else
+               r600_bytecode_add_alu(ctx->bc, &alu);
+
 
        /* XXX: Handle other KILL instructions */
        if (alu.inst == CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT)) {
@@ -329,16 +350,6 @@ static unsigned r600_alu_from_byte_stream(struct r600_shader_ctx *ctx,
 static void llvm_if(struct r600_shader_ctx *ctx, struct r600_bytecode_alu * alu,
        unsigned pred_inst)
 {
-       alu->inst = pred_inst; 
-       alu->execute_mask = 1;
-       alu->update_pred = 1;
-       alu->dst.write = 0;
-       alu->src[1].sel = V_SQ_ALU_SRC_0;
-       alu->src[1].chan = 0;
-       alu->last = 1;
-       r600_bytecode_add_alu_type(ctx->bc, alu,
-               CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE));
-
        r600_bytecode_add_cfinst(ctx->bc, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP));
        fc_pushlevel(ctx, FC_IF);
        callstack_check_depth(ctx, FC_PUSH_VPM, 0);