~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/amd/compiler/aco_interface.cpp

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
}
81
81
 
82
82
static std::string
83
 
get_disasm_string(aco::Program* program, std::vector<uint32_t>& code,
84
 
                  unsigned exec_size)
 
83
get_disasm_string(aco::Program* program, std::vector<uint32_t>& code, unsigned exec_size)
85
84
{
86
85
   std::string disasm;
87
86
 
111
110
 
112
111
static std::string
113
112
aco_postprocess_shader(const struct aco_compiler_options* options,
114
 
                       const struct aco_shader_info *info,
115
 
                       std::unique_ptr<aco::Program>& program)
 
113
                       const struct aco_shader_info* info, std::unique_ptr<aco::Program>& program)
116
114
{
117
115
   std::string llvm_ir;
118
116
 
119
117
   if (options->dump_preoptir)
120
118
      aco_print_program(program.get(), stderr);
121
119
 
 
120
   ASSERTED bool is_valid = aco::validate_cfg(program.get());
 
121
   assert(is_valid);
 
122
 
122
123
   aco::live live_vars;
123
124
   if (!info->is_trap_handler_shader) {
124
125
      aco::dominator_tree(program.get());
192
193
 
193
194
   /* Lower to HW Instructions */
194
195
   aco::lower_to_hw_instr(program.get());
 
196
   validate(program.get());
195
197
 
196
198
   /* Insert Waitcnt */
197
199
   aco::insert_wait_states(program.get());
207
209
}
208
210
 
209
211
void
210
 
aco_compile_shader(const struct aco_compiler_options* options,
211
 
                   const struct aco_shader_info* info,
 
212
aco_compile_shader(const struct aco_compiler_options* options, const struct aco_shader_info* info,
212
213
                   unsigned shader_count, struct nir_shader* const* shaders,
213
 
                   const struct ac_shader_args *args,
214
 
                   aco_callback *build_binary,
215
 
                   void **binary)
 
214
                   const struct ac_shader_args* args, aco_callback* build_binary, void** binary)
216
215
{
217
216
   aco::init();
218
217
 
236
235
 
237
236
   /* assembly */
238
237
   std::vector<uint32_t> code;
239
 
   unsigned exec_size = aco::emit_program(program.get(), code);
 
238
   std::vector<struct aco_symbol> symbols;
 
239
   unsigned exec_size = aco::emit_program(program.get(), code, &symbols);
240
240
 
241
241
   if (program->collect_statistics)
242
242
      aco::collect_postasm_stats(program.get(), code);
252
252
      stats_size = aco_num_statistics * sizeof(uint32_t);
253
253
 
254
254
   (*build_binary)(binary, &config, llvm_ir.c_str(), llvm_ir.size(), disasm.c_str(), disasm.size(),
255
 
                   program->statistics, stats_size, exec_size, code.data(), code.size());
 
255
                   program->statistics, stats_size, exec_size, code.data(), code.size(),
 
256
                   symbols.data(), symbols.size());
256
257
}
257
258
 
258
259
void
271
272
   program->debug.private_data = NULL;
272
273
 
273
274
   aco::select_rt_prolog(program.get(), &config, options, info, in_args, out_args);
 
275
   validate(program.get());
274
276
   aco::insert_wait_states(program.get());
275
277
   aco::insert_NOPs(program.get());
276
278
   if (program->gfx_level >= GFX10)
282
284
   /* assembly */
283
285
   std::vector<uint32_t> code;
284
286
   code.reserve(align(program->blocks[0].instructions.size() * 2, 16));
285
 
   unsigned exec_size = aco::emit_program(program.get(), code);
 
287
   unsigned exec_size = aco::emit_program(program.get(), code, NULL);
286
288
 
287
289
   bool get_disasm = options->dump_shader || options->record_ir;
288
290
 
291
293
      disasm = get_disasm_string(program.get(), code, exec_size);
292
294
 
293
295
   (*build_prolog)(binary, &config, NULL, 0, disasm.c_str(), disasm.size(), program->statistics, 0,
294
 
                   exec_size, code.data(), code.size());
 
296
                   exec_size, code.data(), code.size(), NULL, 0);
295
297
}
296
298
 
297
299
void
311
313
 
312
314
   /* create IR */
313
315
   aco::select_vs_prolog(program.get(), pinfo, &config, options, info, args);
 
316
   validate(program.get());
314
317
   aco::insert_NOPs(program.get());
315
318
 
316
319
   if (options->dump_shader)
319
322
   /* assembly */
320
323
   std::vector<uint32_t> code;
321
324
   code.reserve(align(program->blocks[0].instructions.size() * 2, 16));
322
 
   unsigned exec_size = aco::emit_program(program.get(), code);
 
325
   unsigned exec_size = aco::emit_program(program.get(), code, NULL);
323
326
 
324
327
   bool get_disasm = options->dump_shader || options->record_ir;
325
328
 
327
330
   if (get_disasm)
328
331
      disasm = get_disasm_string(program.get(), code, exec_size);
329
332
 
330
 
   (*build_prolog)(binary,
331
 
                   config.num_sgprs,
332
 
                   config.num_vgprs,
333
 
                   code.data(),
334
 
                   code.size(),
335
 
                   disasm.data(),
336
 
                   disasm.size());
 
333
   (*build_prolog)(binary, config.num_sgprs, config.num_vgprs, code.data(), code.size(),
 
334
                   disasm.data(), disasm.size());
337
335
}
338
336
 
339
337
void
361
359
 
362
360
   /* assembly */
363
361
   std::vector<uint32_t> code;
364
 
   unsigned exec_size = aco::emit_program(program.get(), code);
 
362
   unsigned exec_size = aco::emit_program(program.get(), code, NULL);
365
363
 
366
364
   bool get_disasm = options->dump_shader || options->record_ir;
367
365
 
369
367
   if (get_disasm)
370
368
      disasm = get_disasm_string(program.get(), code, exec_size);
371
369
 
372
 
   (*build_epilog)(binary,
373
 
                   config.num_sgprs,
374
 
                   config.num_vgprs,
375
 
                   code.data(),
376
 
                   code.size(),
377
 
                   disasm.data(),
378
 
                   disasm.size());
 
370
   (*build_epilog)(binary, config.num_sgprs, config.num_vgprs, code.data(), code.size(),
 
371
                   disasm.data(), disasm.size());
379
372
}