diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 27633de0d0d..0763cb3f4d8 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -475,24 +475,6 @@ LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value) return ac_build_intrinsic(ctx, name, ctx->iN_wavemask, args, 3, 0); } -LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx, LLVMValueRef value) -{ - const char *name; - - if (ctx->wave_size == 64) - name = "llvm.amdgcn.icmp.i64.i1"; - else - name = "llvm.amdgcn.icmp.i32.i1"; - - LLVMValueRef args[3] = { - value, - ctx->i1false, - LLVMConstInt(ctx->i32, LLVMIntNE, 0), - }; - - return ac_build_intrinsic(ctx, name, ctx->iN_wavemask, args, 3, 0); -} - LLVMValueRef ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value) { LLVMValueRef active_set = ac_build_ballot(ctx, ctx->i32_1); @@ -507,17 +489,6 @@ LLVMValueRef ac_build_vote_any(struct ac_llvm_context *ctx, LLVMValueRef value) ""); } -LLVMValueRef ac_build_vote_eq(struct ac_llvm_context *ctx, LLVMValueRef value) -{ - LLVMValueRef active_set = ac_build_ballot(ctx, ctx->i32_1); - LLVMValueRef vote_set = ac_build_ballot(ctx, value); - - LLVMValueRef all = LLVMBuildICmp(ctx->builder, LLVMIntEQ, vote_set, active_set, ""); - LLVMValueRef none = - LLVMBuildICmp(ctx->builder, LLVMIntEQ, vote_set, LLVMConstInt(ctx->iN_wavemask, 0, 0), ""); - return LLVMBuildOr(ctx->builder, all, none, ""); -} - LLVMValueRef ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values, unsigned value_count, unsigned component) { @@ -643,21 +614,6 @@ LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx, LLVMValueRef v return ac_build_expand(ctx, value, num_channels, 4); } -LLVMValueRef ac_build_round(struct ac_llvm_context *ctx, LLVMValueRef value) -{ - unsigned type_size = ac_get_type_size(LLVMTypeOf(value)); - const char *name; - - if (type_size == 2) - name = "llvm.rint.f16"; - else if (type_size == 4) - name = "llvm.rint.f32"; - else - name = "llvm.rint.f64"; - - return ac_build_intrinsic(ctx, name, LLVMTypeOf(value), &value, 1, 0); -} - LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, LLVMValueRef num, LLVMValueRef den) { unsigned type_size = ac_get_type_size(LLVMTypeOf(den)); @@ -676,55 +632,6 @@ LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, LLVMValueRef num, LLVMVa return LLVMBuildFMul(ctx->builder, num, rcp, ""); } -/* See fast_idiv_by_const.h. */ -/* Set: increment = util_fast_udiv_info::increment ? multiplier : 0; */ -LLVMValueRef ac_build_fast_udiv(struct ac_llvm_context *ctx, LLVMValueRef num, - LLVMValueRef multiplier, LLVMValueRef pre_shift, - LLVMValueRef post_shift, LLVMValueRef increment) -{ - LLVMBuilderRef builder = ctx->builder; - - num = LLVMBuildLShr(builder, num, pre_shift, ""); - num = LLVMBuildMul(builder, LLVMBuildZExt(builder, num, ctx->i64, ""), - LLVMBuildZExt(builder, multiplier, ctx->i64, ""), ""); - num = LLVMBuildAdd(builder, num, LLVMBuildZExt(builder, increment, ctx->i64, ""), ""); - num = LLVMBuildLShr(builder, num, LLVMConstInt(ctx->i64, 32, 0), ""); - num = LLVMBuildTrunc(builder, num, ctx->i32, ""); - return LLVMBuildLShr(builder, num, post_shift, ""); -} - -/* See fast_idiv_by_const.h. */ -/* If num != UINT_MAX, this more efficient version can be used. */ -/* Set: increment = util_fast_udiv_info::increment; */ -LLVMValueRef ac_build_fast_udiv_nuw(struct ac_llvm_context *ctx, LLVMValueRef num, - LLVMValueRef multiplier, LLVMValueRef pre_shift, - LLVMValueRef post_shift, LLVMValueRef increment) -{ - LLVMBuilderRef builder = ctx->builder; - - num = LLVMBuildLShr(builder, num, pre_shift, ""); - num = LLVMBuildNUWAdd(builder, num, increment, ""); - num = LLVMBuildMul(builder, LLVMBuildZExt(builder, num, ctx->i64, ""), - LLVMBuildZExt(builder, multiplier, ctx->i64, ""), ""); - num = LLVMBuildLShr(builder, num, LLVMConstInt(ctx->i64, 32, 0), ""); - num = LLVMBuildTrunc(builder, num, ctx->i32, ""); - return LLVMBuildLShr(builder, num, post_shift, ""); -} - -/* See fast_idiv_by_const.h. */ -/* Both operands must fit in 31 bits and the divisor must not be 1. */ -LLVMValueRef ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context *ctx, LLVMValueRef num, - LLVMValueRef multiplier, LLVMValueRef post_shift) -{ - LLVMBuilderRef builder = ctx->builder; - - num = LLVMBuildMul(builder, LLVMBuildZExt(builder, num, ctx->i64, ""), - LLVMBuildZExt(builder, multiplier, ctx->i64, ""), ""); - num = LLVMBuildLShr(builder, num, LLVMConstInt(ctx->i64, 32, 0), ""); - num = LLVMBuildTrunc(builder, num, ctx->i32, ""); - return LLVMBuildLShr(builder, num, post_shift, ""); -} - LLVMValueRef ac_build_fs_interp(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan, LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i, LLVMValueRef j) @@ -863,34 +770,6 @@ LLVMValueRef ac_build_fs_interp_mov(struct ac_llvm_context *ctx, unsigned parame } } -LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, - LLVMValueRef index) -{ - return LLVMBuildGEP2(ctx->builder, type, base_ptr, &index, 1, ""); -} - -LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index) -{ - switch (LLVMGetTypeKind(pointee_type)) { - case LLVMPointerTypeKind: - return pointee_type; - case LLVMArrayTypeKind: - /* If input is a pointer to an array GEP2 will return a pointer to - * the array elements type. - */ - return LLVMGetElementType(pointee_type); - case LLVMStructTypeKind: - /* If input is a pointer to a struct, GEP2 will return a pointer to - * the index-nth field, so get its type. - */ - return LLVMStructGetTypeAtIndex(pointee_type, LLVMConstIntGetZExtValue(index)); - default: - /* gep0 shouldn't receive any other types. */ - assert(false); - } - return NULL; -} - LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { LLVMValueRef indices[2] = { @@ -901,11 +780,6 @@ LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, struct ac_llvm_pointer p return LLVMBuildGEP2(ctx->builder, ptr.t, ptr.v, indices, 2, ""); } -LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef ptr, LLVMValueRef index) -{ - return LLVMBuildGEP2(ctx->builder, type, ptr, &index, 1, ""); -} - void ac_build_indexed_store(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index, LLVMValueRef value) { @@ -961,11 +835,6 @@ static LLVMValueRef ac_build_load_custom(struct ac_llvm_context *ctx, LLVMTypeRe return result; } -LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) -{ - return ac_build_load_custom(ctx, ptr.t, ptr.v, index, false, false, false); -} - LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) { @@ -980,12 +849,6 @@ LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, struct ac_llvm_p return ac_build_load_custom(ctx, ptr.t, ptr.v, index, true, true, true); } -/* See ac_build_load_custom() documentation. */ -LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index) -{ - return ac_build_load_custom(ctx, ptr.t, ptr.v, index, true, true, false); -} - static unsigned get_cache_flags(struct ac_llvm_context *ctx, enum gl_access_qualifier access) { return ac_get_hw_cache_flags(ctx->gfx_level, access).value; @@ -1954,20 +1817,6 @@ LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_ return result; } -LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx, LLVMValueRef rsrc) -{ - LLVMValueRef samples; - - /* Read the samples from the descriptor directly. - * Hardware doesn't have any instruction for this. - */ - samples = LLVMBuildExtractElement(ctx->builder, rsrc, LLVMConstInt(ctx->i32, 3, 0), ""); - samples = LLVMBuildLShr(ctx->builder, samples, LLVMConstInt(ctx->i32, 16, 0), ""); - samples = LLVMBuildAnd(ctx->builder, samples, LLVMConstInt(ctx->i32, 0xf, 0), ""); - samples = LLVMBuildShl(ctx->builder, ctx->i32_1, samples, ""); - return samples; -} - LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx, LLVMValueRef args[2]) { return ac_build_intrinsic(ctx, "llvm.amdgcn.cvt.pkrtz", ctx->v2f16, args, 2, 0); @@ -2396,18 +2245,6 @@ void ac_declare_lds_as_pointer(struct ac_llvm_context *ctx) }; } -LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx, LLVMValueRef dw_addr) -{ - LLVMValueRef v = ac_build_gep0(ctx, ctx->lds, dw_addr); - return LLVMBuildLoad2(ctx->builder, ctx->i32, v, ""); -} - -void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef dw_addr, LLVMValueRef value) -{ - value = ac_to_integer(ctx, value); - ac_build_indexed_store(ctx, ctx->lds, dw_addr, value); -} - LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0) { unsigned src0_bitsize = ac_get_elem_bits(ctx, LLVMTypeOf(src0)); @@ -2667,26 +2504,6 @@ LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type, return res; } -LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name) -{ - LLVMValueRef ptr = ac_build_alloca_undef(ac, type, name); - LLVMBuildStore(ac->builder, LLVMConstNull(type), ptr); - return ptr; -} - -LLVMValueRef ac_build_alloca_init(struct ac_llvm_context *ac, LLVMValueRef val, const char *name) -{ - LLVMValueRef ptr = ac_build_alloca_undef(ac, LLVMTypeOf(val), name); - LLVMBuildStore(ac->builder, val, ptr); - return ptr; -} - -LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type) -{ - int addr_space = LLVMGetPointerAddressSpace(LLVMTypeOf(ptr)); - return LLVMBuildBitCast(ctx->builder, ptr, LLVMPointerType(type, addr_space), ""); -} - LLVMValueRef ac_trim_vector(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned count) { unsigned num_components = ac_get_llvm_num_components(value); @@ -2776,23 +2593,6 @@ static LLVMValueRef ac_build_readlane_common(struct ac_llvm_context *ctx, LLVMVa return LLVMBuildBitCast(ctx->builder, ret, src_type, ""); } -/** - * Builds the "llvm.amdgcn.readlane" or "llvm.amdgcn.readfirstlane" intrinsic. - * - * The optimization barrier is not needed if the value is the same in all lanes - * or if this is called in the outermost block. - * - * @param ctx - * @param src - * @param lane - id of the lane or NULL for the first active lane - * @return value of the lane - */ -LLVMValueRef ac_build_readlane_no_opt_barrier(struct ac_llvm_context *ctx, LLVMValueRef src, - LLVMValueRef lane) -{ - return ac_build_readlane_common(ctx, src, lane, false); -} - LLVMValueRef ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef lane) { return ac_build_readlane_common(ctx, src, lane, true); @@ -3897,13 +3697,6 @@ struct ac_llvm_pointer ac_build_main(const struct ac_shader_args *args, struct a return ctx->main_function; } -void ac_build_s_endpgm(struct ac_llvm_context *ctx) -{ - LLVMTypeRef calltype = LLVMFunctionType(ctx->voidt, NULL, 0, false); - LLVMValueRef code = LLVMConstInlineAsm(calltype, "s_endpgm", "", true, false); - LLVMBuildCall2(ctx->builder, calltype, code, NULL, 0, ""); -} - LLVMValueRef ac_build_is_inf_or_nan(struct ac_llvm_context *ctx, LLVMValueRef a) { LLVMValueRef args[2] = { diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h index 08b10ea7c75..e62540a131b 100644 --- a/src/amd/llvm/ac_llvm_build.h +++ b/src/amd/llvm/ac_llvm_build.h @@ -182,14 +182,11 @@ void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pg LLVMValueRef ac_build_shader_clock(struct ac_llvm_context *ctx, mesa_scope scope); LLVMValueRef ac_build_ballot(struct ac_llvm_context *ctx, LLVMValueRef value); -LLVMValueRef ac_get_i1_sgpr_mask(struct ac_llvm_context *ctx, LLVMValueRef value); LLVMValueRef ac_build_vote_all(struct ac_llvm_context *ctx, LLVMValueRef value); LLVMValueRef ac_build_vote_any(struct ac_llvm_context *ctx, LLVMValueRef value); -LLVMValueRef ac_build_vote_eq(struct ac_llvm_context *ctx, LLVMValueRef value); - LLVMValueRef ac_build_varying_gather_values(struct ac_llvm_context *ctx, LLVMValueRef *values, unsigned value_count, unsigned component); @@ -209,19 +206,8 @@ LLVMValueRef ac_build_expand(struct ac_llvm_context *ctx, LLVMValueRef value, LLVMValueRef ac_build_expand_to_vec4(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned num_channels); -LLVMValueRef ac_build_round(struct ac_llvm_context *ctx, LLVMValueRef value); - LLVMValueRef ac_build_fdiv(struct ac_llvm_context *ctx, LLVMValueRef num, LLVMValueRef den); -LLVMValueRef ac_build_fast_udiv(struct ac_llvm_context *ctx, LLVMValueRef num, - LLVMValueRef multiplier, LLVMValueRef pre_shift, - LLVMValueRef post_shift, LLVMValueRef increment); -LLVMValueRef ac_build_fast_udiv_nuw(struct ac_llvm_context *ctx, LLVMValueRef num, - LLVMValueRef multiplier, LLVMValueRef pre_shift, - LLVMValueRef post_shift, LLVMValueRef increment); -LLVMValueRef ac_build_fast_udiv_u31_d_not_one(struct ac_llvm_context *ctx, LLVMValueRef num, - LLVMValueRef multiplier, LLVMValueRef post_shift); - LLVMValueRef ac_build_fs_interp(struct ac_llvm_context *ctx, LLVMValueRef llvm_chan, LLVMValueRef attr_number, LLVMValueRef params, LLVMValueRef i, LLVMValueRef j); @@ -234,27 +220,16 @@ LLVMValueRef ac_build_fs_interp_mov(struct ac_llvm_context *ctx, unsigned parame LLVMValueRef llvm_chan, LLVMValueRef attr_number, LLVMValueRef params); -LLVMValueRef ac_build_gep_ptr(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef base_ptr, - LLVMValueRef index); - -LLVMValueRef ac_build_pointer_add(struct ac_llvm_context *ctx, LLVMTypeRef type, LLVMValueRef ptr, - LLVMValueRef index); - -LLVMTypeRef ac_build_gep0_type(LLVMTypeRef pointee_type, LLVMValueRef index); LLVMValueRef ac_build_gep0(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); void ac_build_indexed_store(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index, LLVMValueRef value); -LLVMValueRef ac_build_load(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); LLVMValueRef ac_build_load_invariant(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); LLVMValueRef ac_build_load_to_sgpr(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, LLVMValueRef index); -LLVMValueRef ac_build_load_to_sgpr_uint_wraparound(struct ac_llvm_context *ctx, struct ac_llvm_pointer ptr, - LLVMValueRef index); - void ac_build_buffer_store_dword(struct ac_llvm_context *ctx, LLVMValueRef rsrc, LLVMValueRef vdata, LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset, enum gl_access_qualifier access); @@ -395,7 +370,6 @@ struct ac_image_args { }; LLVMValueRef ac_build_image_opcode(struct ac_llvm_context *ctx, struct ac_image_args *a); -LLVMValueRef ac_build_image_get_sample_count(struct ac_llvm_context *ctx, LLVMValueRef rsrc); LLVMValueRef ac_build_cvt_pkrtz_f16(struct ac_llvm_context *ctx, LLVMValueRef args[2]); LLVMValueRef ac_build_cvt_pknorm_i16(struct ac_llvm_context *ctx, LLVMValueRef args[2]); LLVMValueRef ac_build_cvt_pknorm_u16(struct ac_llvm_context *ctx, LLVMValueRef args[2]); @@ -433,8 +407,6 @@ LLVMValueRef ac_build_sudot_4x8(struct ac_llvm_context *ctx, LLVMValueRef s0, LL void ac_init_exec_full_mask(struct ac_llvm_context *ctx); void ac_declare_lds_as_pointer(struct ac_llvm_context *ac); -LLVMValueRef ac_lds_load(struct ac_llvm_context *ctx, LLVMValueRef dw_addr); -void ac_lds_store(struct ac_llvm_context *ctx, LLVMValueRef dw_addr, LLVMValueRef value); LLVMValueRef ac_find_lsb(struct ac_llvm_context *ctx, LLVMTypeRef dst_type, LLVMValueRef src0); @@ -449,11 +421,7 @@ void ac_build_endif(struct ac_llvm_context *ctx, int lable_id); void ac_build_endloop(struct ac_llvm_context *ctx, int lable_id); void ac_build_ifcc(struct ac_llvm_context *ctx, LLVMValueRef cond, int label_id); -LLVMValueRef ac_build_alloca(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name); LLVMValueRef ac_build_alloca_undef(struct ac_llvm_context *ac, LLVMTypeRef type, const char *name); -LLVMValueRef ac_build_alloca_init(struct ac_llvm_context *ac, LLVMValueRef val, const char *name); - -LLVMValueRef ac_cast_ptr(struct ac_llvm_context *ctx, LLVMValueRef ptr, LLVMTypeRef type); LLVMValueRef ac_trim_vector(struct ac_llvm_context *ctx, LLVMValueRef value, unsigned count); @@ -462,9 +430,6 @@ LLVMValueRef ac_unpack_param(struct ac_llvm_context *ctx, LLVMValueRef param, un LLVMValueRef ac_build_ds_swizzle(struct ac_llvm_context *ctx, LLVMValueRef src, unsigned mask); -LLVMValueRef ac_build_readlane_no_opt_barrier(struct ac_llvm_context *ctx, LLVMValueRef src, - LLVMValueRef lane); - LLVMValueRef ac_build_readlane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef lane); LLVMValueRef ac_build_writelane(struct ac_llvm_context *ctx, LLVMValueRef src, LLVMValueRef value, @@ -551,7 +516,6 @@ enum ac_llvm_calling_convention struct ac_llvm_pointer ac_build_main(const struct ac_shader_args *args, struct ac_llvm_context *ctx, enum ac_llvm_calling_convention convention, const char *name, LLVMTypeRef ret_type, LLVMModuleRef module); -void ac_build_s_endpgm(struct ac_llvm_context *ctx); LLVMValueRef ac_build_is_inf_or_nan(struct ac_llvm_context *ctx, LLVMValueRef a); diff --git a/src/amd/llvm/ac_llvm_helper.cpp b/src/amd/llvm/ac_llvm_helper.cpp index 59800955ff2..e02c9c3fd07 100644 --- a/src/amd/llvm/ac_llvm_helper.cpp +++ b/src/amd/llvm/ac_llvm_helper.cpp @@ -92,14 +92,6 @@ void ac_add_attr_alignment(LLVMValueRef val, uint64_t bytes) A->addAttr(Attribute::getWithAlignment(A->getContext(), Align(bytes))); } -bool ac_is_sgpr_param(LLVMValueRef arg) -{ - Argument *A = unwrap(arg); - AttributeList AS = A->getParent()->getAttributes(); - unsigned ArgNo = A->getArgNo(); - return AS.hasParamAttr(ArgNo, Attribute::InReg); -} - LLVMModuleRef ac_create_module(LLVMTargetMachineRef tm, LLVMContextRef ctx) { TargetMachine *TM = reinterpret_cast(tm); @@ -184,11 +176,6 @@ struct raw_memory_ostream : public raw_pwrite_stream { free(buffer); } - void clear() - { - written = 0; - } - void take(char *&out_buffer, size_t &out_size) { out_buffer = buffer; diff --git a/src/amd/llvm/ac_llvm_util.h b/src/amd/llvm/ac_llvm_util.h index 4ab3cc47bf3..75a5db26dde 100644 --- a/src/amd/llvm/ac_llvm_util.h +++ b/src/amd/llvm/ac_llvm_util.h @@ -61,7 +61,6 @@ bool ac_is_llvm_processor_supported(LLVMTargetMachineRef tm, const char *process void ac_reset_llvm_all_options_occurrences(); void ac_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes); void ac_add_attr_alignment(LLVMValueRef val, uint64_t bytes); -bool ac_is_sgpr_param(LLVMValueRef param); LLVMAttributeRef ac_get_llvm_attribute(LLVMContextRef ctx, const char *str); void ac_add_function_attr(LLVMContextRef ctx, LLVMValueRef function, int attr_idx, const char *attr);