summaryrefslogtreecommitdiff
path: root/src/amd/compiler/aco_live_var_analysis.cpp
diff options
context:
space:
mode:
authorRhys Perry <pendingchaos02@gmail.com>2020-02-21 20:14:03 +0000
committerMarge Bot <eric+marge@anholt.net>2020-03-16 16:09:02 +0000
commitc51348bd9b652aef65b5fd999165ecb8c388e61b (patch)
treeef38026e2e40d58557be153e29c5892f5f0a622a /src/amd/compiler/aco_live_var_analysis.cpp
parente1b08b55ff461677f05e827ebeab02918096ba0a (diff)
downloadmesa-c51348bd9b652aef65b5fd999165ecb8c388e61b.tar.gz
aco: move some register demand helpers into aco_live_var_analysis.cpp
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Daniel Schürmann <daniel@schuermann.dev> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3914>
Diffstat (limited to 'src/amd/compiler/aco_live_var_analysis.cpp')
-rw-r--r--src/amd/compiler/aco_live_var_analysis.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp
index eb965e4e05c..3c8e4472db1 100644
--- a/src/amd/compiler/aco_live_var_analysis.cpp
+++ b/src/amd/compiler/aco_live_var_analysis.cpp
@@ -36,8 +36,46 @@
#include "vulkan/radv_shader.h"
namespace aco {
-namespace {
+RegisterDemand get_live_changes(aco_ptr<Instruction>& instr)
+{
+ RegisterDemand changes;
+ for (const Definition& def : instr->definitions) {
+ if (!def.isTemp() || def.isKill())
+ continue;
+ changes += def.getTemp();
+ }
+
+ for (const Operand& op : instr->operands) {
+ if (!op.isTemp() || !op.isFirstKill())
+ continue;
+ changes -= op.getTemp();
+ }
+
+ return changes;
+}
+
+RegisterDemand get_temp_registers(aco_ptr<Instruction>& instr)
+{
+ RegisterDemand temp_registers;
+ for (Definition def : instr->definitions) {
+ if (!def.isTemp())
+ continue;
+ if (def.isKill())
+ temp_registers += def.getTemp();
+ }
+ return temp_registers;
+}
+
+RegisterDemand get_demand_before(RegisterDemand demand, aco_ptr<Instruction>& instr, aco_ptr<Instruction>& instr_before)
+{
+ demand -= get_live_changes(instr);
+ demand -= get_temp_registers(instr);
+ if (instr_before)
+ demand += get_temp_registers(instr_before);
+ return demand;
+}
+namespace {
void process_live_temps_per_block(Program *program, live& lives, Block* block,
std::set<unsigned>& worklist, std::vector<uint16_t>& phi_sgpr_ops)
{
@@ -101,7 +139,6 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
new_demand -= temp;
definition.setKill(false);
} else {
- register_demand[idx] += temp;
definition.setKill(true);
}
@@ -146,6 +183,8 @@ void process_live_temps_per_block(Program *program, live& lives, Block* block,
}
}
+ register_demand[idx] += get_temp_registers(block->instructions[idx]);
+
block->register_demand.update(register_demand[idx]);
}