From: Nicolai Hähnle <nicolai.haeh...@amd.com> --- src/amd/common/ac_llvm_build.c | 5 ++++- src/amd/common/ac_llvm_build.h | 7 ++++++- src/amd/common/ac_nir_to_llvm.c | 4 ++-- src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c | 2 +- 4 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c index 7193b80be59..4077bd81bbc 100644 --- a/src/amd/common/ac_llvm_build.c +++ b/src/amd/common/ac_llvm_build.c @@ -39,24 +39,27 @@ #include "util/u_atomic.h" #include "sid.h" #include "shader_enums.h" /* Initialize module-independent parts of the context. * * The caller is responsible for initializing ctx::module and ctx::builder. */ void -ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context) +ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context, + enum chip_class chip_class) { LLVMValueRef args[1]; + ctx->chip_class = chip_class; + ctx->context = context; ctx->module = NULL; ctx->builder = NULL; ctx->voidt = LLVMVoidTypeInContext(ctx->context); ctx->i1 = LLVMInt1TypeInContext(ctx->context); ctx->i8 = LLVMInt8TypeInContext(ctx->context); ctx->i16 = LLVMIntTypeInContext(ctx->context, 16); ctx->i32 = LLVMIntTypeInContext(ctx->context, 32); ctx->i64 = LLVMIntTypeInContext(ctx->context, 64); diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h index 14ec03f5c84..b6434893cfa 100644 --- a/src/amd/common/ac_llvm_build.h +++ b/src/amd/common/ac_llvm_build.h @@ -21,20 +21,22 @@ * next paragraph) shall be included in all copies or substantial portions * of the Software. * */ #ifndef AC_LLVM_BUILD_H #define AC_LLVM_BUILD_H #include <stdbool.h> #include <llvm-c/TargetMachine.h> +#include "amd_family.h" + #ifdef __cplusplus extern "C" { #endif struct ac_llvm_context { LLVMContextRef context; LLVMModuleRef module; LLVMBuilderRef builder; LLVMTypeRef voidt; @@ -54,24 +56,27 @@ struct ac_llvm_context { LLVMValueRef i32_1; LLVMValueRef f32_0; LLVMValueRef f32_1; unsigned range_md_kind; unsigned invariant_load_md_kind; unsigned uniform_md_kind; unsigned fpmath_md_kind; LLVMValueRef fpmath_md_2p5_ulp; LLVMValueRef empty_md; + + enum chip_class chip_class; }; void -ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context); +ac_llvm_context_init(struct ac_llvm_context *ctx, LLVMContextRef context, + enum chip_class chip_class); unsigned ac_get_type_size(LLVMTypeRef type); LLVMTypeRef ac_to_integer_type(struct ac_llvm_context *ctx, LLVMTypeRef t); LLVMValueRef ac_to_integer(struct ac_llvm_context *ctx, LLVMValueRef v); LLVMTypeRef ac_to_float_type(struct ac_llvm_context *ctx, LLVMTypeRef t); LLVMValueRef ac_to_float(struct ac_llvm_context *ctx, LLVMValueRef v); LLVMValueRef ac_build_intrinsic(struct ac_llvm_context *ctx, const char *name, diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index 8b0d0ec23e8..c0c4441022a 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -6321,21 +6321,21 @@ LLVMModuleRef ac_translate_nir_to_llvm(LLVMTargetMachineRef tm, struct ac_shader_variant_info *shader_info, const struct ac_nir_compiler_options *options) { struct nir_to_llvm_context ctx = {0}; unsigned i; ctx.options = options; ctx.shader_info = shader_info; ctx.context = LLVMContextCreate(); ctx.module = LLVMModuleCreateWithNameInContext("shader", ctx.context); - ac_llvm_context_init(&ctx.ac, ctx.context); + ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class); ctx.ac.module = ctx.module; memset(shader_info, 0, sizeof(*shader_info)); ac_nir_shader_info_pass(nir, options, &shader_info->info); LLVMSetTarget(ctx.module, options->supports_spill ? "amdgcn-mesa-mesa3d" : "amdgcn--"); LLVMTargetDataRef data_layout = LLVMCreateTargetDataLayout(tm); char *data_layout_str = LLVMCopyStringRepOfTargetData(data_layout); @@ -6645,21 +6645,21 @@ void ac_create_gs_copy_shader(LLVMTargetMachineRef tm, struct ac_shader_variant_info *shader_info, const struct ac_nir_compiler_options *options, bool dump_shader) { struct nir_to_llvm_context ctx = {0}; ctx.context = LLVMContextCreate(); ctx.module = LLVMModuleCreateWithNameInContext("shader", ctx.context); ctx.options = options; ctx.shader_info = shader_info; - ac_llvm_context_init(&ctx.ac, ctx.context); + ac_llvm_context_init(&ctx.ac, ctx.context, options->chip_class); ctx.ac.module = ctx.module; ctx.is_gs_copy_shader = true; LLVMSetTarget(ctx.module, "amdgcn--"); setup_types(&ctx); ctx.builder = LLVMCreateBuilderInContext(ctx.context); ctx.ac.builder = ctx.builder; ctx.stage = MESA_SHADER_VERTEX; diff --git a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c index 231f16f049d..0ad394d461e 100644 --- a/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c +++ b/src/gallium/drivers/radeonsi/si_shader_tgsi_setup.c @@ -1186,21 +1186,21 @@ void si_llvm_context_init(struct si_shader_context *ctx, LLVMDisposeMessage(data_layout_str); bool unsafe_fpmath = (sscreen->b.debug_flags & DBG_UNSAFE_MATH) != 0; enum lp_float_mode float_mode = unsafe_fpmath ? LP_FLOAT_MODE_UNSAFE_FP_MATH : LP_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH; ctx->gallivm.builder = lp_create_builder(ctx->gallivm.context, float_mode); - ac_llvm_context_init(&ctx->ac, ctx->gallivm.context); + ac_llvm_context_init(&ctx->ac, ctx->gallivm.context, sscreen->b.chip_class); ctx->ac.module = ctx->gallivm.module; ctx->ac.builder = ctx->gallivm.builder; struct lp_build_tgsi_context *bld_base = &ctx->bld_base; type.floating = true; type.fixed = false; type.sign = true; type.norm = false; type.width = 32; -- 2.11.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev