radeonsi: pass llvm type to si_llvm_emit_fetch_64bit()
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 7 Nov 2017 10:27:18 +0000 (21:27 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 4 Dec 2017 01:52:18 +0000 (12:52 +1100)
v2: use LLVMBuildBitCast() directly

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader_internal.h
src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c

index e8b4ec7b98633422e2d894c33bac0b394d529998..c3b5f58cd26a9bc788bdc0aea401f898a76f8ebd 100644 (file)
@@ -1063,7 +1063,8 @@ 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, type, value, value2);
+       return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
+                                       value, value2);
 }
 
 /**
@@ -1096,7 +1097,8 @@ static LLVMValueRef lds_load(struct lp_build_tgsi_context *bld_base,
 
                lo = lds_load(bld_base, TGSI_TYPE_UNSIGNED, swizzle, dw_addr);
                hi = lds_load(bld_base, TGSI_TYPE_UNSIGNED, swizzle + 1, dw_addr);
-               return si_llvm_emit_fetch_64bit(bld_base, type, lo, hi);
+               return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
+                                               lo, hi);
        }
 
        dw_addr = lp_build_add(&bld_base->uint_bld, dw_addr,
@@ -1375,7 +1377,7 @@ static LLVMValueRef fetch_input_gs(
                value2 = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1,
                                              ctx->i32_0, vtx_offset, soffset,
                                              0, 1, 0, true, false);
-               return si_llvm_emit_fetch_64bit(bld_base, type,
+               return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
                                                value, value2);
        }
        return bitcast(bld_base, type, value);
@@ -1978,7 +1980,8 @@ static LLVMValueRef fetch_constant(
 
                lo = fetch_constant(bld_base, reg, TGSI_TYPE_UNSIGNED, swizzle);
                hi = fetch_constant(bld_base, reg, TGSI_TYPE_UNSIGNED, swizzle + 1);
-               return si_llvm_emit_fetch_64bit(bld_base, type, lo, hi);
+               return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
+                                               lo, hi);
        }
 
        idx = reg->Register.Index * 4 + swizzle;
index 4bd128ef56c5d8fe344144953d6dd7277242d45c..e7c097c5fce35442ebe52cd0a130e5bf29e97863 100644 (file)
@@ -268,7 +268,7 @@ void si_llvm_dispose(struct si_shader_context *ctx);
 void si_llvm_optimize_module(struct si_shader_context *ctx);
 
 LLVMValueRef si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base,
-                                     enum tgsi_opcode_type type,
+                                     LLVMTypeRef type,
                                      LLVMValueRef ptr,
                                      LLVMValueRef ptr2);
 
index e965fa7c415ec1d3cddd6089ff0a6595b9077b8c..0843b3c63c00a981e086eeb89ea55bfc788ef921 100644 (file)
@@ -399,7 +399,7 @@ get_pointer_into_array(struct si_shader_context *ctx,
 
 LLVMValueRef
 si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base,
-                        enum tgsi_opcode_type type,
+                        LLVMTypeRef type,
                         LLVMValueRef ptr,
                         LLVMValueRef ptr2)
 {
@@ -416,7 +416,7 @@ si_llvm_emit_fetch_64bit(struct lp_build_tgsi_context *bld_base,
                                        result,
                                        ac_to_integer(&ctx->ac, ptr2),
                                        ctx->i32_1, "");
-       return bitcast(bld_base, type, result);
+       return LLVMBuildBitCast(ctx->ac.builder, result, type, "");
 }
 
 static LLVMValueRef
@@ -461,7 +461,8 @@ load_value_from_array(struct lp_build_tgsi_context *bld_base,
                        LLVMValueRef ptr_hi, val_hi;
                        ptr_hi = LLVMBuildGEP(builder, ptr, &ctx->i32_1, 1, "");
                        val_hi = LLVMBuildLoad(builder, ptr_hi, "");
-                       val = si_llvm_emit_fetch_64bit(bld_base, type, val, val_hi);
+                       val = si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
+                                                      val, val_hi);
                }
 
                return val;
@@ -609,7 +610,8 @@ LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base,
                if (tgsi_type_is_64bit(type)) {
                        ptr = result;
                        ptr2 = input[swizzle + 1];
-                       return si_llvm_emit_fetch_64bit(bld_base, type, ptr, ptr2);
+                       return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
+                                                       ptr, ptr2);
                }
                break;
        }
@@ -620,7 +622,7 @@ LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base,
                ptr = ctx->temps[reg->Register.Index * TGSI_NUM_CHANNELS + swizzle];
                if (tgsi_type_is_64bit(type)) {
                        ptr2 = ctx->temps[reg->Register.Index * TGSI_NUM_CHANNELS + swizzle + 1];
-                       return si_llvm_emit_fetch_64bit(bld_base, type,
+                       return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
                                                        LLVMBuildLoad(builder, ptr, ""),
                                                        LLVMBuildLoad(builder, ptr2, ""));
                }
@@ -631,7 +633,7 @@ LLVMValueRef si_llvm_emit_fetch(struct lp_build_tgsi_context *bld_base,
                ptr = get_output_ptr(bld_base, reg->Register.Index, swizzle);
                if (tgsi_type_is_64bit(type)) {
                        ptr2 = get_output_ptr(bld_base, reg->Register.Index, swizzle + 1);
-                       return si_llvm_emit_fetch_64bit(bld_base, type,
+                       return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
                                                        LLVMBuildLoad(builder, ptr, ""),
                                                        LLVMBuildLoad(builder, ptr2, ""));
                }
@@ -664,7 +666,8 @@ static LLVMValueRef fetch_system_value(struct lp_build_tgsi_context *bld_base,
                hi = LLVMBuildExtractElement(
                        builder, cval, LLVMConstInt(ctx->i32, swizzle + 1, 0), "");
 
-               return si_llvm_emit_fetch_64bit(bld_base, type, lo, hi);
+               return si_llvm_emit_fetch_64bit(bld_base, tgsi2llvmtype(bld_base, type),
+                                               lo, hi);
        }
 
        if (LLVMGetTypeKind(LLVMTypeOf(cval)) == LLVMVectorTypeKind) {