LLVMValueRef offset;
LLVMValueRef ptr;
- assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0));
+ ASSERTED LLVMTypeRef element_type = LLVMInt8TypeInContext(gallivm->context);
+ assert(LLVMTypeOf(base_ptr) == LLVMPointerType(element_type, 0));
if (length == 1) {
assert(i == 0);
offset = LLVMBuildExtractElement(gallivm->builder, offsets, index, "");
}
- ptr = LLVMBuildGEP(gallivm->builder, base_ptr, &offset, 1, "");
+ ptr = LLVMBuildGEP2(gallivm->builder, element_type, base_ptr, &offset, 1, "");
return ptr;
}
boolean vector_justify)
{
LLVMTypeRef src_type = LLVMIntTypeInContext(gallivm->context, src_width);
- LLVMTypeRef src_ptr_type = LLVMPointerType(src_type, 0);
LLVMTypeRef dst_elem_type = LLVMIntTypeInContext(gallivm->context, dst_width);
LLVMValueRef ptr;
LLVMValueRef res;
assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0));
ptr = lp_build_gather_elem_ptr(gallivm, length, base_ptr, offsets, i);
- ptr = LLVMBuildBitCast(gallivm->builder, ptr, src_ptr_type, "");
- res = LLVMBuildLoad(gallivm->builder, ptr, "");
+ ptr = LLVMBuildBitCast(gallivm->builder, ptr, LLVMPointerType(src_type, 0), "");
+ res = LLVMBuildLoad2(gallivm->builder, src_type, ptr, "");
/* XXX
* On some archs we probably really want to avoid having to deal
boolean vector_justify)
{
LLVMValueRef ptr, res;
- LLVMTypeRef src_ptr_type = LLVMPointerType(src_type, 0);
assert(LLVMTypeOf(base_ptr) == LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0));
ptr = lp_build_gather_elem_ptr(gallivm, length, base_ptr, offsets, i);
- ptr = LLVMBuildBitCast(gallivm->builder, ptr, src_ptr_type, "");
- res = LLVMBuildLoad(gallivm->builder, ptr, "");
+ ptr = LLVMBuildBitCast(gallivm->builder, ptr, LLVMPointerType(src_type, 0), "");
+ res = LLVMBuildLoad2(gallivm->builder, src_type, ptr, "");
/* XXX
* On some archs we probably really want to avoid having to deal
assert(LLVMTypeOf(offsets) == i32_vec_type);
offsets = LLVMBuildSDiv(builder, offsets, scale, "");
- src_ptr = LLVMBuildGEP(builder, base_ptr, &offsets, 1, "vector-gep");
+ src_ptr = LLVMBuildGEP2(builder, src_type, base_ptr, &offsets, 1, "vector-gep");
char intrinsic[64];
snprintf(intrinsic, sizeof intrinsic, "llvm.masked.gather.v%u%s%u",