From 2c5835a33d2be64b9fcb3f37a41e025233ee28be Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 18 Jul 2013 15:28:37 -0400 Subject: [PATCH 1/2] radeonsi: Add helper function for emitting constant loads --- src/gallium/drivers/radeonsi/radeonsi_shader.c | 29 ++++++++++++++++++-------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c index fee6262..4d8a479 100644 --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c @@ -115,6 +115,22 @@ static LLVMValueRef build_indexed_load( return result; } +static LLVMValueRef build_constant_load( + struct si_shader_context * si_shader_ctx, + LLVMValueRef base_ptr, + LLVMValueRef offset) +{ + struct lp_build_context * base = + &si_shader_ctx->radeon_bld.soa.bld_base.base; + LLVMValueRef args[2]; + args[0] = base_ptr; + args[1] = offset; + return build_intrinsic(base->gallivm->builder, "llvm.SI.load.const", + base->elem_type, args, 2, + LLVMReadNoneAttribute | LLVMNoUnwindAttribute); + +} + static LLVMValueRef get_instance_index( struct radeon_llvm_context * radeon_bld, unsigned divisor) @@ -434,8 +450,7 @@ static LLVMValueRef fetch_constant( addr = lp_build_mul_imm(&bld_base->uint_bld, addr, 16); args[1] = lp_build_add(&bld_base->uint_bld, addr, args[1]); - result = build_intrinsic(base->gallivm->builder, "llvm.SI.load.const", base->elem_type, - args, 2, LLVMReadNoneAttribute | LLVMNoUnwindAttribute); + result = build_constant_load(si_shader_ctx, args[0], args[1]); return bitcast(bld_base, type, result); } @@ -594,11 +609,7 @@ static void si_llvm_emit_clipvertex(struct lp_build_tgsi_context * bld_base, args[1] = lp_build_const_int32(base->gallivm, ((reg_index * 4 + chan) * 4 + const_chan) * 4); - base_elt = build_intrinsic(base->gallivm->builder, - "llvm.SI.load.const", - base->elem_type, - args, 2, - LLVMReadNoneAttribute | LLVMNoUnwindAttribute); + base_elt = build_constant_load(si_shader_ctx, args[0], args[1]); args[5 + chan] = lp_build_add(base, args[5 + chan], lp_build_mul(base, base_elt, @@ -1287,8 +1298,8 @@ static void preload_constants(struct si_shader_context *si_shader_ctx) si_shader_ctx->const_resource, lp_build_const_int32(gallivm, i * 4) }; - si_shader_ctx->constants[i] = build_intrinsic(gallivm->builder, "llvm.SI.load.const", - bld_base->base.elem_type, args, 2, LLVMReadNoneAttribute | LLVMNoUnwindAttribute); + si_shader_ctx->constants[i] = build_constant_load(si_shader_ctx, + args[0], args[1]); } } -- 1.8.1.5