shader_ir: Corrections, documenting and asserting control_flow

This commit is contained in:
Fernando Sahmkow
2019-06-25 20:15:40 -04:00
committed by FernandoS27
parent d5533b440c
commit 01b21ee1e8
3 changed files with 54 additions and 52 deletions

View File

@ -1,3 +1,7 @@
// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#pragma once
#include <cstring>
@ -20,12 +24,15 @@ struct Condition {
ConditionCode cc{ConditionCode::T};
bool IsUnconditional() const {
return (predicate == Pred::UnusedIndex) && (cc == ConditionCode::T);
return predicate == Pred::UnusedIndex && cc == ConditionCode::T;
}
bool operator==(const Condition& other) const {
return std::tie(predicate, cc) == std::tie(other.predicate, other.cc);
}
};
struct ShaderBlock {
ShaderBlock() {}
ShaderBlock() = default;
ShaderBlock(const ShaderBlock& sb) = default;
u32 start{};
u32 end{};
@ -35,11 +42,12 @@ struct ShaderBlock {
bool kills{};
s32 address{};
bool operator==(const Branch& b) const {
return std::memcmp(this, &b, sizeof(Branch)) == 0;
return std::tie(cond, kills, address) == std::tie(b.cond, b.kills, b.address);
}
} branch;
bool operator==(const ShaderBlock& sb) const {
return std::memcmp(this, &sb, sizeof(ShaderBlock)) == 0;
return std::tie(start, end, ignore_branch, branch) ==
std::tie(sb.start, sb.end, sb.ignore_branch, sb.branch);
}
};