radeonsi: pass llvm type directly to buffer_load()
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 23 Nov 2017 00:29:59 +0000 (11:29 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 5 Dec 2017 04:15:36 +0000 (15:15 +1100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c

index a94c2af8709d53649434534f40bc4af55371dbf7..6a1293b99d1ac8da911ab663489ea798f69e2bb6 100644 (file)
@@ -1041,14 +1041,13 @@ static LLVMValueRef get_tcs_tes_buffer_address_from_reg(
 }
 
 static LLVMValueRef buffer_load(struct lp_build_tgsi_context *bld_base,
-                                enum tgsi_opcode_type type, unsigned swizzle,
+                                LLVMTypeRef type, unsigned swizzle,
                                 LLVMValueRef buffer, LLVMValueRef offset,
                                 LLVMValueRef base, bool can_speculate)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
        LLVMValueRef value, value2;
-       LLVMTypeRef llvm_type = tgsi2llvmtype(bld_base, type);
-       LLVMTypeRef vec_type = LLVMVectorType(llvm_type, 4);
+       LLVMTypeRef vec_type = LLVMVectorType(type, 4);
 
        if (swizzle == ~0) {
                value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset,
@@ -1057,7 +1056,7 @@ static LLVMValueRef buffer_load(struct lp_build_tgsi_context *bld_base,
                return LLVMBuildBitCast(ctx->ac.builder, value, vec_type, "");
        }
 
-       if (!tgsi_type_is_64bit(type)) {
+       if (!llvm_type_is_64bit(ctx, type)) {
                value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset,
                                             0, 1, 0, can_speculate, false);
 
@@ -1072,8 +1071,7 @@ static LLVMValueRef buffer_load(struct lp_build_tgsi_context *bld_base,
        value2 = ac_build_buffer_load(&ctx->ac, buffer, 1, NULL, base, offset,
                                   swizzle * 4 + 4, 1, 0, can_speculate, false);
 
-       return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
-                                       value, value2);
+       return si_llvm_emit_fetch_64bit(bld_base, type, value, value2);
 }
 
 /**
@@ -1206,7 +1204,8 @@ static LLVMValueRef fetch_input_tes(
        base = LLVMGetParam(ctx->main_fn, ctx->param_tcs_offchip_offset);
        addr = get_tcs_tes_buffer_address_from_reg(ctx, NULL, reg);
 
-       return buffer_load(bld_base, type, swizzle, buffer, base, addr, true);
+       return buffer_load(bld_base, tgsi2llvmtype(bld_base, type), swizzle,
+                          buffer, base, addr, true);
 }
 
 static void store_output_tcs(struct lp_build_tgsi_context *bld_base,
@@ -1788,7 +1787,7 @@ void si_load_system_value(struct si_shader_context *ctx,
                addr = get_tcs_tes_buffer_address(ctx, get_rel_patch_id(ctx), NULL,
                                          LLVMConstInt(ctx->i32, param, 0));
 
-               value = buffer_load(&ctx->bld_base, TGSI_TYPE_FLOAT,
+               value = buffer_load(&ctx->bld_base, ctx->f32,
                                    ~0, buffer, base, addr, true);
 
                break;