From 38d1456931ddd8294c02e4bf2bde9f63f9782ebf Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 6 Jun 2024 12:57:38 +0100 Subject: [PATCH] ac/llvm: remove push constants These are lowered in NIR. Signed-off-by: Rhys Perry Reviewed-by: Georg Lehmann Part-of: --- src/amd/llvm/ac_nir_to_llvm.c | 50 ----------------------------------- 1 file changed, 50 deletions(-) diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index 4ef8638ac5a..480896e7884 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -1515,53 +1515,6 @@ static LLVMValueRef build_tex_intrinsic(struct ac_nir_context *ctx, const nir_te return ac_build_image_opcode(&ctx->ac, args); } -static LLVMValueRef visit_load_push_constant(struct ac_nir_context *ctx, nir_intrinsic_instr *instr) -{ - LLVMValueRef ptr, addr; - LLVMValueRef src0 = get_src(ctx, instr->src[0]); - unsigned index = nir_intrinsic_base(instr); - assert(instr->def.bit_size >= 32); - - addr = LLVMConstInt(ctx->ac.i32, index, 0); - addr = LLVMBuildAdd(ctx->ac.builder, addr, src0, ""); - - /* Load constant values from user SGPRS when possible, otherwise - * fallback to the default path that loads directly from memory. - */ - if (LLVMIsConstant(src0)) { - unsigned count = instr->def.num_components; - unsigned offset = index; - - if (instr->def.bit_size == 64) - count *= 2; - - offset += LLVMConstIntGetZExtValue(src0); - offset /= 4; - - uint64_t mask = BITFIELD64_MASK(count) << offset; - if ((ctx->args->inline_push_const_mask | mask) == ctx->args->inline_push_const_mask && - offset + count <= (sizeof(ctx->args->inline_push_const_mask) * 8u)) { - LLVMValueRef *const push_constants = alloca(count * sizeof(LLVMValueRef)); - unsigned arg_index = - util_bitcount64(ctx->args->inline_push_const_mask & BITFIELD64_MASK(offset)); - for (unsigned i = 0; i < count; i++) - push_constants[i] = ac_get_arg(&ctx->ac, ctx->args->inline_push_consts[arg_index++]); - LLVMValueRef res = ac_build_gather_values(&ctx->ac, push_constants, count); - return instr->def.bit_size == 64 - ? LLVMBuildBitCast(ctx->ac.builder, res, get_def_type(ctx, &instr->def), "") - : res; - } - } - - struct ac_llvm_pointer pc = ac_get_ptr_arg(&ctx->ac, ctx->args, ctx->args->push_constants); - ptr = LLVMBuildGEP2(ctx->ac.builder, pc.t, pc.v, &addr, 1, ""); - - LLVMTypeRef ptr_type = get_def_type(ctx, &instr->def); - ptr = ac_cast_ptr(&ctx->ac, ptr, ptr_type); - - return LLVMBuildLoad2(ctx->ac.builder, ptr_type, ptr, ""); -} - static LLVMValueRef visit_get_ssbo_size(struct ac_nir_context *ctx, const nir_intrinsic_instr *instr) { @@ -3074,9 +3027,6 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins case nir_intrinsic_first_invocation: result = visit_first_invocation(ctx); break; - case nir_intrinsic_load_push_constant: - result = visit_load_push_constant(ctx, instr); - break; case nir_intrinsic_store_ssbo: visit_store_ssbo(ctx, instr); break;