mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 08:22:32 +00:00
broken. add some asserts
This commit is contained in:
parent
c4d47ff48d
commit
7001cfa347
@ -15,6 +15,10 @@ if (NOT CMAKE_BUILD_TYPE)
|
|||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
add_compile_definitions(_DEBUG)
|
||||||
|
endif()
|
||||||
|
|
||||||
project(shadPS4)
|
project(shadPS4)
|
||||||
|
|
||||||
# Forcing PIE makes sure that the base address is high enough so that it doesn't clash with the PS4 memory.
|
# Forcing PIE makes sure that the base address is high enough so that it doesn't clash with the PS4 memory.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <any>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "shader_recompiler/exception.h"
|
#include "shader_recompiler/exception.h"
|
||||||
@ -31,6 +32,8 @@ 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 {
|
||||||
@ -175,12 +178,19 @@ void Inst::ClearArgs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Inst::ReplaceUsesWith(Value replacement) {
|
void Inst::ReplaceUsesWith(Value replacement) {
|
||||||
|
// move uses because SetArg will call UndoUse and would otherwise
|
||||||
|
// mutate uses while iterating
|
||||||
|
#ifdef _DEBUG
|
||||||
|
boost::container::list<IR::Use> temp_uses = uses;
|
||||||
|
#else
|
||||||
|
boost::container::list<IR::Use> temp_uses = std::move(uses);
|
||||||
|
#endif
|
||||||
if (!replacement.IsImmediate()) {
|
if (!replacement.IsImmediate()) {
|
||||||
for (auto& [user, operand] : uses) {
|
for (auto& [user, operand] : temp_uses) {
|
||||||
|
DEBUG_ASSERT(user->Arg(operand).Inst() == this);
|
||||||
user->SetArg(operand, replacement);
|
user->SetArg(operand, replacement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uses.clear();
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,11 +207,15 @@ 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) {
|
||||||
|
return use.operand == operand && use.user == this;
|
||||||
|
}));
|
||||||
used->uses.emplace_front(this, operand);
|
used->uses.emplace_front(this, operand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Inst::UndoUse(Inst* used, u32 operand) {
|
void Inst::UndoUse(Inst* used, u32 operand) {
|
||||||
IR::Use use(this, operand);
|
IR::Use use(this, operand);
|
||||||
|
DEBUG_ASSERT(1 == std::count(used->uses.begin(), used->uses.end(), use));
|
||||||
used->uses.remove(use);
|
used->uses.remove(use);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "shader_recompiler/exception.h"
|
#include "shader_recompiler/exception.h"
|
||||||
#include "shader_recompiler/ir/attribute.h"
|
#include "shader_recompiler/ir/attribute.h"
|
||||||
#include "shader_recompiler/ir/opcodes.h"
|
#include "shader_recompiler/ir/opcodes.h"
|
||||||
#include "shader_recompiler/ir/patch.h"
|
|
||||||
#include "shader_recompiler/ir/reg.h"
|
#include "shader_recompiler/ir/reg.h"
|
||||||
#include "shader_recompiler/ir/type.h"
|
#include "shader_recompiler/ir/type.h"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user