return range;
}
-static LLVMValueRef
-emit_array_index(struct si_shader_context *ctx,
- const struct tgsi_ind_register *reg,
- unsigned offset)
-{
- struct gallivm_state *gallivm = &ctx->gallivm;
-
- if (!reg) {
- return LLVMConstInt(ctx->i32, offset, 0);
- }
- LLVMValueRef addr = LLVMBuildLoad(gallivm->builder, ctx->addrs[reg->Index][reg->Swizzle], "");
- return LLVMBuildAdd(gallivm->builder, addr, LLVMConstInt(ctx->i32, offset, 0), "");
-}
-
/**
* For indirect registers, construct a pointer directly to the requested
* element using getelementptr if possible.
if (!(array->writemask & (1 << swizzle)))
return ctx->undef_alloca;
- index = emit_array_index(ctx, reg_indirect,
- reg_index - ctx->temp_arrays[array_id - 1].range.First);
+ index = si_get_indirect_index(ctx, reg_indirect, 1,
+ reg_index - ctx->temp_arrays[array_id - 1].range.First);
/* Ensure that the index is within a valid range, to guard against
* VM faults and overwriting critical data (e.g. spilled resource
struct tgsi_declaration_range range =
get_array_range(bld_base, file, reg_index, reg_indirect);
LLVMValueRef index =
- emit_array_index(ctx, reg_indirect, reg_index - range.First);
+ si_get_indirect_index(ctx, reg_indirect, 1, reg_index - range.First);
LLVMValueRef array =
emit_array_fetch(bld_base, file, type, range, swizzle);
return LLVMBuildExtractElement(builder, array, index, "");
} else {
unsigned i, size;
struct tgsi_declaration_range range = get_array_range(bld_base, file, reg_index, reg_indirect);
- LLVMValueRef index = emit_array_index(ctx, reg_indirect, reg_index - range.First);
+ LLVMValueRef index = si_get_indirect_index(ctx, reg_indirect, 1, reg_index - range.First);
LLVMValueRef array =
emit_array_fetch(bld_base, file, TGSI_TYPE_FLOAT, range, chan_index);
LLVMValueRef temp_ptr;