mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
cleanup
This commit is contained in:
parent
50e8998c2b
commit
e96afcd1cb
@ -1,5 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
@ -32,8 +32,6 @@ Inst::Inst(const Inst& base) : op{base.op}, flags{base.flags} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Inst::~Inst() {
|
Inst::~Inst() {
|
||||||
// necessary? Or are all Insts destroyed at once?
|
|
||||||
ClearArgs();
|
|
||||||
if (op == Opcode::Phi) {
|
if (op == Opcode::Phi) {
|
||||||
std::destroy_at(&phi_args);
|
std::destroy_at(&phi_args);
|
||||||
} else {
|
} else {
|
||||||
@ -178,9 +176,8 @@ void Inst::ClearArgs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Inst::ReplaceUsesWith(Value replacement, bool preserve) {
|
void Inst::ReplaceUsesWith(Value replacement, bool preserve) {
|
||||||
// Could also do temp_uses = std::move(uses)
|
|
||||||
// But clearer this way
|
|
||||||
// Copy since user->SetArg will mutate this->uses
|
// Copy since user->SetArg will mutate this->uses
|
||||||
|
// Could also do temp_uses = std::move(uses) but more readable
|
||||||
boost::container::list<IR::Use> temp_uses = uses;
|
boost::container::list<IR::Use> temp_uses = uses;
|
||||||
for (auto& [user, operand] : temp_uses) {
|
for (auto& [user, operand] : temp_uses) {
|
||||||
DEBUG_ASSERT(user->Arg(operand).Inst() == this);
|
DEBUG_ASSERT(user->Arg(operand).Inst() == this);
|
||||||
@ -208,9 +205,7 @@ void Inst::ReplaceOpcode(IR::Opcode opcode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Inst::Use(Inst* used, u32 operand) {
|
void Inst::Use(Inst* used, u32 operand) {
|
||||||
DEBUG_ASSERT(std::none_of(used->uses.begin(), used->uses.end(), [&](const IR::Use& use) {
|
DEBUG_ASSERT(0 == std::count(used->uses.begin(), used->uses.end(), IR::Use(this, operand)));
|
||||||
return use.operand == operand && use.user == this;
|
|
||||||
}));
|
|
||||||
used->uses.emplace_front(this, operand);
|
used->uses.emplace_front(this, operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user