ac: create the LLVM builder in ac_llvm_context_init

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
This commit is contained in:
Marek Olšák
2019-07-12 17:35:39 -04:00
parent eb54b8c222
commit 81091a5183
4 changed files with 15 additions and 17 deletions

View File

@@ -60,7 +60,7 @@ void
ac_llvm_context_init(struct ac_llvm_context *ctx,
struct ac_llvm_compiler *compiler,
enum chip_class chip_class, enum radeon_family family,
unsigned wave_size)
enum ac_float_mode float_mode, unsigned wave_size)
{
LLVMValueRef args[1];
@@ -72,7 +72,7 @@ ac_llvm_context_init(struct ac_llvm_context *ctx,
ctx->module = ac_create_module(wave_size == 32 ? compiler->tm_wave32
: compiler->tm,
ctx->context);
ctx->builder = NULL;
ctx->builder = ac_create_builder(ctx->context, float_mode);
ctx->voidt = LLVMVoidTypeInContext(ctx->context);
ctx->i1 = LLVMInt1TypeInContext(ctx->context);

View File

@@ -49,6 +49,7 @@ enum {
struct ac_llvm_flow;
struct ac_llvm_compiler;
enum ac_float_mode;
struct ac_llvm_context {
LLVMContextRef context;
@@ -113,7 +114,7 @@ void
ac_llvm_context_init(struct ac_llvm_context *ctx,
struct ac_llvm_compiler *compiler,
enum chip_class chip_class, enum radeon_family family,
unsigned wave_size);
enum ac_float_mode float_mode, unsigned wave_size);
void
ac_llvm_context_dispose(struct ac_llvm_context *ctx);

View File

@@ -4319,14 +4319,13 @@ LLVMModuleRef ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm,
ctx.options = options;
ctx.shader_info = shader_info;
ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class, options->family, 64);
ctx.context = ctx.ac.context;
enum ac_float_mode float_mode =
options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
AC_FLOAT_MODE_DEFAULT;
ctx.ac.builder = ac_create_builder(ctx.context, float_mode);
ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class,
options->family, float_mode, 64);
ctx.context = ctx.ac.context;
radv_nir_shader_info_init(&shader_info->info);
@@ -4837,16 +4836,15 @@ radv_compile_gs_copy_shader(struct ac_llvm_compiler *ac_llvm,
ctx.options = options;
ctx.shader_info = shader_info;
ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class, options->family, 64);
ctx.context = ctx.ac.context;
ctx.is_gs_copy_shader = true;
enum ac_float_mode float_mode =
options->unsafe_math ? AC_FLOAT_MODE_UNSAFE_FP_MATH :
AC_FLOAT_MODE_DEFAULT;
ctx.ac.builder = ac_create_builder(ctx.context, float_mode);
ac_llvm_context_init(&ctx.ac, ac_llvm, options->chip_class,
options->family, float_mode, 64);
ctx.context = ctx.ac.context;
ctx.is_gs_copy_shader = true;
ctx.stage = MESA_SHADER_VERTEX;
radv_nir_shader_info_pass(geom_shader, options, &shader_info->info);

View File

@@ -962,14 +962,13 @@ void si_llvm_context_init(struct si_shader_context *ctx,
ctx->screen = sscreen;
ctx->compiler = compiler;
ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class,
sscreen->info.family, 64);
enum ac_float_mode float_mode =
sscreen->debug_flags & DBG(UNSAFE_MATH) ?
AC_FLOAT_MODE_UNSAFE_FP_MATH :
AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH;
ctx->ac.builder = ac_create_builder(ctx->ac.context, float_mode);
ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class,
sscreen->info.family, float_mode, 64);
ctx->gallivm.context = ctx->ac.context;
ctx->gallivm.module = ctx->ac.module;