diff options
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_struct.c')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_struct.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_struct.c b/src/gallium/auxiliary/gallivm/lp_bld_struct.c index 4693c2de6f9..0dc2f24d10a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_struct.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_struct.c @@ -37,12 +37,13 @@ #include "util/u_debug.h" #include "util/u_memory.h" +#include "lp_bld_const.h" #include "lp_bld_debug.h" #include "lp_bld_struct.h" LLVMValueRef -lp_build_struct_get_ptr(LLVMBuilderRef builder, +lp_build_struct_get_ptr(struct gallivm_state *gallivm, LLVMValueRef ptr, unsigned member, const char *name) @@ -51,16 +52,16 @@ lp_build_struct_get_ptr(LLVMBuilderRef builder, LLVMValueRef member_ptr; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); - indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); - indices[1] = LLVMConstInt(LLVMInt32Type(), member, 0); - member_ptr = LLVMBuildGEP(builder, ptr, indices, Elements(indices), ""); + indices[0] = lp_build_const_int32(gallivm, 0); + indices[1] = lp_build_const_int32(gallivm, member); + member_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), ""); lp_build_name(member_ptr, "%s.%s_ptr", LLVMGetValueName(ptr), name); return member_ptr; } LLVMValueRef -lp_build_struct_get(LLVMBuilderRef builder, +lp_build_struct_get(struct gallivm_state *gallivm, LLVMValueRef ptr, unsigned member, const char *name) @@ -69,15 +70,15 @@ lp_build_struct_get(LLVMBuilderRef builder, LLVMValueRef res; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMStructTypeKind); - member_ptr = lp_build_struct_get_ptr(builder, ptr, member, name); - res = LLVMBuildLoad(builder, member_ptr, ""); + member_ptr = lp_build_struct_get_ptr(gallivm, ptr, member, name); + res = LLVMBuildLoad(gallivm->builder, member_ptr, ""); lp_build_name(res, "%s.%s", LLVMGetValueName(ptr), name); return res; } LLVMValueRef -lp_build_array_get_ptr(LLVMBuilderRef builder, +lp_build_array_get_ptr(struct gallivm_state *gallivm, LLVMValueRef ptr, LLVMValueRef index) { @@ -85,9 +86,9 @@ lp_build_array_get_ptr(LLVMBuilderRef builder, LLVMValueRef element_ptr; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind); - indices[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + indices[0] = lp_build_const_int32(gallivm, 0); indices[1] = index; - element_ptr = LLVMBuildGEP(builder, ptr, indices, Elements(indices), ""); + element_ptr = LLVMBuildGEP(gallivm->builder, ptr, indices, Elements(indices), ""); #ifdef DEBUG lp_build_name(element_ptr, "&%s[%s]", LLVMGetValueName(ptr), LLVMGetValueName(index)); @@ -97,7 +98,7 @@ lp_build_array_get_ptr(LLVMBuilderRef builder, LLVMValueRef -lp_build_array_get(LLVMBuilderRef builder, +lp_build_array_get(struct gallivm_state *gallivm, LLVMValueRef ptr, LLVMValueRef index) { @@ -105,8 +106,8 @@ lp_build_array_get(LLVMBuilderRef builder, LLVMValueRef res; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind); - element_ptr = lp_build_array_get_ptr(builder, ptr, index); - res = LLVMBuildLoad(builder, element_ptr, ""); + element_ptr = lp_build_array_get_ptr(gallivm, ptr, index); + res = LLVMBuildLoad(gallivm->builder, element_ptr, ""); #ifdef DEBUG lp_build_name(res, "%s[%s]", LLVMGetValueName(ptr), LLVMGetValueName(index)); #endif @@ -115,7 +116,7 @@ lp_build_array_get(LLVMBuilderRef builder, void -lp_build_array_set(LLVMBuilderRef builder, +lp_build_array_set(struct gallivm_state *gallivm, LLVMValueRef ptr, LLVMValueRef index, LLVMValueRef value) @@ -123,8 +124,8 @@ lp_build_array_set(LLVMBuilderRef builder, LLVMValueRef element_ptr; assert(LLVMGetTypeKind(LLVMTypeOf(ptr)) == LLVMPointerTypeKind); assert(LLVMGetTypeKind(LLVMGetElementType(LLVMTypeOf(ptr))) == LLVMArrayTypeKind); - element_ptr = lp_build_array_get_ptr(builder, ptr, index); - LLVMBuildStore(builder, value, element_ptr); + element_ptr = lp_build_array_get_ptr(gallivm, ptr, index); + LLVMBuildStore(gallivm->builder, value, element_ptr); } |