1 /*
2 * Copyright © 2016 Red Hat.
3 * Copyright © 2016 Bas Nieuwenhuizen
4 *
5 * based in part on anv driver which is:
6 * Copyright © 2015 Intel Corporation
7 *
8 * SPDX-License-Identifier: MIT
9 */
10
11 #include "radv_nir_to_llvm.h"
12 #include "nir/nir.h"
13 #include "radv_debug.h"
14 #include "radv_llvm_helper.h"
15 #include "radv_shader.h"
16 #include "radv_shader_args.h"
17
18 #include "ac_binary.h"
19 #include "ac_llvm_build.h"
20 #include "ac_nir.h"
21 #include "ac_nir_to_llvm.h"
22 #include "ac_shader_abi.h"
23 #include "ac_shader_util.h"
24 #include "sid.h"
25
26 struct radv_shader_context {
27 struct ac_llvm_context ac;
28 const struct nir_shader *shader;
29 struct ac_shader_abi abi;
30 const struct radv_nir_compiler_options *options;
31 const struct radv_shader_info *shader_info;
32 const struct radv_shader_args *args;
33
34 gl_shader_stage stage;
35
36 unsigned max_workgroup_size;
37 LLVMContextRef context;
38 struct ac_llvm_pointer main_function;
39 };
40
41 static inline struct radv_shader_context *
radv_shader_context_from_abi(struct ac_shader_abi * abi)42 radv_shader_context_from_abi(struct ac_shader_abi *abi)
43 {
44 return container_of(abi, struct radv_shader_context, abi);
45 }
46
47 static struct ac_llvm_pointer
create_llvm_function(struct ac_llvm_context * ctx,LLVMModuleRef module,LLVMBuilderRef builder,const struct ac_shader_args * args,enum ac_llvm_calling_convention convention,unsigned max_workgroup_size,const struct radv_nir_compiler_options * options)48 create_llvm_function(struct ac_llvm_context *ctx, LLVMModuleRef module, LLVMBuilderRef builder,
49 const struct ac_shader_args *args, enum ac_llvm_calling_convention convention,
50 unsigned max_workgroup_size, const struct radv_nir_compiler_options *options)
51 {
52 struct ac_llvm_pointer main_function = ac_build_main(args, ctx, convention, "main", ctx->voidt, module);
53
54 if (options->info->address32_hi) {
55 ac_llvm_add_target_dep_function_attr(main_function.value, "amdgpu-32bit-address-high-bits",
56 options->info->address32_hi);
57 }
58
59 ac_llvm_set_workgroup_size(main_function.value, max_workgroup_size);
60 ac_llvm_set_target_features(main_function.value, ctx, true);
61
62 return main_function;
63 }
64
65 static enum ac_llvm_calling_convention
get_llvm_calling_convention(LLVMValueRef func,gl_shader_stage stage)66 get_llvm_calling_convention(LLVMValueRef func, gl_shader_stage stage)
67 {
68 switch (stage) {
69 case MESA_SHADER_VERTEX:
70 case MESA_SHADER_TESS_EVAL:
71 return AC_LLVM_AMDGPU_VS;
72 break;
73 case MESA_SHADER_GEOMETRY:
74 return AC_LLVM_AMDGPU_GS;
75 break;
76 case MESA_SHADER_TESS_CTRL:
77 return AC_LLVM_AMDGPU_HS;
78 break;
79 case MESA_SHADER_FRAGMENT:
80 return AC_LLVM_AMDGPU_PS;
81 break;
82 case MESA_SHADER_COMPUTE:
83 return AC_LLVM_AMDGPU_CS;
84 break;
85 default:
86 unreachable("Unhandle shader type");
87 }
88 }
89
90 /* Returns whether the stage is a stage that can be directly before the GS */
91 static bool
is_pre_gs_stage(gl_shader_stage stage)92 is_pre_gs_stage(gl_shader_stage stage)
93 {
94 return stage == MESA_SHADER_VERTEX || stage == MESA_SHADER_TESS_EVAL;
95 }
96
97 static void
create_function(struct radv_shader_context * ctx,gl_shader_stage stage,bool has_previous_stage)98 create_function(struct radv_shader_context *ctx, gl_shader_stage stage, bool has_previous_stage)
99 {
100 if (ctx->ac.gfx_level >= GFX10) {
101 if (is_pre_gs_stage(stage) && ctx->shader_info->is_ngg) {
102 /* On GFX10+, VS and TES are merged into GS for NGG. */
103 stage = MESA_SHADER_GEOMETRY;
104 has_previous_stage = true;
105 }
106 }
107
108 ctx->main_function = create_llvm_function(&ctx->ac, ctx->ac.module, ctx->ac.builder, &ctx->args->ac,
109 get_llvm_calling_convention(ctx->main_function.value, stage),
110 ctx->max_workgroup_size, ctx->options);
111
112 if (stage == MESA_SHADER_TESS_CTRL || (stage == MESA_SHADER_VERTEX && ctx->shader_info->vs.as_ls) ||
113 ctx->shader_info->is_ngg ||
114 /* GFX9 has the ESGS ring buffer in LDS. */
115 (stage == MESA_SHADER_GEOMETRY && has_previous_stage)) {
116 ac_declare_lds_as_pointer(&ctx->ac);
117 }
118 }
119
120 static LLVMValueRef
radv_load_base_vertex(struct ac_shader_abi * abi,bool non_indexed_is_zero)121 radv_load_base_vertex(struct ac_shader_abi *abi, bool non_indexed_is_zero)
122 {
123 struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
124 return ac_get_arg(&ctx->ac, ctx->args->ac.base_vertex);
125 }
126
127 static LLVMValueRef
radv_load_rsrc(struct radv_shader_context * ctx,LLVMValueRef ptr,LLVMTypeRef type)128 radv_load_rsrc(struct radv_shader_context *ctx, LLVMValueRef ptr, LLVMTypeRef type)
129 {
130 if (ptr && LLVMTypeOf(ptr) == ctx->ac.i32) {
131 LLVMValueRef result;
132
133 LLVMTypeRef ptr_type = LLVMPointerType(type, AC_ADDR_SPACE_CONST_32BIT);
134 ptr = LLVMBuildIntToPtr(ctx->ac.builder, ptr, ptr_type, "");
135 LLVMSetMetadata(ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
136
137 result = LLVMBuildLoad2(ctx->ac.builder, type, ptr, "");
138 LLVMSetMetadata(result, ctx->ac.invariant_load_md_kind, ctx->ac.empty_md);
139
140 return result;
141 }
142
143 return ptr;
144 }
145
146 static LLVMValueRef
radv_load_ubo(struct ac_shader_abi * abi,LLVMValueRef buffer_ptr)147 radv_load_ubo(struct ac_shader_abi *abi, LLVMValueRef buffer_ptr)
148 {
149 struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
150 return radv_load_rsrc(ctx, buffer_ptr, ctx->ac.v4i32);
151 }
152
153 static LLVMValueRef
radv_load_ssbo(struct ac_shader_abi * abi,LLVMValueRef buffer_ptr,bool write,bool non_uniform)154 radv_load_ssbo(struct ac_shader_abi *abi, LLVMValueRef buffer_ptr, bool write, bool non_uniform)
155 {
156 struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
157 return radv_load_rsrc(ctx, buffer_ptr, ctx->ac.v4i32);
158 }
159
160 static LLVMValueRef
radv_get_sampler_desc(struct ac_shader_abi * abi,LLVMValueRef index,enum ac_descriptor_type desc_type)161 radv_get_sampler_desc(struct ac_shader_abi *abi, LLVMValueRef index, enum ac_descriptor_type desc_type)
162 {
163 struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
164
165 /* 3 plane formats always have same size and format for plane 1 & 2, so
166 * use the tail from plane 1 so that we can store only the first 16 bytes
167 * of the last plane. */
168 if (desc_type == AC_DESC_PLANE_2 && index && LLVMTypeOf(index) == ctx->ac.i32) {
169 LLVMValueRef plane1_addr = LLVMBuildSub(ctx->ac.builder, index, LLVMConstInt(ctx->ac.i32, 32, false), "");
170 LLVMValueRef descriptor1 = radv_load_rsrc(ctx, plane1_addr, ctx->ac.v8i32);
171 LLVMValueRef descriptor2 = radv_load_rsrc(ctx, index, ctx->ac.v4i32);
172
173 LLVMValueRef components[8];
174 for (unsigned i = 0; i < 4; ++i)
175 components[i] = ac_llvm_extract_elem(&ctx->ac, descriptor2, i);
176
177 for (unsigned i = 4; i < 8; ++i)
178 components[i] = ac_llvm_extract_elem(&ctx->ac, descriptor1, i);
179 return ac_build_gather_values(&ctx->ac, components, 8);
180 }
181
182 bool v4 = desc_type == AC_DESC_BUFFER || desc_type == AC_DESC_SAMPLER;
183 return radv_load_rsrc(ctx, index, v4 ? ctx->ac.v4i32 : ctx->ac.v8i32);
184 }
185
186 static LLVMValueRef
radv_load_output(struct radv_shader_context * ctx,unsigned index,unsigned chan)187 radv_load_output(struct radv_shader_context *ctx, unsigned index, unsigned chan)
188 {
189 int idx = ac_llvm_reg_index_soa(index, chan);
190 LLVMValueRef output = ctx->abi.outputs[idx];
191 LLVMTypeRef type = ctx->abi.is_16bit[idx] ? ctx->ac.f16 : ctx->ac.f32;
192 return LLVMBuildLoad2(ctx->ac.builder, type, output, "");
193 }
194
195 static void
ac_llvm_finalize_module(struct radv_shader_context * ctx,LLVMPassManagerRef passmgr)196 ac_llvm_finalize_module(struct radv_shader_context *ctx, LLVMPassManagerRef passmgr)
197 {
198 LLVMRunPassManager(passmgr, ctx->ac.module);
199
200 ac_llvm_context_dispose(&ctx->ac);
201 }
202
203 /* Ensure that the esgs ring is declared.
204 *
205 * We declare it with 64KB alignment as a hint that the
206 * pointer value will always be 0.
207 */
208 static void
declare_esgs_ring(struct radv_shader_context * ctx)209 declare_esgs_ring(struct radv_shader_context *ctx)
210 {
211 assert(!LLVMGetNamedGlobal(ctx->ac.module, "esgs_ring"));
212
213 LLVMValueRef esgs_ring =
214 LLVMAddGlobalInAddressSpace(ctx->ac.module, LLVMArrayType(ctx->ac.i32, 0), "esgs_ring", AC_ADDR_SPACE_LDS);
215 LLVMSetLinkage(esgs_ring, LLVMExternalLinkage);
216 LLVMSetAlignment(esgs_ring, 64 * 1024);
217 }
218
219 static LLVMValueRef
radv_intrinsic_load(struct ac_shader_abi * abi,nir_intrinsic_instr * intrin)220 radv_intrinsic_load(struct ac_shader_abi *abi, nir_intrinsic_instr *intrin)
221 {
222 switch (intrin->intrinsic) {
223 case nir_intrinsic_load_base_vertex:
224 case nir_intrinsic_load_first_vertex:
225 return radv_load_base_vertex(abi, intrin->intrinsic == nir_intrinsic_load_base_vertex);
226 default:
227 return NULL;
228 }
229 }
230
231 static LLVMModuleRef
ac_translate_nir_to_llvm(struct ac_llvm_compiler * ac_llvm,const struct radv_nir_compiler_options * options,const struct radv_shader_info * info,struct nir_shader * const * shaders,int shader_count,const struct radv_shader_args * args)232 ac_translate_nir_to_llvm(struct ac_llvm_compiler *ac_llvm, const struct radv_nir_compiler_options *options,
233 const struct radv_shader_info *info, struct nir_shader *const *shaders, int shader_count,
234 const struct radv_shader_args *args)
235 {
236 struct radv_shader_context ctx = {0};
237 ctx.args = args;
238 ctx.options = options;
239 ctx.shader_info = info;
240
241 enum ac_float_mode float_mode = AC_FLOAT_MODE_DEFAULT;
242
243 if (shaders[0]->info.float_controls_execution_mode & FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP32) {
244 float_mode = AC_FLOAT_MODE_DENORM_FLUSH_TO_ZERO;
245 }
246
247 bool exports_mrtz = false;
248 bool exports_color_null = false;
249 if (shaders[0]->info.stage == MESA_SHADER_FRAGMENT) {
250 exports_mrtz = info->ps.writes_z || info->ps.writes_stencil || info->ps.writes_sample_mask;
251 exports_color_null = !exports_mrtz || (shaders[0]->info.outputs_written & (0xffu << FRAG_RESULT_DATA0));
252 }
253
254 ac_llvm_context_init(&ctx.ac, ac_llvm, options->info, float_mode, info->wave_size, info->ballot_bit_size,
255 exports_color_null, exports_mrtz);
256
257 uint32_t length = 1;
258 for (uint32_t i = 0; i < shader_count; i++)
259 if (shaders[i]->info.name)
260 length += strlen(shaders[i]->info.name) + 1;
261
262 char *name = malloc(length);
263 if (name) {
264 uint32_t offset = 0;
265 for (uint32_t i = 0; i < shader_count; i++) {
266 if (!shaders[i]->info.name)
267 continue;
268
269 strcpy(name + offset, shaders[i]->info.name);
270 offset += strlen(shaders[i]->info.name);
271 if (i != shader_count - 1)
272 name[offset++] = ',';
273 }
274
275 LLVMSetSourceFileName(ctx.ac.module, name, offset);
276 }
277
278 ctx.context = ctx.ac.context;
279
280 ctx.max_workgroup_size = info->workgroup_size;
281
282 create_function(&ctx, shaders[shader_count - 1]->info.stage, shader_count >= 2);
283
284 ctx.abi.intrinsic_load = radv_intrinsic_load;
285 ctx.abi.load_ubo = radv_load_ubo;
286 ctx.abi.load_ssbo = radv_load_ssbo;
287 ctx.abi.load_sampler_desc = radv_get_sampler_desc;
288 ctx.abi.clamp_shadow_reference = false;
289 ctx.abi.robust_buffer_access = options->robust_buffer_access_llvm;
290 ctx.abi.load_grid_size_from_user_sgpr = args->load_grid_size_from_user_sgpr;
291
292 bool is_ngg = is_pre_gs_stage(shaders[0]->info.stage) && info->is_ngg;
293 if (shader_count >= 2 || is_ngg)
294 ac_init_exec_full_mask(&ctx.ac);
295
296 if (args->ac.vertex_id.used)
297 ctx.abi.vertex_id = ac_get_arg(&ctx.ac, args->ac.vertex_id);
298 if (args->ac.vs_rel_patch_id.used)
299 ctx.abi.vs_rel_patch_id = ac_get_arg(&ctx.ac, args->ac.vs_rel_patch_id);
300 if (args->ac.instance_id.used)
301 ctx.abi.instance_id = ac_get_arg(&ctx.ac, args->ac.instance_id);
302
303 if (options->info->has_ls_vgpr_init_bug && shaders[shader_count - 1]->info.stage == MESA_SHADER_TESS_CTRL)
304 ac_fixup_ls_hs_input_vgprs(&ctx.ac, &ctx.abi, &args->ac);
305
306 if (is_ngg) {
307 if (!info->is_ngg_passthrough)
308 declare_esgs_ring(&ctx);
309
310 if (ctx.stage == MESA_SHADER_GEOMETRY) {
311 /* Scratch space used by NGG GS for repacking vertices at the end. */
312 LLVMTypeRef ai32 = LLVMArrayType(ctx.ac.i32, 8);
313 LLVMValueRef gs_ngg_scratch =
314 LLVMAddGlobalInAddressSpace(ctx.ac.module, ai32, "ngg_scratch", AC_ADDR_SPACE_LDS);
315 LLVMSetInitializer(gs_ngg_scratch, LLVMGetUndef(ai32));
316 LLVMSetLinkage(gs_ngg_scratch, LLVMExternalLinkage);
317 LLVMSetAlignment(gs_ngg_scratch, 4);
318
319 /* Vertex emit space used by NGG GS for storing all vertex attributes. */
320 LLVMValueRef gs_ngg_emit =
321 LLVMAddGlobalInAddressSpace(ctx.ac.module, LLVMArrayType(ctx.ac.i32, 0), "ngg_emit", AC_ADDR_SPACE_LDS);
322 LLVMSetInitializer(gs_ngg_emit, LLVMGetUndef(ai32));
323 LLVMSetLinkage(gs_ngg_emit, LLVMExternalLinkage);
324 LLVMSetAlignment(gs_ngg_emit, 4);
325 }
326
327 /* GFX10 hang workaround - there needs to be an s_barrier before gs_alloc_req always */
328 if (ctx.ac.gfx_level == GFX10 && shader_count == 1)
329 ac_build_s_barrier(&ctx.ac, shaders[0]->info.stage);
330 }
331
332 for (int shader_idx = 0; shader_idx < shader_count; ++shader_idx) {
333 ctx.stage = shaders[shader_idx]->info.stage;
334 ctx.shader = shaders[shader_idx];
335
336 if (shader_idx && !(shaders[shader_idx]->info.stage == MESA_SHADER_GEOMETRY && info->is_ngg)) {
337 /* Execute a barrier before the second shader in
338 * a merged shader.
339 *
340 * Execute the barrier inside the conditional block,
341 * so that empty waves can jump directly to s_endpgm,
342 * which will also signal the barrier.
343 *
344 * This is possible in gfx9, because an empty wave
345 * for the second shader does not participate in
346 * the epilogue. With NGG, empty waves may still
347 * be required to export data (e.g. GS output vertices),
348 * so we cannot let them exit early.
349 *
350 * If the shader is TCS and the TCS epilog is present
351 * and contains a barrier, it will wait there and then
352 * reach s_endpgm.
353 */
354 ac_build_waitcnt(&ctx.ac, AC_WAIT_DS);
355 ac_build_s_barrier(&ctx.ac, shaders[shader_idx]->info.stage);
356 }
357
358 bool check_merged_wave_info = shader_count >= 2 && !(is_ngg && shader_idx == 1);
359 LLVMBasicBlockRef merge_block = NULL;
360
361 if (check_merged_wave_info) {
362 LLVMValueRef fn = LLVMGetBasicBlockParent(LLVMGetInsertBlock(ctx.ac.builder));
363 LLVMBasicBlockRef then_block = LLVMAppendBasicBlockInContext(ctx.ac.context, fn, "");
364 merge_block = LLVMAppendBasicBlockInContext(ctx.ac.context, fn, "");
365
366 LLVMValueRef count =
367 ac_unpack_param(&ctx.ac, ac_get_arg(&ctx.ac, args->ac.merged_wave_info), 8 * shader_idx, 8);
368 LLVMValueRef thread_id = ac_get_thread_id(&ctx.ac);
369 LLVMValueRef cond = LLVMBuildICmp(ctx.ac.builder, LLVMIntULT, thread_id, count, "");
370 LLVMBuildCondBr(ctx.ac.builder, cond, then_block, merge_block);
371
372 LLVMPositionBuilderAtEnd(ctx.ac.builder, then_block);
373 }
374
375 if (!ac_nir_translate(&ctx.ac, &ctx.abi, &args->ac, shaders[shader_idx])) {
376 abort();
377 }
378
379 if (check_merged_wave_info) {
380 LLVMBuildBr(ctx.ac.builder, merge_block);
381 LLVMPositionBuilderAtEnd(ctx.ac.builder, merge_block);
382 }
383 }
384
385 LLVMBuildRetVoid(ctx.ac.builder);
386
387 if (options->dump_preoptir) {
388 fprintf(stderr, "%s LLVM IR:\n\n", radv_get_shader_name(info, shaders[shader_count - 1]->info.stage));
389 ac_dump_module(ctx.ac.module);
390 fprintf(stderr, "\n");
391 }
392
393 ac_llvm_finalize_module(&ctx, ac_llvm->passmgr);
394
395 free(name);
396
397 return ctx.ac.module;
398 }
399
400 static void
ac_diagnostic_handler(LLVMDiagnosticInfoRef di,void * context)401 ac_diagnostic_handler(LLVMDiagnosticInfoRef di, void *context)
402 {
403 unsigned *retval = (unsigned *)context;
404 LLVMDiagnosticSeverity severity = LLVMGetDiagInfoSeverity(di);
405 char *description = LLVMGetDiagInfoDescription(di);
406
407 if (severity == LLVMDSError) {
408 *retval = 1;
409 fprintf(stderr, "LLVM triggered Diagnostic Handler: %s\n", description);
410 }
411
412 LLVMDisposeMessage(description);
413 }
414
415 static unsigned
radv_llvm_compile(LLVMModuleRef M,char ** pelf_buffer,size_t * pelf_size,struct ac_llvm_compiler * ac_llvm)416 radv_llvm_compile(LLVMModuleRef M, char **pelf_buffer, size_t *pelf_size, struct ac_llvm_compiler *ac_llvm)
417 {
418 unsigned retval = 0;
419 LLVMContextRef llvm_ctx;
420
421 /* Setup Diagnostic Handler*/
422 llvm_ctx = LLVMGetModuleContext(M);
423
424 LLVMContextSetDiagnosticHandler(llvm_ctx, ac_diagnostic_handler, &retval);
425
426 /* Compile IR*/
427 if (!radv_compile_to_elf(ac_llvm, M, pelf_buffer, pelf_size))
428 retval = 1;
429 return retval;
430 }
431
432 static void
ac_compile_llvm_module(struct ac_llvm_compiler * ac_llvm,LLVMModuleRef llvm_module,struct radv_shader_binary ** rbinary,const char * name,const struct radv_nir_compiler_options * options)433 ac_compile_llvm_module(struct ac_llvm_compiler *ac_llvm, LLVMModuleRef llvm_module, struct radv_shader_binary **rbinary,
434 const char *name, const struct radv_nir_compiler_options *options)
435 {
436 char *elf_buffer = NULL;
437 size_t elf_size = 0;
438 char *llvm_ir_string = NULL;
439
440 if (options->dump_shader) {
441 fprintf(stderr, "%s LLVM IR:\n\n", name);
442 ac_dump_module(llvm_module);
443 fprintf(stderr, "\n");
444 }
445
446 if (options->record_ir) {
447 char *llvm_ir = LLVMPrintModuleToString(llvm_module);
448 llvm_ir_string = strdup(llvm_ir);
449 LLVMDisposeMessage(llvm_ir);
450 }
451
452 int v = radv_llvm_compile(llvm_module, &elf_buffer, &elf_size, ac_llvm);
453 if (v) {
454 fprintf(stderr, "compile failed\n");
455 }
456
457 LLVMContextRef ctx = LLVMGetModuleContext(llvm_module);
458 LLVMDisposeModule(llvm_module);
459 LLVMContextDispose(ctx);
460
461 size_t llvm_ir_size = llvm_ir_string ? strlen(llvm_ir_string) : 0;
462 size_t alloc_size = sizeof(struct radv_shader_binary_rtld) + elf_size + llvm_ir_size + 1;
463 struct radv_shader_binary_rtld *rbin = calloc(1, alloc_size);
464 memcpy(rbin->data, elf_buffer, elf_size);
465 if (llvm_ir_string)
466 memcpy(rbin->data + elf_size, llvm_ir_string, llvm_ir_size + 1);
467
468 rbin->base.type = RADV_BINARY_TYPE_RTLD;
469 rbin->base.total_size = alloc_size;
470 rbin->elf_size = elf_size;
471 rbin->llvm_ir_size = llvm_ir_size;
472 *rbinary = &rbin->base;
473
474 free(llvm_ir_string);
475 free(elf_buffer);
476 }
477
478 static void
radv_compile_nir_shader(struct ac_llvm_compiler * ac_llvm,const struct radv_nir_compiler_options * options,const struct radv_shader_info * info,struct radv_shader_binary ** rbinary,const struct radv_shader_args * args,struct nir_shader * const * nir,int nir_count)479 radv_compile_nir_shader(struct ac_llvm_compiler *ac_llvm, const struct radv_nir_compiler_options *options,
480 const struct radv_shader_info *info, struct radv_shader_binary **rbinary,
481 const struct radv_shader_args *args, struct nir_shader *const *nir, int nir_count)
482 {
483
484 LLVMModuleRef llvm_module;
485
486 llvm_module = ac_translate_nir_to_llvm(ac_llvm, options, info, nir, nir_count, args);
487
488 ac_compile_llvm_module(ac_llvm, llvm_module, rbinary, radv_get_shader_name(info, nir[nir_count - 1]->info.stage),
489 options);
490 }
491
492 void
llvm_compile_shader(const struct radv_nir_compiler_options * options,const struct radv_shader_info * info,unsigned shader_count,struct nir_shader * const * shaders,struct radv_shader_binary ** binary,const struct radv_shader_args * args)493 llvm_compile_shader(const struct radv_nir_compiler_options *options, const struct radv_shader_info *info,
494 unsigned shader_count, struct nir_shader *const *shaders, struct radv_shader_binary **binary,
495 const struct radv_shader_args *args)
496 {
497 enum ac_target_machine_options tm_options = 0;
498 struct ac_llvm_compiler ac_llvm;
499
500 tm_options |= AC_TM_SUPPORTS_SPILL;
501 if (options->check_ir)
502 tm_options |= AC_TM_CHECK_IR;
503
504 radv_init_llvm_compiler(&ac_llvm, options->info->family, tm_options, info->wave_size);
505
506 radv_compile_nir_shader(&ac_llvm, options, info, binary, args, shaders, shader_count);
507 }
508