ac/nir: move cast_ptr() to ac_llvm_build.c
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 9 Mar 2018 15:26:34 +0000 (16:26 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 13 Mar 2018 13:05:06 +0000 (14:05 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/amd/common/ac_nir_to_llvm.c

index 8d4f114a65bb529e93d4e5d330e21c4d3f042127..0a02ee38c15a7580d5958dbdda7d855db04c0852 100644 (file)
@@ -2368,3 +2368,11 @@ LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac,
        LLVMBuildStore(ac->builder, LLVMGetUndef(type), ptr);
        return ptr;
 }
+
+LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr,
+                         LLVMTypeRef type)
+{
+       int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
+       return LLVMBuildBitCast(ctx->builder, ptr,
+                               LLVMPointerType(type, addr_space), "");
+}
index 2587c94315c6e31e95040a13e9344a5f8be04182..33d392315716e34f11bcf522fe4a2e4d7ca74e7c 100644 (file)
@@ -395,6 +395,9 @@ LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type,
 LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type,
                                   const char *name);
 
+LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr,
+                        LLVMTypeRef type);
+
 #ifdef __cplusplus
 }
 #endif
index 9f2219a5467bafbafeee3e08e9b13a3938896c51..c57568f7b2414bc71360242f6ed1b72c9b862853 100644 (file)
@@ -2090,14 +2090,6 @@ static void visit_load_const(struct ac_nir_context *ctx,
        _mesa_hash_table_insert(ctx->defs, &instr->def, value);
 }
 
-static LLVMValueRef cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr,
-                             LLVMTypeRef type)
-{
-       int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr));
-       return LLVMBuildBitCast(ctx->builder, ptr,
-                               LLVMPointerType(type, addr_space), "");
-}
-
 static LLVMValueRef
 get_buffer_size(struct ac_nir_context *ctx, LLVMValueRef descriptor, bool in_elements)
 {
@@ -2352,7 +2344,7 @@ radv_load_resource(struct ac_shader_abi *abi, LLVMValueRef index,
        offset = LLVMBuildAdd(ctx->ac.builder, offset, index, "");
        
        desc_ptr = ac_build_gep0(&ctx->ac, desc_ptr, offset);
-       desc_ptr = cast_ptr(&ctx->ac, desc_ptr, ctx->ac.v4i32);
+       desc_ptr = ac_cast_ptr(&ctx->ac, desc_ptr, ctx->ac.v4i32);
        LLVMSetMetadata(desc_ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
 
        return desc_ptr;
@@ -2379,7 +2371,7 @@ static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx,
                            get_src(ctx, instr->src[0]), "");
 
        ptr = ac_build_gep0(&ctx->ac, ctx->abi->push_constants, addr);
-       ptr = cast_ptr(&ctx->ac, ptr, get_def_type(ctx, &instr->dest.ssa));
+       ptr = ac_cast_ptr(&ctx->ac, ptr, get_def_type(ctx, &instr->dest.ssa));
 
        return LLVMBuildLoad(ctx->ac.builder, ptr, "");
 }