diff options
author | Samuel Pitoiset <[email protected]> | 2018-03-01 22:12:54 +0100 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2018-03-06 10:38:38 +0100 |
commit | 3b8e7459f2db084f46a0a064675cb226c372c037 (patch) | |
tree | 129306d721cdb7ec2b246fe8d28cf20b807e3c2d /src/gallium/drivers/radeonsi/si_shader.c | |
parent | f3275ca01cddd5d1e999e3805eff42e06ce6e974 (diff) |
ac: add ac_count_scratch_private_memory()
Imported from RadeonSI.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_shader.c')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 2ae2544e3f7..2e57eca6e54 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -5981,32 +5981,6 @@ static void si_optimize_vs_outputs(struct si_shader_context *ctx) &shader->info.nr_param_exports); } -static void si_count_scratch_private_memory(struct si_shader_context *ctx) -{ - ctx->shader->config.private_mem_vgprs = 0; - - /* Process all LLVM instructions. */ - LLVMBasicBlockRef bb = LLVMGetFirstBasicBlock(ctx->main_fn); - while (bb) { - LLVMValueRef next = LLVMGetFirstInstruction(bb); - - while (next) { - LLVMValueRef inst = next; - next = LLVMGetNextInstruction(next); - - if (LLVMGetInstructionOpcode(inst) != LLVMAlloca) - continue; - - LLVMTypeRef type = LLVMGetElementType(LLVMTypeOf(inst)); - /* No idea why LLVM aligns allocas to 4 elements. */ - unsigned alignment = LLVMGetAlignment(inst); - unsigned dw_size = align(ac_get_type_size(type) / 4, alignment); - ctx->shader->config.private_mem_vgprs += dw_size; - } - bb = LLVMGetNextBasicBlock(bb); - } -} - static void si_init_exec_from_input(struct si_shader_context *ctx, unsigned param, unsigned bitoffset) { @@ -6953,8 +6927,10 @@ int si_compile_tgsi_shader(struct si_screen *sscreen, si_optimize_vs_outputs(&ctx); if ((debug && debug->debug_message) || - si_can_dump_shader(sscreen, ctx.type)) - si_count_scratch_private_memory(&ctx); + si_can_dump_shader(sscreen, ctx.type)) { + ctx.shader->config.private_mem_vgprs = + ac_count_scratch_private_memory(ctx.main_fn); + } /* Compile to bytecode. */ r = si_compile_llvm(sscreen, &shader->binary, &shader->config, tm, |