update readme and fix always playing str (#1139)

* update readme deps

* replace assert

* bump timeout

* fix memory corruption in kernel

* use unknown if level name is invalid
This commit is contained in:
water111
2022-02-08 19:02:47 -05:00
committed by GitHub
parent 3f394ef4d6
commit 78cde74d5a
243 changed files with 3525 additions and 3503 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 20
timeout-minutes: 45
env: # overrides: https://github.com/mbitsnbites/buildcache/blob/master/doc/configuration.md
BUILDCACHE_MAX_CACHE_SIZE: 1000000000 # 1gb
+1 -1
View File
@@ -25,7 +25,7 @@ jobs:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 25 # 5 more minutes than linux
timeout-minutes: 45
env: # overrides: https://github.com/mbitsnbites/buildcache/blob/master/doc/configuration.md
BUILDCACHE_MAX_CACHE_SIZE: 1000000000 # 1gb
+1 -1
View File
@@ -78,7 +78,7 @@ We don't save any assets from the game - you must bring your own copy of the gam
Install packages and init repository:
```sh
sudo apt install gcc make cmake build-essential g++ nasm clang-format
sudo apt install gcc make cmake build-essential g++ nasm clang-format libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev
git submodule update --init --recursive
```
+1
View File
@@ -26,6 +26,7 @@ add_library(common
type_system/TypeFieldLookup.cpp
type_system/TypeSpec.cpp
type_system/TypeSystem.cpp
util/Assert.cpp
util/BitUtils.cpp
util/compress.cpp
util/dgo_util.cpp
+4 -4
View File
@@ -53,11 +53,11 @@ std::vector<s16> decode_adpcm(BinaryReader& reader) {
u8 filter = shift_filter >> 4;
if (shift > 12) {
assert(false);
ASSERT(false);
}
if (filter > 4) {
assert(false);
ASSERT(false);
}
if (flags == 7) {
@@ -143,7 +143,7 @@ int get_shift_error(int shift, const s32* samples, bool /*debug*/) {
for (int sample_idx = 0; sample_idx < SAMPLES_PER_BLOCK; sample_idx++) {
int left_shift = 32 - (12 + 4 - shift);
assert(left_shift >= 0);
ASSERT(left_shift >= 0);
s32 sample_left = samples[sample_idx] << left_shift;
s32 sample_right = sample_left >> (32 - 4);
s32 sample_compressed = sample_right << (12 - shift);
@@ -290,7 +290,7 @@ void test_encode_adpcm(const std::vector<s16>& samples,
fmt::print(" [{}] {} {}\n", i, filter_errors[i], filter_shifts[i]);
}
fmt::print("prev: {} {}\n", prev_block_samples[0], prev_block_samples[1]);
assert(false);
ASSERT(false);
}
prev_block_samples[0] = samples.at(block_idx * 28 + 27);
+1 -1
View File
@@ -103,7 +103,7 @@ bool check_stopped(const ThreadID& tid, SignalInfo* out) {
return true;
}
printf("[Debugger] Failed to waitpid: %s.\n", strerror(errno));
// assert(false); // todo, temp because I think we should never hit this.
// ASSERT(false); // todo, temp because I think we should never hit this.
return false;
}
+3 -3
View File
@@ -1,5 +1,5 @@
#include "Tfrag3Data.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace tfrag3 {
@@ -97,7 +97,7 @@ void Level::serialize(Serializer& ser) {
if (ser.is_loading() && version != TFRAG3_VERSION) {
fmt::print("version mismatch when loading tfrag3 data. Got {}, expected {}\n", version,
TFRAG3_VERSION);
assert(false);
ASSERT(false);
}
ser.from_str(&level_name);
@@ -133,7 +133,7 @@ void Level::serialize(Serializer& ser) {
if (ser.is_loading() && version2 != TFRAG3_VERSION) {
fmt::print("version mismatch when loading tfrag3 data (at end). Got {}, expected {}\n",
version2, TFRAG3_VERSION);
assert(false);
ASSERT(false);
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
#include "common/dma/gs.h"
#include "common/util/Serializer.h"
#include "common/math/Vector.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace tfrag3 {
+2 -2
View File
@@ -1,7 +1,7 @@
#include "dma.h"
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
std::string DmaTag::print() {
std::string result;
@@ -111,7 +111,7 @@ std::string VifCode::print() {
fmt::print("Unhandled vif code {}\n", (int)kind);
result = "???";
assert(false);
ASSERT(false);
break;
}
// TODO: the rest of the VIF code.
+2 -2
View File
@@ -8,7 +8,7 @@
#include <string>
#include <cstring>
#include "common/common_types.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
struct DmaStats {
double sync_time_ms = 0;
@@ -89,7 +89,7 @@ inline void emulate_dma(const void* source_base, void* dest_base, u32 tadr, u32
} break;
default:
printf("bad tag: %d\n", (int)tag.kind);
assert(false);
ASSERT(false);
}
}
}
+7 -7
View File
@@ -2,7 +2,7 @@
#include <cstring>
#include "common/dma/dma.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* @file dma_chain_read.h
@@ -59,12 +59,12 @@ class DmaFollower {
DmaTransfer result;
result.transferred_tag = read_val<u64>(m_tag_offset + 8);
result.size_bytes = (u32)tag.qwc * 16;
assert(!tag.spr);
assert(!m_ended);
ASSERT(!tag.spr);
ASSERT(!m_ended);
switch (tag.kind) {
case DmaTag::Kind::CNT:
// data, then next tag. doesn't read address.
assert(tag.addr == 0);
ASSERT(tag.addr == 0);
result.data_offset = m_tag_offset + 16;
m_tag_offset = result.data_offset + result.size_bytes;
break;
@@ -84,12 +84,12 @@ class DmaFollower {
break;
case DmaTag::Kind::CALL:
result.data_offset = m_tag_offset + 16;
assert(m_sp <= 1);
ASSERT(m_sp <= 1);
m_tag_offset = tag.addr;
m_stack[m_sp++] = result.data_offset + tag.qwc * 16;
break;
case DmaTag::Kind::RET:
assert(m_sp > 0);
ASSERT(m_sp > 0);
result.data_offset = m_tag_offset + 16;
m_tag_offset = m_stack[--m_sp];
break;
@@ -99,7 +99,7 @@ class DmaFollower {
break;
default:
assert(false);
ASSERT(false);
}
result.data = (const u8*)m_base + result.data_offset;
return result;
+4 -4
View File
@@ -69,8 +69,8 @@ void FixedChunkDmaCopier::serialize_last_result(Serializer& serializer) {
FixedChunkDmaCopier::FixedChunkDmaCopier(u32 main_memory_size)
: m_main_memory_size(main_memory_size), m_chunk_count(main_memory_size / chunk_size) {
assert(chunk_size * m_chunk_count == m_main_memory_size); // make sure the memory size is valid.
assert(chunk_size >= 16);
ASSERT(chunk_size * m_chunk_count == m_main_memory_size); // make sure the memory size is valid.
ASSERT(chunk_size >= 16);
m_chunk_mask.resize(m_chunk_count);
}
@@ -96,7 +96,7 @@ const DmaData& FixedChunkDmaCopier::run(const void* memory, u32 offset, bool ver
m_chunk_mask.at(tag_chunk_idx) = true;
if (tag.addr) {
assert(tag.addr > EE_MAIN_MEM_LOW_PROTECT);
ASSERT(tag.addr > EE_MAIN_MEM_LOW_PROTECT);
u32 addr_chunk_idx = tag.addr / chunk_size;
u32 addr_offset_in_chunk = tag.addr % chunk_size;
// next, make sure that we get the address (if applicable)
@@ -175,7 +175,7 @@ const DmaData& FixedChunkDmaCopier::run(const void* memory, u32 offset, bool ver
}
diff_dma_chains(DmaFollower(memory, offset),
DmaFollower(m_result.data.data(), m_result.start_offset));
assert(false);
ASSERT(false);
} else {
fmt::print("verification ok: {} bytes\n", ref.size());
}
+15 -15
View File
@@ -1,7 +1,7 @@
#include "gs.h"
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
std::string reg_descriptor_name(GifTag::RegisterDescriptor reg) {
switch (reg) {
@@ -37,7 +37,7 @@ std::string reg_descriptor_name(GifTag::RegisterDescriptor reg) {
return "NOP";
default:
assert(false);
ASSERT(false);
}
}
@@ -57,7 +57,7 @@ std::string GifTag::print() const {
result += "disable ";
return result;
default:
assert(false);
ASSERT(false);
}
result += fmt::format("nloop: {} ", nloop());
@@ -196,7 +196,7 @@ std::string register_address_name(GsRegisterAddress reg) {
case GsRegisterAddress::LABEL:
return "LABEL";
default:
assert(false);
ASSERT(false);
}
}
@@ -230,7 +230,7 @@ std::string GsTest::print() const {
result += "NOTEQUAL ";
break;
default:
assert(false);
ASSERT(false);
}
result += fmt::format("ref: 0x{:x} alpha-fail: ", aref());
switch (afail()) {
@@ -247,7 +247,7 @@ std::string GsTest::print() const {
result += "RGB_ONLY ";
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -271,7 +271,7 @@ std::string GsTest::print() const {
result += "GREATER";
break;
default:
assert(false);
ASSERT(false);
}
}
return result;
@@ -290,7 +290,7 @@ std::string GsAlpha::print() const {
result += "0 ";
break;
default:
assert(false);
ASSERT(false);
}
switch (b_mode()) {
@@ -304,7 +304,7 @@ std::string GsAlpha::print() const {
result += "- 0) * ";
break;
default:
assert(false);
ASSERT(false);
}
switch (c_mode()) {
@@ -320,7 +320,7 @@ std::string GsAlpha::print() const {
result += fmt::format("{:.4f}", div);
} break;
default:
assert(false);
ASSERT(false);
}
switch (d_mode()) {
@@ -333,7 +333,7 @@ std::string GsAlpha::print() const {
case BlendMode::ZERO_OR_FIXED:
break;
default:
assert(false);
ASSERT(false);
}
return result;
@@ -376,7 +376,7 @@ std::string DrawMode::to_string() const {
result += "greater\n";
break;
default:
assert(false);
ASSERT(false);
}
result += fmt::format(" alpha: ");
switch (get_alpha_blend()) {
@@ -390,7 +390,7 @@ std::string DrawMode::to_string() const {
result += "disabled\n";
break;
default:
assert(false);
ASSERT(false);
}
result += fmt::format(" clamp: s {} t {}\n", get_clamp_s_enable(), get_clamp_t_enable());
result += fmt::format(" filt: {}\n", get_filt_enable());
@@ -409,7 +409,7 @@ std::string DrawMode::to_string() const {
result += "never\n";
break;
default:
assert(false);
ASSERT(false);
}
result += fmt::format(" zte: {}\n", get_zt_enable());
result += fmt::format(" abe: {}\n", get_ab_enable());
@@ -428,7 +428,7 @@ std::string DrawMode::to_string() const {
result += "zb-only\n";
break;
default:
assert(false);
ASSERT(false);
}
return result;
}
+1 -1
View File
@@ -140,7 +140,7 @@ struct GsZbuf {
case 0b1010:
return TextureFormat::PSMZ16S;
default:
assert(false);
ASSERT(false);
}
}
+1 -1
View File
@@ -305,7 +305,7 @@ Arguments Interpreter::get_args(const Object& form, const Object& rest, const Ar
if (args.unnamed.size() < spec.unnamed.size()) {
throw_eval_error(form, "didn't get enough arguments");
}
assert(args.unnamed.size() == spec.unnamed.size());
ASSERT(args.unnamed.size() == spec.unnamed.size());
if (!args.rest.empty() && spec.rest.empty()) {
throw_eval_error(form, "got too many arguments");
+1 -1
View File
@@ -84,7 +84,7 @@ std::string object_type_to_string(ObjectType type) {
template <>
std::string fixed_to_string(FloatType x) {
auto result = float_to_string(x);
assert((float)x == (float)std::stod(result));
ASSERT((float)x == (float)std::stod(result));
return result;
}
+1 -1
View File
@@ -49,7 +49,7 @@
#include <stdexcept>
#include <map>
#include "common/common_types.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace goos {
+1 -1
View File
@@ -42,7 +42,7 @@ bool va_check(
const std::vector<std::optional<goos::ObjectType>>& unnamed,
const std::unordered_map<std::string, std::pair<bool, std::optional<goos::ObjectType>>>& named,
std::string* err_string) {
assert(args.rest.empty());
ASSERT(args.rest.empty());
if (unnamed.size() != args.unnamed.size()) {
*err_string = "Got " + std::to_string(args.unnamed.size()) + " arguments, but expected " +
std::to_string(unnamed.size());
+1 -1
View File
@@ -23,7 +23,7 @@ void for_each_in_list(const goos::Object& list, T f) {
iter = &lap->cdr;
}
assert(iter->is_empty_list());
ASSERT(iter->is_empty_list());
}
int list_length(const goos::Object& list);
+25 -25
View File
@@ -13,7 +13,7 @@
#include "common/log/log.h"
#include "common/goos/PrettyPrinter2.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace pretty_print {
@@ -141,7 +141,7 @@ void add_to_token_list(const goos::Object& obj, std::vector<FormToken>* tokens)
case goos::ObjectType::ENVIRONMENT:
throw std::runtime_error("tried to pretty print a goos object kind which is not supported.");
default:
assert(false);
ASSERT(false);
}
}
@@ -248,19 +248,19 @@ void insertNewlineBefore(NodePool& pool, PrettyPrinterNode* node, int specialInd
* After this has been called, the entire selection should be reformatted with propagate_pretty
*/
void breakList(NodePool& pool, PrettyPrinterNode* leftParen) {
assert(!leftParen->is_line_separator);
assert(leftParen->tok->kind == FormToken::TokenKind::OPEN_PAREN);
ASSERT(!leftParen->is_line_separator);
ASSERT(leftParen->tok->kind == FormToken::TokenKind::OPEN_PAREN);
auto* rp = leftParen->paren;
assert(rp->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
ASSERT(rp->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
for (auto* n = leftParen->next; n && n != rp; n = n->next) {
if (!n->is_line_separator) {
if (n->tok->kind == FormToken::TokenKind::OPEN_PAREN) {
n = n->paren;
assert(n->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
ASSERT(n->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
insertNewlineAfter(pool, n, 0);
} else if (n->tok->kind != FormToken::TokenKind::WHITESPACE) {
assert(n->tok->kind != FormToken::TokenKind::CLOSE_PAREN);
ASSERT(n->tok->kind != FormToken::TokenKind::CLOSE_PAREN);
insertNewlineAfter(pool, n, 0);
}
}
@@ -338,7 +338,7 @@ static PrettyPrinterNode* propagatePretty(NodePool& pool,
* Get the token on the start of the next line. nullptr if we're the last line.
*/
PrettyPrinterNode* getNextLine(PrettyPrinterNode* start) {
assert(!start->is_line_separator);
ASSERT(!start->is_line_separator);
int line = start->line;
for (;;) {
if (start->is_line_separator || start->line == line) {
@@ -359,7 +359,7 @@ PrettyPrinterNode* getNextLine(PrettyPrinterNode* start) {
*/
PrettyPrinterNode* getNextListOnLine(PrettyPrinterNode* start) {
int line = start->line;
assert(!start->is_line_separator);
ASSERT(!start->is_line_separator);
if (!start->next || start->next->is_line_separator) {
return nullptr;
}
@@ -380,7 +380,7 @@ PrettyPrinterNode* getNextListOnLine(PrettyPrinterNode* start) {
PrettyPrinterNode* getNextOfKindOrStringOnLine(PrettyPrinterNode* start,
FormToken::TokenKind kind) {
int line = start->line;
assert(!start->is_line_separator);
ASSERT(!start->is_line_separator);
if (!start->next || start->next->is_line_separator) {
return nullptr;
}
@@ -400,7 +400,7 @@ PrettyPrinterNode* getNextOfKindOrStringOnLine(PrettyPrinterNode* start,
PrettyPrinterNode* getNextListOrEmptyListOnLine(PrettyPrinterNode* start) {
int line = start->line;
assert(!start->is_line_separator);
ASSERT(!start->is_line_separator);
if (!start->next || start->next->is_line_separator) {
return nullptr;
}
@@ -454,7 +454,7 @@ loop_end:
*/
PrettyPrinterNode* getFirstListOnLine(PrettyPrinterNode* start) {
int line = start->line;
assert(!start->is_line_separator);
ASSERT(!start->is_line_separator);
while (!start->is_line_separator && start->line == line) {
if (start->tok->kind == FormToken::TokenKind::OPEN_PAREN)
return start;
@@ -469,12 +469,12 @@ PrettyPrinterNode* getFirstListOnLine(PrettyPrinterNode* start) {
* Get the first token on the first line which exceeds the max length
*/
PrettyPrinterNode* getFirstBadLine(PrettyPrinterNode* start, int line_length) {
assert(!start->is_line_separator);
ASSERT(!start->is_line_separator);
int currentLine = start->line;
auto* currentLineNode = start;
for (;;) {
if (start->is_line_separator) {
assert(start->next);
ASSERT(start->next);
start = start->next;
} else {
if (start->line != currentLine) {
@@ -518,7 +518,7 @@ void insertBreaksAsNeeded(NodePool& pool, PrettyPrinterNode* head, int line_leng
break;
// okay, we have a line which needs fixing.
assert(!candidate_line->prev || candidate_line->prev->is_line_separator);
ASSERT(!candidate_line->prev || candidate_line->prev->is_line_separator);
PrettyPrinterNode* form_to_start = getFirstListOnLine(candidate_line);
for (;;) {
if (!form_to_start) {
@@ -547,10 +547,10 @@ void insertBreaksAsNeeded(NodePool& pool, PrettyPrinterNode* head, int line_leng
* After this has been called, the entire selection should be reformatted with propagate_pretty
*/
void breakList(NodePool& pool, PrettyPrinterNode* leftParen, PrettyPrinterNode* first_elt) {
assert(!leftParen->is_line_separator);
assert(leftParen->tok->kind == FormToken::TokenKind::OPEN_PAREN);
ASSERT(!leftParen->is_line_separator);
ASSERT(leftParen->tok->kind == FormToken::TokenKind::OPEN_PAREN);
auto* rp = leftParen->paren;
assert(rp->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
ASSERT(rp->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
bool breaking = false;
for (auto* n = leftParen->next; n && n != rp; n = n->next) {
@@ -560,13 +560,13 @@ void breakList(NodePool& pool, PrettyPrinterNode* leftParen, PrettyPrinterNode*
if (!n->is_line_separator) {
if (n->tok->kind == FormToken::TokenKind::OPEN_PAREN) {
n = n->paren;
assert(n->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
ASSERT(n->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
if (breaking) {
insertNewlineAfter(pool, n, 0);
}
} else if (n->tok->kind != FormToken::TokenKind::WHITESPACE) {
assert(n->tok->kind != FormToken::TokenKind::CLOSE_PAREN);
ASSERT(n->tok->kind != FormToken::TokenKind::CLOSE_PAREN);
if (breaking) {
insertNewlineAfter(pool, n, 0);
}
@@ -694,9 +694,9 @@ void insertSpecialBreaks(NodePool& pool, PrettyPrinterNode* node) {
while (true) {
// let's break this case:
assert(start_of_case->tok->kind == FormToken::TokenKind::OPEN_PAREN);
ASSERT(start_of_case->tok->kind == FormToken::TokenKind::OPEN_PAREN);
auto end_of_case = start_of_case->paren;
assert(end_of_case->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
ASSERT(end_of_case->tok->kind == FormToken::TokenKind::CLOSE_PAREN);
// get the first thing in the case
// and break there.
@@ -746,7 +746,7 @@ std::string to_string_v1(const goos::Object& obj, int line_length) {
NodePool pool;
std::vector<FormToken> tokens;
add_to_token_list(obj, &tokens);
assert(!tokens.empty());
ASSERT(!tokens.empty());
std::string pretty;
// build linked list of nodes
@@ -780,8 +780,8 @@ std::string to_string_v1(const goos::Object& obj, int line_length) {
n->paren = parenStack.back();
}
}
assert(parenStack.size() == 1);
assert(!parenStack.back());
ASSERT(parenStack.size() == 1);
ASSERT(!parenStack.back());
insertSpecialBreaks(pool, head);
propagatePretty(pool, head, line_length);
+10 -10
View File
@@ -1,7 +1,7 @@
#include "PrettyPrinter2.h"
#include "common/common_types.h"
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace pretty_print {
@@ -46,13 +46,13 @@ struct Node {
break;
case Kind::LIST:
case Kind::IMPROPER_LIST:
assert(!child_nodes.empty());
ASSERT(!child_nodes.empty());
for (auto& child : child_nodes) {
child.link(this, bfs_order, depth + 1);
}
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -77,7 +77,7 @@ struct Node {
case Kind::IMPROPER_LIST:
return "[improper list]";
default:
assert(false);
ASSERT(false);
}
}
@@ -141,7 +141,7 @@ Node to_node(const goos::Object& obj) {
case goos::ObjectType::ENVIRONMENT:
throw std::runtime_error("tried to pretty print a goos object kind which is not supported.");
default:
assert(false);
ASSERT(false);
}
}
@@ -186,7 +186,7 @@ void recompute_lengths(const std::vector<Node*>& bfs_order) {
}
} break;
default:
assert(false);
ASSERT(false);
}
}
}
@@ -197,7 +197,7 @@ void recompute_lengths(const std::vector<Node*>& bfs_order) {
* If you want to force a form to always be broken up, see insert_required_breaks
*/
void break_list(Node* node) {
assert(!node->break_list);
ASSERT(!node->break_list);
node->break_list = true;
node->sub_elt_indent = 2;
node->top_line_count = 1;
@@ -306,7 +306,7 @@ int run_algorithm(const std::vector<Node*>& bfs_order, int line_length) {
}
int compute_extra_offset(const std::string& str, int s0, int ei) {
assert(!str.empty());
ASSERT(!str.empty());
for (size_t i = str.length(); i-- > 0;) {
if ((int)i == s0) {
return ei + str.length() - s0;
@@ -381,7 +381,7 @@ void append_node_to_string(const Node* node,
str.push_back(')');
} else {
str.push_back('(');
assert(!node->child_nodes.empty());
ASSERT(!node->child_nodes.empty());
int listing_indent = next_indent_level + node->quoted;
int extra_indent = 1;
int c0 = 0;
@@ -413,7 +413,7 @@ void append_node_to_string(const Node* node,
}
break;
default:
assert(false);
ASSERT(false);
}
}
+2 -2
View File
@@ -63,7 +63,7 @@ goos::Object build_list(const std::vector<goos::Object>& objects) {
// build a list out of an array of forms
goos::Object build_list(const goos::Object* objects, int count) {
assert(count);
ASSERT(count);
auto car = objects[0];
goos::Object cdr;
if (count - 1) {
@@ -94,7 +94,7 @@ void append(goos::Object& _in, const goos::Object& add) {
}
if (!in->is_pair()) {
assert(false); // invalid list
ASSERT(false); // invalid list
}
in->as_pair()->cdr = add;
}
+13 -13
View File
@@ -77,8 +77,8 @@ void TextStream::seek_past_whitespace_and_comments() {
case '#':
if (text_remains(1) && peek(1) == '|') {
assert(read() == '#'); // #
assert(read() == '|'); // |
ASSERT(read() == '#'); // #
ASSERT(read() == '|'); // |
bool found_end = false;
// find |#
@@ -311,7 +311,7 @@ bool Reader::check_string_is_valid(const std::string& str) const {
* whitespace at the end and leaves the stream on the first character after the token.
*/
Token Reader::get_next_token(TextStream& stream) {
assert(stream.text_remains());
ASSERT(stream.text_remains());
Token t;
t.source_line = stream.line_count;
t.source_offset = stream.seek;
@@ -389,7 +389,7 @@ bool Reader::read_object(Token& tok, TextStream& ts, Object& obj) {
// try as string
if (tok.text[0] == '"') {
// it's a string.
assert(tok.text.length() == 1);
ASSERT(tok.text.length() == 1);
if (read_string(ts, obj)) {
return true;
} else {
@@ -420,22 +420,22 @@ bool Reader::read_object(Token& tok, TextStream& ts, Object& obj) {
}
bool Reader::read_array(TextStream& stream, Object& o) {
// assert(stream.read() == '(');
// ASSERT(stream.read() == '(');
stream.seek_past_whitespace_and_comments();
std::vector<Object> objects;
bool got_close_paren = false;
while (stream.text_remains()) {
auto tok = get_next_token(stream);
assert(!tok.text.empty());
ASSERT(!tok.text.empty());
if (tok.text[0] == '(') {
assert(tok.text.length() == 1);
ASSERT(tok.text.length() == 1);
objects.push_back(read_list(stream, true));
stream.seek_past_whitespace_and_comments();
continue;
} else if (tok.text[0] == ')') {
assert(tok.text.length() == 1);
ASSERT(tok.text.length() == 1);
got_close_paren = true;
break;
} else {
@@ -531,19 +531,19 @@ Object Reader::read_list(TextStream& ts, bool expect_close_paren) {
};
if (tok.text.empty()) {
assert(false);
ASSERT(false);
// empty list
break;
} else if (tok.text[0] == '(') {
// nested list
assert(tok.text.length() == 1);
ASSERT(tok.text.length() == 1);
insert_object(read_list(ts, true));
ts.seek_past_whitespace_and_comments();
continue;
} else if (tok.text[0] == ')') {
// end of this list
got_close_paren = true;
assert(tok.text.length() == 1);
ASSERT(tok.text.length() == 1);
break;
} else {
// try to get an object
@@ -604,7 +604,7 @@ Object Reader::read_list(TextStream& ts, bool expect_close_paren) {
*/
bool Reader::try_token_as_symbol(const Token& tok, Object& obj) {
// check start character is valid:
assert(!tok.text.empty());
ASSERT(!tok.text.empty());
char start = tok.text[0];
if (m_valid_symbols_chars[(int)start]) {
obj = SymbolObject::make_new(symbolTable, tok.text);
@@ -663,7 +663,7 @@ bool Reader::read_string(TextStream& stream, Object& obj) {
if (end != 2) {
throw_reader_error(stream, "invalid character escape", -2);
}
assert(value < 256);
ASSERT(value < 256);
str.push_back(char(value));
} else {
throw_reader_error(stream, "unknown string escape code", -1);
+4 -4
View File
@@ -21,7 +21,7 @@
#include "ReplUtils.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace goos {
@@ -36,17 +36,17 @@ struct TextStream {
int line_count = 0;
char peek() {
assert(seek < text->get_size());
ASSERT(seek < text->get_size());
return text->get_text()[seek];
}
char peek(int i) {
assert(seek + i < text->get_size());
ASSERT(seek + i < text->get_size());
return text->get_text()[seek + i];
}
char read() {
assert(seek < text->get_size());
ASSERT(seek < text->get_size());
char c = text->get_text()[seek++];
if (c == '\n')
line_count++;
+1 -1
View File
@@ -104,7 +104,7 @@ void TextDb::insert(const std::shared_ptr<SourceText>& frag) {
void TextDb::link(const Object& o, std::shared_ptr<SourceText> frag, int offset) {
if (o.is_empty_list())
return;
assert(o.is_pair());
ASSERT(o.is_pair());
TextRef ref;
ref.offset = offset;
ref.frag = std::move(frag);
+4 -4
View File
@@ -6,7 +6,7 @@
#ifdef _WIN32 // see lg::initialize
#include <Windows.h>
#endif
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace lg {
struct Logger {
@@ -76,9 +76,9 @@ void log_message(level log_level, LogTime& now, const char* message) {
} // namespace internal
void set_file(const std::string& filename) {
assert(!gLogger.fp);
ASSERT(!gLogger.fp);
gLogger.fp = fopen(filename.c_str(), "w");
assert(gLogger.fp);
ASSERT(gLogger.fp);
}
void set_flush_level(level log_level) {
@@ -100,7 +100,7 @@ void set_max_debug_levels() {
}
void initialize() {
assert(!gLogger.initialized);
ASSERT(!gLogger.initialized);
#ifdef _WIN32
// Enable some console terminal flags. Some of these may not be enabled by default, unless
+4 -4
View File
@@ -156,8 +156,8 @@ inline u32 psmt4_addr_half_byte(u32 x, u32 y, u32 width) {
const u32 psm4_table[8][4] = {{0, 2, 8, 10}, {1, 3, 9, 11}, {4, 6, 12, 14},
{5, 7, 13, 15}, {16, 18, 24, 26}, {17, 19, 25, 27},
{20, 22, 28, 30}, {21, 23, 29, 31}};
assert(block_row < 8);
assert(block_col < 4);
ASSERT(block_row < 8);
ASSERT(block_col < 4);
u32 block = psm4_table[block_row][block_col]; // it's the same table!!!
// both columns and pixels within columns.
@@ -196,8 +196,8 @@ inline u32 psmt4_addr_half_byte(u32 x, u32 y, u32 width) {
405, 413, 437, 445, 469, 477, 501, 509, 407, 415, 439, 447, 471, 479, 503, 511},
};
assert(block_y < 16);
assert(block_x < 32);
ASSERT(block_y < 16);
ASSERT(block_x < 32);
u32 pixel = pix_table[block_y][block_x];
return (page * 128 * 128) + (block * 32 * 16) + pixel;
}
+5 -5
View File
@@ -6,7 +6,7 @@
#include <stdexcept>
#include "third-party/fmt/core.h"
#include "Type.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace {
std::string reg_kind_to_string(RegClass kind) {
@@ -326,7 +326,7 @@ bool Type::get_my_method(const std::string& name, MethodInfo* out) const {
* Get a method that is defined specifically in this type by id. Returns if it was found or not.
*/
bool Type::get_my_method(int id, MethodInfo* out) const {
assert(id > 0); // 0 is new, should use explicit new method functions instead.
ASSERT(id > 0); // 0 is new, should use explicit new method functions instead.
for (auto& x : m_methods) {
if (x.id == id) {
*out = x;
@@ -369,7 +369,7 @@ bool Type::get_my_new_method(MethodInfo* out) const {
const MethodInfo& Type::add_method(const MethodInfo& info) {
for (auto it = m_methods.rbegin(); it != m_methods.rend(); it++) {
if (!it->overrides_method_type_of_parent) {
assert(it->id + 1 == info.id);
ASSERT(it->id + 1 == info.id);
break;
}
}
@@ -383,7 +383,7 @@ const MethodInfo& Type::add_method(const MethodInfo& info) {
* this is specific to the method named NEW.
*/
const MethodInfo& Type::add_new_method(const MethodInfo& info) {
assert(info.name == "new");
ASSERT(info.name == "new");
m_new_method_info_defined = true;
m_new_method_info = info;
return m_new_method_info;
@@ -553,7 +553,7 @@ bool ValueType::get_load_signed() const {
void ValueType::set_offset(int offset) {
if (offset) {
assert(m_is_boxed);
ASSERT(m_is_boxed);
}
m_offset = offset;
}
+3 -3
View File
@@ -10,7 +10,7 @@
#include <unordered_map>
#include "common/goal_constants.h"
#include "TypeSpec.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
class TypeSystem;
@@ -219,12 +219,12 @@ class Field {
std::string diff(const Field& other) const;
int alignment() const {
assert(m_alignment != -1);
ASSERT(m_alignment != -1);
return m_alignment;
}
int array_size() const {
assert(is_array() && !is_dynamic());
ASSERT(is_array() && !is_dynamic());
return m_array_size;
}
+6 -6
View File
@@ -18,8 +18,8 @@ bool deref_matches(const DerefInfo& expected,
const DerefKind& actual,
bool is_integer,
bool is_basic) {
assert(expected.mem_deref);
assert(expected.can_deref);
ASSERT(expected.mem_deref);
ASSERT(expected.can_deref);
if (actual.is_store || actual.size >= 8 || !is_integer) {
// don't check sign extension
return expected.load_size == actual.size;
@@ -62,7 +62,7 @@ std::string FieldReverseLookupOutput::Token::print() const {
case Kind::VAR_IDX:
return "__VAR__";
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -132,7 +132,7 @@ void try_reverse_lookup_array_like(const FieldReverseLookupInput& input,
auto di = ts.get_deref_info(array_data_type);
bool is_integer = ts.tc(TypeSpec("integer"), input.base_type.get_single_arg());
bool is_basic = ts.tc(TypeSpec("basic"), input.base_type.get_single_arg());
assert(di.mem_deref); // it's accessing a pointer.
ASSERT(di.mem_deref); // it's accessing a pointer.
auto elt_type = di.result_type;
if (input.stride) {
@@ -243,8 +243,8 @@ void try_reverse_lookup_inline_array(const FieldReverseLookupInput& input,
return;
}
auto di = ts.get_deref_info(input.base_type);
assert(di.can_deref);
assert(!di.mem_deref);
ASSERT(di.can_deref);
ASSERT(!di.mem_deref);
if (input.stride && input.stride == di.stride && input.offset < di.stride) {
// variable lookup.
+7 -7
View File
@@ -9,7 +9,7 @@
#include <string>
#include <optional>
#include "common/util/SmallVector.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* A :name value modifier to apply to a type.
@@ -103,8 +103,8 @@ class TypeSpec {
}
const TypeSpec& get_single_arg() const {
assert(m_arguments);
assert(m_arguments->size() == 1);
ASSERT(m_arguments);
ASSERT(m_arguments->size() == 1);
return m_arguments->front();
}
@@ -118,16 +118,16 @@ class TypeSpec {
}
const TypeSpec& get_arg(int idx) const {
assert(m_arguments);
ASSERT(m_arguments);
return m_arguments->at(idx);
}
TypeSpec& get_arg(int idx) {
assert(m_arguments);
ASSERT(m_arguments);
return m_arguments->at(idx);
}
const TypeSpec& last_arg() const {
assert(m_arguments);
assert(!m_arguments->empty());
ASSERT(m_arguments);
ASSERT(!m_arguments->empty());
return m_arguments->back();
}
+8 -8
View File
@@ -10,7 +10,7 @@
#include <stdexcept>
#include "TypeSystem.h"
#include "common/util/math_util.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace {
template <typename... Args>
@@ -283,7 +283,7 @@ DerefInfo TypeSystem::get_deref_info(const TypeSpec& ts) const {
result_type->get_inline_array_stride_alignment());
} else {
// can't have an inline array of value types!
assert(false);
ASSERT(false);
}
} else if (ts.base_type() == "pointer") {
info.can_deref = true;
@@ -300,7 +300,7 @@ DerefInfo TypeSystem::get_deref_info(const TypeSpec& ts) const {
info.sign_extend = result_type->get_load_signed();
info.reg = result_type->get_preferred_reg_class();
info.load_size = result_type->get_load_size();
assert(result_type->get_size_in_memory() == result_type->get_load_size());
ASSERT(result_type->get_size_in_memory() == result_type->get_load_size());
}
} else {
info.can_deref = false;
@@ -474,7 +474,7 @@ int TypeSystem::get_load_size_allow_partial_def(const TypeSpec& ts) const {
throw_typesystem_error("Cannot perform a load or store from partially defined type {}",
ts.print());
}
assert(partial_def->get_load_size() == 4);
ASSERT(partial_def->get_load_size() == 4);
return partial_def->get_load_size();
}
@@ -1212,7 +1212,7 @@ int TypeSystem::get_size_in_type(const Field& field) const {
"Attempted to use `{}` inline, this probably isn't what you wanted.\n",
field_type->get_name());
}
assert(field_type->is_reference());
ASSERT(field_type->is_reference());
return field.array_size() * align(field_type->get_size_in_memory(),
field_type->get_inline_array_stride_alignment());
} else {
@@ -1236,7 +1236,7 @@ int TypeSystem::get_size_in_type(const Field& field) const {
"may not be defined fully.\n",
field_type->get_name());
}
assert(field_type->is_reference());
ASSERT(field_type->is_reference());
// return align(field_type->get_size_in_memory(), field_type->get_in_memory_alignment());
// looking at dead-pool-heap we tightly pack in this case
return field_type->get_size_in_memory();
@@ -1475,7 +1475,7 @@ std::string TypeSystem::lca_base(const std::string& a, const std::string& b) con
bi--;
}
assert(result);
ASSERT(result);
return *result;
}
@@ -1508,7 +1508,7 @@ TypeSpec TypeSystem::lowest_common_ancestor_reg(const TypeSpec& a, const TypeSpe
* Lowest common ancestor of multiple (or at least one) type.
*/
TypeSpec TypeSystem::lowest_common_ancestor(const std::vector<TypeSpec>& types) const {
assert(!types.empty());
ASSERT(!types.empty());
if (types.size() == 1) {
return types.front();
}
+5 -5
View File
@@ -526,7 +526,7 @@ TypeSpec parse_typespec(const TypeSystem* type_system, const goos::Object& src)
} else {
throw std::runtime_error("invalid typespec: " + src.print());
}
assert(false);
ASSERT(false);
return {};
}
@@ -553,7 +553,7 @@ DeftypeResult parse_deftype(const goos::Object& deftype, TypeSystem* ts) {
if (is_type("basic", parent_type, ts)) {
auto new_type = std::make_unique<BasicType>(parent_type_name, name, false, 0);
auto pto = dynamic_cast<BasicType*>(ts->lookup_type(parent_type));
assert(pto);
ASSERT(pto);
if (pto->final()) {
throw std::runtime_error(
fmt::format("[TypeSystem] Cannot make a child type {} of final basic type {}", name,
@@ -589,7 +589,7 @@ DeftypeResult parse_deftype(const goos::Object& deftype, TypeSystem* ts) {
} else if (is_type("structure", parent_type, ts)) {
auto new_type = std::make_unique<StructureType>(parent_type_name, name, false, false, false, 0);
auto pto = dynamic_cast<StructureType*>(ts->lookup_type(parent_type));
assert(pto);
ASSERT(pto);
new_type->inherit(pto);
ts->forward_declare_type_as(name, "structure");
auto sr = parse_structure_def(new_type.get(), ts, field_list_obj, options_obj);
@@ -612,11 +612,11 @@ DeftypeResult parse_deftype(const goos::Object& deftype, TypeSystem* ts) {
ts->add_type(name, std::move(new_type));
} else if (is_type("integer", parent_type, ts)) {
auto pto = ts->lookup_type(parent_type);
assert(pto);
ASSERT(pto);
auto new_type = std::make_unique<BitFieldType>(
parent_type_name, name, pto->get_size_in_memory(), pto->get_load_signed());
auto parent_value = dynamic_cast<ValueType*>(pto);
assert(parent_value);
ASSERT(parent_value);
new_type->inherit(parent_value);
new_type->set_runtime_type(pto->get_runtime_name());
auto sr = parse_bitfield_type_def(new_type.get(), ts, field_list_obj, options_obj);
+4 -4
View File
@@ -5,7 +5,7 @@
* Convert a (state <blah> ...) to the function required to go. Must be state.
*/
TypeSpec state_to_go_function(const TypeSpec& state_type, const TypeSpec& return_type) {
assert(state_type.base_type() == "state");
ASSERT(state_type.base_type() == "state");
std::vector<TypeSpec> arg_types;
for (int i = 0; i < (int)state_type.arg_count() - 1; i++) {
arg_types.push_back(state_type.get_arg(i));
@@ -31,7 +31,7 @@ StateHandler handler_name_to_kind(const std::string& name) {
} else if (name == "post") {
return StateHandler::POST;
} else {
assert(false);
ASSERT(false);
}
}
@@ -50,7 +50,7 @@ std::string handler_kind_to_name(StateHandler kind) {
case StateHandler::POST:
return "post";
default:
assert(false);
ASSERT(false);
}
}
@@ -80,7 +80,7 @@ TypeSpec get_state_handler_type(StateHandler kind, const TypeSpec& state_type) {
break;
default:
assert(false);
ASSERT(false);
}
result.add_or_modify_tag("behavior", state_type.last_arg().base_type());
return result;
+9
View File
@@ -0,0 +1,9 @@
#include <cstdio>
#include <cstdlib>
#include "Assert.h"
void private_assert_failed(const char* expr, const char* file, int line, const char* function) {
fprintf(stderr, "%s:%d: Assertion failed: %s\nFunction: %s\n", file, line, expr, function);
abort();
}
+18
View File
@@ -0,0 +1,18 @@
/*!
* @file assert.h
* Custom ASSERT macro
*/
#pragma once
[[noreturn]] void private_assert_failed(const char* expr,
const char* file,
int line,
const char* function);
#ifdef _WIN32
#define __PRETTY_FUNCTION__ __FUNCSIG__
#endif
#define ASSERT(EX) \
(void)((EX) || (private_assert_failed(#EX, __FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
+3 -3
View File
@@ -9,7 +9,7 @@
#include <cstring>
#include <vector>
#include "common/common_types.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
class BinaryReader {
public:
@@ -17,7 +17,7 @@ class BinaryReader {
template <typename T>
T read() {
assert(m_seek + sizeof(T) <= m_buffer.size());
ASSERT(m_seek + sizeof(T) <= m_buffer.size());
T obj;
memcpy(&obj, m_buffer.data() + m_seek, sizeof(T));
m_seek += sizeof(T);
@@ -26,7 +26,7 @@ class BinaryReader {
void ffwd(int amount) {
m_seek += amount;
assert(m_seek <= m_buffer.size());
ASSERT(m_seek <= m_buffer.size());
}
uint32_t bytes_left() const { return m_buffer.size() - m_seek; }
+3 -3
View File
@@ -9,7 +9,7 @@
#include <vector>
#include <cstdint>
#include <cstring>
#include "common/util/assert.h"
#include "common/util/Assert.h"
struct BinaryWriterRef {
size_t offset;
@@ -30,8 +30,8 @@ class BinaryWriter {
template <typename T>
void add_at_ref(const T& obj, const BinaryWriterRef& ref) {
assert(ref.write_size == sizeof(T));
assert(ref.offset + ref.write_size < get_size());
ASSERT(ref.write_size == sizeof(T));
ASSERT(ref.offset + ref.write_size < get_size());
memcpy(data.data() + ref.offset, &obj, sizeof(T));
}
+1 -1
View File
@@ -25,7 +25,7 @@ bool integer_fits(s64 in, int size, bool is_signed) {
case 8:
return true;
default:
assert(false);
ASSERT(false);
return false;
}
}
+2 -2
View File
@@ -3,7 +3,7 @@
#include <optional>
#include "common/util/Range.h"
#include "common/common_types.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
constexpr int BITS_PER_BYTE = 8;
template <typename T>
@@ -56,7 +56,7 @@ std::optional<int> get_power_of_two(T in) {
return i;
}
}
assert(false);
ASSERT(false);
} else {
return std::nullopt;
}
+4 -4
View File
@@ -1,5 +1,5 @@
#include <utility>
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*
template<typename T, typename... Args>
@@ -90,9 +90,9 @@ class CopyOnWrite {
}
if (!m_data->unique()) {
assert(!m_data->dead());
ASSERT(!m_data->dead());
m_data->remove_ref(); // don't need to check for dead here, there's another ref somewhere.
assert(!m_data->dead());
ASSERT(!m_data->dead());
m_data = new ObjectAndCount(m_data->object);
m_data->add_ref();
}
@@ -111,7 +111,7 @@ class CopyOnWrite {
}
void acquire_object(ObjectAndCount* obj) {
assert(!m_data);
ASSERT(!m_data);
m_data = obj;
if (obj) {
m_data->add_ref();
+4 -4
View File
@@ -28,7 +28,7 @@ DgoReader::DgoReader(std::string file_name, const std::vector<u8>& data)
(int)reader.bytes_left());
obj_header.size = reader.bytes_left();
}
assert(reader.bytes_left() >= obj_header.size);
ASSERT(reader.bytes_left() >= obj_header.size);
assert_string_empty_after(obj_header.name, 60);
DgoDataEntry entry;
@@ -44,7 +44,7 @@ DgoReader::DgoReader(std::string file_name, const std::vector<u8>& data)
all_unique_names.insert(entry.unique_name);
entry.data.resize(obj_header.size);
assert((reader.get_seek() % 16) == 0);
ASSERT((reader.get_seek() % 16) == 0);
memcpy(entry.data.data(), reader.here(), obj_header.size);
m_entries.push_back(entry);
@@ -52,8 +52,8 @@ DgoReader::DgoReader(std::string file_name, const std::vector<u8>& data)
}
// check we're at the end
assert(0 == reader.bytes_left());
assert(all_unique_names.size() == m_entries.size());
ASSERT(0 == reader.bytes_left());
ASSERT(all_unique_names.size() == m_entries.size());
}
std::string DgoReader::description_as_json() const {
+6 -6
View File
@@ -23,7 +23,7 @@
#include <unistd.h>
#include <cstring>
#endif
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace file_util {
std::filesystem::path get_user_home_dir() {
@@ -176,7 +176,7 @@ std::string combine_path(const std::string& parent, const std::string& child) {
std::string base_name(const std::string& filename) {
size_t pos = 0;
assert(!filename.empty());
ASSERT(!filename.empty());
for (size_t i = filename.size() - 1; i-- > 0;) {
if (filename.at(i) == '/' || filename.at(i) == '\\') {
pos = (i + 1);
@@ -201,7 +201,7 @@ void init_crc() {
}
uint32_t crc32(const uint8_t* data, size_t size) {
assert(sInitCrc);
ASSERT(sInitCrc);
uint32_t crc = 0;
for (size_t i = size; i != 0; i--, data++) {
crc = crc_table[crc >> 24u] ^ ((crc << 8u) | *data);
@@ -343,7 +343,7 @@ void MakeISOName(char* dst, const char* src) {
void assert_file_exists(const char* path, const char* error_message) {
if (!std::filesystem::exists(path)) {
fprintf(stderr, "File %s was not found: %s\n", path, error_message);
assert(false);
ASSERT(false);
}
}
@@ -385,12 +385,12 @@ std::vector<u8> decompress_dgo(const std::vector<u8>& data_in) {
lzokay::EResult ok = lzokay::decompress(
compressed_reader.here(), chunk_size, decompressed_data.data() + output_offset,
decompressed_data.size() - output_offset, bytes_written);
assert(ok == lzokay::EResult::Success);
ASSERT(ok == lzokay::EResult::Success);
compressed_reader.ffwd(chunk_size);
output_offset += bytes_written;
} else {
// nope - sometimes chunk_size is bigger than MAX, but we should still use max.
// assert(chunk_size == MAX_CHUNK_SIZE);
// ASSERT(chunk_size == MAX_CHUNK_SIZE);
memcpy(decompressed_data.data() + output_offset, compressed_reader.here(), MAX_CHUNK_SIZE);
compressed_reader.ffwd(MAX_CHUNK_SIZE);
output_offset += MAX_CHUNK_SIZE;
+2 -2
View File
@@ -60,7 +60,7 @@ const EncodeInfo* GameTextFontBank::find_encode_to_game(const std::string& in, i
continue;
bool found = true;
for (int i = 0; found && i < (int)info.chars.length() && i + off < in.size(); ++i) {
for (int i = 0; found && i < (int)info.chars.length() && i + off < (int)in.size(); ++i) {
if (in.at(i + off) != info.chars.at(i)) {
found = false;
}
@@ -101,7 +101,7 @@ std::string GameTextFontBank::replace_to_game(std::string& str) const {
std::string GameTextFontBank::encode_utf8_to_game(std::string& str) const {
std::string new_str;
for (int i = 0; i < str.length();) {
for (int i = 0; i < (int)str.length();) {
auto remap = find_encode_to_game(str, i);
if (!remap) {
new_str.push_back(str.at(i));
+9 -9
View File
@@ -3,7 +3,7 @@
#include <cstring>
#include <string>
#include <vector>
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* The Serializer is a tool to load or save data from a buffer.
@@ -93,7 +93,7 @@ class Serializer {
*/
template <typename T>
T load() {
assert(!m_writing);
ASSERT(!m_writing);
T result;
read_or_write(&result, sizeof(T));
return result;
@@ -104,7 +104,7 @@ class Serializer {
*/
template <typename T>
void save(const T& thing) {
assert(m_writing);
ASSERT(m_writing);
read_or_write(const_cast<T*>(&thing), sizeof(T));
}
@@ -126,7 +126,7 @@ class Serializer {
* const_cast.
*/
void save_str(const std::string* str) {
assert(is_saving());
ASSERT(is_saving());
// safe, we're saving, so from_str will only read.
from_str(const_cast<std::string*>(str));
}
@@ -135,7 +135,7 @@ class Serializer {
* Load a std::string and return it.
*/
std::string load_string() {
assert(is_loading());
ASSERT(is_loading());
std::string s;
from_str(&s);
return s;
@@ -168,7 +168,7 @@ class Serializer {
* Reset a load back to the beginning.
*/
void reset_load() {
assert(is_loading());
ASSERT(is_loading());
m_offset = 0;
}
@@ -176,7 +176,7 @@ class Serializer {
* Get the result of the save. This is a view of the buffer owned by the Serializer.
*/
std::pair<const u8*, size_t> get_save_result() {
assert(m_writing);
ASSERT(m_writing);
return {m_data, m_offset};
}
@@ -184,7 +184,7 @@ class Serializer {
* Have we reached the end of the load?
*/
bool get_load_finished() const {
assert(!m_writing);
ASSERT(!m_writing);
return m_offset == m_size;
}
@@ -206,7 +206,7 @@ class Serializer {
memcpy(m_data + m_offset, data, size);
} else {
// if we would overflow, it's an error.
assert(m_offset + size <= m_size);
ASSERT(m_offset + size <= m_size);
memcpy(data, m_data + m_offset, size);
}
m_offset += size;
+3 -3
View File
@@ -5,7 +5,7 @@
#include <new>
#include <type_traits>
#include <utility>
#include "assert.h"
#include "common/util/Assert.h"
namespace cu {
// This might seem stupid, but compiling an empty file with #include <algorithm> takes 0.5 seconds.
@@ -346,7 +346,7 @@ class SmallVector {
* Get the element at the index. Assert the index is valid.
*/
T& at(std::size_t idx) {
assert(idx < m_size);
ASSERT(idx < m_size);
return m_storage_begin[idx];
}
@@ -354,7 +354,7 @@ class SmallVector {
* Get the element at the index. Assert the index is valid.
*/
const T& at(std::size_t idx) const {
assert(idx < m_size);
ASSERT(idx < m_size);
return m_storage_begin[idx];
}
+1 -1
View File
@@ -2,7 +2,7 @@
#include <cstdint>
#include <ctime>
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* Timer for measuring time elapsed with clock_monotonic
+1 -1
View File
@@ -2,7 +2,7 @@
#include <vector>
#include <string>
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* A simple prefix tree. It works similarly to a map, but also supports fast lookups by prefix with
-19
View File
@@ -1,19 +0,0 @@
/*!
* @file assert.h
* Wrapper around <cassert>.
* Make sure this file is always the last one included.
*/
#if defined NDEBUG
#undef NDEBUG
#undef assert
#include <cassert>
#define NDEBUG 1
#else
#include <cassert>
#endif
+5 -5
View File
@@ -3,7 +3,7 @@
#include "compress.h"
#include "third-party/zstd/lib/zstd.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace compression {
@@ -18,7 +18,7 @@ std::vector<u8> compress_zstd(const void* data, size_t size) {
ZSTD_compress(result.data() + sizeof(size_t), max_compressed, data, size, 1);
if (ZSTD_isError(compressed_size)) {
printf("ZSTD error: %s\n", ZSTD_getErrorName(compressed_size));
assert(false);
ASSERT(false);
}
result.resize(sizeof(size_t) + compressed_size);
return result;
@@ -29,7 +29,7 @@ std::vector<u8> compress_zstd(const void* data, size_t size) {
* decompressed data's size.
*/
std::vector<u8> decompress_zstd(const void* data, size_t size) {
assert(size >= sizeof(size_t));
ASSERT(size >= sizeof(size_t));
size_t decompressed_size;
memcpy(&decompressed_size, data, sizeof(size_t));
size_t compressed_size = size - sizeof(size_t);
@@ -39,10 +39,10 @@ std::vector<u8> decompress_zstd(const void* data, size_t size) {
(const u8*)data + sizeof(size_t), compressed_size);
if (ZSTD_isError(decomp_size)) {
printf("ZSTD error: %s\n", ZSTD_getErrorName(compressed_size));
assert(false);
ASSERT(false);
}
assert(decomp_size == decompressed_size);
ASSERT(decomp_size == decompressed_size);
return result;
}
} // namespace compression
+5 -5
View File
@@ -2,7 +2,7 @@
#include "dgo_util.h"
#include "common/versions.h"
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* Assert false if the char[] has non-null data after the null terminated string.
@@ -13,7 +13,7 @@ void assert_string_empty_after(const char* str, int size) {
while (*ptr)
ptr++;
while (ptr - str < size) {
assert(!*ptr);
ASSERT(!*ptr);
ptr++;
}
}
@@ -37,12 +37,12 @@ std::string get_object_file_name(const std::string& original_name, u8* data, int
if (!failed) {
for (int i = 0; i < int(original_name.length()); i++) {
if (start + len + i >= size || data[start + len + i] != original_name[i]) {
assert(false);
ASSERT(false);
}
}
assert(int(suffix.length()) + start + len + int(original_name.length()) < size);
assert(
ASSERT(int(suffix.length()) + start + len + int(original_name.length()) < size);
ASSERT(
!memcmp(data + start + len + original_name.length(), suffix.data(), suffix.length() + 1));
return original_name + "-ag";
+2 -2
View File
@@ -1,6 +1,6 @@
#include "common/log/log.h"
#include "json_util.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* Strip out // and / * comments
@@ -57,7 +57,7 @@ std::string strip_cpp_style_comments(const std::string& input) {
output.push_back(c);
break;
default:
assert(false);
ASSERT(false);
}
}
+2 -2
View File
@@ -4,7 +4,7 @@
#include "common/goal_constants.h"
#include "third-party/dragonbox.h"
#include "print_float.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
/*!
* Convert a float to a string. The string is _always_ in this format:
@@ -28,7 +28,7 @@ std::string meters_to_string(float value, bool append_trailing_decimal) {
}
int float_to_cstr(float value, char* buffer, bool append_trailing_decimal) {
assert(std::isfinite(value));
ASSERT(std::isfinite(value));
// dragonbox gives us:
// - an integer, representing the decimal value
// - sign
+21 -21
View File
@@ -7,7 +7,7 @@
#include "Instruction.h"
#include "decompiler/ObjectFile/LinkedObjectFile.h"
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/*!
@@ -28,7 +28,7 @@ std::string InstructionAtom::to_string(const std::vector<DecompilerLabel>& label
case IMM_SYM:
return sym;
case VF_FIELD:
assert(imm >= 0 && imm < 4);
ASSERT(imm >= 0 && imm < 4);
return fmt::format(".{}", "xyzw"[imm]);
default:
throw std::runtime_error("Unsupported InstructionAtom");
@@ -87,14 +87,14 @@ void InstructionAtom::set_sym(std::string _sym) {
void InstructionAtom::set_vf_field(uint32_t value) {
kind = VF_FIELD;
imm = value;
assert(value < 4);
ASSERT(value < 4);
}
/*!
* Get as register, or error if not a register.
*/
Register InstructionAtom::get_reg() const {
assert(kind == REGISTER);
ASSERT(kind == REGISTER);
return reg;
}
@@ -102,7 +102,7 @@ Register InstructionAtom::get_reg() const {
* Get as integer immediate, or error if not an integer immediate.
*/
int32_t InstructionAtom::get_imm() const {
assert(kind == IMM);
ASSERT(kind == IMM);
return imm;
}
@@ -110,7 +110,7 @@ int32_t InstructionAtom::get_imm() const {
* Get the VF_FIELD as an integer immediate, or error if not applicable.
*/
int32_t InstructionAtom::get_vf_field() const {
assert(kind == VF_FIELD);
ASSERT(kind == VF_FIELD);
return imm;
}
@@ -118,7 +118,7 @@ int32_t InstructionAtom::get_vf_field() const {
* Get as label index, or error if not a label.
*/
int InstructionAtom::get_label() const {
assert(kind == LABEL);
ASSERT(kind == LABEL);
return label_id;
}
@@ -126,7 +126,7 @@ int InstructionAtom::get_label() const {
* Get as symbol, or error if not a symbol.
*/
std::string InstructionAtom::get_sym() const {
assert(kind == IMM_SYM);
ASSERT(kind == IMM_SYM);
return sym;
}
@@ -152,7 +152,7 @@ bool InstructionAtom::operator==(const InstructionAtom& other) const {
case VU_Q:
return true;
default:
assert(false);
ASSERT(false);
return false;
}
}
@@ -231,8 +231,8 @@ std::string Instruction::to_string(const std::vector<DecompilerLabel>& labels) c
// relative store and load instructions have a special syntax in MIPS
if (info.is_store) {
assert(n_dst == 0);
assert(n_src == 3);
ASSERT(n_dst == 0);
ASSERT(n_src == 3);
result += " ";
result += src[0].to_string(labels);
result += ", ";
@@ -241,8 +241,8 @@ std::string Instruction::to_string(const std::vector<DecompilerLabel>& labels) c
result += src[2].to_string(labels);
result += ")";
} else if (info.is_load) {
assert(n_dst == 1);
assert(n_src == 2);
ASSERT(n_dst == 1);
ASSERT(n_src == 2);
result += " ";
result += dst[0].to_string(labels);
result += ", ";
@@ -290,7 +290,7 @@ bool Instruction::is_valid() const {
* Add a destination atom to this Instruction
*/
void Instruction::add_dst(InstructionAtom& a) {
assert(n_dst < MAX_INTRUCTION_DEST);
ASSERT(n_dst < MAX_INTRUCTION_DEST);
dst[n_dst++] = a;
}
@@ -298,7 +298,7 @@ void Instruction::add_dst(InstructionAtom& a) {
* Add a source atom to this Instruction
*/
void Instruction::add_src(InstructionAtom& a) {
assert(n_src < MAX_INSTRUCTION_SOURCE);
ASSERT(n_src < MAX_INSTRUCTION_SOURCE);
src[n_src++] = a;
}
@@ -311,7 +311,7 @@ InstructionAtom& Instruction::get_imm_src() {
return src[i];
}
}
assert(false);
ASSERT(false);
return src[0];
}
@@ -326,7 +326,7 @@ int32_t Instruction::get_imm_src_int() {
* Safe get dst atom
*/
InstructionAtom& Instruction::get_dst(size_t idx) {
assert(idx < n_dst);
ASSERT(idx < n_dst);
return dst[idx];
}
@@ -334,7 +334,7 @@ InstructionAtom& Instruction::get_dst(size_t idx) {
* Safe get src atom
*/
InstructionAtom& Instruction::get_src(size_t idx) {
assert(idx < n_src);
ASSERT(idx < n_src);
return src[idx];
}
@@ -342,7 +342,7 @@ InstructionAtom& Instruction::get_src(size_t idx) {
* Safe get dst atom
*/
const InstructionAtom& Instruction::get_dst(size_t idx) const {
assert(idx < n_dst);
ASSERT(idx < n_dst);
return dst[idx];
}
@@ -350,7 +350,7 @@ const InstructionAtom& Instruction::get_dst(size_t idx) const {
* Safe get src atom
*/
const InstructionAtom& Instruction::get_src(size_t idx) const {
assert(idx < n_src);
ASSERT(idx < n_src);
return src[idx];
}
@@ -369,7 +369,7 @@ int Instruction::get_label_target() const {
int result = -1;
for (int i = 0; i < n_src; i++) {
if (src[i].kind == InstructionAtom::AtomKind::LABEL) {
assert(result == -1);
ASSERT(result == -1);
result = src[i].get_label();
}
}
+159 -159
View File
@@ -6,7 +6,7 @@
#include "InstructionDecode.h"
#include "decompiler/ObjectFile/LinkedObjectFile.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
// utility class to extract fields of an opcode.
@@ -83,7 +83,7 @@ static InstructionKind decode_cop2(OpcodeFields fields) {
return IK::QMFC2;
case 0b00101:
assert(((fields.data >> 1) & (0b1111111111)) == 0);
ASSERT(((fields.data >> 1) & (0b1111111111)) == 0);
return IK::QMTC2;
case 0b00010:
@@ -101,139 +101,139 @@ static InstructionKind decode_cop2(OpcodeFields fields) {
case 0b00010111101:
case 0b00010111110:
case 0b00010111111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMADDA_BC;
case 0b00000111100:
case 0b00000111101:
case 0b00000111110:
case 0b00000111111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VADDA_BC;
case 0b00110111100:
case 0b00110111101:
case 0b00110111110:
case 0b00110111111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMULA_BC;
case 0b01010111110:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMULA;
case 0b01010111100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VADDA;
case 0b01010111101:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMADDA;
case 0b00011111100:
case 0b00011111101:
case 0b00011111110:
case 0b00011111111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMSUBA_BC;
case 0b00101111100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VFTOI0;
case 0b00101111101:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VFTOI4;
case 0b00101111110:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VFTOI12;
case 0b00100111100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VITOF0;
case 0b00100111110:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VITOF12;
case 0b00100111111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VITOF15;
case 0b00111111100:
assert(fields.data & (1 << 25));
assert(fields.ft() == 0);
ASSERT(fields.data & (1 << 25));
ASSERT(fields.ft() == 0);
return IK::VMULAQ;
case 0b00111111101:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VABS;
case 0b00111111111:
assert(fields.data & (1 << 25));
assert(fields.dest() == 0b1110);
ASSERT(fields.data & (1 << 25));
ASSERT(fields.dest() == 0b1110);
return IK::VCLIP;
case 0b01011111111:
assert(fields.dest() == 0);
assert(fields.ft() == 0);
assert(fields.fs() == 0);
ASSERT(fields.dest() == 0);
ASSERT(fields.ft() == 0);
ASSERT(fields.fs() == 0);
return IK::VNOP;
case 0b01101111101:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VSQI;
case 0b01101111100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VLQI;
case 0b01110111111:
assert(fields.dest() == 0);
assert(fields.ft() == 0);
assert(fields.fs() == 0);
ASSERT(fields.dest() == 0);
ASSERT(fields.ft() == 0);
ASSERT(fields.fs() == 0);
return IK::VWAITQ;
case 0b01011111110:
assert(fields.dest() == 0b1110);
assert(fields.data & (1 << 25));
ASSERT(fields.dest() == 0b1110);
ASSERT(fields.data & (1 << 25));
return IK::VOPMULA;
case 0b01100111100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMOVE;
case 0b01110111100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VDIV;
case 0b01110111101:
assert(fields.fs() == 0);
assert(((fields.data >> 21) & 3) == 0);
assert(fields.data & (1 << 25));
ASSERT(fields.fs() == 0);
ASSERT(((fields.data >> 21) & 3) == 0);
ASSERT(fields.data & (1 << 25));
return IK::VSQRT;
case 0b01111111100:
assert(((fields.data >> 23) & 3) == 0);
assert(fields.data & (1 << 25));
ASSERT(((fields.data >> 23) & 3) == 0);
ASSERT(fields.data & (1 << 25));
return IK::VMTIR;
case 0b01110111110:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VRSQRT;
case 0b10000111100:
assert(fields.fs() == 0);
assert(fields.data & (1 << 25));
ASSERT(fields.fs() == 0);
ASSERT(fields.data & (1 << 25));
return IK::VRNEXT;
case 0b10000111101:
assert(fields.fs() == 0);
assert(fields.data & (1 << 25));
ASSERT(fields.fs() == 0);
ASSERT(fields.data & (1 << 25));
return IK::VRGET;
case 0b10000111111:
assert(fields.ft() == 0);
assert(fields.data & (1 << 25));
assert(((fields.data >> 23) & 3) == 0);
ASSERT(fields.ft() == 0);
ASSERT(fields.data & (1 << 25));
ASSERT(((fields.data >> 23) & 3) == 0);
return IK::VRXOR;
default:
@@ -242,105 +242,105 @@ static InstructionKind decode_cop2(OpcodeFields fields) {
case 0b000001:
case 0b000010:
case 0b000011:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VADD_BC;
case 0b000100:
case 0b000101:
case 0b000110:
case 0b000111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VSUB_BC;
case 0b001000:
case 0b001001:
case 0b001010:
case 0b001011:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMADD_BC;
case 0b001100:
case 0b001101:
case 0b001110:
case 0b001111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMSUB_BC;
case 0b010000:
case 0b010001:
case 0b010010:
case 0b010011:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMAX_BC;
case 0b010100:
case 0b010101:
case 0b010110:
case 0b010111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMINI_BC;
case 0b011000:
case 0b011001:
case 0b011010:
case 0b011011:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMUL_BC;
case 0b011100:
assert(fields.ft() == 0);
assert(fields.data & (1 << 25));
ASSERT(fields.ft() == 0);
ASSERT(fields.data & (1 << 25));
return IK::VMULQ;
case 0b100000:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VADDQ;
case 0b100100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VSUBQ;
case 0b100101:
assert(fields.ft() == 0);
assert(fields.data & (1 << 25));
ASSERT(fields.ft() == 0);
ASSERT(fields.data & (1 << 25));
return IK::VMSUBQ;
case 0b101000:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VADD;
case 0b101001:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMADD;
case 0b101010:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMUL;
case 0b101011:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMAX;
case 0b101100:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VSUB;
case 0b101101:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMSUB;
case 0b101110:
assert(fields.data & (1 << 25));
assert(fields.dest() == 0b1110);
ASSERT(fields.data & (1 << 25));
ASSERT(fields.dest() == 0b1110);
return IK::VOPMSUB;
case 0b101111:
assert(fields.data & (1 << 25));
ASSERT(fields.data & (1 << 25));
return IK::VMINI;
case 0b110010:
assert(fields.data & (1 << 25));
assert(fields.dest() == 0b0);
ASSERT(fields.data & (1 << 25));
ASSERT(fields.dest() == 0b0);
return IK::VIADDI;
case 0b110100:
assert(fields.data & (1 << 25));
assert(fields.dest() == 0b0);
ASSERT(fields.data & (1 << 25));
ASSERT(fields.dest() == 0b0);
return IK::VIAND;
case 0b111000:
assert(fields.data & (1 << 25));
assert(fields.dest() == 0b0);
ASSERT(fields.data & (1 << 25));
ASSERT(fields.dest() == 0b0);
return IK::VCALLMS;
default:
return IK::UNKNOWN;
@@ -352,7 +352,7 @@ static InstructionKind decode_W(OpcodeFields fields) {
typedef InstructionKind IK;
switch (fields.function()) {
case 0b100000:
assert(fields.ft() == 0);
ASSERT(fields.ft() == 0);
return IK::CVTSW;
default:
return IK::UNKNOWN;
@@ -373,47 +373,47 @@ static InstructionKind decode_S(OpcodeFields fields) {
case 0b000101:
return IK::ABSS;
case 0b000110:
assert(fields.ft() == 0);
ASSERT(fields.ft() == 0);
return IK::MOVS;
case 0b000111:
assert(fields.ft() == 0);
ASSERT(fields.ft() == 0);
return IK::NEGS;
case 0b000100:
assert(fields.fs() == 0);
ASSERT(fields.fs() == 0);
return IK::SQRTS;
case 0b010110:
return IK::RSQRTS;
case 0b011000:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::ADDAS;
case 0b011010:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::MULAS;
case 0b011100:
return IK::MADDS;
case 0b011101:
return IK::MSUBS;
case 0b011110:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::MADDAS;
case 0b011111:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::MSUBAS;
case 0b100100:
assert(fields.ft() == 0);
ASSERT(fields.ft() == 0);
return IK::CVTWS;
case 0b101000:
return IK::MAXS;
case 0b101001:
return IK::MINS;
case 0b110010:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::CEQS;
case 0b110100:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::CLTS;
case 0b110110:
assert(fields.fd() == 0);
ASSERT(fields.fd() == 0);
return IK::CLES;
default:
return IK::UNKNOWN;
@@ -440,12 +440,12 @@ static InstructionKind decode_cop1(OpcodeFields fields) {
typedef InstructionKind IK;
switch (fields.cop_func()) {
case 0b00000:
assert(fields.sa() == 0);
assert(fields.function() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.function() == 0);
return IK::MFC1;
case 0b00100:
assert(fields.sa() == 0);
assert(fields.function() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.function() == 0);
return IK::MTC1;
case 0b01000:
return decode_BC1(fields);
@@ -464,7 +464,7 @@ static InstructionKind decode_c0(OpcodeFields fields) {
case 0b011000:
return IK::ERET;
case 0b111000:
assert(fields.sa() == 0 && fields.rd() == 0 && fields.rt() == 0);
ASSERT(fields.sa() == 0 && fields.rd() == 0 && fields.rt() == 0);
return IK::EI;
default:
return IK::UNKNOWN;
@@ -477,10 +477,10 @@ static InstructionKind decode_mt0(OpcodeFields fields) {
case 0b00000000000:
return IK::MTC0;
case 0b00000000100:
assert(fields.rd() == 0b11000);
ASSERT(fields.rd() == 0b11000);
return IK::MTDAB;
case 0b00000000101:
assert(fields.rd() == 0b11000);
ASSERT(fields.rd() == 0b11000);
return IK::MTDABM;
default:
if (fields.rd() == 0b11001 && fields.sa() == 0 && (fields.data & 1) == 1) {
@@ -530,7 +530,7 @@ static InstructionKind decode_mmi3(OpcodeFields fields) {
case 0b10011:
return IK::PNOR;
case 0b11011:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::PCPYH;
default:
return IK::UNKNOWN;
@@ -619,16 +619,16 @@ static InstructionKind decode_pmfhl(OpcodeFields fields) {
typedef InstructionKind IK;
switch (fields.sa()) {
case 0b00001:
assert(fields.rs() == 0);
assert(fields.rt() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rt() == 0);
return IK::PMFHL_UW;
case 0b00000:
assert(fields.rs() == 0);
assert(fields.rt() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rt() == 0);
return IK::PMFHL_LW;
case 0b00011:
assert(fields.rs() == 0);
assert(fields.rt() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rt() == 0);
return IK::PMFHL_LH;
default:
return IK::UNKNOWN;
@@ -639,8 +639,8 @@ static InstructionKind decode_mmi(OpcodeFields fields) {
typedef InstructionKind IK;
switch (fields.function()) {
case 0b000100:
assert(fields.sa() == 0);
assert(fields.rt() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.rt() == 0);
return IK::PLZCW;
case 0b001000:
return decode_mmi0(fields);
@@ -648,14 +648,14 @@ static InstructionKind decode_mmi(OpcodeFields fields) {
return decode_mmi2(fields);
case 0b010011:
assert(fields.sa() == 0);
assert(fields.rd() == 0);
assert(fields.rt() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.rd() == 0);
ASSERT(fields.rt() == 0);
return IK::MTLO1;
case 0b010010:
assert(fields.sa() == 0);
assert(fields.rs() == 0);
assert(fields.rt() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rt() == 0);
return IK::MFLO1;
case 0b101000:
@@ -702,9 +702,9 @@ static InstructionKind decode_sync(OpcodeFields fields) {
// to avoid implementing this, we just split SYNC into two separate instructions.
typedef InstructionKind IK;
auto stype = fields.sa();
assert(fields.rt() == 0);
assert(fields.rs() == 0);
assert(fields.rd() == 0);
ASSERT(fields.rt() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rd() == 0);
if (stype == 0b00000) {
return IK::SYNCL;
} else if (stype == 0b10000) {
@@ -718,35 +718,35 @@ static InstructionKind decode_special(OpcodeFields fields) {
typedef InstructionKind IK;
switch (fields.function()) {
case 0b000000:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::SLL;
// RESERVED
case 0b000010:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::SRL;
case 0b000011:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::SRA;
case 0b000100:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::SLLV;
// RESERVED
// SRLV
// SRAV
case 0b001000:
assert(fields.sa() == 0);
assert(fields.rd() == 0);
assert(fields.rt() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.rd() == 0);
ASSERT(fields.rt() == 0);
return IK::JR;
case 0b001001:
assert(fields.rt() == 0);
assert(fields.sa() == 0);
ASSERT(fields.rt() == 0);
ASSERT(fields.sa() == 0);
return IK::JALR;
case 0b001010:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::MOVZ;
case 0b001011:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::MOVN;
case 0b001100:
return IK::SYSCALL;
@@ -756,69 +756,69 @@ static InstructionKind decode_special(OpcodeFields fields) {
return decode_sync(fields);
case 0b010000:
assert(fields.rs() == 0);
assert(fields.rt() == 0);
assert(fields.sa() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rt() == 0);
ASSERT(fields.sa() == 0);
return IK::MFHI;
// MTHI
case 0b010010:
assert(fields.rs() == 0);
assert(fields.rt() == 0);
assert(fields.sa() == 0);
ASSERT(fields.rs() == 0);
ASSERT(fields.rt() == 0);
ASSERT(fields.sa() == 0);
return IK::MFLO;
// MTLO
case 0b010100:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::DSLLV;
// RESERVED
case 0b010110:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::DSRLV;
case 0b010111:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::DSRAV;
case 0b011000:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::MULT3;
case 0b011001:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::MULTU3;
case 0b011010:
assert(fields.sa() == 0);
assert(fields.rd() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.rd() == 0);
return IK::DIV;
case 0b011011:
assert(fields.sa() == 0);
assert(fields.rd() == 0);
ASSERT(fields.sa() == 0);
ASSERT(fields.rd() == 0);
return IK::DIVU;
// 4x UNSUPPORTED
// ADD
case 0b100001:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::ADDU;
// SUB
case 0b100011:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::SUBU;
case 0b100100:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::AND;
case 0b100101:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::OR;
case 0b100110:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::XOR;
case 0b100111:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::NOR;
// MFSA
// MTSA
case 0b101010:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::SLT;
case 0b101011:
assert(fields.sa() == 0);
ASSERT(fields.sa() == 0);
return IK::SLTU;
// DADD
case 0b101101:
@@ -835,24 +835,24 @@ static InstructionKind decode_special(OpcodeFields fields) {
// TNE
// RESERVED
case 0b111000:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::DSLL;
// RESERVED
case 0b111010:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::DSRL;
case 0b111011:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::DSRA;
case 0b111100:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::DSLL32;
// RESERVED
case 0b111110:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::DSRL32;
case 0b111111:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::DSRA32;
default:
return IK::UNKNOWN;
@@ -906,7 +906,7 @@ static InstructionKind decode_opcode(uint32_t code) {
case 0b001110:
return IK::XORI;
case 0b001111:
assert(fields.rs() == 0);
ASSERT(fields.rs() == 0);
return IK::LUI;
case 0b010000:
return decode_cop0(fields);
@@ -923,7 +923,7 @@ static InstructionKind decode_opcode(uint32_t code) {
// 010110
// blezl
case 0b010111:
assert(fields.rt() == 0);
ASSERT(fields.rt() == 0);
return IK::BGTZL;
// 0b011000:
// daddi
@@ -1070,7 +1070,7 @@ Instruction decode_instruction(LinkedWord& word, LinkedObjectFile& file, int seg
value = fields.fs_f();
break;
default:
assert(false);
ASSERT(false);
}
// use the value, to possibly add an atom
@@ -1125,7 +1125,7 @@ Instruction decode_instruction(LinkedWord& word, LinkedObjectFile& file, int seg
continue;
default:
assert(false);
ASSERT(false);
}
if (step.is_src) {
@@ -1143,11 +1143,11 @@ Instruction decode_instruction(LinkedWord& word, LinkedObjectFile& file, int seg
i.src[j].set_sym(word.symbol_name());
}
}
assert(fixed);
ASSERT(fixed);
}
if (word.kind() == LinkedWord::HI_PTR) {
assert(i.kind == InstructionKind::LUI);
ASSERT(i.kind == InstructionKind::LUI);
bool fixed = false;
for (int j = 0; j < i.n_src; j++) {
if (i.src[j].kind == InstructionAtom::IMM) {
@@ -1155,11 +1155,11 @@ Instruction decode_instruction(LinkedWord& word, LinkedObjectFile& file, int seg
i.src[j].set_label(word.label_id());
}
}
assert(fixed);
ASSERT(fixed);
}
if (word.kind() == LinkedWord::LO_PTR) {
assert(i.kind == InstructionKind::ORI);
ASSERT(i.kind == InstructionKind::ORI);
bool fixed = false;
for (int j = 0; j < i.n_src; j++) {
if (i.src[j].kind == InstructionAtom::IMM) {
@@ -1167,7 +1167,7 @@ Instruction decode_instruction(LinkedWord& word, LinkedObjectFile& file, int seg
i.src[j].set_label(word.label_id());
}
}
assert(fixed);
ASSERT(fixed);
}
return i;
+9 -9
View File
@@ -4,7 +4,7 @@
*/
#include "InstructionMatching.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/*!
@@ -44,7 +44,7 @@ bool is_no_link_gpr_store(const Instruction& instr,
}
break;
default:
assert(false);
ASSERT(false);
}
} else {
// just make sure it's a gpr store
@@ -53,7 +53,7 @@ bool is_no_link_gpr_store(const Instruction& instr,
}
}
assert(instr.n_src == 3);
ASSERT(instr.n_src == 3);
// match other arguments
return src == instr.src[0].get_reg() && offset == instr.src[1].get_imm() &&
@@ -103,7 +103,7 @@ bool is_no_ll_gpr_load(const Instruction& instr,
}
break;
default:
assert(false);
ASSERT(false);
}
} else {
if (is_signed.value) {
@@ -134,7 +134,7 @@ bool is_no_ll_gpr_load(const Instruction& instr,
}
break;
default:
assert(false);
ASSERT(false);
}
} else {
switch (size.value) {
@@ -164,7 +164,7 @@ bool is_no_ll_gpr_load(const Instruction& instr,
}
break;
default:
assert(false);
ASSERT(false);
}
}
}
@@ -261,8 +261,8 @@ bool is_gpr_load(const Instruction& instr, MatchParam<bool> is_signed) {
* Given a store, get the offset as an integer.
*/
int32_t get_gpr_store_offset_as_int(const Instruction& instr) {
assert(is_gpr_store(instr));
assert(instr.n_src == 3);
ASSERT(is_gpr_store(instr));
ASSERT(instr.n_src == 3);
return instr.src[1].get_imm();
}
@@ -344,7 +344,7 @@ bool is_always_branch(const Instruction& instr) {
if (instr.kind == InstructionKind::BEQL && instr.get_src(0).get_reg() == r0 &&
instr.get_src(1).get_reg() == r0) {
assert(false);
ASSERT(false);
return true;
}
+24 -24
View File
@@ -3,7 +3,7 @@
#include <optional>
#include "common/common_types.h"
#include "InstructionParser.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
InstructionParser::InstructionParser() {
@@ -64,12 +64,12 @@ InstructionParser::InstructionParser() {
added++;
}
}
assert(added == int(m_opcode_name_lookup.size()) + int(m_opcode_name_broadcast_lookup.size()));
ASSERT(added == int(m_opcode_name_lookup.size()) + int(m_opcode_name_broadcast_lookup.size()));
}
namespace {
std::string get_until_space(std::string& instr) {
assert(!instr.empty());
ASSERT(!instr.empty());
size_t i;
for (i = 0; i < instr.length(); i++) {
if (instr[i] == ' ') {
@@ -86,7 +86,7 @@ std::string get_until_space(std::string& instr) {
}
std::string get_instr_name(std::string& instr) {
assert(!instr.empty());
ASSERT(!instr.empty());
size_t i;
for (i = 0; i < instr.length(); i++) {
if (instr[i] == ' ') {
@@ -121,12 +121,12 @@ std::string get_instr_name(std::string& instr) {
}
std::string get_comma_separated(std::string& instr) {
assert(!instr.empty());
ASSERT(!instr.empty());
auto arg = get_until_space(instr);
if (instr.empty()) {
assert(arg.back() != ',');
ASSERT(arg.back() != ',');
} else {
assert(arg.back() == ',');
ASSERT(arg.back() == ',');
arg.pop_back();
}
return arg;
@@ -141,13 +141,13 @@ std::string get_before_paren(std::string& instr) {
return result;
}
}
assert(false);
ASSERT(false);
return {};
}
std::string get_in_paren(std::string& instr) {
assert(instr.length() > 2);
assert(instr.front() == '(');
ASSERT(instr.length() > 2);
ASSERT(instr.front() == '(');
size_t i;
for (i = 0; i < instr.length(); i++) {
if (instr[i] == ')') {
@@ -160,22 +160,22 @@ std::string get_in_paren(std::string& instr) {
return result;
}
}
assert(false);
ASSERT(false);
return {};
}
bool is_integer(const std::string& str) {
assert(!str.empty());
ASSERT(!str.empty());
char* end;
std::strtol(str.c_str(), &end, 10);
return end == str.c_str() + str.length();
}
int parse_integer(const std::string& str) {
assert(!str.empty());
ASSERT(!str.empty());
char* end;
int result = std::strtol(str.c_str(), &end, 10);
assert(end == str.c_str() + str.length());
ASSERT(end == str.c_str() + str.length());
return result;
}
@@ -233,7 +233,7 @@ u8 cop2_dst(const std::string& str) {
}
if (*ptr) {
assert(false);
ASSERT(false);
}
return result;
}
@@ -283,7 +283,7 @@ Instruction InstructionParser::parse_single_instruction(
}
Register reg(gpr_name);
assert(reg.get_kind() == Reg::GPR);
ASSERT(reg.get_kind() == Reg::GPR);
InstructionAtom atom;
atom.set_reg(reg);
if (step.is_src) {
@@ -296,7 +296,7 @@ Instruction InstructionParser::parse_single_instruction(
case DecodeType::FPR: {
auto reg_name = get_comma_separated(str);
Register reg(reg_name);
assert(reg.get_kind() == Reg::FPR);
ASSERT(reg.get_kind() == Reg::FPR);
InstructionAtom atom;
atom.set_reg(reg);
if (step.is_src) {
@@ -309,7 +309,7 @@ Instruction InstructionParser::parse_single_instruction(
case DecodeType::VF: {
auto reg_name = get_comma_separated(str);
Register reg(reg_name);
assert(reg.get_kind() == Reg::VF);
ASSERT(reg.get_kind() == Reg::VF);
InstructionAtom atom;
atom.set_reg(reg);
if (step.is_src) {
@@ -359,7 +359,7 @@ Instruction InstructionParser::parse_single_instruction(
auto label = get_comma_separated(str);
auto f = std::find_if(labels.begin(), labels.end(),
[&](const DecompilerLabel& l) { return l.name == label; });
assert(f != labels.end());
ASSERT(f != labels.end());
auto idx = f - labels.begin();
InstructionAtom atom;
atom.set_label(idx);
@@ -384,7 +384,7 @@ Instruction InstructionParser::parse_single_instruction(
instr.il = 0;
} else {
printf("Bad interlock specification. Got %s\n", thing.c_str());
assert(false);
ASSERT(false);
}
} break;
@@ -400,17 +400,17 @@ Instruction InstructionParser::parse_single_instruction(
instr.cop2_bc = 3;
} else {
printf("Bad broadcast. Got %s\n", thing.c_str());
assert(false);
ASSERT(false);
}
} break;
default:
printf("missing DecodeType: %d\n", (int)step.decode);
assert(false);
ASSERT(false);
}
}
assert(str.empty());
ASSERT(str.empty());
return instr;
}
@@ -446,7 +446,7 @@ ParsedProgram InstructionParser::parse_program(const std::string& str,
if (line.back() == ':') {
line.pop_back();
} else {
assert(false);
ASSERT(false);
}
DecompilerLabel label;
label.target_segment = 0;
+3 -3
View File
@@ -4,7 +4,7 @@
*/
#include "OpcodeInfo.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
OpcodeInfo gOpcodeInfo[(uint32_t)InstructionKind::EE_OP_MAX];
@@ -462,12 +462,12 @@ void init_opcode_info() {
// for the UNKNOWN op which shouldn't be valid.
total_count--;
assert(total_count == valid_count);
ASSERT(total_count == valid_count);
opcodes_initialized = true;
}
void OpcodeInfo::step(DecodeStep& s) {
assert(step_count < MAX_DECODE_STEPS);
ASSERT(step_count < MAX_DECODE_STEPS);
steps[step_count] = s;
step_count++;
defined = true;
+23 -23
View File
@@ -6,7 +6,7 @@
#include "Register.h"
#include <stdexcept>
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
namespace Reg {
@@ -65,32 +65,32 @@ const static char* special_names[Reg::MAX_SPECIAL] = {"pcr0", "pcr1", "Q", "ACC"
namespace {
const char* gpr_to_charp(Reg::Gpr gpr) {
assert(gpr < 32);
ASSERT(gpr < 32);
return gpr_names[gpr];
}
const char* fpr_to_charp(uint32_t fpr) {
assert(fpr < 32);
ASSERT(fpr < 32);
return fpr_names[fpr];
}
const char* cop0_to_charp(Reg::Cop0 cpr) {
assert(cpr < 32);
ASSERT(cpr < 32);
return cop0_names[cpr];
}
const char* vf_to_charp(uint32_t vf) {
assert(vf < 32);
ASSERT(vf < 32);
return vf_names[vf];
}
const char* vi_to_charp(uint32_t vi) {
assert(vi < 32);
ASSERT(vi < 32);
return vi_names[vi];
}
const char* special_to_charp(uint32_t special) {
assert(special < Reg::MAX_SPECIAL);
ASSERT(special < Reg::MAX_SPECIAL);
return special_names[special];
}
} // namespace
@@ -126,17 +126,17 @@ Register::Register(Reg::RegisterKind kind, uint32_t num) {
case Reg::VI:
if (num > 32) {
fmt::print("RegisterKind: {}, greater than 32: {}\n", kind, num);
assert(false);
ASSERT(false);
}
break;
case Reg::SPECIAL:
if (num > 4) {
fmt::print("Special RegisterKind: {}, greater than 4: {}\n", kind, num);
assert(false);
ASSERT(false);
}
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -202,7 +202,7 @@ std::string Register::to_string() const {
*/
Reg::RegisterKind Register::get_kind() const {
uint16_t kind = id >> REG_CATEGORY_SHIFT;
assert(kind < Reg::MAX_KIND);
ASSERT(kind < Reg::MAX_KIND);
return (Reg::RegisterKind)kind;
}
@@ -210,9 +210,9 @@ Reg::RegisterKind Register::get_kind() const {
* Get the GPR number. Must be a GPR.
*/
Reg::Gpr Register::get_gpr() const {
assert(get_kind() == Reg::GPR);
ASSERT(get_kind() == Reg::GPR);
uint16_t kind = id & REG_IDX_MASK;
assert(kind < Reg::MAX_GPR);
ASSERT(kind < Reg::MAX_GPR);
return (Reg::Gpr)(kind);
}
@@ -220,9 +220,9 @@ Reg::Gpr Register::get_gpr() const {
* Get the FPR number. Must be an FPR.
*/
uint32_t Register::get_fpr() const {
assert(get_kind() == Reg::FPR);
ASSERT(get_kind() == Reg::FPR);
uint16_t kind = id & REG_IDX_MASK;
assert(kind < 32);
ASSERT(kind < 32);
return kind;
}
@@ -230,9 +230,9 @@ uint32_t Register::get_fpr() const {
* Get the VF number. Must be a VF.
*/
uint32_t Register::get_vf() const {
assert(get_kind() == Reg::VF);
ASSERT(get_kind() == Reg::VF);
uint16_t kind = id & REG_IDX_MASK;
assert(kind < 32);
ASSERT(kind < 32);
return kind;
}
@@ -240,9 +240,9 @@ uint32_t Register::get_vf() const {
* Get the VI number. Must be a VI.
*/
uint32_t Register::get_vi() const {
assert(get_kind() == Reg::VI);
ASSERT(get_kind() == Reg::VI);
uint16_t kind = id & REG_IDX_MASK;
assert(kind < 32);
ASSERT(kind < 32);
return kind;
}
@@ -250,9 +250,9 @@ uint32_t Register::get_vi() const {
* Get the COP0 number. Must be a COP0.
*/
Reg::Cop0 Register::get_cop0() const {
assert(get_kind() == Reg::COP0);
ASSERT(get_kind() == Reg::COP0);
uint16_t kind = id & REG_IDX_MASK;
assert(kind < Reg::MAX_COP0);
ASSERT(kind < Reg::MAX_COP0);
return (Reg::Cop0)(kind);
}
@@ -260,9 +260,9 @@ Reg::Cop0 Register::get_cop0() const {
* Get the PCR number. Must be a PCR.
*/
uint32_t Register::get_special() const {
assert(get_kind() == Reg::SPECIAL);
ASSERT(get_kind() == Reg::SPECIAL);
uint16_t kind = id & REG_IDX_MASK;
assert(kind < Reg::MAX_SPECIAL);
ASSERT(kind < Reg::MAX_SPECIAL);
return kind;
}
+3 -3
View File
@@ -7,7 +7,7 @@
#include <cstdint>
#include <string>
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
// Namespace for register name constants
@@ -147,13 +147,13 @@ class Register {
Register() = default;
Register(Reg::RegisterKind kind, uint32_t num);
explicit Register(int reg_id) {
assert(reg_id < Reg::MAX_REG_ID);
ASSERT(reg_id < Reg::MAX_REG_ID);
id = reg_id;
}
Register(const std::string& name);
static Register get_arg_reg(int idx) {
assert(idx >= 0 && idx < 8);
ASSERT(idx >= 0 && idx < 8);
return Register(Reg::GPR, Reg::A0 + idx);
}
+12 -12
View File
@@ -2,7 +2,7 @@
#include "BasicBlocks.h"
#include "decompiler/ObjectFile/LinkedObjectFile.h"
#include "decompiler/Disasm/InstructionMatching.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/*!
@@ -25,34 +25,34 @@ std::vector<BasicBlock> find_blocks_in_function(const LinkedObjectFile& file,
if (instr_info.is_branch && !instr_info.is_branch_likely) {
// make sure the delay slot of this branch is included in the function
assert(i + func.start_word < func.end_word - 1);
ASSERT(i + func.start_word < func.end_word - 1);
// divider after delay slot
dividers.push_back(i + 2);
auto label_id = instr.get_label_target();
assert(label_id != -1);
ASSERT(label_id != -1);
const auto& label = file.labels.at(label_id);
// should only jump to within our own function
assert(label.target_segment == seg);
assert(label.offset / 4 > func.start_word);
assert(label.offset / 4 < func.end_word - 1);
ASSERT(label.target_segment == seg);
ASSERT(label.offset / 4 > func.start_word);
ASSERT(label.offset / 4 < func.end_word - 1);
dividers.push_back(label.offset / 4 - func.start_word);
}
// for branch likely, we treat the likely instruction as a separate block.
if (instr_info.is_branch_likely) {
assert(i + func.start_word < func.end_word - 1);
ASSERT(i + func.start_word < func.end_word - 1);
// divider after branch instruction
dividers.push_back(i + 1);
// divider after likely delay slot.
dividers.push_back(i + 2);
// divider at the destination.
auto label_id = instr.get_label_target();
assert(label_id != -1);
ASSERT(label_id != -1);
const auto& label = file.labels.at(label_id);
// should only jump to within our own function
assert(label.target_segment == seg);
assert(label.offset / 4 > func.start_word);
assert(label.offset / 4 < func.end_word - 1);
ASSERT(label.target_segment == seg);
ASSERT(label.offset / 4 > func.start_word);
ASSERT(label.offset / 4 < func.end_word - 1);
dividers.push_back(label.offset / 4 - func.start_word);
}
}
@@ -62,7 +62,7 @@ std::vector<BasicBlock> find_blocks_in_function(const LinkedObjectFile& file,
for (size_t i = 0; i < dividers.size() - 1; i++) {
if (dividers[i] != dividers[i + 1]) {
basic_blocks.emplace_back(dividers[i], dividers[i + 1]);
assert(dividers[i] >= 0);
ASSERT(dividers[i] >= 0);
}
}
+88 -88
View File
@@ -3,7 +3,7 @@
#include "decompiler/ObjectFile/LinkedObjectFile.h"
#include "CfgVtx.h"
#include "Function.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/////////////////////////////////////////
@@ -32,12 +32,12 @@ void CfgVtx::replace_pred_and_check(CfgVtx* old_pred, CfgVtx* new_pred) {
bool replaced = false;
for (auto& x : pred) {
if (x == old_pred) {
assert(!replaced);
ASSERT(!replaced);
x = new_pred;
replaced = true;
}
}
assert(replaced);
ASSERT(replaced);
}
/*!
@@ -56,7 +56,7 @@ void CfgVtx::replace_succ_and_check(CfgVtx* old_succ, CfgVtx* new_succ) {
replaced = true;
}
assert(replaced);
ASSERT(replaced);
}
void CfgVtx::remove_pred(CfgVtx* to_remove) {
@@ -68,7 +68,7 @@ void CfgVtx::remove_pred(CfgVtx* to_remove) {
break;
}
}
assert(found);
ASSERT(found);
}
/*!
@@ -87,7 +87,7 @@ void CfgVtx::replace_preds_with_and_check(std::vector<CfgVtx*> old_preds, CfgVtx
size_t idx = -1;
for (size_t i = 0; i < old_preds.size(); i++) {
if (existing_pred == old_preds[i]) {
assert(!match);
ASSERT(!match);
idx = i;
match = true;
}
@@ -107,7 +107,7 @@ void CfgVtx::replace_preds_with_and_check(std::vector<CfgVtx*> old_preds, CfgVtx
pred = new_pred_list;
for (auto x : found) {
assert(x);
ASSERT(x);
}
}
@@ -169,7 +169,7 @@ int BlockVtx::get_first_block_id() const {
}
std::string SequenceVtx::to_string() const {
assert(!seq.empty());
ASSERT(!seq.empty());
// todo - this is not a great way to print it. Maybe sequences should have an ID or name?
std::string result =
"Seq " + seq.front()->to_string() + " ... " + seq.back()->to_string() + std::to_string(uid);
@@ -198,7 +198,7 @@ goos::Object EntryVtx::to_form() const {
}
int EntryVtx::get_first_block_id() const {
assert(false);
ASSERT(false);
return -1;
}
@@ -211,7 +211,7 @@ goos::Object ExitVtx::to_form() const {
}
int ExitVtx::get_first_block_id() const {
assert(false);
ASSERT(false);
return -1;
}
@@ -264,7 +264,7 @@ goos::Object WhileLoop::to_form() const {
}
int WhileLoop::get_first_block_id() const {
assert(false);
ASSERT(false);
return -1;
}
@@ -293,7 +293,7 @@ goos::Object UntilLoop_single::to_form() const {
int UntilLoop_single::get_first_block_id() const {
return block->get_first_block_id();
assert(false);
ASSERT(false);
return -1;
}
@@ -307,7 +307,7 @@ goos::Object InfiniteLoopBlock::to_form() const {
}
int InfiniteLoopBlock::get_first_block_id() const {
assert(false);
ASSERT(false);
return -1;
}
@@ -377,7 +377,7 @@ goos::Object EmptyVtx::to_form() const {
}
int EmptyVtx::get_first_block_id() const {
assert(false);
ASSERT(false);
return -1;
}
@@ -448,13 +448,13 @@ int ControlFlowGraph::get_top_level_vertices_count() {
* Get the top level vertex. Only safe to call if we are fully resolved.
*/
CfgVtx* ControlFlowGraph::get_single_top_level() {
assert(get_top_level_vertices_count() == 1);
ASSERT(get_top_level_vertices_count() == 1);
for (auto* x : m_node_pool) {
if (!x->parent && x != entry() && x != exit()) {
return x;
}
}
assert(false);
ASSERT(false);
return nullptr;
}
@@ -516,8 +516,8 @@ bool ControlFlowGraph::is_while_loop(CfgVtx* b0, CfgVtx* b1, CfgVtx* b2) {
return false;
if (b0->succ_branch != b2)
return false;
assert(b0->end_branch.has_branch);
assert(b0->end_branch.branch_always);
ASSERT(b0->end_branch.has_branch);
ASSERT(b0->end_branch.branch_always);
if (b0->end_branch.branch_likely)
return false;
@@ -526,7 +526,7 @@ bool ControlFlowGraph::is_while_loop(CfgVtx* b0, CfgVtx* b1, CfgVtx* b2) {
return false;
if (b1->succ_branch)
return false;
assert(!b1->end_branch.has_branch);
ASSERT(!b1->end_branch.has_branch);
if (!b2->has_pred(b0)) {
printf("expect b2 (%s) to have pred b0 (%s)\n", b2->to_string().c_str(),
b0->to_string().c_str());
@@ -541,8 +541,8 @@ bool ControlFlowGraph::is_while_loop(CfgVtx* b0, CfgVtx* b1, CfgVtx* b2) {
printf("b0's succ_branch: %s\n", b0->succ_branch->to_string().c_str());
}
}
assert(b2->has_pred(b0));
assert(b2->has_pred(b1));
ASSERT(b2->has_pred(b0));
ASSERT(b2->has_pred(b1));
if (b2->pred.size() != 2)
return false;
@@ -577,14 +577,14 @@ bool ControlFlowGraph::is_until_loop(CfgVtx* b1, CfgVtx* b2) {
return false;
if (b1->succ_branch)
return false;
assert(!b1->end_branch.has_branch);
ASSERT(!b1->end_branch.has_branch);
if (!b2->has_pred(b1)) {
fmt::print("Graph error {} (s {}) should have pred {} (s {})\n", b2->to_string(),
b2->get_first_block_id(), b1->to_string(), b1->get_first_block_id());
}
assert(b2->has_pred(b1));
ASSERT(b2->has_pred(b1));
if (b2->pred.size() != 1)
return false;
@@ -618,7 +618,7 @@ bool ControlFlowGraph::is_goto_not_end_and_unreachable(CfgVtx* b0, CfgVtx* b1) {
return false;
}
assert(b1->prev == b0);
ASSERT(b1->prev == b0);
// b1 should have no preds and be unreachable.
if (!b1->pred.empty()) {
@@ -657,7 +657,7 @@ bool ControlFlowGraph::is_goto_end_and_unreachable(CfgVtx* b0, CfgVtx* b1) {
// b0 should next to b1
if (b0->next != b1)
return false;
assert(b1->prev == b0);
ASSERT(b1->prev == b0);
// b1 should have no preds
if (!b1->pred.empty())
@@ -699,7 +699,7 @@ bool ControlFlowGraph::find_while_loop_top_level() {
b0->replace_succ_and_check(b2, new_vtx);
new_vtx->pred = {b0};
assert(b2->succ_ft);
ASSERT(b2->succ_ft);
b2->succ_ft->replace_pred_and_check(b2, new_vtx);
new_vtx->succ_ft = b2->succ_ft;
// succ_branch is going back into the loop
@@ -750,7 +750,7 @@ bool ControlFlowGraph::find_until_loop() {
new_vtx->pred = b1->pred;
new_vtx->replace_preds_with_and_check({b2}, nullptr);
assert(b2->succ_ft);
ASSERT(b2->succ_ft);
b2->succ_ft->replace_pred_and_check(b2, new_vtx);
new_vtx->succ_ft = b2->succ_ft;
// succ_branch is going back into the loop
@@ -962,17 +962,17 @@ bool ControlFlowGraph::find_infinite_continue() {
}
new_goto->pred = b0->pred;
assert(b0->succs().size() == 1 && b0->succs().front() == b0->succ_branch);
ASSERT(b0->succs().size() == 1 && b0->succs().front() == b0->succ_branch);
// patch up next and prev.
new_goto->next = b0->next;
if (new_goto->next) {
assert(new_goto->next->prev == b0);
ASSERT(new_goto->next->prev == b0);
new_goto->next->prev = new_goto;
}
new_goto->prev = b0->prev;
if (new_goto->prev) {
assert(new_goto->prev->next == b0);
ASSERT(new_goto->prev->next == b0);
new_goto->prev->next = new_goto;
}
@@ -980,9 +980,9 @@ bool ControlFlowGraph::find_infinite_continue() {
if (new_goto->next) {
// now we will fall through
new_goto->succ_ft = b0->next;
assert(!new_goto->succ_ft->has_pred(new_goto));
ASSERT(!new_goto->succ_ft->has_pred(new_goto));
new_goto->succ_ft->pred.push_back(new_goto);
assert(!new_goto->succ_branch);
ASSERT(!new_goto->succ_branch);
}
// break goto preds.
@@ -1082,12 +1082,12 @@ bool ControlFlowGraph::is_sequence(CfgVtx* b0, CfgVtx* b1, bool allow_self_loops
return false;
if (b0->succ_ft)
return false;
assert(b0->end_branch.branch_always);
ASSERT(b0->end_branch.branch_always);
} else {
// falls through
if (b0->succ_branch)
return false;
assert(!b0->end_branch.has_branch);
ASSERT(!b0->end_branch.has_branch);
}
if (b1->prev != b0)
@@ -1210,10 +1210,10 @@ bool ControlFlowGraph::clean_up_asm_branches() {
replaced = true;
m_blocks.at(bds->succ_branch->get_first_block_id())->needs_label = true;
auto* seq = dynamic_cast<SequenceVtx*>(b0);
assert(seq);
ASSERT(seq);
auto* old_seq = dynamic_cast<SequenceVtx*>(b1);
assert(old_seq);
ASSERT(old_seq);
if (b0->succ_branch) {
b0->succ_branch->replace_preds_with_and_check({b0}, nullptr);
@@ -1253,7 +1253,7 @@ bool ControlFlowGraph::clean_up_asm_branches() {
m_blocks.at(bds->succ_branch->get_first_block_id())->needs_label = true;
auto* seq = dynamic_cast<SequenceVtx*>(b0);
assert(seq);
ASSERT(seq);
if (b0->succ_branch) {
b0->succ_branch->replace_preds_with_and_check({b0}, nullptr);
@@ -1308,7 +1308,7 @@ bool ControlFlowGraph::clean_up_asm_branches() {
replaced = true;
if (!b0->succ_branch) {
fmt::print("asm missing branch in block {}\n", b0->to_string());
assert(false);
ASSERT(false);
}
m_blocks.at(b0->succ_branch->get_first_block_id())->needs_label = true;
@@ -1357,7 +1357,7 @@ bool ControlFlowGraph::clean_up_asm_branches() {
b1->parent_claim(new_seq);
if (new_seq->succ_branch) {
assert(!new_seq->succ_branch->parent);
ASSERT(!new_seq->succ_branch->parent);
}
new_seq->end_branch = b1->end_branch;
@@ -1372,12 +1372,12 @@ bool ControlFlowGraph::clean_up_asm_branches() {
if (debug_asm_branch) {
fmt::print(" b1 succ_ft is {}\n", b1->succ_ft->to_string());
}
assert(b1->succ_ft->has_pred(b1));
ASSERT(b1->succ_ft->has_pred(b1));
}
replaced = true;
m_blocks.at(b0->succ_branch->get_first_block_id())->needs_label = true;
auto* seq = dynamic_cast<SequenceVtx*>(b0);
assert(seq);
ASSERT(seq);
seq->seq.push_back(b1);
@@ -1400,11 +1400,11 @@ bool ControlFlowGraph::clean_up_asm_branches() {
}
if (b1->succ_ft) {
assert(b1->succ_ft->has_pred(b0));
ASSERT(b1->succ_ft->has_pred(b0));
}
if (b1->succ_ft) {
assert(b1->succ_ft->has_pred(b0));
ASSERT(b1->succ_ft->has_pred(b0));
}
// try
@@ -1412,7 +1412,7 @@ bool ControlFlowGraph::clean_up_asm_branches() {
seq->succ_ft = b1->succ_ft;
seq->succ_branch = b1->succ_branch;
if (b1->succ_branch) {
assert(!b1->succ_branch->parent);
ASSERT(!b1->succ_branch->parent);
}
if (seq->succ_branch && debug_asm_branch) {
@@ -1425,7 +1425,7 @@ bool ControlFlowGraph::clean_up_asm_branches() {
b1->parent_claim(seq);
if (seq->succ_branch) {
assert(!seq->succ_branch->parent);
ASSERT(!seq->succ_branch->parent);
}
seq->end_branch = b1->end_branch;
return false;
@@ -1439,10 +1439,10 @@ bool ControlFlowGraph::clean_up_asm_branches() {
replaced = true;
m_blocks.at(b0->succ_branch->get_first_block_id())->needs_label = true;
auto* seq = dynamic_cast<SequenceVtx*>(b0);
assert(seq);
ASSERT(seq);
auto* old_seq = dynamic_cast<SequenceVtx*>(b1);
assert(old_seq);
ASSERT(old_seq);
if (b0->succ_branch) {
if (debug_asm_branch) {
@@ -1484,7 +1484,7 @@ bool ControlFlowGraph::clean_up_asm_branches() {
}
m_blocks.at(b0->succ_branch->get_first_block_id())->needs_label = true;
auto* old_seq = dynamic_cast<SequenceVtx*>(b1);
assert(old_seq);
ASSERT(old_seq);
if (b0->succ_branch) {
if (debug_asm_branch) {
fmt::print(" sbp: {}\n", !!b0->succ_branch->parent);
@@ -1615,7 +1615,7 @@ bool ControlFlowGraph::find_seq_top_level(bool allow_self_loops) {
// printf("make seq type 2 %s %s\n", b0->to_string().c_str(), b1->to_string().c_str());
replaced = true;
auto* seq = dynamic_cast<SequenceVtx*>(b0);
assert(seq);
ASSERT(seq);
seq->seq.push_back(b1);
@@ -1637,7 +1637,7 @@ bool ControlFlowGraph::find_seq_top_level(bool allow_self_loops) {
if (is_sequence_of_non_sequence_and_sequence(b0, b1, allow_self_loops)) {
replaced = true;
auto* seq = dynamic_cast<SequenceVtx*>(b1);
assert(seq);
ASSERT(seq);
seq->seq.insert(seq->seq.begin(), b0);
for (auto* p : b0->pred) {
@@ -1657,10 +1657,10 @@ bool ControlFlowGraph::find_seq_top_level(bool allow_self_loops) {
// printf("make seq type 3 %s %s\n", b0->to_string().c_str(), b1->to_string().c_str());
replaced = true;
auto* seq = dynamic_cast<SequenceVtx*>(b0);
assert(seq);
ASSERT(seq);
auto* old_seq = dynamic_cast<SequenceVtx*>(b1);
assert(old_seq);
ASSERT(old_seq);
for (auto* x : old_seq->seq) {
x->parent_claim(seq);
@@ -1739,9 +1739,9 @@ bool ControlFlowGraph::find_cond_w_else(const CondWithElseLengthHack& hack) {
return true;
}
assert(b0->end_branch.has_branch);
assert(b0->end_branch.branch_always);
assert(b0->succ_branch);
ASSERT(b0->end_branch.has_branch);
ASSERT(b0->end_branch.branch_always);
ASSERT(b0->succ_branch);
// TODO - check what's in the delay slot!
auto* end_block = b0->succ_branch;
@@ -1770,7 +1770,7 @@ bool ControlFlowGraph::find_cond_w_else(const CondWithElseLengthHack& hack) {
if (else_block->succ_ft != end_block) {
return true;
}
assert(!else_block->end_branch.has_branch);
ASSERT(!else_block->end_branch.has_branch);
std::vector<CondWithElse::Entry> entries = {{c0, b0}};
auto* prev_condition = c0;
@@ -1923,9 +1923,9 @@ bool ControlFlowGraph::find_cond_w_empty_else() {
return true;
}
assert(b0->end_branch.has_branch);
assert(b0->end_branch.branch_always);
assert(b0->succ_branch);
ASSERT(b0->end_branch.has_branch);
ASSERT(b0->end_branch.branch_always);
ASSERT(b0->succ_branch);
// TODO - check what's in the delay slot!
auto* end_block = b0->succ_branch;
@@ -2105,9 +2105,9 @@ bool ControlFlowGraph::find_cond_n_else() {
printf("reject 2A\n");
return true;
}
assert(b0->end_branch.has_branch);
assert(b0->end_branch.branch_always);
assert(b0->succ_branch);
ASSERT(b0->end_branch.has_branch);
ASSERT(b0->end_branch.branch_always);
ASSERT(b0->succ_branch);
} else {
single_case = true;
}
@@ -2467,7 +2467,7 @@ bool ControlFlowGraph::find_short_circuits() {
* The returned vector will have blocks in ordered, so the i-th entry is for the i-th block.
*/
const std::vector<BlockVtx*>& ControlFlowGraph::create_blocks(int count) {
assert(m_blocks.empty());
ASSERT(m_blocks.empty());
BlockVtx* prev = nullptr; // for linking next/prev
for (int i = 0; i < count; i++) {
@@ -2492,12 +2492,12 @@ const std::vector<BlockVtx*>& ControlFlowGraph::create_blocks(int count) {
void ControlFlowGraph::link_fall_through(BlockVtx* first,
BlockVtx* second,
std::vector<BasicBlock>& blocks) {
assert(!first->succ_ft); // don't want to overwrite something by accident.
ASSERT(!first->succ_ft); // don't want to overwrite something by accident.
// can only fall through to the next code in memory.
assert(first->next == second);
assert(second->prev == first);
ASSERT(first->next == second);
ASSERT(second->prev == first);
first->succ_ft = second;
assert(blocks.at(first->block_id).succ_ft == -1);
ASSERT(blocks.at(first->block_id).succ_ft == -1);
blocks.at(first->block_id).succ_ft = second->block_id;
if (!second->has_pred(first)) {
@@ -2515,9 +2515,9 @@ void ControlFlowGraph::link_fall_through(BlockVtx* first,
void ControlFlowGraph::link_branch(BlockVtx* first,
BlockVtx* second,
std::vector<BasicBlock>& blocks) {
assert(!first->succ_branch);
ASSERT(!first->succ_branch);
first->succ_branch = second;
assert(blocks.at(first->block_id).succ_branch == -1);
ASSERT(blocks.at(first->block_id).succ_branch == -1);
blocks.at(first->block_id).succ_branch = second->block_id;
if (!second->has_pred(first)) {
@@ -2530,12 +2530,12 @@ void ControlFlowGraph::link_branch(BlockVtx* first,
void ControlFlowGraph::link_fall_through_likely(BlockVtx* first,
BlockVtx* second,
std::vector<BasicBlock>& blocks) {
assert(!first->succ_ft); // don't want to overwrite something by accident.
ASSERT(!first->succ_ft); // don't want to overwrite something by accident.
// can only fall through to the next code in memory.
assert(first->next->next == second);
assert(second->prev->prev == first);
ASSERT(first->next->next == second);
ASSERT(second->prev->prev == first);
first->succ_ft = second;
assert(blocks.at(first->block_id).succ_ft == -1);
ASSERT(blocks.at(first->block_id).succ_ft == -1);
blocks.at(first->block_id).succ_ft = second->block_id;
if (!second->has_pred(first)) {
@@ -2553,7 +2553,7 @@ void ControlFlowGraph::flag_early_exit(const std::vector<BasicBlock>& blocks) {
if (block.start_word == block.end_word) {
b->is_early_exit_block = true;
assert(!b->end_branch.has_branch);
ASSERT(!b->end_branch.has_branch);
}
}
@@ -2643,7 +2643,7 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
} else {
// room for at least a likely branch, try that first.
int likely_branch_idx = b.end_word - 1;
assert(likely_branch_idx >= b.start_word);
ASSERT(likely_branch_idx >= b.start_word);
auto& likely_branch_candidate = func.instructions.at(likely_branch_idx);
if (is_branch(likely_branch_candidate, true)) {
@@ -2656,12 +2656,12 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
// need to find block target
int block_target = -1;
int label_target = likely_branch_candidate.get_label_target();
assert(label_target != -1);
ASSERT(label_target != -1);
const auto& label = file.labels.at(label_target);
assert(label.target_segment == seg);
assert((label.offset % 4) == 0);
ASSERT(label.target_segment == seg);
ASSERT((label.offset % 4) == 0);
int offset = label.offset / 4 - func.start_word;
assert(offset >= 0);
ASSERT(offset >= 0);
for (int j = int(func.basic_blocks.size()); j-- > 0;) {
if (func.basic_blocks[j].start_word == offset) {
block_target = j;
@@ -2669,7 +2669,7 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
}
}
assert(block_target != -1);
ASSERT(block_target != -1);
// branch to delay slot
cfg->link_branch(blocks.at(i), blocks.at(i + 1), func.basic_blocks);
@@ -2700,7 +2700,7 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
} else {
// try as a normal branch.
int idx = b.end_word - 2;
assert(idx >= b.start_word);
ASSERT(idx >= b.start_word);
auto& branch_candidate = func.instructions.at(idx);
auto& delay_slot_candidate = func.instructions.at(idx + 1);
if (is_branch(branch_candidate, false)) {
@@ -2712,12 +2712,12 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
// need to find block target
int block_target = -1;
int label_target = branch_candidate.get_label_target();
assert(label_target != -1);
ASSERT(label_target != -1);
const auto& label = file.labels.at(label_target);
assert(label.target_segment == seg);
assert((label.offset % 4) == 0);
ASSERT(label.target_segment == seg);
ASSERT((label.offset % 4) == 0);
int offset = label.offset / 4 - func.start_word;
assert(offset >= 0);
ASSERT(offset >= 0);
// the order here matters when there are zero size blocks. Unclear what the best answer
// is.
@@ -2730,7 +2730,7 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
}
}
assert(block_target != -1);
ASSERT(block_target != -1);
cfg->link_branch(blocks.at(i), blocks.at(block_target), func.basic_blocks);
if (branch_always) {
@@ -2771,7 +2771,7 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
// room for at least a likely branch, try that first.
int likely_branch_idx = bb.end_word - 1;
assert(likely_branch_idx >= bb.start_word);
ASSERT(likely_branch_idx >= bb.start_word);
auto& likely_branch_candidate = func.instructions.at(likely_branch_idx);
if (is_branch(likely_branch_candidate, true)) {
@@ -2789,7 +2789,7 @@ std::shared_ptr<ControlFlowGraph> build_cfg(
if (bb.end_word - bb.start_word >= 2) {
int idx = bb.end_word - 2;
assert(idx >= bb.start_word);
ASSERT(idx >= bb.start_word);
auto& branch_candidate = func.instructions.at(idx);
auto& delay_slot_candidate = func.instructions.at(idx + 1);
if (is_branch(branch_candidate, false)) {
+3 -3
View File
@@ -2,7 +2,7 @@
#include <string>
#include <vector>
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace goos {
class Object;
@@ -18,12 +18,12 @@ void replace_exactly_one_in(std::vector<T>& v, T old, T replace) {
bool replaced = false;
for (auto& x : v) {
if (x == old) {
assert(!replaced);
ASSERT(!replaced);
x = replace;
replaced = true;
}
}
assert(replaced);
ASSERT(replaced);
}
/*!
+36 -36
View File
@@ -8,7 +8,7 @@
#include "decompiler/IR/IR.h"
#include "decompiler/IR2/Form.h"
#include "common/util/BitUtils.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
namespace {
@@ -20,14 +20,14 @@ std::vector<Register> fpr_backups = {make_fpr(30), make_fpr(28), make_fpr(26),
make_fpr(24), make_fpr(22), make_fpr(20)};
Register get_expected_gpr_backup(int n, int total) {
assert(total <= int(gpr_backups.size()));
assert(n < total);
ASSERT(total <= int(gpr_backups.size()));
ASSERT(n < total);
return gpr_backups.at((total - 1) - n);
}
Register get_expected_fpr_backup(int n, int total) {
assert(total <= int(fpr_backups.size()));
assert(n < total);
ASSERT(total <= int(fpr_backups.size()));
ASSERT(n < total);
return fpr_backups.at((total - 1) - n);
}
@@ -79,7 +79,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
Register(Reg::GPR, Reg::SP))) {
prologue.ra_backed_up = true;
prologue.ra_backup_offset = get_gpr_store_offset_as_int(instructions.at(idx));
assert(prologue.ra_backup_offset == 0);
ASSERT(prologue.ra_backup_offset == 0);
idx++;
}
@@ -107,13 +107,13 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
prologue.fp_backup_offset = get_gpr_store_offset_as_int(instructions.at(idx));
// in Jak 1 like we never backup fp unless ra is also backed up, so the offset is always 8.
// but it seems like it could be possible to do one without the other?
assert(prologue.fp_backup_offset == 8);
ASSERT(prologue.fp_backup_offset == 8);
idx++;
// after backing up fp, we always set it to t9.
prologue.fp_set = is_gpr_3(instructions.at(idx), InstructionKind::OR, make_gpr(Reg::FP),
make_gpr(Reg::T9), make_gpr(Reg::R0));
assert(prologue.fp_set);
ASSERT(prologue.fp_set);
idx++;
}
@@ -144,7 +144,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
for (int i = 0; i < n_gpr_backups; i++) {
int this_offset = get_gpr_store_offset_as_int(instructions.at(idx + i));
auto this_reg = instructions.at(idx + i).get_src(0).get_reg();
assert(this_offset == prologue.gpr_backup_offset + 16 * i);
ASSERT(this_offset == prologue.gpr_backup_offset + 16 * i);
if (this_reg != get_expected_gpr_backup(i, n_gpr_backups)) {
suspected_asm = true;
lg::warn("Function {} stores on the stack in a strange way ({}), flagging as asm!",
@@ -173,7 +173,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
for (int i = 0; i < n_fpr_backups; i++) {
int this_offset = instructions.at(idx + i).get_src(1).get_imm();
auto this_reg = instructions.at(idx + i).get_src(0).get_reg();
assert(this_offset == prologue.fpr_backup_offset + 4 * i);
ASSERT(this_offset == prologue.fpr_backup_offset + 4 * i);
if (this_reg != get_expected_fpr_backup(i, n_fpr_backups)) {
suspected_asm = true;
lg::warn("Function {} stores on the stack in a strange way ({}), flagging as asm!",
@@ -209,11 +209,11 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
prologue.n_stack_var_bytes = prologue.gpr_backup_offset - prologue.stack_var_offset;
} else {
// both, use gprs
assert(prologue.fpr_backup_offset > prologue.gpr_backup_offset);
ASSERT(prologue.fpr_backup_offset > prologue.gpr_backup_offset);
prologue.n_stack_var_bytes = prologue.gpr_backup_offset - prologue.stack_var_offset;
}
assert(prologue.n_stack_var_bytes >= 0);
ASSERT(prologue.n_stack_var_bytes >= 0);
// check that the stack lines up by going in order
@@ -221,7 +221,7 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
int total_stack = 0;
if (prologue.ra_backed_up) {
total_stack = align8(total_stack);
assert(prologue.ra_backup_offset == total_stack);
ASSERT(prologue.ra_backup_offset == total_stack);
total_stack += 8;
}
@@ -233,42 +233,42 @@ void Function::analyze_prologue(const LinkedObjectFile& file) {
// FP backup
if (prologue.fp_backed_up) {
total_stack = align8(total_stack);
assert(prologue.fp_backup_offset == total_stack);
ASSERT(prologue.fp_backup_offset == total_stack);
total_stack += 8;
assert(prologue.fp_set);
ASSERT(prologue.fp_set);
}
// Stack Variables
if (prologue.n_stack_var_bytes) {
// no alignment because we don't know how the stack vars are aligned.
// stack var padding counts toward this section.
assert(prologue.stack_var_offset == total_stack);
ASSERT(prologue.stack_var_offset == total_stack);
total_stack += prologue.n_stack_var_bytes;
}
// GPRS
if (prologue.n_gpr_backup) {
total_stack = align16(total_stack);
assert(prologue.gpr_backup_offset == total_stack);
ASSERT(prologue.gpr_backup_offset == total_stack);
total_stack += 16 * prologue.n_gpr_backup;
}
// FPRS
if (prologue.n_fpr_backup) {
total_stack = align4(total_stack);
assert(prologue.fpr_backup_offset == total_stack);
ASSERT(prologue.fpr_backup_offset == total_stack);
total_stack += 4 * prologue.n_fpr_backup;
}
total_stack = align16(total_stack);
// End!
assert(prologue.total_stack_usage == total_stack);
ASSERT(prologue.total_stack_usage == total_stack);
}
// it's fine to have the entire first basic block be the prologue - you could loop back to the
// first instruction past the prologue.
assert(basic_blocks.at(0).end_word >= prologue_end);
ASSERT(basic_blocks.at(0).end_word >= prologue_end);
resize_first_block(prologue_end, file);
prologue.decoded = true;
@@ -366,24 +366,24 @@ void Function::check_epilogue(const LinkedObjectFile& file) {
if (is_gpr_3(instructions.at(idx), InstructionKind::DADDU, make_gpr(Reg::SP), make_gpr(Reg::SP),
make_gpr(Reg::R0))) {
idx--;
assert(is_jr_ra(instructions.at(idx)));
ASSERT(is_jr_ra(instructions.at(idx)));
idx--;
lg::warn("Function {} has a double return and is being flagged as asm.", name());
warnings.general_warning("Flagged as asm due to double return");
}
// delay slot should be daddiu sp, sp, offset
assert(is_gpr_2_imm_int(instructions.at(idx), InstructionKind::DADDIU, make_gpr(Reg::SP),
ASSERT(is_gpr_2_imm_int(instructions.at(idx), InstructionKind::DADDIU, make_gpr(Reg::SP),
make_gpr(Reg::SP), prologue.total_stack_usage));
idx--;
} else {
// delay slot is always daddu sp, sp, r0...
assert(is_gpr_3(instructions.at(idx), InstructionKind::DADDU, make_gpr(Reg::SP),
ASSERT(is_gpr_3(instructions.at(idx), InstructionKind::DADDU, make_gpr(Reg::SP),
make_gpr(Reg::SP), make_gpr(Reg::R0)));
idx--;
}
// jr ra
assert(is_jr_ra(instructions.at(idx)));
ASSERT(is_jr_ra(instructions.at(idx)));
idx--;
// restore gprs
@@ -391,7 +391,7 @@ void Function::check_epilogue(const LinkedObjectFile& file) {
int gpr_idx = prologue.n_gpr_backup - (1 + i);
const auto& expected_reg = gpr_backups.at(gpr_idx);
auto expected_offset = prologue.gpr_backup_offset + 16 * i;
assert(is_no_ll_gpr_load(instructions.at(idx), 16, true, expected_reg, expected_offset,
ASSERT(is_no_ll_gpr_load(instructions.at(idx), 16, true, expected_reg, expected_offset,
make_gpr(Reg::SP)));
idx--;
}
@@ -401,27 +401,27 @@ void Function::check_epilogue(const LinkedObjectFile& file) {
int fpr_idx = prologue.n_fpr_backup - (1 + i);
const auto& expected_reg = fpr_backups.at(fpr_idx);
auto expected_offset = prologue.fpr_backup_offset + 4 * i;
assert(
ASSERT(
is_no_ll_fpr_load(instructions.at(idx), expected_reg, expected_offset, make_gpr(Reg::SP)));
idx--;
}
// restore fp
if (prologue.fp_backed_up) {
assert(is_no_ll_gpr_load(instructions.at(idx), 8, true, make_gpr(Reg::FP),
ASSERT(is_no_ll_gpr_load(instructions.at(idx), 8, true, make_gpr(Reg::FP),
prologue.fp_backup_offset, make_gpr(Reg::SP)));
idx--;
}
// restore ra
if (prologue.ra_backed_up) {
assert(is_no_ll_gpr_load(instructions.at(idx), 8, true, make_gpr(Reg::RA),
ASSERT(is_no_ll_gpr_load(instructions.at(idx), 8, true, make_gpr(Reg::RA),
prologue.ra_backup_offset, make_gpr(Reg::SP)));
idx--;
}
assert(!basic_blocks.empty());
assert(idx + 1 >= basic_blocks.back().start_word);
ASSERT(!basic_blocks.empty());
ASSERT(idx + 1 >= basic_blocks.back().start_word);
basic_blocks.back().end_word = idx + 1;
prologue.epilogue_ok = true;
epilogue_start = idx + 1;
@@ -445,7 +445,7 @@ void Function::find_global_function_defs(LinkedObjectFile& file, DecompilerTypeS
state = 1;
reg = instr.get_dst(0).get_reg();
label_id = instr.get_src(0).get_label();
assert(label_id != -1);
ASSERT(label_id != -1);
continue;
}
@@ -471,7 +471,7 @@ void Function::find_global_function_defs(LinkedObjectFile& file, DecompilerTypeS
// printf("discard as not code: %s\n", name.c_str());
} else {
auto& func = file.get_function_at_label(label_id);
assert(func.guessed_name.empty());
ASSERT(func.guessed_name.empty());
func.guessed_name.set_as_global(name);
dts.add_symbol(name, "function");
;
@@ -538,7 +538,7 @@ void Function::find_method_defs(LinkedObjectFile& file, DecompilerTypeSystem& dt
state = 4;
lui_reg = instr.get_dst(0).get_reg();
label_id = instr.get_src(0).get_label();
assert(label_id != -1);
ASSERT(label_id != -1);
continue;
} else {
state = 0;
@@ -560,7 +560,7 @@ void Function::find_method_defs(LinkedObjectFile& file, DecompilerTypeSystem& dt
if (instr.kind == InstructionKind::JALR && instr.get_dst(0).get_reg() == make_gpr(Reg::RA) &&
instr.get_src(0).get_reg() == make_gpr(Reg::T9)) {
auto& func = file.get_function_at_label(label_id);
assert(func.guessed_name.empty());
ASSERT(func.guessed_name.empty());
func.guessed_name.set_as_method(type_name, method_id);
func.method_of_type = type_name;
if (method_id == GOAL_INSPECT_METHOD) {
@@ -675,7 +675,7 @@ void Function::find_type_defs(LinkedObjectFile& file, DecompilerTypeSystem& dts)
void Function::add_basic_op(std::shared_ptr<IR_Atomic> op, int start_instr, int end_instr) {
op->is_basic_op = true;
assert(end_instr > start_instr);
ASSERT(end_instr > start_instr);
for (int i = start_instr; i < end_instr; i++) {
instruction_to_basic_op[i] = basic_ops.size();
@@ -734,7 +734,7 @@ BlockTopologicalSort Function::bb_topo_sort() {
std::unordered_set<int> visit_set;
std::vector<int> visit_queue;
if (basic_blocks.empty()) {
assert(false);
ASSERT(false);
}
visit_queue.push_back(0);
+1 -1
View File
@@ -60,7 +60,7 @@ struct FunctionName {
}
int get_anon_id() const {
assert(kind == FunctionKind::UNIDENTIFIED);
ASSERT(kind == FunctionKind::UNIDENTIFIED);
return id_in_object;
}
+42 -42
View File
@@ -28,9 +28,9 @@ FieldPrint get_field_print(const std::string& str) {
// first is ~T
char c0 = next();
assert(c0 == '~');
ASSERT(c0 == '~');
char c1 = next();
assert(c1 == 'T');
ASSERT(c1 == 'T');
// next the name:
char name_char = next();
@@ -50,21 +50,21 @@ FieldPrint get_field_print(const std::string& str) {
field_print.has_array = true;
field_print.array_size = size;
assert(num_char == ']');
ASSERT(num_char == ']');
char c = next();
assert(c == ' ');
ASSERT(c == ' ');
c = next();
assert(c == '@');
ASSERT(c == '@');
c = next();
assert(c == ' ');
ASSERT(c == ' ');
c = next();
assert(c == '#');
ASSERT(c == '#');
c = next();
assert(c == 'x');
ASSERT(c == 'x');
} else {
// next a space
char space_char = next();
assert(space_char == ' ');
ASSERT(space_char == ' ');
}
// next the format
@@ -73,10 +73,10 @@ FieldPrint get_field_print(const std::string& str) {
char fmt_code = next();
field_print.format = fmt_code;
char end1 = next();
assert(end1 == '~');
ASSERT(end1 == '~');
char end2 = next();
assert(end2 == '%');
assert(idx == (int)str.size());
ASSERT(end2 == '%');
ASSERT(idx == (int)str.size());
} else if (fmt1 == '#' && peek(0) == '<') { // struct #<my-struct @ #x~X>~%
next();
char type_name_c = next();
@@ -88,17 +88,17 @@ FieldPrint get_field_print(const std::string& str) {
std::string expect_end = "@ #x~X>~%";
for (char i : expect_end) {
char c = next();
assert(i == c);
ASSERT(i == c);
}
field_print.format = 'X';
assert(idx == (int)str.size());
ASSERT(idx == (int)str.size());
} else if (fmt1 == '#' && peek(0) == 'x') { // #x~X~%
next();
std::string expect_end = "~X~%";
for (char i : expect_end) {
char c = next();
assert(i == c);
ASSERT(i == c);
}
field_print.format = 'X';
} else if (fmt1 == '~' && peek(0) == '`') { // ~`my-type-with-overriden-print`P~%
@@ -112,11 +112,11 @@ FieldPrint get_field_print(const std::string& str) {
std::string expect_end = "P~%";
for (char i : expect_end) {
char c = next();
assert(i == c);
ASSERT(i == c);
}
field_print.format = 'P';
assert(idx == (int)str.size());
ASSERT(idx == (int)str.size());
} else if (str.substr(idx - 1) == "(meters ~m)~%") {
field_print.format = 'm';
} else if (str.substr(idx - 1) == "(deg ~r)~%") {
@@ -173,9 +173,9 @@ struct LoadInfo {
LoadInfo get_load_info_from_set(IR* load) {
auto as_set = dynamic_cast<IR_Set*>(load);
assert(as_set);
ASSERT(as_set);
auto as_load = dynamic_cast<IR_Load*>(as_set->src.get());
assert(as_load);
ASSERT(as_load);
LoadInfo info;
info.kind = as_load->kind;
info.size = as_load->size;
@@ -185,10 +185,10 @@ LoadInfo get_load_info_from_set(IR* load) {
}
auto as_math = dynamic_cast<IR_IntMath2*>(as_load->location.get());
assert(as_math);
assert(as_math->kind == IR_IntMath2::ADD);
ASSERT(as_math);
ASSERT(as_math->kind == IR_IntMath2::ADD);
auto as_int = dynamic_cast<IR_IntegerConstant*>(as_math->arg1.get());
assert(as_int);
ASSERT(as_int);
info.offset = as_int->value;
return info;
}
@@ -200,13 +200,13 @@ Register get_base_of_load(IR_Load* load) {
}
auto as_math = dynamic_cast<IR_IntMath2*>(load->location.get());
assert(as_math->kind == IR_IntMath2::ADD);
assert(dynamic_cast<IR_IntegerConstant*>(as_math->arg1.get()));
ASSERT(as_math->kind == IR_IntMath2::ADD);
ASSERT(dynamic_cast<IR_IntegerConstant*>(as_math->arg1.get()));
auto math_reg = dynamic_cast<IR_Register*>(as_math->arg0.get());
if (math_reg) {
return math_reg->reg;
} else {
assert(false);
ASSERT(false);
}
return {};
}
@@ -443,8 +443,8 @@ int identify_basic_field(int idx,
FieldPrint& print_info) {
(void)file;
auto load_info = get_load_info_from_set(function.basic_ops.at(idx++).get());
assert(load_info.size == 4);
assert(load_info.kind == IR_Load::UNSIGNED || load_info.kind == IR_Load::SIGNED);
ASSERT(load_info.size == 4);
ASSERT(load_info.kind == IR_Load::UNSIGNED || load_info.kind == IR_Load::SIGNED);
if (load_info.kind == IR_Load::SIGNED) {
result->warnings += "field " + print_info.field_name + " is a basic loaded with a signed load ";
@@ -467,8 +467,8 @@ int identify_pointer_field(int idx,
FieldPrint& print_info) {
(void)file;
auto load_info = get_load_info_from_set(function.basic_ops.at(idx++).get());
assert(load_info.size == 4);
assert(load_info.kind == IR_Load::UNSIGNED);
ASSERT(load_info.size == 4);
ASSERT(load_info.kind == IR_Load::UNSIGNED);
int offset = load_info.offset;
if (result->is_basic) {
@@ -489,7 +489,7 @@ int identify_array_field(int idx,
int offset = 0;
if (!get_ptr_offset(get_op.get(), make_gpr(Reg::A2), make_gpr(Reg::GP), &offset)) {
printf("bad get ptr offset %s\n", get_op->print(file).c_str());
assert(false);
ASSERT(false);
}
if (result->is_basic) {
offset += BASIC_OFFSET;
@@ -511,13 +511,13 @@ int identify_float_field(int idx,
TypeInspectorResult* result,
FieldPrint& print_info) {
auto load_info = get_load_info_from_set(function.basic_ops.at(idx++).get());
assert(load_info.size == 4);
assert(load_info.kind == IR_Load::FLOAT);
ASSERT(load_info.size == 4);
ASSERT(load_info.kind == IR_Load::FLOAT);
auto& float_move = function.basic_ops.at(idx++);
if (!is_reg_reg_move(float_move.get(), make_gpr(Reg::A2), make_fpr(0))) {
printf("bad float move: %s\n", float_move->print(file).c_str());
assert(false);
ASSERT(false);
}
std::string type;
@@ -536,7 +536,7 @@ int identify_float_field(int idx,
result->warnings += "field " + print_info.field_name + " is a float printed as hex? ";
break;
default:
assert(false);
ASSERT(false);
}
int offset = load_info.offset;
if (result->is_basic) {
@@ -578,7 +578,7 @@ int identify_struct_inline_field(int idx,
int offset = 0;
if (!get_ptr_offset(get_op.get(), make_gpr(Reg::A2), make_gpr(Reg::GP), &offset)) {
printf("bad get ptr offset %s\n", get_op->print(file).c_str());
assert(false);
ASSERT(false);
}
if (result->is_basic) {
offset += BASIC_OFFSET;
@@ -602,7 +602,7 @@ int identify_int_field(int idx,
if (load_info.kind == IR_Load::UNSIGNED) {
field_type_name += "u";
} else if (load_info.kind == IR_Load::FLOAT) {
assert(false); // ...
ASSERT(false); // ...
}
field_type_name += "int";
@@ -636,9 +636,9 @@ int identify_int_field(int idx,
field_type_name = "useconds";
break;
default:
assert(false);
ASSERT(false);
}
assert(load_info.size == 8);
ASSERT(load_info.size == 8);
}
int offset = load_info.offset;
@@ -656,13 +656,13 @@ int detect(int idx, Function& function, LinkedObjectFile& file, TypeInspectorRes
auto& get_format_op = function.basic_ops.at(idx++);
if (!is_get_sym_value(get_format_op.get(), make_gpr(Reg::T9), "format")) {
printf("bad get format");
assert(false);
ASSERT(false);
}
auto& get_true = function.basic_ops.at(idx++);
if (!is_get_sym(get_true.get(), make_gpr(Reg::A0), "#t")) {
printf("bad get true");
assert(false);
ASSERT(false);
}
auto& get_str = function.basic_ops.at(idx++);
@@ -717,7 +717,7 @@ int detect(int idx, Function& function, LinkedObjectFile& file, TypeInspectorRes
auto& call_op = function.basic_ops.at(idx++);
if (!dynamic_cast<IR_Call*>(call_op.get())) {
printf("bad call\n");
assert(false);
ASSERT(false);
}
return idx;
@@ -739,7 +739,7 @@ TypeInspectorResult inspect_inspect_method(Function& inspect,
result.type_size = flags.size;
result.type_method_count = flags.methods;
result.type_heap_base = flags.heap_base;
assert(flags.pad == 0);
ASSERT(flags.pad == 0);
int idx = get_start_idx(inspect, file, &result, result.parent_type_name);
if (idx == 0 || skip_fields) {
+2 -2
View File
@@ -3,7 +3,7 @@
#include <vector>
#include <stdexcept>
#include "third-party/fmt/core.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
class DecompWarnings {
@@ -91,7 +91,7 @@ class DecompWarnings {
case Kind::INFO:
return fmt::format("INFO: {}\n", message);
default:
assert(false);
ASSERT(false);
return {};
}
}
+76 -76
View File
@@ -112,7 +112,7 @@ std::shared_ptr<IR> instr_atom_to_ir(const InstructionAtom& ia, int idx) {
// not supported by IR1
return std::make_shared<IR_Failed>();
default:
assert(false);
ASSERT(false);
return nullptr;
}
}
@@ -130,8 +130,8 @@ std::shared_ptr<IR_Atomic> to_asm_automatic(const std::string& str, Instruction&
// not supported by IR1
return std::make_shared<IR_Failed_Atomic>();
}
assert(instr.n_dst < 2);
assert(instr.n_src < 4);
ASSERT(instr.n_dst < 2);
ASSERT(instr.n_src < 4);
if (instr.n_dst >= 1) {
result->dst = instr_atom_to_ir(instr.get_dst(0), idx);
}
@@ -609,7 +609,7 @@ std::shared_ptr<IR_Atomic> try_lwu(Instruction& instr, int idx) {
std::shared_ptr<IR_Atomic> try_lq(Instruction& instr, int idx) {
if (instr.kind == InstructionKind::LQ && instr.get_src(1).is_reg(make_gpr(Reg::S7)) &&
instr.get_src(0).kind == InstructionAtom::IMM_SYM) {
assert(false);
ASSERT(false);
} else if (instr.kind == InstructionKind::LQ && instr.get_dst(0).is_reg() &&
instr.get_src(0).is_link_or_label() && instr.get_src(1).is_reg(make_gpr(Reg::FP))) {
// static
@@ -1349,7 +1349,7 @@ BranchDelay get_branch_delay(Instruction& i, int idx) {
b.write_regs.push_back(dst);
return b;
} else {
assert(false);
ASSERT(false);
}
} else if (i.kind == InstructionKind::DSLLV) {
// this is used for ash?
@@ -1521,10 +1521,10 @@ std::shared_ptr<IR_Atomic> try_daddiu(Instruction& i0, Instruction& i1, int idx)
i0.get_src(0).get_reg() == make_gpr(Reg::S7)) {
auto dst_reg = i0.get_dst(0).get_reg();
auto src_reg = i1.get_src(1).get_reg();
assert(i0.get_src(0).get_reg() == make_gpr(Reg::S7));
assert(i0.get_src(1).get_imm() == 8);
assert(i1.get_dst(0).get_reg() == dst_reg);
assert(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i0.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i0.get_src(1).get_imm() == 8);
ASSERT(i1.get_dst(0).get_reg() == dst_reg);
ASSERT(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
auto op = make_set_atomic(
IR_Set_Atomic::REG_64, make_reg(dst_reg, idx),
std::make_shared<IR_Compare>(
@@ -1537,10 +1537,10 @@ std::shared_ptr<IR_Atomic> try_daddiu(Instruction& i0, Instruction& i1, int idx)
i0.get_src(0).get_reg() == make_gpr(Reg::S7)) {
auto dst_reg = i0.get_dst(0).get_reg();
auto src_reg = i1.get_src(1).get_reg();
assert(i0.get_src(0).get_reg() == make_gpr(Reg::S7));
assert(i0.get_src(1).get_imm() == 8);
assert(i1.get_dst(0).get_reg() == dst_reg);
assert(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i0.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i0.get_src(1).get_imm() == 8);
ASSERT(i1.get_dst(0).get_reg() == dst_reg);
ASSERT(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
auto op = make_set_atomic(
IR_Set_Atomic::REG_64, make_reg(dst_reg, idx),
std::make_shared<IR_Compare>(
@@ -1556,8 +1556,8 @@ std::shared_ptr<IR_Atomic> try_daddiu(Instruction& i0, Instruction& i1, int idx)
std::shared_ptr<IR_Atomic> try_lui(Instruction& i0, Instruction& i1, int idx) {
if (i0.kind == InstructionKind::LUI && i1.kind == InstructionKind::ORI &&
i0.get_src(0).is_label() && i1.get_src(1).is_label()) {
assert(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg());
assert(i0.get_src(0).get_label() == i1.get_src(1).get_label());
ASSERT(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg());
ASSERT(i0.get_src(0).get_label() == i1.get_src(1).get_label());
auto op = make_set_atomic(IR_Set_Atomic::REG_64, make_reg(i1.get_dst(0).get_reg(), idx),
std::make_shared<IR_StaticAddress>(i0.get_src(0).get_label()));
if (i0.get_dst(0).get_reg() != i1.get_dst(0).get_reg()) {
@@ -1628,10 +1628,10 @@ std::shared_ptr<IR_Atomic> try_lui(Instruction& i0, Instruction& i1, Instruction
if (i0.kind == InstructionKind::LUI && i1.kind == InstructionKind::ORI &&
i0.get_src(0).is_label() && i1.get_src(1).is_label() &&
is_gpr_3(i2, InstructionKind::ADDU, {}, make_gpr(Reg::FP), {})) {
assert(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg());
assert(i0.get_src(0).get_label() == i1.get_src(1).get_label());
assert(i2.get_dst(0).get_reg() == i2.get_src(1).get_reg());
assert(i2.get_dst(0).get_reg() == i1.get_dst(0).get_reg());
ASSERT(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg());
ASSERT(i0.get_src(0).get_label() == i1.get_src(1).get_label());
ASSERT(i2.get_dst(0).get_reg() == i2.get_src(1).get_reg());
ASSERT(i2.get_dst(0).get_reg() == i1.get_dst(0).get_reg());
auto op = make_set_atomic(IR_Set_Atomic::REG_64, make_reg(i1.get_dst(0).get_reg(), idx),
std::make_shared<IR_StaticAddress>(i0.get_src(0).get_label()));
if (i0.get_dst(0).get_reg() != i1.get_dst(0).get_reg()) {
@@ -1653,11 +1653,11 @@ std::shared_ptr<IR_Atomic> try_dsubu(Instruction& i0, Instruction& i1, Instructi
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
assert(i2.get_src(1).get_reg() == clobber_reg);
ASSERT(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i2.get_src(1).get_reg() == clobber_reg);
auto op = make_set_atomic(
IR_Set_Atomic::REG_64, make_reg(dst_reg, idx),
std::make_shared<IR_Compare>(Condition(Condition::EQUAL, make_reg(src0_reg, idx),
@@ -1672,10 +1672,10 @@ std::shared_ptr<IR_Atomic> try_dsubu(Instruction& i0, Instruction& i1, Instructi
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1695,8 +1695,8 @@ std::shared_ptr<IR_Atomic> try_slt(Instruction& i0, Instruction& i1, Instruction
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::LESS_THAN_SIGNED, make_reg(src0_reg, idx), make_reg(src1_reg, idx),
make_reg(clobber_reg, idx)),
@@ -1709,10 +1709,10 @@ std::shared_ptr<IR_Atomic> try_slt(Instruction& i0, Instruction& i1, Instruction
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1738,8 +1738,8 @@ std::shared_ptr<IR_Atomic> try_slt(Instruction& i0, Instruction& i1, Instruction
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::GEQ_SIGNED, make_reg(src0_reg, idx), make_reg(src1_reg, idx),
make_reg(clobber_reg, idx)),
@@ -1752,10 +1752,10 @@ std::shared_ptr<IR_Atomic> try_slt(Instruction& i0, Instruction& i1, Instruction
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1785,8 +1785,8 @@ std::shared_ptr<IR_Atomic> try_slti(Instruction& i0, Instruction& i1, Instructio
if (i0.kind == InstructionKind::SLTI && i1.kind == InstructionKind::BNE) {
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::LESS_THAN_SIGNED, make_reg(src0_reg, idx), src1,
make_reg(clobber_reg, idx)),
@@ -1798,10 +1798,10 @@ std::shared_ptr<IR_Atomic> try_slti(Instruction& i0, Instruction& i1, Instructio
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1815,8 +1815,8 @@ std::shared_ptr<IR_Atomic> try_slti(Instruction& i0, Instruction& i1, Instructio
} else if (i0.kind == InstructionKind::SLTI && i1.kind == InstructionKind::BEQ) {
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::GEQ_SIGNED, make_reg(src0_reg, idx), src1, make_reg(clobber_reg, idx)),
i1.get_src(2).get_label(), get_branch_delay(i2, idx), false);
@@ -1827,10 +1827,10 @@ std::shared_ptr<IR_Atomic> try_slti(Instruction& i0, Instruction& i1, Instructio
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1850,8 +1850,8 @@ std::shared_ptr<IR_Atomic> try_sltiu(Instruction& i0, Instruction& i1, Instructi
if (i0.kind == InstructionKind::SLTIU && i1.kind == InstructionKind::BNE) {
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::LESS_THAN_UNSIGNED, make_reg(src0_reg, idx), src1,
make_reg(clobber_reg, idx)),
@@ -1863,10 +1863,10 @@ std::shared_ptr<IR_Atomic> try_sltiu(Instruction& i0, Instruction& i1, Instructi
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1880,8 +1880,8 @@ std::shared_ptr<IR_Atomic> try_sltiu(Instruction& i0, Instruction& i1, Instructi
} else if (i0.kind == InstructionKind::SLTIU && i1.kind == InstructionKind::BEQ) {
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::GEQ_UNSIGNED, make_reg(src0_reg, idx), src1,
make_reg(clobber_reg, idx)),
@@ -1893,10 +1893,10 @@ std::shared_ptr<IR_Atomic> try_sltiu(Instruction& i0, Instruction& i1, Instructi
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -1973,8 +1973,8 @@ std::shared_ptr<IR_Atomic> try_sltu(Instruction& i0, Instruction& i1, Instructio
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::LESS_THAN_UNSIGNED, make_reg(src0_reg, idx), make_reg(src1_reg, idx),
make_reg(clobber_reg, idx)),
@@ -1987,10 +1987,10 @@ std::shared_ptr<IR_Atomic> try_sltu(Instruction& i0, Instruction& i1, Instructio
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
@@ -2005,8 +2005,8 @@ std::shared_ptr<IR_Atomic> try_sltu(Instruction& i0, Instruction& i1, Instructio
auto clobber_reg = i0.get_dst(0).get_reg();
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
assert(i1.get_src(0).get_reg() == clobber_reg);
assert(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
ASSERT(i1.get_src(0).get_reg() == clobber_reg);
ASSERT(i1.get_src(1).get_reg() == make_gpr(Reg::R0));
auto op = std::make_shared<IR_Branch_Atomic>(
Condition(Condition::GEQ_UNSIGNED, make_reg(src0_reg, idx), make_reg(src1_reg, idx),
make_reg(clobber_reg, idx)),
@@ -2019,10 +2019,10 @@ std::shared_ptr<IR_Atomic> try_sltu(Instruction& i0, Instruction& i1, Instructio
auto src0_reg = i0.get_src(0).get_reg();
auto src1_reg = i0.get_src(1).get_reg();
auto dst_reg = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
assert(i1.get_src(1).get_imm() == 8);
assert(i2.get_dst(0).get_reg() == dst_reg);
assert(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
ASSERT(i1.get_src(0).is_reg(make_gpr(Reg::S7)));
ASSERT(i1.get_src(1).get_imm() == 8);
ASSERT(i2.get_dst(0).get_reg() == dst_reg);
ASSERT(i2.get_src(0).get_reg() == make_gpr(Reg::S7));
if (i2.get_src(1).get_reg() != clobber_reg) {
return nullptr; // TODO!
}
+43 -43
View File
@@ -21,7 +21,7 @@ std::vector<std::shared_ptr<IR>> IR::get_all_ir(LinkedObjectFile& file) const {
auto end_of_check = result.size();
for (size_t i = last_checked; i < end_of_check; i++) {
auto it = result.at(i).get();
assert(it);
ASSERT(it);
it->get_children(&result);
}
last_checked = end_of_check;
@@ -87,7 +87,7 @@ void IR_Set_Atomic::update_reginfo_self<IR_IntMath2>(int n_dest, int n_src, int
}
auto src_as = dynamic_cast<IR_IntMath2*>(src.get());
assert(src_as);
ASSERT(src_as);
for (auto& x : {src_as->arg0, src_as->arg1}) {
auto reg = dynamic_cast<IR_Register*>(x.get());
@@ -96,9 +96,9 @@ void IR_Set_Atomic::update_reginfo_self<IR_IntMath2>(int n_dest, int n_src, int
}
}
assert(int(write_regs.size()) == n_dest);
assert(int(read_regs.size()) == n_src);
assert(int(clobber_regs.size()) == n_clobber);
ASSERT(int(write_regs.size()) == n_dest);
ASSERT(int(read_regs.size()) == n_src);
ASSERT(int(clobber_regs.size()) == n_clobber);
reg_info_set = true;
}
@@ -110,16 +110,16 @@ void IR_Set_Atomic::update_reginfo_self<IR_IntMath1>(int n_dest, int n_src, int
}
auto src_as = dynamic_cast<IR_IntMath1*>(src.get());
assert(src_as);
ASSERT(src_as);
auto reg = dynamic_cast<IR_Register*>(src_as->arg.get());
if (reg) {
read_regs.push_back(reg->reg);
}
assert(int(write_regs.size()) == n_dest);
assert(int(read_regs.size()) == n_src);
assert(int(clobber_regs.size()) == n_clobber);
ASSERT(int(write_regs.size()) == n_dest);
ASSERT(int(read_regs.size()) == n_src);
ASSERT(int(clobber_regs.size()) == n_clobber);
reg_info_set = true;
}
@@ -131,7 +131,7 @@ void IR_Set_Atomic::update_reginfo_self<IR_Load>(int n_dest, int n_src, int n_cl
}
auto src_as = dynamic_cast<IR_Load*>(src.get());
assert(src_as);
ASSERT(src_as);
// try to get the source as a register
auto reg = dynamic_cast<IR_Register*>(src_as->location.get());
@@ -150,9 +150,9 @@ void IR_Set_Atomic::update_reginfo_self<IR_Load>(int n_dest, int n_src, int n_cl
}
}
assert(int(write_regs.size()) == n_dest);
assert(int(read_regs.size()) == n_src);
assert(int(clobber_regs.size()) == n_clobber);
ASSERT(int(write_regs.size()) == n_dest);
ASSERT(int(read_regs.size()) == n_src);
ASSERT(int(clobber_regs.size()) == n_clobber);
reg_info_set = true;
}
@@ -164,7 +164,7 @@ void IR_Set_Atomic::update_reginfo_self<IR_Compare>(int n_dest, int n_src, int n
}
auto src_as_cmp = dynamic_cast<IR_Compare*>(src.get());
assert(src_as_cmp);
ASSERT(src_as_cmp);
for (auto& x : {src_as_cmp->condition.src0, src_as_cmp->condition.src1}) {
auto as_reg = dynamic_cast<IR_Register*>(x.get());
if (as_reg) {
@@ -177,9 +177,9 @@ void IR_Set_Atomic::update_reginfo_self<IR_Compare>(int n_dest, int n_src, int n
clobber_regs.push_back(as_reg->reg);
}
assert(int(write_regs.size()) == n_dest);
assert(int(read_regs.size()) == n_src);
assert(int(clobber_regs.size()) == n_clobber);
ASSERT(int(write_regs.size()) == n_dest);
ASSERT(int(read_regs.size()) == n_src);
ASSERT(int(clobber_regs.size()) == n_clobber);
reg_info_set = true;
}
@@ -198,9 +198,9 @@ void IR_Set_Atomic::update_reginfo_regreg() {
read_regs.push_back(src_as->reg);
}
assert(int(write_regs.size()) == 1);
assert(int(read_regs.size()) == 1);
assert(int(clobber_regs.size()) == 0);
ASSERT(int(write_regs.size()) == 1);
ASSERT(int(read_regs.size()) == 1);
ASSERT(int(clobber_regs.size()) == 0);
reg_info_set = true;
}
@@ -228,11 +228,11 @@ goos::Object IR_Store::to_form(const LinkedObjectFile& file) const {
store_operator = "s.q";
break;
default:
assert(false);
ASSERT(false);
}
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(store_operator), dst->to_form(file),
@@ -263,11 +263,11 @@ goos::Object IR_Store_Atomic::to_form(const LinkedObjectFile& file) const {
store_operator = "s.q";
break;
default:
assert(false);
ASSERT(false);
}
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(store_operator), dst->to_form(file),
@@ -296,9 +296,9 @@ void IR_Store_Atomic::update_reginfo_self(int n_dest, int n_src, int n_clobber)
}
}
assert(int(write_regs.size()) == n_dest);
assert(int(read_regs.size()) == n_src);
assert(int(clobber_regs.size()) == n_clobber);
ASSERT(int(write_regs.size()) == n_dest);
ASSERT(int(read_regs.size()) == n_src);
ASSERT(int(clobber_regs.size()) == n_clobber);
reg_info_set = true;
}
@@ -375,7 +375,7 @@ goos::Object IR_Load::to_form(const LinkedObjectFile& file) const {
load_operator = "l.q";
break;
default:
assert(false);
ASSERT(false);
}
break;
case SIGNED:
@@ -390,11 +390,11 @@ goos::Object IR_Load::to_form(const LinkedObjectFile& file) const {
load_operator = "l.ws";
break;
default:
assert(false);
ASSERT(false);
}
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(load_operator), location->to_form(file));
}
@@ -425,7 +425,7 @@ goos::Object IR_FloatMath2::to_form(const LinkedObjectFile& file) const {
math_operator = "max.f";
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg0->to_form(file),
@@ -496,7 +496,7 @@ goos::Object IR_IntMath2::to_form(const LinkedObjectFile& file) const {
math_operator = "max.si";
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg0->to_form(file),
arg1->to_form(file));
@@ -520,7 +520,7 @@ goos::Object IR_IntMath1::to_form(const LinkedObjectFile& file) const {
math_operator = "-.i";
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg->to_form(file));
}
@@ -548,7 +548,7 @@ goos::Object IR_FloatMath1::to_form(const LinkedObjectFile& file) const {
math_operator = "sqrt.f";
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(math_operator), arg->to_form(file));
}
@@ -613,7 +613,7 @@ goos::Object BranchDelay::to_form(const LinkedObjectFile& file) const {
case UNKNOWN:
return pretty_print::build_list("unknown-branch-delay");
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -669,7 +669,7 @@ int Condition::num_args() const {
case NEVER:
return 0;
default:
assert(false);
ASSERT(false);
return -1;
}
}
@@ -765,7 +765,7 @@ void Condition::invert() {
kind = FLOAT_GREATER_THAN;
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -852,7 +852,7 @@ goos::Object Condition::to_form(const LinkedObjectFile& file) const {
condtion_operator = "<=0.si";
break;
default:
assert(false);
ASSERT(false);
}
if (nargs == 2) {
@@ -868,7 +868,7 @@ goos::Object Condition::to_form(const LinkedObjectFile& file) const {
} else if (nargs == 0) {
return pretty_print::to_symbol(condtion_operator);
} else {
assert(false);
ASSERT(false);
return {};
}
}
@@ -897,9 +897,9 @@ void IR_Branch_Atomic::update_reginfo_self(int n_dest, int n_src, int n_clobber)
if (as_reg) {
clobber_regs.push_back(as_reg->reg);
}
assert(int(write_regs.size()) == n_dest);
assert(int(read_regs.size()) == n_src);
assert(int(clobber_regs.size()) == n_clobber);
ASSERT(int(write_regs.size()) == n_dest);
ASSERT(int(read_regs.size()) == n_src);
ASSERT(int(clobber_regs.size()) == n_clobber);
// copy from branch delay
read_regs.insert(read_regs.end(), branch_delay.read_regs.begin(), branch_delay.read_regs.end());
@@ -994,7 +994,7 @@ goos::Object IR_AsmReg::to_form(const LinkedObjectFile& file) const {
case VU_ACC:
return pretty_print::to_symbol("ACC");
default:
assert(false);
ASSERT(false);
return {};
}
}
+5 -5
View File
@@ -11,7 +11,7 @@
#include "common/type_system/TypeSpec.h"
#include "decompiler/util/DecompilerTypeSystem.h"
#include "decompiler/util/TP_Type.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace goos {
class Object;
@@ -234,7 +234,7 @@ class IR_IntMath1 : public virtual IR {
IR_IntMath1(Kind _kind, std::shared_ptr<IR> _arg) : kind(_kind), arg(std::move(_arg)) {}
IR_IntMath1(Kind _kind, std::shared_ptr<IR> _arg, std::shared_ptr<IR_Atomic> _abs_op)
: kind(_kind), arg(std::move(_arg)), abs_op(std::move(_abs_op)) {
assert(abs_op);
ASSERT(abs_op);
}
std::shared_ptr<IR> arg;
std::shared_ptr<IR_Atomic> abs_op = nullptr;
@@ -327,11 +327,11 @@ struct Condition {
: kind(_kind), src0(std::move(_src0)), src1(std::move(_src1)), clobber(std::move(_clobber)) {
int nargs = num_args();
if (nargs == 2) {
assert(src0 && src1);
ASSERT(src0 && src1);
} else if (nargs == 1) {
assert(src0 && !src1);
ASSERT(src0 && !src1);
} else if (nargs == 0) {
assert(!src0 && !src1);
ASSERT(!src0 && !src1);
}
}
+74 -74
View File
@@ -7,7 +7,7 @@
#include "AtomicOp.h"
#include "OpenGoalMapping.h"
#include "Form.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/////////////////////////////
@@ -48,7 +48,7 @@ goos::Object RegisterAccess::to_form(const Env& env, Print mode) const {
return pretty_print::to_symbol(m_reg.to_string());
}
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -163,7 +163,7 @@ goos::Object SimpleAtom::to_form(const std::vector<DecompilerLabel>& labels, con
case Kind::STATIC_ADDRESS:
return pretty_print::to_symbol(labels.at(m_int).name);
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -200,7 +200,7 @@ bool SimpleAtom::operator==(const SimpleAtom& other) const {
case Kind::STATIC_ADDRESS:
return m_int == other.m_int;
default:
assert(false);
ASSERT(false);
return false;
}
}
@@ -310,7 +310,7 @@ std::string get_simple_expression_op_name(SimpleExpression::Kind kind) {
case SimpleExpression::Kind::SET_ON_LESS_THAN_IMM:
return "set-on-less-than";
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -374,7 +374,7 @@ int get_simple_expression_arg_count(SimpleExpression::Kind kind) {
case SimpleExpression::Kind::SET_ON_LESS_THAN_IMM:
return 2;
default:
assert(false);
ASSERT(false);
return -1;
}
}
@@ -382,7 +382,7 @@ int get_simple_expression_arg_count(SimpleExpression::Kind kind) {
SimpleExpression::SimpleExpression(Kind kind, const SimpleAtom& arg0) : n_args(1) {
m_args[0] = arg0;
m_kind = kind;
assert(get_simple_expression_arg_count(kind) == 1);
ASSERT(get_simple_expression_arg_count(kind) == 1);
}
SimpleExpression::SimpleExpression(Kind kind, const SimpleAtom& arg0, const SimpleAtom& arg1)
@@ -390,7 +390,7 @@ SimpleExpression::SimpleExpression(Kind kind, const SimpleAtom& arg0, const Simp
m_args[0] = arg0;
m_args[1] = arg1;
m_kind = kind;
assert(get_simple_expression_arg_count(kind) == 2);
ASSERT(get_simple_expression_arg_count(kind) == 2);
}
SimpleExpression::SimpleExpression(Kind kind,
@@ -402,7 +402,7 @@ SimpleExpression::SimpleExpression(Kind kind,
m_args[1] = arg1;
m_args[2] = arg2;
m_kind = kind;
assert(get_simple_expression_arg_count(kind) == 3);
ASSERT(get_simple_expression_arg_count(kind) == 3);
}
goos::Object SimpleExpression::to_form(const std::vector<DecompilerLabel>& labels,
@@ -410,7 +410,7 @@ goos::Object SimpleExpression::to_form(const std::vector<DecompilerLabel>& label
std::vector<goos::Object> forms;
if (m_kind == Kind::IDENTITY) {
// we are "identity" so just pass through the atom
assert(args() == 1);
ASSERT(args() == 1);
return get_arg(0).to_form(labels, env);
} else {
forms.push_back(pretty_print::to_symbol(get_simple_expression_op_name(m_kind)));
@@ -429,7 +429,7 @@ bool SimpleExpression::operator==(const SimpleExpression& other) const {
if (m_kind != other.m_kind) {
return false;
}
assert(args() == other.args());
ASSERT(args() == other.args());
for (int i = 0; i < args(); i++) {
if (other.get_arg(i) != get_arg(i)) {
return false;
@@ -464,7 +464,7 @@ bool SetVarOp::operator==(const AtomicOp& other) const {
return false;
}
auto po = dynamic_cast<const SetVarOp*>(&other);
assert(po);
ASSERT(po);
return m_dst == po->m_dst && m_src == po->m_src;
}
@@ -501,7 +501,7 @@ void SetVarOp::collect_vars(RegAccessSet& vars) const {
/////////////////////////////
AsmOp::AsmOp(Instruction instr, int my_idx) : AtomicOp(my_idx), m_instr(std::move(instr)) {
assert(m_instr.n_dst <= 1);
ASSERT(m_instr.n_dst <= 1);
if (m_instr.n_dst == 1) {
auto& dst = m_instr.get_dst(0);
if (dst.is_reg()) {
@@ -512,7 +512,7 @@ AsmOp::AsmOp(Instruction instr, int my_idx) : AtomicOp(my_idx), m_instr(std::mov
}
}
assert(m_instr.n_src <= 4);
ASSERT(m_instr.n_src <= 4);
for (int i = 0; i < m_instr.n_src; i++) {
auto& src = m_instr.get_src(i);
if (src.is_reg()) {
@@ -530,7 +530,7 @@ AsmOp::AsmOp(Instruction instr, int my_idx) : AtomicOp(my_idx), m_instr(std::mov
goos::Object AsmOp::to_form(const std::vector<DecompilerLabel>& labels, const Env& env) const {
std::vector<goos::Object> forms;
forms.push_back(pretty_print::to_symbol("." + m_instr.op_name_to_string()));
assert(m_instr.n_dst <= 1);
ASSERT(m_instr.n_dst <= 1);
if (m_instr.n_dst == 1) {
if (m_dst.has_value()) {
@@ -542,7 +542,7 @@ goos::Object AsmOp::to_form(const std::vector<DecompilerLabel>& labels, const En
}
}
assert(m_instr.n_src <= 4);
ASSERT(m_instr.n_src <= 4);
for (int i = 0; i < m_instr.n_src; i++) {
if (m_src[i].has_value()) {
forms.push_back(m_src[i].value().to_form(env));
@@ -574,7 +574,7 @@ goos::Object AsmOp::to_open_goal_form(const std::vector<DecompilerLabel>& labels
OpenGOALAsm goalOp = OpenGOALAsm(m_instr, m_dst, src);
forms.push_back(pretty_print::to_symbol(goalOp.full_function_name()));
assert(m_instr.n_dst <= 1);
ASSERT(m_instr.n_dst <= 1);
if (m_instr.n_dst == 1) {
if (m_dst.has_value()) {
// then print it as a variable
@@ -585,7 +585,7 @@ goos::Object AsmOp::to_open_goal_form(const std::vector<DecompilerLabel>& labels
}
}
assert(m_instr.n_src <= 4);
ASSERT(m_instr.n_src <= 4);
std::vector<goos::Object> args = goalOp.get_args(labels, env);
forms.insert(forms.end(), args.begin(), args.end());
@@ -598,7 +598,7 @@ bool AsmOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const AsmOp*>(&other);
assert(po);
ASSERT(po);
return (m_instr == po->m_instr) && (m_dst == po->m_dst) && (m_src[0] == po->m_src[0]) &&
(m_src[1] == po->m_src[1]) && (m_src[2] == po->m_src[2]);
@@ -719,7 +719,7 @@ void AsmOp::update_register_info() {
break;
default:
assert(false);
ASSERT(false);
break;
}
}
@@ -814,7 +814,7 @@ std::string get_condition_kind_name(IR2_Condition::Kind kind) {
case IR2_Condition::Kind::GEQ_ZERO_UNSIGNED:
return ">=0.ui";
default:
assert(false);
ASSERT(false);
return "";
}
}
@@ -857,7 +857,7 @@ int get_condition_num_args(IR2_Condition::Kind kind) {
case IR2_Condition::Kind::NEVER:
return 0;
default:
assert(false);
ASSERT(false);
return -1;
}
}
@@ -929,7 +929,7 @@ IR2_Condition::Kind get_condition_opposite(IR2_Condition::Kind kind) {
case IR2_Condition::Kind::GEQ_ZERO_UNSIGNED:
return IR2_Condition::Kind::LESS_THAN_ZERO_UNSIGNED;
default:
assert(false);
ASSERT(false);
return IR2_Condition::Kind::INVALID;
}
}
@@ -949,19 +949,19 @@ bool condition_uses_float(IR2_Condition::Kind kind) {
}
IR2_Condition::IR2_Condition(Kind kind) : m_kind(kind) {
assert(get_condition_num_args(m_kind) == 0);
ASSERT(get_condition_num_args(m_kind) == 0);
}
IR2_Condition::IR2_Condition(Kind kind, const SimpleAtom& src0) : m_kind(kind) {
m_src[0] = src0;
assert(get_condition_num_args(m_kind) == 1);
ASSERT(get_condition_num_args(m_kind) == 1);
}
IR2_Condition::IR2_Condition(Kind kind, const SimpleAtom& src0, const SimpleAtom& src1)
: m_kind(kind) {
m_src[0] = src0;
m_src[1] = src1;
assert(get_condition_num_args(m_kind) == 2);
ASSERT(get_condition_num_args(m_kind) == 2);
}
void IR2_Condition::invert() {
@@ -1027,7 +1027,7 @@ bool SetVarConditionOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const SetVarConditionOp*>(&other);
assert(po);
ASSERT(po);
return m_dst == po->m_dst && m_condition == po->m_condition;
}
@@ -1081,19 +1081,19 @@ goos::Object StoreOp::to_form(const std::vector<DecompilerLabel>& labels, const
store_name = "s.q!";
break;
default:
assert(false);
ASSERT(false);
}
break;
case Kind::FLOAT:
assert(m_size == 4);
ASSERT(m_size == 4);
store_name = "s.f!";
break;
case Kind::VECTOR_FLOAT:
assert(m_size == 16);
ASSERT(m_size == 16);
store_name = "s.vf!";
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(pretty_print::to_symbol(store_name), m_addr.to_form(labels, env),
@@ -1106,7 +1106,7 @@ bool StoreOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const StoreOp*>(&other);
assert(po);
ASSERT(po);
return m_addr == po->m_addr && m_value == po->m_value;
}
@@ -1144,7 +1144,7 @@ std::string load_kind_to_string(LoadVarOp::Kind kind) {
case LoadVarOp::Kind::UNSIGNED:
return "unsigned";
default:
assert(false);
ASSERT(false);
}
}
@@ -1156,7 +1156,7 @@ goos::Object LoadVarOp::to_form(const std::vector<DecompilerLabel>& labels, cons
switch (m_kind) {
case Kind::FLOAT:
assert(m_size == 4);
ASSERT(m_size == 4);
forms.push_back(pretty_print::build_list("l.f", m_src.to_form(labels, env)));
break;
case Kind::UNSIGNED:
@@ -1177,7 +1177,7 @@ goos::Object LoadVarOp::to_form(const std::vector<DecompilerLabel>& labels, cons
forms.push_back(pretty_print::build_list("l.q", m_src.to_form(labels, env)));
break;
default:
assert(false);
ASSERT(false);
}
break;
case Kind::SIGNED:
@@ -1192,16 +1192,16 @@ goos::Object LoadVarOp::to_form(const std::vector<DecompilerLabel>& labels, cons
forms.push_back(pretty_print::build_list("l.w", m_src.to_form(labels, env)));
break;
default:
assert(false);
ASSERT(false);
}
break;
case Kind::VECTOR_FLOAT:
assert(m_size == 16);
ASSERT(m_size == 16);
forms.push_back(pretty_print::build_list("l.vf", m_src.to_form(labels, env)));
break;
default:
assert(false);
ASSERT(false);
}
return pretty_print::build_list(forms);
}
@@ -1212,7 +1212,7 @@ bool LoadVarOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const LoadVarOp*>(&other);
assert(po);
ASSERT(po);
return m_dst == po->m_dst && m_src == po->m_src;
}
@@ -1239,21 +1239,21 @@ void LoadVarOp::collect_vars(RegAccessSet& vars) const {
/////////////////////////////
IR2_BranchDelay::IR2_BranchDelay(Kind kind) : m_kind(kind) {
assert(m_kind == Kind::NOP || m_kind == Kind::NO_DELAY || m_kind == Kind::UNKNOWN);
ASSERT(m_kind == Kind::NOP || m_kind == Kind::NO_DELAY || m_kind == Kind::UNKNOWN);
}
IR2_BranchDelay::IR2_BranchDelay(Kind kind, RegisterAccess var0) : m_kind(kind) {
assert(m_kind == Kind::SET_REG_FALSE || m_kind == Kind::SET_REG_TRUE ||
ASSERT(m_kind == Kind::SET_REG_FALSE || m_kind == Kind::SET_REG_TRUE ||
m_kind == Kind::SET_BINTEGER || m_kind == Kind::SET_PAIR);
assert(var0.mode() == AccessMode::WRITE);
ASSERT(var0.mode() == AccessMode::WRITE);
m_var[0] = var0;
}
IR2_BranchDelay::IR2_BranchDelay(Kind kind, RegisterAccess var0, RegisterAccess var1)
: m_kind(kind) {
assert(m_kind == Kind::NEGATE || m_kind == Kind::SET_REG_REG);
assert(var0.mode() == AccessMode::WRITE);
assert(var1.mode() == AccessMode::READ);
ASSERT(m_kind == Kind::NEGATE || m_kind == Kind::SET_REG_REG);
ASSERT(var0.mode() == AccessMode::WRITE);
ASSERT(var1.mode() == AccessMode::READ);
m_var[0] = var0;
m_var[1] = var1;
}
@@ -1263,10 +1263,10 @@ IR2_BranchDelay::IR2_BranchDelay(Kind kind,
RegisterAccess var1,
RegisterAccess var2)
: m_kind(kind) {
assert(m_kind == Kind::DSLLV);
assert(var0.mode() == AccessMode::WRITE);
assert(var1.mode() == AccessMode::READ);
assert(var2.mode() == AccessMode::READ);
ASSERT(m_kind == Kind::DSLLV);
ASSERT(var0.mode() == AccessMode::WRITE);
ASSERT(var1.mode() == AccessMode::READ);
ASSERT(var2.mode() == AccessMode::READ);
m_var[0] = var0;
m_var[1] = var1;
m_var[2] = var2;
@@ -1281,37 +1281,37 @@ goos::Object IR2_BranchDelay::to_form(const std::vector<DecompilerLabel>& labels
case Kind::NO_DELAY:
return pretty_print::build_list("no-delay!");
case Kind::SET_REG_FALSE:
assert(m_var[0].has_value());
ASSERT(m_var[0].has_value());
return pretty_print::build_list("set!", m_var[0]->to_form(env), "#f");
case Kind::SET_REG_TRUE:
assert(m_var[0].has_value());
ASSERT(m_var[0].has_value());
return pretty_print::build_list("set!", m_var[0]->to_form(env), "#t");
case Kind::SET_REG_REG:
assert(m_var[0].has_value());
assert(m_var[1].has_value());
ASSERT(m_var[0].has_value());
ASSERT(m_var[1].has_value());
return pretty_print::build_list("set!", m_var[0]->to_form(env), m_var[1]->to_form(env));
case Kind::SET_BINTEGER:
assert(m_var[0].has_value());
ASSERT(m_var[0].has_value());
return pretty_print::build_list("set!", m_var[0]->to_form(env), "binteger");
case Kind::SET_PAIR:
assert(m_var[0].has_value());
ASSERT(m_var[0].has_value());
return pretty_print::build_list("set!", m_var[0]->to_form(env), "pair");
case Kind::DSLLV:
assert(m_var[0].has_value());
assert(m_var[1].has_value());
assert(m_var[2].has_value());
ASSERT(m_var[0].has_value());
ASSERT(m_var[1].has_value());
ASSERT(m_var[2].has_value());
return pretty_print::build_list(
"set!", m_var[0]->to_form(env),
pretty_print::build_list("sll", m_var[1]->to_form(env), m_var[2]->to_form(env)));
case Kind::NEGATE:
assert(m_var[0].has_value());
assert(m_var[1].has_value());
ASSERT(m_var[0].has_value());
ASSERT(m_var[1].has_value());
return pretty_print::build_list("set!", m_var[0]->to_form(env),
pretty_print::build_list("-", m_var[1]->to_form(env)));
case Kind::UNKNOWN:
return pretty_print::build_list("unknown-branch-delay!");
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -1347,7 +1347,7 @@ void IR2_BranchDelay::get_regs(std::vector<Register>* write, std::vector<Registe
read->push_back(m_var[2]->reg());
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -1396,7 +1396,7 @@ bool BranchOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const BranchOp*>(&other);
assert(po);
ASSERT(po);
return m_likely == po->m_likely && m_condition == po->m_condition && m_label == po->m_label &&
m_branch_delay == po->m_branch_delay;
}
@@ -1473,7 +1473,7 @@ bool AsmBranchOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const AsmBranchOp*>(&other);
assert(po);
ASSERT(po);
return m_likely == po->m_likely && m_condition == po->m_condition && m_label == po->m_label &&
m_branch_delay == po->m_branch_delay;
}
@@ -1531,7 +1531,7 @@ goos::Object SpecialOp::to_form(const std::vector<DecompilerLabel>& labels, cons
case Kind::SUSPEND:
return pretty_print::build_list("suspend");
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -1542,7 +1542,7 @@ bool SpecialOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const SpecialOp*>(&other);
assert(po);
ASSERT(po);
return m_kind == po->m_kind;
}
@@ -1569,7 +1569,7 @@ void SpecialOp::update_register_info() {
clobber_temps();
return;
default:
assert(false);
ASSERT(false);
}
}
@@ -1601,7 +1601,7 @@ bool CallOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const CallOp*>(&other);
assert(po);
ASSERT(po);
return true;
}
@@ -1658,7 +1658,7 @@ bool ConditionalMoveFalseOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const ConditionalMoveFalseOp*>(&other);
assert(po);
ASSERT(po);
return m_dst == po->m_dst && m_src == po->m_src && m_on_zero == po->m_on_zero &&
m_old_value == po->m_old_value;
}
@@ -1722,7 +1722,7 @@ bool FunctionEndOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const FunctionEndOp*>(&other);
assert(po);
ASSERT(po);
return m_function_has_return_value == po->m_function_has_return_value;
}
@@ -1751,7 +1751,7 @@ void FunctionEndOp::collect_vars(RegAccessSet& vars) const {
StackSpillStoreOp::StackSpillStoreOp(const SimpleAtom& value, int size, int offset, int my_idx)
: AtomicOp(my_idx), m_value(value), m_size(size), m_offset(offset) {
if (m_value.is_var()) {
assert(m_value.var().mode() == AccessMode::READ);
ASSERT(m_value.var().mode() == AccessMode::READ);
}
}
@@ -1766,7 +1766,7 @@ bool StackSpillStoreOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const StackSpillStoreOp*>(&other);
assert(po);
ASSERT(po);
return m_size == po->m_size && m_value == po->m_value && m_offset == po->m_offset;
}
@@ -1799,7 +1799,7 @@ StackSpillLoadOp::StackSpillLoadOp(RegisterAccess dst,
bool is_signed,
int my_idx)
: AtomicOp(my_idx), m_dst(dst), m_size(size), m_offset(offset), m_is_signed(is_signed) {
assert(m_dst.mode() == AccessMode::WRITE);
ASSERT(m_dst.mode() == AccessMode::WRITE);
}
goos::Object StackSpillLoadOp::to_form(const std::vector<DecompilerLabel>&, const Env& env) const {
@@ -1814,7 +1814,7 @@ bool StackSpillLoadOp::operator==(const AtomicOp& other) const {
}
auto po = dynamic_cast<const StackSpillLoadOp*>(&other);
assert(po);
ASSERT(po);
return m_size == po->m_size && m_dst == po->m_dst && m_offset == po->m_offset &&
m_is_signed == po->m_is_signed;
}
+12 -12
View File
@@ -8,7 +8,7 @@
#include "decompiler/Disasm/Instruction.h"
#include "decompiler/IR2/IR2_common.h"
#include "Env.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
class FormElement;
@@ -136,17 +136,17 @@ class SimpleAtom {
bool is_var() const { return m_kind == Kind::VARIABLE; }
bool is_label() const { return m_kind == Kind::STATIC_ADDRESS; }
const RegisterAccess& var() const {
assert(is_var());
ASSERT(is_var());
return m_variable;
}
int label() const {
assert(is_label());
ASSERT(is_label());
return m_int;
}
s64 get_int() const {
assert(is_int());
ASSERT(is_int());
return m_int;
}
bool is_int() const { return m_kind == Kind::INTEGER_CONSTANT; };
@@ -169,7 +169,7 @@ class SimpleAtom {
SimpleExpression as_expr() const;
TP_Type get_type(const TypeState& input, const Env& env, const DecompilerTypeSystem& dts) const;
const std::string& get_str() const {
assert(is_sym_ptr() || is_sym_val());
ASSERT(is_sym_ptr() || is_sym_val());
return m_string;
}
@@ -243,7 +243,7 @@ class SimpleExpression {
// how many arguments?
int args() const { return n_args; }
const SimpleAtom& get_arg(int idx) const {
assert(idx < args());
ASSERT(idx < args());
return m_args[idx];
}
Kind kind() const { return m_kind; }
@@ -260,7 +260,7 @@ class SimpleExpression {
bool is_identity() const { return m_kind == Kind::IDENTITY; }
bool is_var() const { return is_identity() && get_arg(0).is_var(); }
const RegisterAccess& var() const {
assert(is_var());
ASSERT(is_var());
return get_arg(0).var();
}
void get_regs(std::vector<Register>* out) const;
@@ -288,7 +288,7 @@ class SetVarOp : public AtomicOp {
public:
SetVarOp(const RegisterAccess& dst, SimpleExpression src, int my_idx)
: AtomicOp(my_idx), m_dst(dst), m_src(std::move(src)) {
assert(my_idx == dst.idx());
ASSERT(my_idx == dst.idx());
}
virtual goos::Object to_form(const std::vector<DecompilerLabel>& labels,
const Env& env) const override;
@@ -334,7 +334,7 @@ class AsmOp : public AtomicOp {
const Instruction& instruction() const { return m_instr; }
const std::optional<RegisterAccess> dst() const { return m_dst; }
const std::optional<RegisterAccess> src(int i) const {
assert(i < 4);
ASSERT(i < 4);
return m_src[i];
}
@@ -546,8 +546,8 @@ class IR2_BranchDelay {
void collect_vars(RegAccessSet& vars) const;
Kind kind() const { return m_kind; }
const RegisterAccess& var(int idx) const {
assert(idx < 3);
assert(m_var[idx].has_value());
ASSERT(idx < 3);
ASSERT(m_var[idx].has_value());
return m_var[idx].value();
}
@@ -747,7 +747,7 @@ class FunctionEndOp : public AtomicOp {
void collect_vars(RegAccessSet& vars) const override;
void mark_function_as_no_return_value();
const RegisterAccess& return_var() const {
assert(m_function_has_return_value);
ASSERT(m_function_has_return_value);
return m_return_reg;
}
+31 -31
View File
@@ -16,7 +16,7 @@ RegClass get_reg_kind(const Register& r) {
case Reg::FPR:
return RegClass::FLOAT;
default:
assert(false);
ASSERT(false);
return RegClass::INVALID;
}
}
@@ -197,7 +197,7 @@ std::optional<TypeSpec> get_typecast_for_atom(const SimpleAtom& atom,
case SimpleAtom::Kind::SYMBOL_PTR:
case SimpleAtom::Kind::SYMBOL_VAL: {
assert(atom.get_str() == "#f");
ASSERT(atom.get_str() == "#f");
if (expected_type != TypeSpec("symbol")) {
// explicitly cast if we're not using a reference type, including pointers.
@@ -210,14 +210,14 @@ std::optional<TypeSpec> get_typecast_for_atom(const SimpleAtom& atom,
} break;
default:
assert(false);
ASSERT(false);
}
return {};
}
} // namespace
FormElement* StoreOp::get_vf_store_as_form(FormPool& pool, const Env& env) const {
assert(m_value.is_var() && m_value.var().reg().get_kind() == Reg::VF);
ASSERT(m_value.is_var() && m_value.var().reg().get_kind() == Reg::VF);
if (env.has_type_analysis()) {
IR2_RegOffset ro;
if (get_as_reg_offset(m_addr, &ro)) {
@@ -241,7 +241,7 @@ FormElement* StoreOp::get_vf_store_as_form(FormPool& pool, const Env& env) const
for (auto& x : rd.tokens) {
tokens.push_back(to_token(x));
}
assert(!rd.addr_of); // we'll change this to true because .svf uses an address.
ASSERT(!rd.addr_of); // we'll change this to true because .svf uses an address.
auto addr = pool.alloc_single_element_form<DerefElement>(nullptr, source, true, tokens);
return pool.alloc_element<VectorFloatLoadStoreElement>(m_value.var().reg(), addr, false,
m_my_idx);
@@ -331,7 +331,7 @@ FormElement* StoreOp::get_as_form(FormPool& pool, const Env& env) const {
case SimpleAtom::Kind::SYMBOL_PTR:
case SimpleAtom::Kind::SYMBOL_VAL: {
assert(m_value.get_str() == "#f");
ASSERT(m_value.get_str() == "#f");
std::optional<TypeSpec> cast_for_set, cast_for_define;
if (symbol_type != TypeSpec("symbol")) {
cast_for_define = symbol_type;
@@ -347,7 +347,7 @@ FormElement* StoreOp::get_as_form(FormPool& pool, const Env& env) const {
} break;
default:
assert(false);
ASSERT(false);
}
}
@@ -379,7 +379,7 @@ FormElement* StoreOp::get_as_form(FormPool& pool, const Env& env) const {
if (rd.success) {
std::vector<DerefToken> tokens;
assert(!rd.tokens.empty());
ASSERT(!rd.tokens.empty());
for (auto& token : rd.tokens) {
tokens.push_back(to_token(token));
}
@@ -393,7 +393,7 @@ FormElement* StoreOp::get_as_form(FormPool& pool, const Env& env) const {
// auto val = pool.alloc_single_element_form<SimpleExpressionElement>(
// nullptr, m_value.as_expr(), m_my_idx);
assert(!rd.addr_of);
ASSERT(!rd.addr_of);
return pool.alloc_element<StoreArrayAccess>(
source, m_value.as_expr(), m_my_idx, ro.var,
get_typecast_for_atom(m_value, env, coerce_to_reg_type(rd.result_type), m_my_idx));
@@ -418,7 +418,7 @@ FormElement* StoreOp::get_as_form(FormPool& pool, const Env& env) const {
for (auto& x : rd.tokens) {
tokens.push_back(to_token(x));
}
assert(!rd.addr_of);
ASSERT(!rd.addr_of);
auto addr = pool.alloc_element<DerefElement>(source, rd.addr_of, tokens);
return pool.alloc_element<StorePlainDeref>(
@@ -448,7 +448,7 @@ FormElement* StoreOp::get_as_form(FormPool& pool, const Env& env) const {
cast_type = "int128";
break;
default:
assert(false);
ASSERT(false);
}
if (m_value.is_var()) {
@@ -498,19 +498,19 @@ FormElement* make_label_load(int label_idx,
if ((load_kind == LoadVarOp::Kind::FLOAT || load_kind == LoadVarOp::Kind::SIGNED) &&
load_size == 4 && hint.result_type == TypeSpec("float")) {
assert((label.offset % 4) == 0);
ASSERT((label.offset % 4) == 0);
auto word = env.file->words_by_seg.at(label.target_segment).at(label.offset / 4);
assert(word.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word.kind() == LinkedWord::PLAIN_DATA);
float value;
memcpy(&value, &word.data, 4);
return pool.alloc_element<ConstantFloatElement>(value);
} else if (hint.result_type == TypeSpec("uint64") && load_kind != LoadVarOp::Kind::FLOAT &&
load_size == 8) {
assert((label.offset % 8) == 0);
ASSERT((label.offset % 8) == 0);
auto word0 = env.file->words_by_seg.at(label.target_segment).at(label.offset / 4);
auto word1 = env.file->words_by_seg.at(label.target_segment).at(1 + (label.offset / 4));
assert(word0.kind() == LinkedWord::PLAIN_DATA);
assert(word1.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word0.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word1.kind() == LinkedWord::PLAIN_DATA);
u64 value;
memcpy(&value, &word0.data, 4);
memcpy(((u8*)&value) + 4, &word1.data, 4);
@@ -524,20 +524,20 @@ FormElement* make_label_load(int label_idx,
auto as_bitfield = dynamic_cast<BitFieldType*>(ts.lookup_type(hint.result_type));
if (as_bitfield && load_kind != LoadVarOp::Kind::FLOAT && load_size == 8) {
// get the data
assert((label.offset % 8) == 0);
ASSERT((label.offset % 8) == 0);
auto word0 = env.file->words_by_seg.at(label.target_segment).at(label.offset / 4);
auto word1 = env.file->words_by_seg.at(label.target_segment).at(1 + (label.offset / 4));
assert(word0.kind() == LinkedWord::PLAIN_DATA);
assert(word1.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word0.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word1.kind() == LinkedWord::PLAIN_DATA);
u64 value;
memcpy(&value, &word0.data, 4);
memcpy(((u8*)&value) + 4, &word1.data, 4);
// for some reason, GOAL would use a 64-bit constant for all bitfields, even if they are
// smaller. We should check that the higher bits are all zero.
int bits = as_bitfield->get_size_in_memory() * 8;
assert(bits <= 64);
ASSERT(bits <= 64);
if (bits < 64) {
assert((value >> bits) == 0);
ASSERT((value >> bits) == 0);
// technically ub if bits == 64.
}
auto defs = decompile_bitfield_from_int(hint.result_type, ts, value);
@@ -546,11 +546,11 @@ FormElement* make_label_load(int label_idx,
/*
if (load_kind == LoadVarOp::Kind::FLOAT && load_size == 4) {
assert((label.offset % 4) == 0);
ASSERT((label.offset % 4) == 0);
const auto& words = env.file->words_by_seg.at(label.target_segment);
if ((int)words.size() > label.offset / 4) {
auto word = words.at(label.offset / 4);
assert(word.kind == LinkedWord::PLAIN_DATA);
ASSERT(word.kind == LinkedWord::PLAIN_DATA);
float value;
memcpy(&value, &word.data, 4);
return pool.alloc_element<ConstantFloatElement>(value);
@@ -559,11 +559,11 @@ FormElement* make_label_load(int label_idx,
if (load_kind != LoadVarOp::Kind::FLOAT && load_size == 8) {
if ((int)env.file->words_by_seg.at(label.target_segment).size() > (label.offset / 4) + 1) {
assert((label.offset % 8) == 0);
ASSERT((label.offset % 8) == 0);
auto word0 = env.file->words_by_seg.at(label.target_segment).at(label.offset / 4);
auto word1 = env.file->words_by_seg.at(label.target_segment).at(1 + (label.offset / 4));
assert(word0.kind == LinkedWord::PLAIN_DATA);
assert(word1.kind == LinkedWord::PLAIN_DATA);
ASSERT(word0.kind == LinkedWord::PLAIN_DATA);
ASSERT(word1.kind == LinkedWord::PLAIN_DATA);
u64 value;
memcpy(&value, &word0.data, 4);
memcpy(((u8*)&value) + 4, &word1.data, 4);
@@ -627,7 +627,7 @@ Form* LoadVarOp::get_load_src(FormPool& pool, const Env& env) const {
if (rd.success) {
std::vector<DerefToken> tokens;
assert(!rd.tokens.empty());
ASSERT(!rd.tokens.empty());
for (auto& token : rd.tokens) {
tokens.push_back(to_token(token));
}
@@ -711,7 +711,7 @@ Form* LoadVarOp::get_load_src(FormPool& pool, const Env& env) const {
cast_type = "int128";
break;
default:
assert(false);
ASSERT(false);
}
if (m_kind == Kind::UNSIGNED) {
cast_type = "u" + cast_type;
@@ -743,11 +743,11 @@ Form* LoadVarOp::get_load_src(FormPool& pool, const Env& env) const {
FormElement* LoadVarOp::get_as_form(FormPool& pool, const Env& env) const {
auto src = get_load_src(pool, env);
if (m_kind == Kind::VECTOR_FLOAT) {
assert(m_dst.reg().get_kind() == Reg::VF);
ASSERT(m_dst.reg().get_kind() == Reg::VF);
auto src_as_deref = dynamic_cast<DerefElement*>(src->try_as_single_element());
if (src_as_deref) {
assert(!src_as_deref->is_addr_of());
ASSERT(!src_as_deref->is_addr_of());
src_as_deref->set_addr_of(true);
return pool.alloc_element<VectorFloatLoadStoreElement>(m_dst.reg(), src, true, m_my_idx);
}
@@ -761,7 +761,7 @@ FormElement* LoadVarOp::get_as_form(FormPool& pool, const Env& env) const {
throw std::runtime_error("VF unknown load");
} else {
assert(m_dst.reg().get_kind() != Reg::VF);
ASSERT(m_dst.reg().get_kind() != Reg::VF);
return pool.alloc_element<SetVarElement>(m_dst, src, true, m_type.value_or(TypeSpec("object")));
}
}
+13 -13
View File
@@ -30,7 +30,7 @@ RegClass get_reg_kind(const Register& r) {
case Reg::FPR:
return RegClass::FLOAT;
default:
assert(false);
ASSERT(false);
return RegClass::INVALID;
}
}
@@ -167,7 +167,7 @@ TP_Type SimpleAtom::get_type(const TypeState& input,
}
case Kind::INVALID:
default:
assert(false);
ASSERT(false);
}
return {};
}
@@ -337,8 +337,8 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input,
case Kind::LEFT_SHIFT:
// multiplication by constant power of two, optimized to a shift.
if (m_args[1].is_int() && is_int_or_uint(dts, arg0_type)) {
assert(m_args[1].get_int() >= 0);
assert(m_args[1].get_int() < 64);
ASSERT(m_args[1].get_int() >= 0);
ASSERT(m_args[1].get_int() < 64);
// this could be a bitfield access or a multiply.
// we pick bitfield access if the parent is a bitfield.
if (dynamic_cast<BitFieldType*>(dts.ts.lookup_type(arg0_type.typespec()))) {
@@ -388,7 +388,7 @@ TP_Type SimpleExpression::get_type_int2(const TypeState& input,
auto type = dts.ts.lookup_type(arg0_type.get_bitfield_type());
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field(dts.ts, as_bitfield, start_bit, size, is_unsigned);
return TP_Type::make_from_ts(coerce_to_reg_type(field.type()));
}
@@ -794,18 +794,18 @@ TypeState AsmOp::propagate_types_internal(const TypeState& input,
TypeState result = input;
if (m_instr.kind == InstructionKind::QMFC2) {
assert(m_dst);
ASSERT(m_dst);
result.get(m_dst->reg()) = TP_Type::make_from_ts("float");
return result;
}
if (m_instr.kind == InstructionKind::PCPYUD) {
if (m_src[1] && m_src[1]->reg() == Register(Reg::GPR, Reg::R0)) {
assert(m_src[0]);
ASSERT(m_src[0]);
auto& in_type = result.get(m_src[0]->reg());
auto bf = dynamic_cast<BitFieldType*>(dts.ts.lookup_type(in_type.typespec()));
if (bf) {
assert(m_dst);
ASSERT(m_dst);
result.get(m_dst->reg()) = TP_Type::make_from_pcpyud_bitfield(in_type.typespec());
return result;
}
@@ -815,12 +815,12 @@ TypeState AsmOp::propagate_types_internal(const TypeState& input,
// pextuw t0, r0, gp
if (m_instr.kind == InstructionKind::PEXTUW) {
if (m_src[0] && m_src[0]->reg() == Register(Reg::GPR, Reg::R0)) {
assert(m_src[1]);
ASSERT(m_src[1]);
auto type = dts.ts.lookup_type(result.get(m_src[1]->reg()).typespec());
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
if (as_bitfield) {
auto field = find_field(dts.ts, as_bitfield, 64, 32, true);
assert(m_dst);
ASSERT(m_dst);
result.get(m_dst->reg()) = TP_Type::make_from_ts(field.type());
return result;
}
@@ -1007,7 +1007,7 @@ TP_Type LoadVarOp::get_src_type(const TypeState& input,
case Kind::FLOAT:
return TP_Type::make_from_ts(TypeSpec("float"));
default:
assert(false);
ASSERT(false);
}
}
@@ -1117,7 +1117,7 @@ TP_Type LoadVarOp::get_src_type(const TypeState& input,
case Kind::FLOAT:
return TP_Type::make_from_ts(TypeSpec("float"));
default:
assert(false);
ASSERT(false);
}
}
@@ -1183,7 +1183,7 @@ TypeState SpecialOp::propagate_types_internal(const TypeState& input,
case Kind::SUSPEND:
return input;
default:
assert(false);
ASSERT(false);
return input;
}
}
+9 -9
View File
@@ -148,7 +148,7 @@ VariableWithCast Env::get_variable_and_cast(const RegisterAccess& access) const
"(var {}) to type {}, but the actual type is {} ({})",
access.reg().to_charp(), access.idx(), lookup_name, x.type_name,
type_in_reg.print(), type_in_reg.print());
assert(false);
ASSERT(false);
}
}
@@ -228,7 +228,7 @@ std::optional<TypeSpec> Env::get_user_cast_for_access(const RegisterAccess& acce
"(var {}) to type {}, but the actual type is {} ({})",
access.reg().to_charp(), access.idx(), original_name, x.type_name,
type_in_reg.print(), type_in_reg.print());
assert(false);
ASSERT(false);
}
}
@@ -289,7 +289,7 @@ void Env::set_types(const std::vector<TypeState>& block_init_types,
}
for (auto x : m_op_init_types) {
assert(x);
ASSERT(x);
}
m_has_types = true;
@@ -306,7 +306,7 @@ void Env::set_types(const std::vector<TypeState>& block_init_types,
}
std::string Env::print_local_var_types(const Form* top_level_form) const {
assert(has_local_vars());
ASSERT(has_local_vars());
auto var_info = extract_visible_variables(top_level_form);
std::vector<std::string> entries;
for (auto x : var_info) {
@@ -347,7 +347,7 @@ std::string Env::print_local_var_types(const Form* top_level_form) const {
std::vector<VariableNames::VarInfo> Env::extract_visible_variables(
const Form* top_level_form) const {
assert(has_local_vars());
ASSERT(has_local_vars());
std::vector<VariableNames::VarInfo> entries;
if (top_level_form) {
RegAccessSet var_set;
@@ -381,7 +381,7 @@ std::vector<VariableNames::VarInfo> Env::extract_visible_variables(
if (info.initialized) {
entries.push_back(info);
} else {
assert(false);
ASSERT(false);
}
}
} else {
@@ -415,7 +415,7 @@ std::vector<VariableNames::VarInfo> Env::extract_visible_variables(
FunctionVariableDefinitions Env::local_var_type_list(const Form* top_level_form,
int nargs_to_ignore) const {
assert(nargs_to_ignore <= 8);
ASSERT(nargs_to_ignore <= 8);
auto vars = extract_visible_variables(top_level_form);
FunctionVariableDefinitions result;
@@ -480,7 +480,7 @@ RegId Env::get_program_var_id(const RegisterAccess& var) const {
}
const UseDefInfo& Env::get_use_def_info(const RegisterAccess& ra) const {
assert(has_local_vars());
ASSERT(has_local_vars());
auto var_id = get_program_var_id(ra);
return m_var_names.use_def_info.at(var_id);
}
@@ -559,7 +559,7 @@ void Env::set_stack_structure_hints(const std::vector<StackStructureHint>& hints
break;
}
default:
assert(false);
ASSERT(false);
}
m_stack_structures.push_back(entry);
+7 -7
View File
@@ -9,7 +9,7 @@
#include "decompiler/IR2/IR2_common.h"
#include "decompiler/analysis/reg_usage.h"
#include "decompiler/config.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
class LinkedObjectFile;
@@ -61,7 +61,7 @@ class Env {
bool has_type_analysis() const { return m_has_types; }
bool has_reg_use() const { return m_has_reg_use; }
const RegUsageInfo& reg_use() const {
assert(m_has_reg_use);
ASSERT(m_has_reg_use);
return m_reg_use;
}
@@ -71,7 +71,7 @@ class Env {
}
RegUsageInfo& reg_use() {
assert(m_has_reg_use);
ASSERT(m_has_reg_use);
return m_reg_use;
}
@@ -88,12 +88,12 @@ class Env {
* Get the types in registers _after_ the given operation has completed.
*/
const TypeState& get_types_after_op(int atomic_op_id) const {
assert(m_has_types);
ASSERT(m_has_types);
return m_op_end_types.at(atomic_op_id);
}
const TypeState& get_types_before_op(int atomic_op_id) const {
assert(m_has_types);
ASSERT(m_has_types);
return *m_op_init_types.at(atomic_op_id);
}
@@ -110,7 +110,7 @@ class Env {
* have occurred.
*/
const TypeState& get_types_at_block_entry(int block_id) const {
assert(m_has_types);
ASSERT(m_has_types);
return m_block_init_types.at(block_id);
}
@@ -161,7 +161,7 @@ class Env {
const std::string& remapped_name(const std::string& name) const;
bool op_id_is_eliminated_coloring_move(int op_id) const {
assert(has_local_vars());
ASSERT(has_local_vars());
return m_var_names.eliminated_move_op_ids.find(op_id) !=
m_var_names.eliminated_move_op_ids.end();
}
+1 -1
View File
@@ -10,7 +10,7 @@ namespace decompiler {
FormElement* handle_get_property_value_float(const std::vector<Form*>& forms,
FormPool& pool,
const Env& env) {
assert(forms.size() == 7);
ASSERT(forms.size() == 7);
// lump object
// name
// 'interp
+41 -41
View File
@@ -60,7 +60,7 @@ goos::Object FormElement::to_form(const Env& env) const {
//////////////////
goos::Object Form::to_form(const Env& env) const {
assert(!m_elements.empty());
ASSERT(!m_elements.empty());
if (m_elements.size() == 1) {
return m_elements.front()->to_form(env);
} else {
@@ -80,7 +80,7 @@ goos::Object Form::to_form(const Env& env) const {
}
goos::Object Form::to_form_as_condition(const Env& env) const {
assert(!m_elements.empty());
ASSERT(!m_elements.empty());
if (m_elements.size() == 1) {
return m_elements.front()->to_form_as_condition_internal(env);
} else {
@@ -203,7 +203,7 @@ LoadSourceElement::LoadSourceElement(Form* addr, int size, LoadVarOp::Kind kind)
goos::Object LoadSourceElement::to_form_internal(const Env& env) const {
switch (m_kind) {
case LoadVarOp::Kind::FLOAT:
assert(m_size == 4);
ASSERT(m_size == 4);
return pretty_print::build_list("l.f", m_addr->to_form(env));
case LoadVarOp::Kind::UNSIGNED:
switch (m_size) {
@@ -218,7 +218,7 @@ goos::Object LoadSourceElement::to_form_internal(const Env& env) const {
case 16:
return pretty_print::build_list("l.q", m_addr->to_form(env));
default:
assert(false);
ASSERT(false);
return {};
}
break;
@@ -231,16 +231,16 @@ goos::Object LoadSourceElement::to_form_internal(const Env& env) const {
case 4:
return pretty_print::build_list("l.w", m_addr->to_form(env));
default:
assert(false);
ASSERT(false);
return {};
}
break;
case LoadVarOp::Kind::VECTOR_FLOAT:
assert(m_size == 16);
ASSERT(m_size == 16);
return pretty_print::build_list("l.vf", m_addr->to_form(env));
break;
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -271,7 +271,7 @@ void LoadSourceElement::get_modified_regs(RegSet& regs) const {
SimpleAtomElement::SimpleAtomElement(const SimpleAtom& atom, bool omit_var_cast)
: m_atom(atom), m_omit_var_cast(omit_var_cast) {
if (m_omit_var_cast) {
assert(atom.is_var());
ASSERT(atom.is_var());
}
}
@@ -314,7 +314,7 @@ SetVarElement::SetVarElement(const RegisterAccess& var,
}
goos::Object SetVarElement::to_form_internal(const Env& env) const {
assert(active());
ASSERT(active());
auto reg_kind = m_dst.reg().get_kind();
if ((reg_kind == Reg::FPR || reg_kind == Reg::GPR) && env.has_type_analysis() &&
env.has_local_vars()) {
@@ -546,7 +546,7 @@ AsmBranchElement::AsmBranchElement(AsmBranchOp* branch_op, Form* branch_delay, b
: m_branch_op(branch_op), m_branch_delay(branch_delay), m_likely(likely) {
m_branch_delay->parent_element = this;
for (auto& elt : m_branch_delay->elts()) {
assert(elt->parent_form == m_branch_delay);
ASSERT(elt->parent_form == m_branch_delay);
}
}
@@ -622,15 +622,15 @@ goos::Object TranslatedAsmBranch::to_form_internal(const Env& env) const {
}
}
assert(block_id >= 0);
ASSERT(block_id >= 0);
if (m_branch_delay) {
if (m_branch_delay->parent_element != this) {
fmt::print("bad ptr. Parent is {}\n", m_branch_delay->parent_element->to_string(env));
assert(false);
ASSERT(false);
}
assert(m_branch_delay->parent_element->parent_form);
ASSERT(m_branch_delay->parent_element->parent_form);
std::vector<goos::Object> list = {
pretty_print::to_symbol("b!"), m_branch_condition->to_form(env),
pretty_print::to_symbol(fmt::format("cfg-{}", block_id)),
@@ -668,11 +668,11 @@ void TranslatedAsmBranch::collect_vars(RegAccessSet& vars, bool recursive) const
if (m_branch_delay) {
if (m_branch_delay->parent_element != this) {
fmt::print("bad ptr. Parent is {}\n", (void*)m_branch_delay->parent_element);
assert(false);
ASSERT(false);
}
for (auto& elt : m_branch_delay->elts()) {
assert(elt->parent_form == m_branch_delay);
ASSERT(elt->parent_form == m_branch_delay);
}
m_branch_delay->collect_vars(vars, recursive);
@@ -1289,7 +1289,7 @@ goos::Object ShortCircuitElement::to_form_internal(const Env& env) const {
forms.push_back(pretty_print::to_symbol("or"));
break;
default:
assert(false);
ASSERT(false);
}
for (auto& x : entries) {
forms.push_back(x.condition->to_form_as_condition(env));
@@ -1638,7 +1638,7 @@ void GenericOperator::collect_vars(RegAccessSet& vars, bool recursive) const {
}
return;
default:
assert(false);
ASSERT(false);
}
}
@@ -1651,7 +1651,7 @@ goos::Object GenericOperator::to_form(const Env& env) const {
case Kind::FUNCTION_EXPR:
return m_function->to_form(env);
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -1665,7 +1665,7 @@ void GenericOperator::apply(const std::function<void(FormElement*)>& f) {
m_function->apply(f);
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -1678,7 +1678,7 @@ void GenericOperator::apply_form(const std::function<void(Form*)>& f) {
m_function->apply_form(f);
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -1694,7 +1694,7 @@ bool GenericOperator::operator==(const GenericOperator& other) const {
case Kind::FUNCTION_EXPR:
return false;
default:
assert(false);
ASSERT(false);
return false;
}
}
@@ -1712,7 +1712,7 @@ void GenericOperator::get_modified_regs(RegSet& regs) const {
m_function->get_modified_regs(regs);
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -1855,7 +1855,7 @@ std::string fixed_operator_to_string(FixedOperatorKind kind) {
case FixedOperatorKind::CPAD_HOLD_P:
return "cpad-hold?";
default:
assert(false);
ASSERT(false);
return "";
}
}
@@ -1898,7 +1898,7 @@ GenericElement::GenericElement(GenericOperator op, std::vector<Form*> forms)
goos::Object GenericElement::to_form_internal(const Env& env) const {
if (m_head.kind() == GenericOperator::Kind::CONDITION_OPERATOR &&
m_head.condition_kind() == IR2_Condition::Kind::TRUTHY) {
assert(m_elts.size() == 1);
ASSERT(m_elts.size() == 1);
return m_elts.front()->to_form_as_condition(env);
} else if (m_head.kind() == GenericOperator::Kind::CONDITION_OPERATOR &&
m_head.condition_kind() == IR2_Condition::Kind::ALWAYS) {
@@ -1907,7 +1907,7 @@ goos::Object GenericElement::to_form_internal(const Env& env) const {
std::vector<goos::Object> result;
result.push_back(m_head.to_form(env));
for (auto x : m_elts) {
assert(x->parent_element);
ASSERT(x->parent_element);
result.push_back(x->to_form(env));
}
return pretty_print::build_list(result);
@@ -1955,7 +1955,7 @@ CastElement::CastElement(TypeSpec type, Form* source, bool numeric)
}
goos::Object CastElement::to_form_internal(const Env& env) const {
// assert(m_source->parent_element == this);
// ASSERT(m_source->parent_element == this);
auto atom = form_as_atom(m_source);
if (atom && atom->is_var()) {
return pretty_print::build_list(
@@ -1967,25 +1967,25 @@ goos::Object CastElement::to_form_internal(const Env& env) const {
}
void CastElement::apply(const std::function<void(FormElement*)>& f) {
// assert(m_source->parent_element == this);
// ASSERT(m_source->parent_element == this);
f(this);
m_source->apply(f);
}
void CastElement::apply_form(const std::function<void(Form*)>& f) {
// assert(m_source->parent_element == this);
// ASSERT(m_source->parent_element == this);
m_source->apply_form(f);
}
void CastElement::collect_vars(RegAccessSet& vars, bool recursive) const {
// assert(m_source->parent_element == this);
// ASSERT(m_source->parent_element == this);
if (recursive) {
m_source->collect_vars(vars, recursive);
}
}
void CastElement::get_modified_regs(RegSet& regs) const {
assert(m_source->parent_element == this);
ASSERT(m_source->parent_element == this);
m_source->get_modified_regs(regs);
}
@@ -2032,7 +2032,7 @@ void DerefToken::collect_vars(RegAccessSet& vars, bool recursive) const {
}
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -2047,7 +2047,7 @@ goos::Object DerefToken::to_form(const Env& env) const {
case Kind::EXPRESSION_PLACEHOLDER:
return pretty_print::to_symbol("PLACEHOLDER");
default:
assert(false);
ASSERT(false);
return {};
}
}
@@ -2062,7 +2062,7 @@ void DerefToken::apply(const std::function<void(FormElement*)>& f) {
m_expr->apply(f);
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -2076,7 +2076,7 @@ void DerefToken::apply_form(const std::function<void(Form*)>& f) {
m_expr->apply_form(f);
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -2090,7 +2090,7 @@ void DerefToken::get_modified_regs(RegSet& regs) const {
m_expr->get_modified_regs(regs);
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -2131,7 +2131,7 @@ DerefElement::DerefElement(Form* base, bool is_addr_of, std::vector<DerefToken>
}
goos::Object DerefElement::to_form_internal(const Env& env) const {
assert(m_base->parent_element);
ASSERT(m_base->parent_element);
std::vector<goos::Object> forms = {pretty_print::to_symbol(m_is_addr_of ? "&->" : "->"),
m_base->to_form(env)};
for (auto& tok : m_tokens) {
@@ -2561,8 +2561,8 @@ CounterLoopElement::CounterLoopElement(Kind kind,
m_kind(kind) {
m_body->parent_element = this;
m_check_value->parent_element = this;
assert(m_var_inc.reg() == m_var_check.reg());
assert(m_var_init.reg() == m_var_inc.reg());
ASSERT(m_var_inc.reg() == m_var_check.reg());
ASSERT(m_var_init.reg() == m_var_inc.reg());
}
goos::Object CounterLoopElement::to_form_internal(const Env& env) const {
@@ -2575,7 +2575,7 @@ goos::Object CounterLoopElement::to_form_internal(const Env& env) const {
loop_name = "countdown";
break;
default:
assert(false);
ASSERT(false);
}
std::vector<goos::Object> outer = {
pretty_print::to_symbol(loop_name),
@@ -2652,7 +2652,7 @@ goos::Object StackStructureDefElement::to_form_internal(const Env&) const {
m_entry.ref_type.get_single_arg().print(),
m_entry.hint.container_size));
default:
assert(false);
ASSERT(false);
}
}
@@ -3269,7 +3269,7 @@ goos::Object ResLumpMacroElement::to_form_internal(const Env& env) const {
forms.push_back(pretty_print::to_symbol("res-lump-value"));
break;
default:
assert(false);
ASSERT(false);
}
forms.push_back(m_lump_object->to_form(env));
+11 -11
View File
@@ -63,7 +63,7 @@ class FormElement {
FormElement& operator=(const FormElement& other) = delete;
void mark_popped() {
assert(!m_popped);
ASSERT(!m_popped);
m_popped = true;
}
@@ -1016,22 +1016,22 @@ class GenericOperator {
void get_modified_regs(RegSet& regs) const;
Kind kind() const { return m_kind; }
FixedOperatorKind fixed_kind() const {
assert(m_kind == Kind::FIXED_OPERATOR);
ASSERT(m_kind == Kind::FIXED_OPERATOR);
return m_fixed_kind;
}
IR2_Condition::Kind condition_kind() const {
assert(m_kind == Kind::CONDITION_OPERATOR);
ASSERT(m_kind == Kind::CONDITION_OPERATOR);
return m_condition_kind;
}
const Form* func() const {
assert(m_kind == Kind::FUNCTION_EXPR);
ASSERT(m_kind == Kind::FUNCTION_EXPR);
return m_function;
}
Form* func() {
assert(m_kind == Kind::FUNCTION_EXPR);
ASSERT(m_kind == Kind::FUNCTION_EXPR);
return m_function;
}
@@ -1129,14 +1129,14 @@ class DerefToken {
Kind kind() const { return m_kind; }
const std::string& field_name() const {
assert(m_kind == Kind::FIELD_NAME);
ASSERT(m_kind == Kind::FIELD_NAME);
return m_name;
}
s64 int_constant() const { return m_int_constant; }
Form* expr() {
assert(m_kind == Kind::INTEGER_EXPRESSION);
ASSERT(m_kind == Kind::INTEGER_EXPRESSION);
return m_expr;
}
@@ -1862,17 +1862,17 @@ class Form {
const FormElement* operator[](int idx) const { return m_elements.at(idx); }
int size() const { return int(m_elements.size()); }
FormElement* back() const {
assert(!m_elements.empty());
ASSERT(!m_elements.empty());
return m_elements.back();
}
FormElement** back_ref() {
assert(!m_elements.empty());
ASSERT(!m_elements.empty());
return &m_elements.back();
}
void pop_back() {
assert(!m_elements.empty());
ASSERT(!m_elements.empty());
m_elements.pop_back();
}
@@ -1986,7 +1986,7 @@ class FormPool {
}
void cache_conversion(const CfgVtx* vtx, Form* form) {
assert(m_vtx_to_form_cache.find(vtx) == m_vtx_to_form_cache.end());
ASSERT(m_vtx_to_form_cache.find(vtx) == m_vtx_to_form_cache.end());
m_vtx_to_form_cache[vtx] = form;
}
+93 -93
View File
@@ -408,7 +408,7 @@ std::vector<Form*> pop_to_forms(const std::vector<RegisterAccess>& vars,
}
// add casts, if needed.
assert(vars.size() == forms.size());
ASSERT(vars.size() == forms.size());
for (size_t i = 0; i < vars.size(); i++) {
auto atom = form_as_atom(forms[i]);
bool is_var = atom && atom->is_var();
@@ -472,7 +472,7 @@ void Form::update_children_from_stack(const Env& env,
FormPool& pool,
FormStack& stack,
bool allow_side_effects) {
assert(!m_elements.empty());
ASSERT(!m_elements.empty());
std::vector<FormElement*> new_elts;
@@ -530,7 +530,7 @@ std::vector<Form*> make_casts_if_needed(const std::vector<Form*>& in,
FormPool& pool,
const Env& env) {
std::vector<Form*> out;
assert(in.size() == in_types.size());
ASSERT(in.size() == in_types.size());
for (size_t i = 0; i < in_types.size(); i++) {
out.push_back(make_cast_if_needed(in.at(i), in_types.at(i), out_type, pool, env));
}
@@ -641,7 +641,7 @@ void SimpleExpressionElement::update_from_stack_fpr_to_gpr(const Env& env,
// set ourself to identity.
m_expr = src.as_expr();
// then go again.
assert(m_popped);
ASSERT(m_popped);
m_popped = false;
update_from_stack(env, pool, stack, result, allow_side_effects);
} else {
@@ -722,7 +722,7 @@ FormElement* make_and_compact_math_op(Form* arg0,
arg0_elts = {arg0};
}
assert(!arg0_elts.empty());
ASSERT(!arg0_elts.empty());
if (arg0_cast) {
arg0_elts.front() = cast_form(arg0_elts.front(), *arg0_cast, pool, env);
}
@@ -735,7 +735,7 @@ FormElement* make_and_compact_math_op(Form* arg0,
arg1_elts = {arg1};
}
assert(!arg1_elts.empty());
ASSERT(!arg1_elts.empty());
if (arg1_cast) {
arg1_elts.front() = cast_form(arg1_elts.front(), *arg1_cast, pool, env);
}
@@ -884,14 +884,14 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
std::vector<DerefToken> tokens;
for (auto& tok : out.tokens) {
if (tok.kind == FieldReverseLookupOutput::Token::Kind::VAR_IDX) {
assert(!used_index);
ASSERT(!used_index);
used_index = true;
tokens.push_back(DerefToken::make_int_expr(match_result.maps.forms.at(0)));
} else {
tokens.push_back(to_token(tok));
}
}
assert(used_index);
ASSERT(used_index);
result->push_back(pool.alloc_element<DerefElement>(args.at(1), out.addr_of, tokens));
return;
} else {
@@ -922,14 +922,14 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
std::vector<DerefToken> tokens;
for (auto& tok : out.tokens) {
if (tok.kind == FieldReverseLookupOutput::Token::Kind::VAR_IDX) {
assert(!used_index);
ASSERT(!used_index);
used_index = true;
tokens.push_back(DerefToken::make_int_expr(match_result.maps.forms.at(0)));
} else {
tokens.push_back(to_token(tok));
}
}
assert(used_index);
ASSERT(used_index);
result->push_back(pool.alloc_element<DerefElement>(args.at(1), out.addr_of, tokens));
return;
} else {
@@ -951,14 +951,14 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
std::vector<DerefToken> tokens;
for (auto& tok : out.tokens) {
if (tok.kind == FieldReverseLookupOutput::Token::Kind::VAR_IDX) {
assert(!used_index);
ASSERT(!used_index);
used_index = true;
tokens.push_back(DerefToken::make_int_expr(match_result.maps.forms.at(0)));
} else {
tokens.push_back(to_token(tok));
}
}
assert(used_index);
ASSERT(used_index);
result->push_back(pool.alloc_element<DerefElement>(args.at(1), out.addr_of, tokens));
return;
} else {
@@ -1003,14 +1003,14 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
std::vector<DerefToken> tokens;
for (auto& tok : rd_ok.tokens) {
if (tok.kind == FieldReverseLookupOutput::Token::Kind::VAR_IDX) {
assert(!used_index);
ASSERT(!used_index);
used_index = true;
tokens.push_back(DerefToken::make_int_expr(match_result.maps.forms.at(0)));
} else {
tokens.push_back(to_token(tok));
}
}
assert(used_index);
ASSERT(used_index);
result->push_back(pool.alloc_element<DerefElement>(args.at(0), rd_ok.addr_of, tokens));
return;
} else {
@@ -1054,14 +1054,14 @@ void SimpleExpressionElement::update_from_stack_add_i(const Env& env,
std::vector<DerefToken> tokens;
for (auto& tok : rd_ok.tokens) {
if (tok.kind == FieldReverseLookupOutput::Token::Kind::VAR_IDX) {
assert(!used_index);
ASSERT(!used_index);
used_index = true;
tokens.push_back(DerefToken::make_int_expr(match_result.maps.forms.at(0)));
} else {
tokens.push_back(to_token(tok));
}
}
assert(used_index);
ASSERT(used_index);
result->push_back(pool.alloc_element<DerefElement>(args.at(1), rd_ok.addr_of, tokens));
return;
} else {
@@ -1160,7 +1160,7 @@ void SimpleExpressionElement::update_from_stack_force_si_2(const Env& env,
if (arg1_reg) {
arg1_i = is_int_type(env, m_my_idx, m_expr.get_arg(1).var());
} else {
assert(m_expr.get_arg(1).is_int());
ASSERT(m_expr.get_arg(1).is_int());
}
std::vector<Form*> args;
@@ -1206,7 +1206,7 @@ void SimpleExpressionElement::update_from_stack_force_ui_2(const Env& env,
if (arg1_reg) {
arg1_u = is_uint_type(env, m_my_idx, m_expr.get_arg(1).var());
} else {
assert(m_expr.get_arg(1).is_int());
ASSERT(m_expr.get_arg(1).is_int());
}
std::vector<Form*> args;
@@ -1447,12 +1447,12 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
had_pcpyud = true;
bitfield_info =
dynamic_cast<BitFieldType*>(env.dts->ts.lookup_type(arg0_reg_type.get_bitfield_type()));
assert(bitfield_info);
ASSERT(bitfield_info);
} else if (arg0_reg_type.kind == TP_Type::Kind::PCPYUD_BITFIELD_AND) {
// already have the pcpyud in the thing.
bitfield_info =
dynamic_cast<BitFieldType*>(env.dts->ts.lookup_type(arg0_reg_type.get_bitfield_type()));
assert(bitfield_info);
ASSERT(bitfield_info);
}
}
@@ -1462,10 +1462,10 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
auto read_elt = dynamic_cast<BitfieldAccessElement*>(base->try_as_single_element());
if (!read_elt) {
read_elt = pool.alloc_element<BitfieldAccessElement>(base, bitfield_type);
assert(!had_pcpyud);
ASSERT(!had_pcpyud);
} else {
if (had_pcpyud) {
assert(read_elt->has_pcpyud());
ASSERT(read_elt->has_pcpyud());
}
}
@@ -1475,7 +1475,7 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
} else if (kind == FixedOperatorKind::LOGIOR) {
manip_kind = BitfieldManip::Kind::LOGIOR_WITH_CONSTANT_INT;
} else {
assert(false);
ASSERT(false);
}
BitfieldManip step(manip_kind, m_expr.get_arg(1).get_int());
@@ -1490,7 +1490,7 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
// andi, something else (don't think this can happen?)
std::vector<FormElement*> result;
update_from_stack_copy_first_int_2(env, kind, pool, stack, &result, allow_side_effects);
assert(result.size() == 1);
ASSERT(result.size() == 1);
return result.at(0);
} else {
// and, two forms
@@ -1512,10 +1512,10 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
if (!read_elt) {
read_elt = pool.alloc_element<BitfieldAccessElement>(args.at(0), bitfield_type);
made_new_read_elt = true;
assert(!had_pcpyud);
ASSERT(!had_pcpyud);
} else {
if (had_pcpyud) {
assert(read_elt->has_pcpyud());
ASSERT(read_elt->has_pcpyud());
}
}
@@ -1529,11 +1529,11 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
} else if (kind == FixedOperatorKind::LOGIOR) {
manip_kind = BitfieldManip::Kind::LOGIOR_WITH_CONSTANT_INT;
} else {
assert(false);
ASSERT(false);
}
BitfieldManip step(manip_kind, *arg1_as_int);
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
// assert(!other); // shouldn't be complete.
// ASSERT(!other); // shouldn't be complete.
if (other) {
return other;
} else {
@@ -1546,7 +1546,7 @@ FormElement* SimpleExpressionElement::update_from_stack_logor_or_logand_helper(
} else if (kind == FixedOperatorKind::LOGIOR) {
manip_kind = BitfieldManip::Kind::LOGIOR_WITH_FORM;
} else {
assert(false);
ASSERT(false);
}
auto step = BitfieldManip::from_form(manip_kind, stripped_arg1);
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
@@ -1723,7 +1723,7 @@ void SimpleExpressionElement::update_from_stack_left_shift(const Env& env,
auto read_elt = pool.alloc_element<BitfieldAccessElement>(base, arg0_type);
BitfieldManip step(BitfieldManip::Kind::LEFT_SHIFT, m_expr.get_arg(1).get_int());
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
assert(!other); // shouldn't be complete.
ASSERT(!other); // shouldn't be complete.
result->push_back(read_elt);
} else {
// try to turn this into a multiplication, if possible
@@ -1735,7 +1735,7 @@ void SimpleExpressionElement::update_from_stack_left_shift(const Env& env,
if (as_ba) {
BitfieldManip step(BitfieldManip::Kind::LEFT_SHIFT, m_expr.get_arg(1).get_int());
auto other = as_ba->push_step(step, env.dts->ts, pool, env);
assert(!other); // shouldn't be complete.
ASSERT(!other); // shouldn't be complete.
result->push_back(as_ba);
return;
}
@@ -1788,7 +1788,7 @@ void SimpleExpressionElement::update_from_stack_right_shift_logic(const Env& env
auto read_elt = pool.alloc_element<BitfieldAccessElement>(base, arg0_type);
BitfieldManip step(BitfieldManip::Kind::RIGHT_SHIFT_LOGICAL, m_expr.get_arg(1).get_int());
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
assert(other); // should be a high field.
ASSERT(other); // should be a high field.
result->push_back(other);
} else {
auto arg0_i = is_int_type(env, m_my_idx, m_expr.get_arg(0).var());
@@ -1857,7 +1857,7 @@ void SimpleExpressionElement::update_from_stack_right_shift_arith(const Env& env
auto read_elt = pool.alloc_element<BitfieldAccessElement>(base, arg0_type);
BitfieldManip step(BitfieldManip::Kind::RIGHT_SHIFT_ARITH, m_expr.get_arg(1).get_int());
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
assert(other); // should be a high field.
ASSERT(other); // should be a high field.
result->push_back(other);
} else {
if (m_expr.get_arg(1).is_int()) {
@@ -1888,7 +1888,7 @@ void SimpleExpressionElement::update_from_stack_right_shift_arith(const Env& env
if (as_ba) {
BitfieldManip step(BitfieldManip::Kind::RIGHT_SHIFT_ARITH, m_expr.get_arg(1).get_int());
auto other = as_ba->push_step(step, env.dts->ts, pool, env);
assert(other); // should be a high field.
ASSERT(other); // should be a high field.
result->push_back(other);
return;
}
@@ -2158,9 +2158,9 @@ void SimpleExpressionElement::update_from_stack(const Env& env,
void SetVarElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stack) {
mark_popped();
for (auto x : m_src->elts()) {
assert(x->parent_form == m_src);
ASSERT(x->parent_form == m_src);
}
assert(m_src->parent_element == this);
ASSERT(m_src->parent_element == this);
// hack for method stuff
if (is_dead_set()) {
@@ -2197,7 +2197,7 @@ void SetVarElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta
m_src->update_children_from_stack(env, pool, stack, true);
for (auto x : m_src->elts()) {
assert(x->parent_form == m_src);
ASSERT(x->parent_form == m_src);
}
if (m_src->is_single_element()) {
@@ -2226,13 +2226,13 @@ void SetVarElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta
stack.push_value_to_reg(m_dst, m_src, true, m_src_type, m_var_info);
for (auto x : m_src->elts()) {
assert(x->parent_form == m_src);
ASSERT(x->parent_form == m_src);
}
}
void SetFormFormElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stack) {
assert(m_popped);
assert(m_real_push_count == 0);
ASSERT(m_popped);
ASSERT(m_real_push_count == 0);
m_real_push_count++;
// check for bitfield setting:
@@ -2795,7 +2795,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto mr = match(matcher, unstacked.at(0));
if (mr.matched && nargs >= 1) {
auto vtable_reg = mr.maps.regs.at(0);
assert(vtable_reg);
ASSERT(vtable_reg);
auto vtable_var_name = env.get_variable_name(*vtable_reg);
auto arg0_mr = match(Matcher::any_reg(0), unstacked.at(1));
if (arg0_mr.matched && env.get_variable_name(*arg0_mr.maps.regs.at(0)) == vtable_var_name) {
@@ -2826,7 +2826,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
new_form = pool.alloc_element<GenericElement>(
GenericOperator::make_function(mr.maps.forms.at(1)), arg_forms);
result->push_back(new_form);
assert(!go_next_state);
ASSERT(!go_next_state);
return;
}
}
@@ -2862,7 +2862,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
// if needed, cast to to correct type.
std::vector<TypeSpec> expected_arg_types = {TypeSpec("symbol"), TypeSpec("type"),
TypeSpec("int")};
assert(new_args.size() >= 3);
ASSERT(new_args.size() >= 3);
for (size_t i = 0; i < 3; i++) {
auto& var = all_pop_vars.at(i + 1); // 0 is the function itself.
auto arg_type = env.get_types_before_op(var.idx()).get(var.reg()).typespec();
@@ -2875,7 +2875,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto new_op = pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::OBJECT_NEW), new_args);
result->push_back(new_op);
assert(!go_next_state);
ASSERT(!go_next_state);
return;
}
if (name == "new" && type_1 == "type") {
@@ -2883,7 +2883,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto new_op = pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::TYPE_NEW), new_args);
result->push_back(new_op);
assert(!go_next_state);
ASSERT(!go_next_state);
return;
} else if (name == "new") {
constexpr int allocation = 2;
@@ -2920,7 +2920,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto cons_op = pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::CONS), cons_args);
result->push_back(cons_op);
assert(!go_next_state);
ASSERT(!go_next_state);
return;
} else {
// just normal construction on the heap
@@ -2930,7 +2930,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto new_op = pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::NEW), new_args);
result->push_back(new_op);
assert(!go_next_state);
ASSERT(!go_next_state);
return;
}
}
@@ -3006,7 +3006,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
auto gop = GenericOperator::make_function(method_op);
result->push_back(pool.alloc_element<GenericElement>(gop, arg_forms));
assert(!go_next_state);
ASSERT(!go_next_state);
return;
}
@@ -3044,7 +3044,7 @@ void FunctionCallElement::update_from_stack(const Env& env,
}
result->push_back(pool.alloc_element<GenericElement>(
GenericOperator::make_fixed(FixedOperatorKind::NEW), stack_new_args));
assert(!go_next_state);
ASSERT(!go_next_state);
return;
}
}
@@ -3130,7 +3130,7 @@ void UntilElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stac
}
condition_to_body = condition_temp_stack.rewrite(pool, env);
condition->clear();
assert(!condition_to_body.empty());
ASSERT(!condition_to_body.empty());
condition->push_back(condition_to_body.back());
condition_to_body.pop_back();
}
@@ -3484,7 +3484,7 @@ void CondWithElseElement::push_to_stack(const Env& env, FormPool& pool, FormStac
// update register info
if (rewrite_as_set && !set_unused) {
// might not be the same if a set is eliminated by a coloring move.
// assert(dest_sets.size() == write_output_forms.size());
// ASSERT(dest_sets.size() == write_output_forms.size());
if (!dest_sets.empty()) {
for (size_t i = 0; i < dest_sets.size() - 1; i++) {
auto var = dest_sets.at(i)->dst();
@@ -3633,7 +3633,7 @@ void ShortCircuitElement::push_to_stack(const Env& env, FormPool& pool, FormStac
to_push = as_handle_get;
}
assert(used_as_value.has_value());
ASSERT(used_as_value.has_value());
stack.push_value_to_reg(final_result, pool.alloc_single_form(nullptr, to_push), true,
env.get_variable_type(final_result, false));
already_rewritten = true;
@@ -3739,7 +3739,7 @@ FormElement* ConditionElement::make_zero_check_generic(const Env& env,
const std::vector<Form*>& source_forms,
const std::vector<TypeSpec>& source_types) {
// (zero? (+ thing small-integer)) -> (= thing (- small-integer))
assert(source_forms.size() == 1);
ASSERT(source_forms.size() == 1);
auto enum_type_info = env.dts->ts.try_enum_lookup(source_types.at(0));
if (enum_type_info && !enum_type_info->is_bitfield()) {
@@ -3863,7 +3863,7 @@ FormElement* ConditionElement::make_nonzero_check_generic(const Env& env,
const std::vector<TypeSpec>&) {
// for (nonzero? (-> obj bitfield))
FormElement* bitfield_compare = nullptr;
assert(source_forms.size() == 1);
ASSERT(source_forms.size() == 1);
auto as_bitfield_op =
dynamic_cast<BitfieldAccessElement*>(source_forms.at(0)->try_as_single_element());
if (as_bitfield_op) {
@@ -3903,7 +3903,7 @@ FormElement* ConditionElement::make_equal_check_generic(const Env& env,
FormPool& pool,
const std::vector<Form*>& source_forms,
const std::vector<TypeSpec>& source_types) {
assert(source_forms.size() == 2);
ASSERT(source_forms.size() == 2);
// (= thing '())
auto ref = source_forms.at(1);
auto ref_atom = form_as_atom(ref);
@@ -3932,7 +3932,7 @@ FormElement* ConditionElement::make_not_equal_check_generic(
FormPool& pool,
const std::vector<Form*>& source_forms,
const std::vector<TypeSpec>& source_types) {
assert(source_forms.size() == 2);
ASSERT(source_forms.size() == 2);
// (!= thing '())
auto ref = source_forms.at(1);
auto ref_atom = form_as_atom(ref);
@@ -3963,7 +3963,7 @@ FormElement* ConditionElement::make_less_than_zero_signed_check_generic(
FormPool& pool,
const std::vector<Form*>& source_forms,
const std::vector<TypeSpec>& types) {
assert(source_forms.size() == 1);
ASSERT(source_forms.size() == 1);
// (< (shl (the-as int iter) 62) 0) -> (pair? iter)
// match (shl [(the-as int [x]) | [x]] 62)
@@ -3994,7 +3994,7 @@ FormElement* ConditionElement::make_geq_zero_signed_check_generic(
FormPool& pool,
const std::vector<Form*>& source_forms,
const std::vector<TypeSpec>& types) {
assert(source_forms.size() == 1);
ASSERT(source_forms.size() == 1);
// (>= (shl (the-as int iter) 62) 0) -> (not (pair? iter))
// match (shl [(the-as int [x]) | [x]] 62)
@@ -4028,7 +4028,7 @@ FormElement* ConditionElement::make_geq_zero_unsigned_check_generic(
FormPool& pool,
const std::vector<Form*>& source_forms,
const std::vector<TypeSpec>& types) {
assert(source_forms.size() == 1);
ASSERT(source_forms.size() == 1);
// (>= (shl (the-as int iter) 62) 0) -> (not (pair? iter))
// match (shl [(the-as int [x]) | [x]] 62)
@@ -4226,8 +4226,8 @@ void ConditionElement::push_to_stack(const Env& env, FormPool& pool, FormStack&
source_forms.push_back(pool.alloc_single_element_form<SimpleAtomElement>(nullptr, *m_src[i]));
}
}
assert(popped_counter == int(popped_forms.size()));
assert(source_forms.size() == source_types.size());
ASSERT(popped_counter == int(popped_forms.size()));
ASSERT(source_forms.size() == source_types.size());
stack.push_form_element(make_generic(env, pool, source_forms, source_types), true);
}
@@ -4279,8 +4279,8 @@ void ConditionElement::update_from_stack(const Env& env,
source_forms.push_back(pool.alloc_single_element_form<SimpleAtomElement>(nullptr, *m_src[i]));
}
}
assert(popped_counter == int(popped_forms.size()));
assert(source_forms.size() == source_types.size());
ASSERT(popped_counter == int(popped_forms.size()));
ASSERT(source_forms.size() == source_types.size());
result->push_back(make_generic(env, pool, source_forms, source_types));
}
@@ -4296,7 +4296,7 @@ void ReturnElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta
std::optional<RegisterAccess> var;
new_entries = rewrite_to_get_var(temp_stack, pool, env.end_var(), env, &var);
assert(!new_entries.empty());
ASSERT(!new_entries.empty());
return_code->clear();
@@ -4333,13 +4333,13 @@ void push_asm_srl_to_stack(const AsmOp* op,
FormStack& stack) {
// we will try to convert this into a bitfield operation. If this fails, fall back to assembly.
auto var = op->src(0);
assert(var.has_value()); // srl should always have this.
ASSERT(var.has_value()); // srl should always have this.
auto dst = op->dst();
assert(dst.has_value());
ASSERT(dst.has_value());
auto integer_atom = op->instruction().get_src(1);
assert(integer_atom.is_imm());
ASSERT(integer_atom.is_imm());
auto integer = integer_atom.get_imm();
auto arg0_type = env.get_variable_type(*var, true);
@@ -4350,7 +4350,7 @@ void push_asm_srl_to_stack(const AsmOp* op,
auto read_elt = pool.alloc_element<BitfieldAccessElement>(base, arg0_type);
BitfieldManip step(BitfieldManip::Kind::RIGHT_SHIFT_LOGICAL_32BIT, integer);
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
assert(other); // should be a high field.
ASSERT(other); // should be a high field.
stack.push_value_to_reg(*dst, pool.alloc_single_form(nullptr, other), true,
env.get_variable_type(*dst, true));
} else {
@@ -4360,7 +4360,7 @@ void push_asm_srl_to_stack(const AsmOp* op,
if (as_ba) {
BitfieldManip step(BitfieldManip::Kind::RIGHT_SHIFT_LOGICAL_32BIT, integer);
auto other = as_ba->push_step(step, env.dts->ts, pool, env);
assert(other); // should immediately get a field.
ASSERT(other); // should immediately get a field.
stack.push_value_to_reg(*dst, pool.alloc_single_form(nullptr, other), true,
env.get_variable_type(*dst, true));
} else {
@@ -4377,10 +4377,10 @@ void push_asm_sllv_to_stack(const AsmOp* op,
FormPool& pool,
FormStack& stack) {
auto var = op->src(0);
assert(var.has_value());
ASSERT(var.has_value());
auto dst = op->dst();
assert(dst.has_value());
ASSERT(dst.has_value());
auto arg0_type = env.get_variable_type(*var, true);
auto type_info = env.dts->ts.lookup_type(arg0_type);
@@ -4391,7 +4391,7 @@ void push_asm_sllv_to_stack(const AsmOp* op,
auto read_elt = pool.alloc_element<BitfieldAccessElement>(base, arg0_type);
BitfieldManip step(BitfieldManip::Kind::SLLV_SEXT, 0);
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
assert(other); // should immediately get a field.
ASSERT(other); // should immediately get a field.
stack.push_value_to_reg(*dst, pool.alloc_single_form(nullptr, other), true,
env.get_variable_type(*dst, true));
} else {
@@ -4401,7 +4401,7 @@ void push_asm_sllv_to_stack(const AsmOp* op,
// part of existing chain.
BitfieldManip step(BitfieldManip::Kind::SLLV_SEXT, 0);
auto other = as_ba->push_step(step, env.dts->ts, pool, env);
assert(other); // should immediately get a field.
ASSERT(other); // should immediately get a field.
stack.push_value_to_reg(*dst, pool.alloc_single_form(nullptr, other), true,
env.get_variable_type(*dst, true));
} else {
@@ -4427,13 +4427,13 @@ void push_asm_pcpyud_to_stack(const AsmOp* op,
// pcpyud v1, gp, r0 for example.
auto var = op->src(0);
assert(var.has_value());
ASSERT(var.has_value());
auto dst = op->dst();
assert(dst.has_value());
ASSERT(dst.has_value());
auto possible_r0 = op->src(1);
assert(possible_r0.has_value());
ASSERT(possible_r0.has_value());
auto arg0_type = env.get_variable_type(*var, true);
auto type_info = env.dts->ts.lookup_type(arg0_type);
@@ -4457,13 +4457,13 @@ void push_asm_pextuw_to_stack(const AsmOp* op,
// (.pextuw t0-0 r0-0 obj)
auto var = op->src(1);
assert(var.has_value());
ASSERT(var.has_value());
auto dst = op->dst();
assert(dst.has_value());
ASSERT(dst.has_value());
auto possible_r0 = op->src(0);
assert(possible_r0.has_value());
ASSERT(possible_r0.has_value());
auto arg0_type = env.get_variable_type(*var, true);
auto type_info = env.dts->ts.lookup_type(arg0_type);
@@ -4473,7 +4473,7 @@ void push_asm_pextuw_to_stack(const AsmOp* op,
auto read_elt = pool.alloc_element<BitfieldAccessElement>(base, arg0_type);
BitfieldManip step(BitfieldManip::Kind::PEXTUW, 0);
auto other = read_elt->push_step(step, env.dts->ts, pool, env);
assert(other); // should immediately get a field.
ASSERT(other); // should immediately get a field.
stack.push_value_to_reg(*dst, pool.alloc_single_form(nullptr, other), true,
env.get_variable_type(*dst, true));
} else {
@@ -4488,13 +4488,13 @@ void push_asm_madds_to_stack(const AsmOp* op,
FormPool& pool,
FormStack& stack) {
auto src0 = op->src(0);
assert(src0.has_value());
ASSERT(src0.has_value());
auto src1 = op->src(1);
assert(src1.has_value());
ASSERT(src1.has_value());
auto dst = op->dst();
assert(dst.has_value());
ASSERT(dst.has_value());
auto vars = pop_to_forms({*src0, *src1}, env, pool, stack, true);
@@ -4566,7 +4566,7 @@ void AtomicOpElement::push_to_stack(const Env& env, FormPool& pool, FormStack& s
if (as_branch && !as_branch->is_likely()) {
// this is a bit of a hack, but we go AsmBranchOp -> AsmBranchElement -> TranslatedAsmBranch
auto delay = as_branch->branch_delay();
assert(delay);
ASSERT(delay);
// this might not be enough - we may need to back up to the cfg builder and do something there.
auto del = pool.alloc_single_element_form<AtomicOpElement>(nullptr, delay);
auto be = pool.alloc_element<AsmBranchElement>(as_branch, del, false);
@@ -4677,7 +4677,7 @@ void BranchElement::push_to_stack(const Env& env, FormPool& pool, FormStack& sta
m_op->to_string(env));
}
assert(!m_op->likely());
ASSERT(!m_op->likely());
auto op = pool.alloc_element<TranslatedAsmBranch>(branch_condition, branch_delay,
m_op->label_id(), m_op->likely());
// fmt::print("rewrote (non-asm) as {}\n", op->to_string(env));
@@ -4720,7 +4720,7 @@ void DynamicMethodAccess::update_from_stack(const Env& env,
auto idx = match_result.maps.regs.at(0);
auto base = match_result.maps.regs.at(1);
assert(idx.has_value() && base.has_value());
ASSERT(idx.has_value() && base.has_value());
auto deref = pool.alloc_element<DerefElement>(
var_to_form(base.value(), pool), false,
@@ -4761,7 +4761,7 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
}
auto idx = match_result.maps.forms.at(1);
auto base = match_result.maps.forms.at(0);
assert(idx && base);
ASSERT(idx && base);
if (m_flipped) {
std::swap(idx, base);
@@ -4810,7 +4810,7 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
auto idx = match_result.maps.forms.at(1);
auto base = match_result.maps.forms.at(0);
assert(idx && base);
ASSERT(idx && base);
std::vector<DerefToken> tokens = m_deref_tokens;
for (auto& x : tokens) {
@@ -4847,7 +4847,7 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
auto base = strip_int_or_uint_cast(mr.maps.forms.at(1));
auto idx = mr.maps.forms.at(0);
assert(idx && base);
ASSERT(idx && base);
std::vector<DerefToken> tokens = m_deref_tokens;
for (auto& x : tokens) {
@@ -4877,7 +4877,7 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
}
auto idx = match_result.maps.forms.at(0);
auto base = match_result.maps.forms.at(1);
assert(idx && base);
ASSERT(idx && base);
std::vector<DerefToken> tokens = m_deref_tokens;
for (auto& x : tokens) {
@@ -4918,7 +4918,7 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
idx = match_result.maps.forms.at(0);
base = match_result.maps.forms.at(1);
assert(idx && base);
ASSERT(idx && base);
std::vector<DerefToken> tokens = m_deref_tokens;
for (auto& x : tokens) {
@@ -4957,7 +4957,7 @@ void ArrayFieldAccess::update_with_val(Form* new_val,
auto base = strip_int_or_uint_cast(mr.maps.forms.at(1));
auto idx = mr.maps.forms.at(0);
assert(idx && base);
ASSERT(idx && base);
std::vector<DerefToken> tokens = m_deref_tokens;
for (auto& x : tokens) {
@@ -5445,7 +5445,7 @@ void BreakElement::push_to_stack(const Env& env, FormPool& pool, FormStack& stac
std::vector<FormElement*> new_entries;
new_entries = temp_stack.rewrite(pool, env);
assert(!new_entries.empty());
ASSERT(!new_entries.empty());
return_code->clear();
for (int i = 0; i < ((int)new_entries.size()); i++) {
+13 -13
View File
@@ -8,7 +8,7 @@
namespace decompiler {
std::string FormStack::StackEntry::print(const Env& env) const {
if (destination.has_value()) {
assert(source && !elt);
ASSERT(source && !elt);
if (active) {
return fmt::format("d: {} s: {} | {} <- {} f: {} w: {}", active, sequence_point,
destination.value().reg().to_charp(), source->to_string(env),
@@ -20,7 +20,7 @@ std::string FormStack::StackEntry::print(const Env& env) const {
}
} else {
assert(elt && !source);
ASSERT(elt && !source);
if (active) {
return fmt::format("d: {} s: {} | {} f: {}", active, sequence_point, elt->to_string(env),
non_seq_source.has_value());
@@ -45,7 +45,7 @@ void FormStack::push_value_to_reg(RegisterAccess var,
bool sequence_point,
TypeSpec type,
const SetVarInfo& info) {
assert(value);
ASSERT(value);
StackEntry entry;
entry.active = true; // by default, we should display everything!
entry.sequence_point = sequence_point;
@@ -61,7 +61,7 @@ void FormStack::push_value_to_reg_dead(RegisterAccess var,
bool sequence_point,
TypeSpec type,
const SetVarInfo& info) {
assert(value);
ASSERT(value);
StackEntry entry;
entry.active = false;
entry.sequence_point = sequence_point;
@@ -77,7 +77,7 @@ void FormStack::push_non_seq_reg_to_reg(const RegisterAccess& dst,
Form* src_as_form,
TypeSpec type,
const SetVarInfo& info) {
assert(src_as_form);
ASSERT(src_as_form);
StackEntry entry;
entry.active = true;
entry.sequence_point = false;
@@ -137,7 +137,7 @@ Form* FormStack::pop_reg(Register reg,
if (found_orig_out) {
*found_orig_out = false;
}
assert(allow_side_effects);
ASSERT(allow_side_effects);
(void)env; // keep this for easy debugging.
RegSet modified;
size_t begin = m_stack.size();
@@ -158,9 +158,9 @@ Form* FormStack::pop_reg(Register reg,
return nullptr;
}
entry.active = false;
assert(entry.source);
ASSERT(entry.source);
if (entry.non_seq_source.has_value()) {
assert(entry.sequence_point == false);
ASSERT(entry.sequence_point == false);
auto result = pop_reg(entry.non_seq_source->reg(), barrier, env, allow_side_effects, i);
if (result) {
if (found_orig_out) {
@@ -184,14 +184,14 @@ Form* FormStack::pop_reg(Register reg,
}
// no match, and not a sequence:
if (entry.source) {
assert(!entry.elt);
ASSERT(!entry.elt);
entry.source->get_modified_regs(modified);
if (!allow_side_effects) {
// shouldn't allow skipping past a set! (may be too conservative?)
return nullptr;
}
} else {
assert(entry.elt);
ASSERT(entry.elt);
entry.elt->get_modified_regs(modified);
if (!allow_side_effects && entry.elt->has_side_effects()) {
// shouldn't allow skipping past something with a set! (also may be too conservative?)
@@ -211,12 +211,12 @@ Form* FormStack::pop_reg(Register reg,
FormElement* FormStack::pop_back(FormPool& pool) {
auto& back = m_stack.back();
assert(back.active);
ASSERT(back.active);
back.active = false;
if (back.elt) {
return back.elt;
} else {
assert(back.destination.has_value());
ASSERT(back.destination.has_value());
auto elt = pool.alloc_element<SetVarElement>(*back.destination, back.source,
back.sequence_point, back.set_type, back.set_info);
back.source->parent_element = elt;
@@ -234,7 +234,7 @@ bool is_op_in_place(SetVarElement* elt,
auto result = match(matcher, elt->src());
if (result.matched) {
auto first = result.maps.regs.at(0);
assert(first.has_value());
ASSERT(first.has_value());
if (first->reg() != elt->dst().reg()) {
return false;
+4 -4
View File
@@ -83,12 +83,12 @@ class FormStack {
if (!my_entry.destination) {
return {};
}
assert(my_entry.source && !my_entry.elt);
ASSERT(my_entry.source && !my_entry.elt);
} else {
if (my_entry.destination) {
return {};
}
assert(my_entry.elt && !my_entry.source);
ASSERT(my_entry.elt && !my_entry.source);
}
entries.push_back(my_entry);
} else {
@@ -100,7 +100,7 @@ class FormStack {
void pop(int count) {
for (int i = 0; i < count; i++) {
assert(!m_stack.empty());
ASSERT(!m_stack.empty());
m_stack.pop_back();
}
}
@@ -125,7 +125,7 @@ class FormStack {
return;
}
}
assert(false);
ASSERT(false);
}
int size() const { return m_stack.size(); }
+3 -3
View File
@@ -594,7 +594,7 @@ bool Matcher::do_match(Form* input, MatchResult::Maps* maps_out) const {
}
default:
assert(false);
ASSERT(false);
return false;
}
}
@@ -661,7 +661,7 @@ bool DerefTokenMatcher::do_match(const DerefToken& input, MatchResult::Maps* map
}
return false;
default:
assert(false);
ASSERT(false);
return false;
}
}
@@ -719,7 +719,7 @@ bool GenericOpMatcher::do_match(GenericOperator& input, MatchResult::Maps* maps_
}
return false;
default:
assert(false);
ASSERT(false);
return false;
}
}
+2 -2
View File
@@ -264,13 +264,13 @@ struct VariableNames {
std::unordered_map<RegId, UseDefInfo, RegId::hash> use_def_info;
void disable_use(const RegisterAccess& access) {
assert(access.mode() == AccessMode::READ);
ASSERT(access.mode() == AccessMode::READ);
auto var_id = read_opid_to_varid.at(access.reg()).at(access.idx());
use_def_info.at(RegId(access.reg(), var_id)).disable_use(access.idx(), access.reg());
}
void disable_def(const RegisterAccess& access, DecompWarnings& warnings) {
assert(access.mode() == AccessMode::WRITE);
ASSERT(access.mode() == AccessMode::WRITE);
auto var_id = write_opid_to_varid.at(access.reg()).at(access.idx());
use_def_info.at(RegId(access.reg(), var_id)).disable_def(access.idx(), warnings);
}
+2 -2
View File
@@ -47,12 +47,12 @@ LabelDB::LabelDB(const std::unordered_map<std::string, LabelConfigInfo>& config,
m_labels_by_offset_into_seg.at(existing_info.target_segment)[existing_info.offset] = (int)i;
}
assert(m_labels_by_name.size() == labels.size());
ASSERT(m_labels_by_name.size() == labels.size());
size_t total_from_offsets = 0;
for (int i = 0; i < N_SEG; i++) {
total_from_offsets += m_labels_by_offset_into_seg[i].size();
}
assert(total_from_offsets == labels.size());
ASSERT(total_from_offsets == labels.size());
// now config
for (const auto& config_it : config) {
+1 -1
View File
@@ -216,7 +216,7 @@ std::vector<goos::Object> OpenGOALAsm::get_args(const std::vector<DecompilerLabe
named_args.push_back(
pretty_print::to_symbol(fmt::format(":ftf #b{:b}", atom.get_vf_field())));
} else {
assert(false);
ASSERT(false);
}
} else if (func.allows_modifier(MOD::OFFSET) && atom.kind == InstructionAtom::AtomKind::IMM) {
// Handle offsetting
+1 -1
View File
@@ -10,7 +10,7 @@
#include "decompiler/IR2/IR2_common.h"
#include "Env.h"
#include "AtomicOp.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
+19 -19
View File
@@ -356,7 +356,7 @@ void BitfieldAccessElement::push_pcpyud(const TypeSystem& ts, FormPool& pool, co
// look for a 64-bit field
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = try_find_field(ts, as_bitfield, 64, 64, true);
if (field) {
auto result =
@@ -395,7 +395,7 @@ std::optional<BitField> BitfieldAccessElement::get_set_field_0(const TypeSystem&
u64 mask = step.amount;
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
// use the mask to figure out the field.
auto field = find_field_from_mask(ts, as_bitfield, ~mask, m_got_pcpyud);
if (field) {
@@ -429,7 +429,7 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
int start_bit = pcpyud_offset + shift_size - size;
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field(ts, as_bitfield, start_bit, size, is_unsigned);
auto result =
pool.alloc_element<DerefElement>(m_base, false, DerefToken::make_field_name(field.name()));
@@ -443,7 +443,7 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
int start_bit = 0 + pcpyud_offset;
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field(ts, as_bitfield, start_bit, size, is_unsigned);
auto result =
pool.alloc_element<DerefElement>(m_base, false, DerefToken::make_field_name(field.name()));
@@ -460,7 +460,7 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
int start_bit = 64;
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field(ts, as_bitfield, start_bit, size, is_unsigned);
auto result =
pool.alloc_element<DerefElement>(m_base, false, DerefToken::make_field_name(field.name()));
@@ -484,7 +484,7 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field(ts, as_bitfield, start_bit, size, is_unsigned);
auto result =
pool.alloc_element<DerefElement>(m_base, false, DerefToken::make_field_name(field.name()));
@@ -506,7 +506,7 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
}
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field_from_mask(ts, as_bitfield, m_steps.at(0).amount, false); // todo PCPYUP
if (field) {
auto get_field = pool.alloc_element<DerefElement>(m_base, false,
@@ -530,10 +530,10 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
}
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
// use the mask to figure out the field.
auto field = find_field_from_mask(ts, as_bitfield, ~mask, m_got_pcpyud);
assert(field);
ASSERT(field);
bool is_signed =
ts.tc(TypeSpec("int"), field->type()) && !ts.tc(TypeSpec("uint"), field->type());
@@ -564,9 +564,9 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
u64 value = step.amount;
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
auto field = find_field_from_mask(ts, as_bitfield, value, m_got_pcpyud);
assert(field);
ASSERT(field);
bool is_signed =
ts.tc(TypeSpec("int"), field->type()) && !ts.tc(TypeSpec("uint"), field->type());
@@ -593,10 +593,10 @@ FormElement* BitfieldAccessElement::push_step(const BitfieldManip step,
auto type = ts.lookup_type(m_type);
auto as_bitfield = dynamic_cast<BitFieldType*>(type);
assert(as_bitfield);
ASSERT(as_bitfield);
// use the mask to figure out the field.
auto field = find_field_from_mask(ts, as_bitfield, ~mask, m_got_pcpyud);
assert(field);
ASSERT(field);
auto val = get_bitfield_initial_set(step.value, as_bitfield, ts, pcpyud_offset);
@@ -634,7 +634,7 @@ std::vector<Form*> compact_nested_logiors(GenericElement* input, const Env&) {
GenericElement* next = input;
while (next) {
assert(next->elts().size() == 2);
ASSERT(next->elts().size() == 2);
result.push_back(next->elts().at(1));
auto next_next = strip_int_or_uint_cast(next->elts().at(0));
next = next_next->try_as_element<GenericElement>();
@@ -808,7 +808,7 @@ std::optional<std::vector<BitFieldDef>> get_field_defs_from_expr(const BitFieldT
BitField field_info;
if (!type_info->lookup_field(maybe_field->field_name, &field_info)) {
assert(false);
ASSERT(false);
}
if (field_info.type() == TypeSpec("symbol") || field_info.type() == TypeSpec("type")) {
maybe_field->value = strip_int_or_uint_cast(maybe_field->value);
@@ -913,7 +913,7 @@ Form* cast_to_bitfield_enum(const EnumType* type_info,
FormPool& pool,
const Env& env,
Form* in) {
assert(type_info->is_bitfield());
ASSERT(type_info->is_bitfield());
auto integer = get_goal_integer_constant(strip_int_or_uint_cast(in), env);
if (integer) {
return cast_to_bitfield_enum(type_info, pool, env, *integer);
@@ -928,7 +928,7 @@ Form* cast_to_int_enum(const EnumType* type_info,
FormPool& pool,
const Env& env,
Form* in) {
assert(!type_info->is_bitfield());
ASSERT(!type_info->is_bitfield());
auto integer = get_goal_integer_constant(strip_int_or_uint_cast(in), env);
if (integer) {
return cast_to_int_enum(type_info, pool, env, *integer);
@@ -939,7 +939,7 @@ Form* cast_to_int_enum(const EnumType* type_info,
}
Form* cast_to_int_enum(const EnumType* type_info, FormPool& pool, const Env& env, s64 in) {
assert(!type_info->is_bitfield());
ASSERT(!type_info->is_bitfield());
auto entry = decompile_int_enum_from_int(TypeSpec(type_info->get_name()), env.dts->ts, in);
auto oper = GenericOperator::make_function(
pool.alloc_single_element_form<ConstantTokenElement>(nullptr, type_info->get_name()));
@@ -948,7 +948,7 @@ Form* cast_to_int_enum(const EnumType* type_info, FormPool& pool, const Env& env
}
Form* cast_to_bitfield_enum(const EnumType* type_info, FormPool& pool, const Env& env, s64 in) {
assert(type_info->is_bitfield());
ASSERT(type_info->is_bitfield());
auto elts = decompile_bitfield_enum_from_int(TypeSpec(type_info->get_name()), env.dts->ts, in);
auto oper = GenericOperator::make_function(
pool.alloc_single_element_form<ConstantTokenElement>(nullptr, type_info->get_name()));
+4 -4
View File
@@ -3,7 +3,7 @@
#include "common/common_types.h"
#include "decompiler/IR2/Form.h"
#include "decompiler/util/data_decompile.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
struct BitfieldManip {
@@ -30,7 +30,7 @@ struct BitfieldManip {
}
bool right_shift_unsigned() const {
assert(is_right_shift());
ASSERT(is_right_shift());
return kind == Kind::RIGHT_SHIFT_LOGICAL || kind == Kind::RIGHT_SHIFT_LOGICAL_32BIT;
}
@@ -79,7 +79,7 @@ struct BitfieldManip {
return "pextuw";
case Kind::INVALID:
default:
assert(false);
ASSERT(false);
}
}
@@ -173,7 +173,7 @@ class ModifiedCopyBitfieldElement : public FormElement {
const std::vector<BitFieldDef> mods() const { return m_field_modifications; }
bool from_pcpyud() const { return m_from_pcpyud; }
void clear_pcpyud_flag() {
assert(m_from_pcpyud);
ASSERT(m_from_pcpyud);
m_from_pcpyud = false;
}
+42 -42
View File
@@ -14,7 +14,7 @@
#include "third-party/json.hpp"
#include "common/log/log.h"
#include "common/goos/PrettyPrinter.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/*!
@@ -22,7 +22,7 @@ namespace decompiler {
* This can only be done once, and must be done before adding any words.
*/
void LinkedObjectFile::set_segment_count(int n_segs) {
assert(segments == 0);
ASSERT(segments == 0);
segments = n_segs;
words_by_seg.resize(n_segs);
label_per_seg_by_offset.resize(n_segs);
@@ -56,8 +56,8 @@ int LinkedObjectFile::get_label_id_for(int seg, int offset) {
} else {
// return an existing label
auto& label = labels.at(kv->second);
assert(label.offset == offset);
assert(label.target_segment == seg);
ASSERT(label.offset == offset);
ASSERT(label.target_segment == seg);
return kv->second;
}
}
@@ -96,7 +96,7 @@ Function& LinkedObjectFile::get_function_at_label(int label_id) {
}
}
assert(false);
ASSERT(false);
return functions_by_seg.front().front(); // to avoid error
}
@@ -147,16 +147,16 @@ bool LinkedObjectFile::pointer_link_word(int source_segment,
int source_offset,
int dest_segment,
int dest_offset) {
assert((source_offset % 4) == 0);
ASSERT((source_offset % 4) == 0);
auto& word = words_by_seg.at(source_segment).at(source_offset / 4);
assert(word.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word.kind() == LinkedWord::PLAIN_DATA);
if (dest_offset / 4 > (int)words_by_seg.at(dest_segment).size()) {
// printf("HACK bad link ignored!\n");
return false;
}
assert(dest_offset / 4 <= (int)words_by_seg.at(dest_segment).size());
ASSERT(dest_offset / 4 <= (int)words_by_seg.at(dest_segment).size());
word.set_to_pointer(LinkedWord::PTR, get_label_id_for(dest_segment, dest_offset));
return true;
@@ -169,9 +169,9 @@ void LinkedObjectFile::symbol_link_word(int source_segment,
int source_offset,
const char* name,
LinkedWord::Kind kind) {
assert((source_offset % 4) == 0);
ASSERT((source_offset % 4) == 0);
auto& word = words_by_seg.at(source_segment).at(source_offset / 4);
// assert(word.kind == LinkedWord::PLAIN_DATA);
// ASSERT(word.kind == LinkedWord::PLAIN_DATA);
if (word.kind() != LinkedWord::PLAIN_DATA) {
printf("bad symbol link word\n");
}
@@ -183,9 +183,9 @@ void LinkedObjectFile::symbol_link_word(int source_segment,
* the symbol table register.
*/
void LinkedObjectFile::symbol_link_offset(int source_segment, int source_offset, const char* name) {
assert((source_offset % 4) == 0);
ASSERT((source_offset % 4) == 0);
auto& word = words_by_seg.at(source_segment).at(source_offset / 4);
assert(word.kind() == LinkedWord::PLAIN_DATA);
ASSERT(word.kind() == LinkedWord::PLAIN_DATA);
word.set_to_symbol(LinkedWord::SYM_OFFSET, name);
}
@@ -197,15 +197,15 @@ void LinkedObjectFile::pointer_link_split_word(int source_segment,
int source_lo_offset,
int dest_segment,
int dest_offset) {
assert((source_hi_offset % 4) == 0);
assert((source_lo_offset % 4) == 0);
ASSERT((source_hi_offset % 4) == 0);
ASSERT((source_lo_offset % 4) == 0);
auto& hi_word = words_by_seg.at(source_segment).at(source_hi_offset / 4);
auto& lo_word = words_by_seg.at(source_segment).at(source_lo_offset / 4);
// assert(dest_offset / 4 <= (int)words_by_seg.at(dest_segment).size());
assert(hi_word.kind() == LinkedWord::PLAIN_DATA);
assert(lo_word.kind() == LinkedWord::PLAIN_DATA);
// ASSERT(dest_offset / 4 <= (int)words_by_seg.at(dest_segment).size());
ASSERT(hi_word.kind() == LinkedWord::PLAIN_DATA);
ASSERT(lo_word.kind() == LinkedWord::PLAIN_DATA);
hi_word.set_to_pointer(LinkedWord::HI_PTR, get_label_id_for(dest_segment, dest_offset));
lo_word.set_to_pointer(LinkedWord::LO_PTR, hi_word.label_id());
@@ -244,7 +244,7 @@ static const char* segment_names[] = {"main segment", "debug segment", "top-leve
std::string LinkedObjectFile::print_words() {
std::string result;
assert(segments <= 3);
ASSERT(segments <= 3);
for (int seg = segments; seg-- > 0;) {
// segment header
result += ";------------------------------------------\n; ";
@@ -321,7 +321,7 @@ void LinkedObjectFile::find_code() {
auto& seg = words_by_seg.front();
for (auto& word : seg) {
if (word.kind() == LinkedWord::TYPE_PTR) {
assert(word.symbol_name() != "function");
ASSERT(word.symbol_name() != "function");
}
}
offset_of_data_zone_by_seg.at(0) = 0;
@@ -361,8 +361,8 @@ void LinkedObjectFile::find_code() {
}
}
assert(found_jr_ra);
assert(jr_ra_loc + 1 < words_by_seg.at(i).size());
ASSERT(found_jr_ra);
ASSERT(jr_ra_loc + 1 < words_by_seg.at(i).size());
offset_of_data_zone_by_seg.at(i) = jr_ra_loc + 2;
} else {
@@ -380,7 +380,7 @@ void LinkedObjectFile::find_code() {
for (size_t j = offset_of_data_zone_by_seg.at(i); j < words_by_seg.at(i).size(); j++) {
auto& word = words_by_seg.at(i).at(j);
if (word.kind() == LinkedWord::TYPE_PTR && word.symbol_name() == "function") {
assert(false);
ASSERT(false);
}
}
@@ -390,7 +390,7 @@ void LinkedObjectFile::find_code() {
}
} else {
// for files which we couldn't extract link data yet, they will have 0 segments and its ok.
assert(segments == 0);
ASSERT(segments == 0);
}
}
@@ -400,7 +400,7 @@ void LinkedObjectFile::find_code() {
void LinkedObjectFile::find_functions() {
if (segments == 1) {
// it's a v2 file, shouldn't have any functions
assert(offset_of_data_zone_by_seg.at(0) == 0);
ASSERT(offset_of_data_zone_by_seg.at(0) == 0);
} else {
// we assume functions don't have any data in between them, so we use the "function" type tag to
// mark the end of the previous function and the start of the next. This means that some
@@ -422,7 +422,7 @@ void LinkedObjectFile::find_functions() {
}
// mark this as a function, and try again from the current function start
assert(found_function_tag_loc);
ASSERT(found_function_tag_loc);
stats.function_count++;
functions_by_seg.at(seg).emplace_back(function_tag_loc, function_end);
function_end = function_tag_loc;
@@ -506,21 +506,21 @@ void LinkedObjectFile::process_fp_relative_links() {
// other cases. Also, the position of the fp register is swapped between the two.
case InstructionKind::DADDU:
case InstructionKind::ADDU: {
assert(prev_instr);
ASSERT(prev_instr);
if (prev_instr->kind != InstructionKind::ORI) {
lg::error("Failed to process fp relative links for (d)addu preceded by: {}",
prev_instr->to_string(labels));
return;
}
assert(prev_instr->kind == InstructionKind::ORI);
ASSERT(prev_instr->kind == InstructionKind::ORI);
int offset_reg_src_id = instr.kind == InstructionKind::DADDU ? 0 : 1;
auto offset_reg = instr.get_src(offset_reg_src_id).get_reg();
assert(offset_reg == prev_instr->get_dst(0).get_reg());
assert(offset_reg == prev_instr->get_src(0).get_reg());
ASSERT(offset_reg == prev_instr->get_dst(0).get_reg());
ASSERT(offset_reg == prev_instr->get_src(0).get_reg());
auto& atom = prev_instr->get_imm_src();
int additional_offset = 0;
if (pprev_instr && pprev_instr->kind == InstructionKind::LUI) {
assert(pprev_instr->get_dst(0).get_reg() == offset_reg);
ASSERT(pprev_instr->get_dst(0).get_reg() == offset_reg);
additional_offset = (1 << 16) * pprev_instr->get_imm_src().get_imm();
pprev_instr->get_imm_src().set_label(
get_label_id_for(seg, current_fp + atom.get_imm() + additional_offset));
@@ -532,7 +532,7 @@ void LinkedObjectFile::process_fp_relative_links() {
default:
printf("unknown fp using op: %s\n", instr.to_string(labels).c_str());
assert(false);
ASSERT(false);
}
}
}
@@ -564,11 +564,11 @@ std::string LinkedObjectFile::print_function_disassembly(Function& func,
}
for (int j = 1; j < 4; j++) {
// assert(get_label_at(seg, (func.start_word + i)*4 + j) == -1);
// ASSERT(get_label_at(seg, (func.start_word + i)*4 + j) == -1);
if (get_label_at(seg, (func.start_word + i) * 4 + j) != -1) {
result += "BAD OFFSET LABEL: ";
result += labels.at(get_label_at(seg, (func.start_word + i) * 4 + j)).name + "\n";
assert(false);
ASSERT(false);
}
}
@@ -695,7 +695,7 @@ std::string LinkedObjectFile::print_asm_function_disassembly(const std::string&
std::string LinkedObjectFile::print_disassembly(bool write_hex) {
std::string result;
assert(segments <= 3);
ASSERT(segments <= 3);
for (int seg = segments; seg-- > 0;) {
// segment header
result += ";------------------------------------------\n; ";
@@ -819,7 +819,7 @@ std::string LinkedObjectFile::print_scripts() {
* Is the object pointed to the empty list?
*/
bool LinkedObjectFile::is_empty_list(int seg, int byte_idx) {
assert((byte_idx % 4) == 0);
ASSERT((byte_idx % 4) == 0);
auto& word = words_by_seg.at(seg).at(byte_idx / 4);
return word.kind() == LinkedWord::EMPTY_PTR;
}
@@ -857,7 +857,7 @@ goos::Object LinkedObjectFile::to_form_script(int seg, int word_idx, std::vector
return result;
} else {
// cdr object should be aligned.
assert((cdr_addr % 4) == 0);
ASSERT((cdr_addr % 4) == 0);
auto& cdr_word = words_by_seg.at(seg).at(cdr_addr / 4);
// check for proper list
if (cdr_word.kind() == LinkedWord::PTR &&
@@ -875,7 +875,7 @@ goos::Object LinkedObjectFile::to_form_script(int seg, int word_idx, std::vector
}
} else {
// improper list, should be impossible to get here because of earlier checks
assert(false);
ASSERT(false);
}
}
@@ -936,7 +936,7 @@ goos::Object LinkedObjectFile::to_form_script_object(int seg,
std::string debug;
append_word_to_string(debug, word);
printf("don't know how to print %s\n", debug.c_str());
assert(false);
ASSERT(false);
}
} break;
@@ -944,21 +944,21 @@ goos::Object LinkedObjectFile::to_form_script_object(int seg,
default:
// pointers should be aligned!
printf("align %d\n", byte_idx & 7);
assert(false);
ASSERT(false);
}
return result;
}
u32 LinkedObjectFile::read_data_word(const DecompilerLabel& label) {
assert(0 == (label.offset % 4));
ASSERT(0 == (label.offset % 4));
auto& word = words_by_seg.at(label.target_segment).at(label.offset / 4);
assert(word.kind() == LinkedWord::Kind::PLAIN_DATA);
ASSERT(word.kind() == LinkedWord::Kind::PLAIN_DATA);
return word.data;
}
std::string LinkedObjectFile::get_goal_string_by_label(const DecompilerLabel& label) const {
assert(0 == (label.offset % 4));
ASSERT(0 == (label.offset % 4));
return get_goal_string(label.target_segment, (label.offset / 4) - 1, false);
}
@@ -10,7 +10,7 @@
#include "decompiler/util/DecompilerTypeSystem.h"
#include "common/link_types.h"
#include "common/util/BitUtils.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
// There are three link versions:
@@ -133,9 +133,9 @@ static uint32_t c_symlink2(LinkedObjectFile& f,
} else {
// offset link - replace lower 16 bits with symbol table offset.
assert((code_value & 0xffff) == 0 || (code_value & 0xffff) == 0xffff);
assert(kind == SymbolLinkKind::SYMBOL);
// assert(false); // this case does not occur in V2/V4. It does in V3.
ASSERT((code_value & 0xffff) == 0 || (code_value & 0xffff) == 0xffff);
ASSERT(kind == SymbolLinkKind::SYMBOL);
// ASSERT(false); // this case does not occur in V2/V4. It does in V3.
f.symbol_link_offset(seg_id, code_ptr_offset - initial_offset, name);
}
@@ -190,7 +190,7 @@ static uint32_t c_symlink3(LinkedObjectFile& f,
f.symbol_link_word(seg, code_ptr - initial_offset, name, word_kind);
} else {
f.stats.v3_symbol_link_offset++;
assert(kind == SymbolLinkKind::SYMBOL);
ASSERT(kind == SymbolLinkKind::SYMBOL);
f.symbol_link_offset(seg, code_ptr - initial_offset, name);
}
@@ -221,7 +221,7 @@ static void link_v2_or_v4(LinkedObjectFile& f,
const std::string& name,
DecompilerTypeSystem& dts) {
const auto* header = (const LinkHeaderV4*)&data.at(0);
assert(header->version == 4 || header->version == 2);
ASSERT(header->version == 4 || header->version == 2);
// these are different depending on the version.
uint32_t code_offset, link_data_offset, code_size;
@@ -241,7 +241,7 @@ static void link_v2_or_v4(LinkedObjectFile& f,
code_offset = header->length;
// we have to compute the code size ourself
code_size = data.size() - code_offset;
assert(header->type_tag == 0xffffffff);
ASSERT(header->type_tag == 0xffffffff);
}
f.stats.total_code_bytes += code_size;
@@ -251,7 +251,7 @@ static void link_v2_or_v4(LinkedObjectFile& f,
const uint8_t* code_start = &data.at(code_offset);
const uint8_t* code_end =
&data.at(code_offset + code_size - 1) + 1; // get the pointer to one past the end.
assert(((code_end - code_start) % 4) == 0);
ASSERT(((code_end - code_start) % 4) == 0);
f.set_segment_count(1);
for (auto x = code_start; x < code_end; x += 4) {
f.push_back_word_to_segment(*((const uint32_t*)x), 0);
@@ -262,9 +262,9 @@ static void link_v2_or_v4(LinkedObjectFile& f,
uint32_t link_ptr_offset = link_data_offset;
link_ptr_offset += sizeof(LinkHeaderV2);
auto* link_header_v2 = (const LinkHeaderV2*)(link_data);
assert(link_header_v2->type_tag == 0xffffffff);
assert(link_header_v2->version == 2);
assert(link_header_v2->length == header->length);
ASSERT(link_header_v2->type_tag == 0xffffffff);
ASSERT(link_header_v2->version == 2);
ASSERT(link_header_v2->length == header->length);
f.stats.total_v2_link_bytes += link_header_v2->length;
// first "section" of link data is a list of where all the pointer are.
@@ -341,7 +341,7 @@ static void link_v2_or_v4(LinkedObjectFile& f,
// always happens.
link_ptr_offset--;
} else {
assert(false);
ASSERT(false);
}
s_name = (const char*)(&data.at(link_ptr_offset));
@@ -360,12 +360,12 @@ static void link_v2_or_v4(LinkedObjectFile& f,
// just be on the safe side.
// (see the !symbolValue case in intern_type_from_c)
} else {
assert(false);
ASSERT(false);
}
}
if (std::string("_empty_") == s_name) {
assert(kind == SymbolLinkKind::SYMBOL);
ASSERT(kind == SymbolLinkKind::SYMBOL);
kind = SymbolLinkKind::EMPTY_LIST;
}
@@ -378,10 +378,10 @@ static void link_v2_or_v4(LinkedObjectFile& f,
}
// check length
assert(link_header_v2->length == align64(link_ptr_offset - link_data_offset + 1));
ASSERT(link_header_v2->length == align64(link_ptr_offset - link_data_offset + 1));
size_t expected_end = header->version == 4 ? data.size() : link_header_v2->length;
while (link_ptr_offset < expected_end) {
assert(data.at(link_ptr_offset) == 0);
ASSERT(data.at(link_ptr_offset) == 0);
link_ptr_offset++;
}
}
@@ -391,7 +391,7 @@ static void assert_string_empty_after(const char* str, int size) {
while (*ptr)
ptr++;
while (ptr - str < size) {
assert(!*ptr);
ASSERT(!*ptr);
ptr++;
}
}
@@ -405,11 +405,11 @@ static void link_v5(LinkedObjectFile& f,
printf("abandon %s!\n", name.c_str());
return;
}
assert(header->type_tag == 0);
assert(name == header->name);
assert(header->n_segments == 3);
assert(header->pad == 0x50);
assert(header->length_to_get_to_code - header->link_length == 0x50);
ASSERT(header->type_tag == 0);
ASSERT(name == header->name);
ASSERT(header->n_segments == 3);
ASSERT(header->pad == 0x50);
ASSERT(header->length_to_get_to_code - header->link_length == 0x50);
f.set_segment_count(3);
@@ -433,15 +433,15 @@ static void link_v5(LinkedObjectFile& f,
for (int i = 0; i < 3; i++) {
segment_data_offsets[i] = data_ptr_offset + header->segment_info[i].data;
segment_link_offsets[i] = header->segment_info[i].relocs + 0x50;
assert(header->segment_info[i].magic == 1);
ASSERT(header->segment_info[i].magic == 1);
}
// check that the data region is filled
for (int i = 0; i < 2; i++) {
assert(align16(segment_data_offsets[i] + header->segment_info[i].size) ==
ASSERT(align16(segment_data_offsets[i] + header->segment_info[i].size) ==
segment_data_offsets[i + 1]);
}
assert(align16(segment_data_offsets[2] + header->segment_info[2].size) == data.size());
ASSERT(align16(segment_data_offsets[2] + header->segment_info[2].size) == data.size());
// loop over segments (reverse order for now)
for (int seg_id = 3; seg_id-- > 0;) {
@@ -471,8 +471,8 @@ static void link_v5(LinkedObjectFile& f,
auto data_ptr = base_ptr - 4;
auto link_ptr = segment_link_offsets[seg_id];
assert((data_ptr % 4) == 0);
assert((segment_size % 4) == 0);
ASSERT((data_ptr % 4) == 0);
ASSERT((segment_size % 4) == 0);
auto code_start = (const uint32_t*)(&data.at(data_ptr + 4));
auto code_end = ((const uint32_t*)(&data.at(data_ptr + segment_size))) + 1;
@@ -503,10 +503,10 @@ static void link_v5(LinkedObjectFile& f,
f.stats.v3_split_pointers++;
auto dest_seg = (old_code >> 8) & 0xf;
auto lo_hi_offset = (old_code >> 12) & 0xf;
assert(lo_hi_offset);
assert(dest_seg < 3);
ASSERT(lo_hi_offset);
ASSERT(dest_seg < 3);
auto offset_upper = old_code & 0xff;
// assert(offset_upper == 0);
// ASSERT(offset_upper == 0);
uint32_t low_code = *(const uint32_t*)(&data.at(data_ptr + 4 * lo_hi_offset));
uint32_t offset = low_code & 0xffff;
if (offset_upper) {
@@ -560,7 +560,7 @@ static void link_v5(LinkedObjectFile& f,
SymbolLinkKind::SYMBOL, sname, seg_id, dts);
}
} else if ((reloc & 0x3f) == 0x3f) {
assert(false); // todo, does this ever get hit?
ASSERT(false); // todo, does this ever get hit?
} else {
int n_methods_base = reloc & 0x3f;
int n_methods = n_methods_base * 4;
@@ -582,21 +582,21 @@ static void link_v5(LinkedObjectFile& f,
segment_link_ends[seg_id] = link_ptr;
}
assert(segment_link_offsets[0] == 128);
ASSERT(segment_link_offsets[0] == 128);
if (header->segment_info[0].size) {
assert(segment_link_ends[0] + 1 == segment_link_offsets[1]);
ASSERT(segment_link_ends[0] + 1 == segment_link_offsets[1]);
} else {
assert(segment_link_offsets[0] + 2 == segment_link_offsets[1]);
ASSERT(segment_link_offsets[0] + 2 == segment_link_offsets[1]);
}
if (header->segment_info[1].size) {
assert(segment_link_ends[1] + 1 == segment_link_offsets[2]);
ASSERT(segment_link_ends[1] + 1 == segment_link_offsets[2]);
} else {
assert(segment_link_offsets[1] + 2 == segment_link_offsets[2]);
ASSERT(segment_link_offsets[1] + 2 == segment_link_offsets[2]);
}
assert(align16(segment_link_ends[2] + 2) == segment_data_offsets[0]);
ASSERT(align16(segment_link_ends[2] + 2) == segment_data_offsets[0]);
}
static void link_v3(LinkedObjectFile& f,
@@ -605,14 +605,14 @@ static void link_v3(LinkedObjectFile& f,
DecompilerTypeSystem& dts,
int game_version) {
auto header = (const LinkHeaderV3*)(&data.at(0));
assert(name == header->name);
assert(header->segments == 3);
ASSERT(name == header->name);
ASSERT(header->segments == 3);
f.set_segment_count(3);
assert_string_empty_after(header->name, 64);
for (int i = 0; i < 3; i++) {
assert(header->segment_info[i].magic == 0);
ASSERT(header->segment_info[i].magic == 0);
// printf(" [%d] %d %d %d %d\n", i, header->segment_info[i].size,
// header->segment_info[i].data, header->segment_info[i].magic,
// header->segment_info[i].relocs);
@@ -631,10 +631,10 @@ static void link_v3(LinkedObjectFile& f,
// check that the data region is filled
for (int i = 0; i < 2; i++) {
assert(align16(segment_data_offsets[i] + header->segment_info[i].size) ==
ASSERT(align16(segment_data_offsets[i] + header->segment_info[i].size) ==
segment_data_offsets[i + 1]);
}
assert(align16(segment_data_offsets[2] + header->segment_info[2].size) == data.size());
ASSERT(align16(segment_data_offsets[2] + header->segment_info[2].size) == data.size());
// todo - check link region is filled.
@@ -673,8 +673,8 @@ static void link_v3(LinkedObjectFile& f,
auto data_ptr = base_ptr - 4;
auto link_ptr = segment_link_offsets[seg_id];
assert((data_ptr % 4) == 0);
assert((segment_size % 4) == 0);
ASSERT((data_ptr % 4) == 0);
ASSERT((segment_size % 4) == 0);
auto code_start = (const uint32_t*)(&data.at(data_ptr + 4));
auto code_end = ((const uint32_t*)(&data.at(data_ptr + segment_size))) + 1;
@@ -705,10 +705,10 @@ static void link_v3(LinkedObjectFile& f,
f.stats.v3_split_pointers++;
auto dest_seg = (old_code >> 8) & 0xf;
auto lo_hi_offset = (old_code >> 12) & 0xf;
assert(lo_hi_offset);
assert(dest_seg < 3);
ASSERT(lo_hi_offset);
ASSERT(dest_seg < 3);
auto offset_upper = old_code & 0xff;
// assert(offset_upper == 0);
// ASSERT(offset_upper == 0);
uint32_t low_code = *(const uint32_t*)(&data.at(data_ptr + 4 * lo_hi_offset));
uint32_t offset = low_code & 0xffff;
if (offset_upper) {
@@ -759,7 +759,7 @@ static void link_v3(LinkedObjectFile& f,
}
if (std::string("_empty_") == s_name) {
assert(kind == SymbolLinkKind::SYMBOL);
ASSERT(kind == SymbolLinkKind::SYMBOL);
kind = SymbolLinkKind::EMPTY_LIST;
}
@@ -770,21 +770,21 @@ static void link_v3(LinkedObjectFile& f,
segment_link_ends[seg_id] = link_ptr;
}
assert(segment_link_offsets[0] == 128);
ASSERT(segment_link_offsets[0] == 128);
if (header->segment_info[0].size) {
assert(segment_link_ends[0] + 1 == segment_link_offsets[1]);
ASSERT(segment_link_ends[0] + 1 == segment_link_offsets[1]);
} else {
assert(segment_link_offsets[0] + 2 == segment_link_offsets[1]);
ASSERT(segment_link_offsets[0] + 2 == segment_link_offsets[1]);
}
if (header->segment_info[1].size) {
assert(segment_link_ends[1] + 1 == segment_link_offsets[2]);
ASSERT(segment_link_ends[1] + 1 == segment_link_offsets[2]);
} else {
assert(segment_link_offsets[1] + 2 == segment_link_offsets[2]);
ASSERT(segment_link_offsets[1] + 2 == segment_link_offsets[2]);
}
assert(align16(segment_link_ends[2] + 2) == segment_data_offsets[0]);
ASSERT(align16(segment_link_ends[2] + 2) == segment_data_offsets[0]);
}
/*!
@@ -799,16 +799,16 @@ LinkedObjectFile to_linked_object_file(const std::vector<uint8_t>& data,
// use appropriate linker
if (header->version == 3) {
assert(header->type_tag == 0);
ASSERT(header->type_tag == 0);
link_v3(result, data, name, dts, game_version);
} else if (header->version == 4 || header->version == 2) {
assert(header->type_tag == 0xffffffff);
ASSERT(header->type_tag == 0xffffffff);
link_v2_or_v4(result, data, name, dts);
} else if (header->version == 5) {
link_v5(result, data, name, dts);
} else {
printf("Unsupported version %d\n", header->version);
assert(false);
ASSERT(false);
}
return result;
+5 -5
View File
@@ -9,7 +9,7 @@
#include <string>
#include <cstring>
#include "common/common_types.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
class LinkedWord {
@@ -114,7 +114,7 @@ class LinkedWord {
}
u8 get_byte(int idx) const {
assert(kind() == PLAIN_DATA);
ASSERT(kind() == PLAIN_DATA);
switch (idx) {
case 0:
return data & 0xff;
@@ -125,7 +125,7 @@ class LinkedWord {
case 3:
return (data >> 24) & 0xff;
default:
assert(false);
ASSERT(false);
return 0;
}
}
@@ -134,12 +134,12 @@ class LinkedWord {
Kind kind() const { return m_kind; }
u32 label_id() const {
assert(m_kind == PTR || m_kind == LO_PTR || m_kind == HI_PTR);
ASSERT(m_kind == PTR || m_kind == LO_PTR || m_kind == HI_PTR);
return m_data_ptr;
}
std::string symbol_name() const {
assert(holds_string());
ASSERT(holds_string());
return (const char*)(m_data_ptr);
}
+22 -22
View File
@@ -65,8 +65,8 @@ std::string obj_filename_to_name(const std::string& x) {
}
}
assert(last_dot > last_slash + 1);
assert(last_slash + 1 < x.length());
ASSERT(last_dot > last_slash + 1);
ASSERT(last_slash + 1 < x.length());
return x.substr(last_slash + 1, last_dot - last_slash - 1);
}
} // namespace
@@ -96,13 +96,13 @@ ObjectFileData& ObjectFileDB::lookup_record(const ObjectFileRecord& rec) {
for (auto& x : obj_files_by_name[rec.name]) {
if (x.record.version == rec.version) {
assert(x.record.hash == rec.hash);
assert(!result);
ASSERT(x.record.hash == rec.hash);
ASSERT(!result);
result = &x;
}
}
assert(result);
ASSERT(result);
return *result;
}
@@ -190,7 +190,7 @@ void ObjectFileDB::load_map_file(const std::string& map_data) {
auto kv = dgo_obj_name_map[dgo].find(game_name_with_ag);
if (kv != dgo_obj_name_map[dgo].end()) {
lg::error("Object {} in dgo {} occurs more than one time.", game_name_with_ag, dgo);
assert(false);
ASSERT(false);
}
dgo_obj_name_map[dgo][game_name_with_ag] = mapped_name;
}
@@ -212,7 +212,7 @@ void ObjectFileDB::get_objs_from_dgo(const std::string& filename, const Config&
auto header = reader.read<DgoHeader>();
auto dgo_base_name = file_util::base_name(filename);
assert(header.name == dgo_base_name);
ASSERT(header.name == dgo_base_name);
assert_string_empty_after(header.name, 60);
// get all obj files...
@@ -226,11 +226,11 @@ void ObjectFileDB::get_objs_from_dgo(const std::string& filename, const Config&
reader.ffwd(reader.bytes_left());
continue;
} else {
assert(false);
ASSERT(false);
}
}
} else {
assert(reader.bytes_left() >= obj_header.object_count);
ASSERT(reader.bytes_left() >= obj_header.object_count);
}
if (std::string(obj_header.name).find("-ag") != std::string::npos) {
@@ -238,7 +238,7 @@ void ObjectFileDB::get_objs_from_dgo(const std::string& filename, const Config&
"Object file {} has \"-ag\" in its name. This will break any tools which use this to "
"detect an art group",
obj_header.name);
assert(false);
ASSERT(false);
}
auto name = get_object_file_name(obj_header.name, reader.here(), obj_header.object_count);
@@ -249,7 +249,7 @@ void ObjectFileDB::get_objs_from_dgo(const std::string& filename, const Config&
}
// check we're at the end
assert(0 == reader.bytes_left());
ASSERT(0 == reader.bytes_left());
}
/*!
@@ -270,7 +270,7 @@ void ObjectFileDB::add_obj_from_dgo(const std::string& obj_name,
}
}
stats.total_obj_files++;
assert(obj_size > 128);
ASSERT(obj_size > 128);
uint16_t version = *(const uint16_t*)(obj_data + 8);
auto hash = file_util::crc32(obj_data, obj_size);
@@ -279,12 +279,12 @@ void ObjectFileDB::add_obj_from_dgo(const std::string& obj_name,
for (auto& e : obj_files_by_name[obj_name]) {
if (e.data.size() == obj_size && e.record.hash == hash) {
// just to make sure we don't have a hash collision.
assert(!memcmp(obj_data, e.data.data(), obj_size));
ASSERT(!memcmp(obj_data, e.data.data(), obj_size));
// already got it!
e.reference_count++;
auto& rec = e.record;
assert(name_in_dgo == e.name_in_dgo);
ASSERT(name_in_dgo == e.name_in_dgo);
e.dgo_names.push_back(dgo_name);
obj_files_by_dgo[dgo_name].push_back(rec);
duplicated = true;
@@ -316,13 +316,13 @@ void ObjectFileDB::add_obj_from_dgo(const std::string& obj_name,
auto dgo_kv = dgo_obj_name_map.find(strip_dgo_extension(dgo_name));
if (dgo_kv == dgo_obj_name_map.end()) {
lg::error("Object {} is from DGO {}, but this DGO was not in the map.", obj_name, dgo_name);
assert(false);
ASSERT(false);
}
auto name_kv = dgo_kv->second.find(obj_name);
if (name_kv == dgo_kv->second.end()) {
lg::error("Object {} from DGO {} was not found in the name map.", obj_name, dgo_name);
assert(false);
ASSERT(false);
}
data.name_from_map = name_kv->second;
}
@@ -384,7 +384,7 @@ std::string ObjectFileDB::generate_obj_listing(const std::unordered_set<std::str
for (auto& x : obj_files_by_name.at(obj_file)) {
std::string dgos = "[";
for (auto& y : x.dgo_names) {
assert(y.length() >= 5);
ASSERT(y.length() >= 5);
std::string new_str = y == "NO-XGO" ? y : y.substr(0, y.length() - 4);
dgos += "\"" + new_str + "\", ";
}
@@ -603,7 +603,7 @@ std::string ObjectFileDB::process_tpages(TextureDB& tex_db) {
}
});
assert(tpage_dir_count <= 1);
ASSERT(tpage_dir_count <= 1);
lg::info("Processed {} / {} textures ({} px) {:.2f}% in {:.2f} ms", success, total, total_px,
100.f * float(success) / float(total), timer.getMs());
@@ -631,7 +631,7 @@ std::string ObjectFileDB::process_game_text_files(GameTextVersion version) {
string_count += statistics.total_text;
char_count += statistics.total_chars;
if (text_by_language_by_id.find(statistics.language) != text_by_language_by_id.end()) {
assert(false);
ASSERT(false);
}
text_by_language_by_id[statistics.language] = std::move(statistics.text);
}
@@ -653,7 +653,7 @@ std::string ObjectFileDB::process_game_count_file() {
for_each_obj([&](ObjectFileData& data) {
if (data.name_in_dgo == "game-cnt") {
assert(!found);
ASSERT(!found);
found = true;
result = write_game_count(process_game_count(data));
}
@@ -683,10 +683,10 @@ void ObjectFileDB::analyze_functions_ir1(const Config& config) {
for_each_obj([&](ObjectFileData& data) {
if (data.linked_data.segments == 3) {
// the top level segment should have a single function
assert(data.linked_data.functions_by_seg.at(2).size() == 1);
ASSERT(data.linked_data.functions_by_seg.at(2).size() == 1);
auto& func = data.linked_data.functions_by_seg.at(2).front();
assert(func.guessed_name.empty());
ASSERT(func.guessed_name.empty());
func.guessed_name.set_as_top_level(data.to_unique_name());
func.find_global_function_defs(data.linked_data, dts);
func.find_type_defs(data.linked_data, dts);
+2 -2
View File
@@ -15,7 +15,7 @@
#include "common/common_types.h"
#include "decompiler/data/TextureDB.h"
#include "decompiler/analysis/symbol_def_map.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
/*!
@@ -125,7 +125,7 @@ class ObjectFileDB {
*/
template <typename Func>
void for_each_obj(Func f) {
assert(obj_files_by_name.size() == obj_file_order.size());
ASSERT(obj_files_by_name.size() == obj_file_order.size());
for (const auto& name : obj_file_order) {
for (auto& obj : obj_files_by_name.at(name)) {
// lg::info("{}...", name);
+12 -12
View File
@@ -185,10 +185,10 @@ void ObjectFileDB::ir2_top_level_pass(const Config& config) {
for_each_obj([&](ObjectFileData& data) {
if (data.linked_data.segments == 3) {
// the top level segment should have a single function
assert(data.linked_data.functions_by_seg.at(2).size() == 1);
ASSERT(data.linked_data.functions_by_seg.at(2).size() == 1);
auto& func = data.linked_data.functions_by_seg.at(2).front();
assert(func.guessed_name.empty());
ASSERT(func.guessed_name.empty());
func.guessed_name.set_as_top_level(data.to_unique_name());
func.find_global_function_defs(data.linked_data, dts);
func.find_type_defs(data.linked_data, dts);
@@ -224,7 +224,7 @@ void ObjectFileDB::ir2_top_level_pass(const Config& config) {
total_unknowns++;
break;
default:
assert(false);
ASSERT(false);
}
total_functions++;
@@ -296,8 +296,8 @@ void ObjectFileDB::ir2_basic_block_pass(int seg, const Config& config, ObjectFil
func.analyze_prologue(data.linked_data);
} else {
// manually exclude the type tag from the basic block.
assert(func.basic_blocks.front().start_word == 0);
assert(func.basic_blocks.front().end_word >= 1);
ASSERT(func.basic_blocks.front().start_word == 0);
ASSERT(func.basic_blocks.front().end_word >= 1);
func.basic_blocks.front().start_word = 1;
}
@@ -629,7 +629,7 @@ std::string ObjectFileDB::ir2_to_file(ObjectFileData& data, const Config& config
std::string result;
const char* segment_names[] = {"main segment", "debug segment", "top-level segment"};
assert(data.linked_data.segments <= 3);
ASSERT(data.linked_data.segments <= 3);
for (int seg = data.linked_data.segments; seg-- > 0;) {
// segment header
result += ";------------------------------------------\n; ";
@@ -676,7 +676,7 @@ std::string ObjectFileDB::ir2_to_file(ObjectFileData& data, const Config& config
}
// check for no misaligned labels in code segments.
for (int j = 1; j < 4; j++) {
assert(data.linked_data.get_label_at(seg, (func.start_word + instr_idx) * 4 + j) ==
ASSERT(data.linked_data.get_label_at(seg, (func.start_word + instr_idx) * 4 + j) ==
-1);
}
@@ -791,7 +791,7 @@ std::string ObjectFileDB::ir2_function_to_string(ObjectFileData& data, Function&
}
// check for no misaligned labels in code segments.
for (int j = 1; j < 4; j++) {
assert(data.linked_data.get_label_at(seg, (func.start_word + i) * 4 + j) == -1);
ASSERT(data.linked_data.get_label_at(seg, (func.start_word + i) * 4 + j) == -1);
}
// print the assembly instruction
@@ -815,7 +815,7 @@ std::string ObjectFileDB::ir2_function_to_string(ObjectFileData& data, Function&
in_delay_slot = true;
}
total_instructions_printed++;
assert(last_instr_printed + 1 == i);
ASSERT(last_instr_printed + 1 == i);
last_instr_printed = i;
};
@@ -909,7 +909,7 @@ std::string ObjectFileDB::ir2_function_to_string(ObjectFileData& data, Function&
result += "\n";
assert(total_instructions_printed == (func.end_word - func.start_word - 1));
ASSERT(total_instructions_printed == (func.end_word - func.start_word - 1));
return result;
}
@@ -983,7 +983,7 @@ bool ObjectFileDB::lookup_function_type(const FunctionName& name,
mi.type.substitute_for_method_call(name.type_name));
return true;
} else {
assert(false);
ASSERT(false);
}
return false;
}
@@ -994,7 +994,7 @@ std::string ObjectFileDB::ir2_final_out(ObjectFileData& data,
std::string result;
result += ";;-*-Lisp-*-\n";
result += "(in-package goal)\n\n";
assert(data.linked_data.functions_by_seg.at(TOP_LEVEL_SEGMENT).size() == 1);
ASSERT(data.linked_data.functions_by_seg.at(TOP_LEVEL_SEGMENT).size() == 1);
auto top_level = data.linked_data.functions_by_seg.at(TOP_LEVEL_SEGMENT).at(0);
result += write_from_top_level(top_level, dts, data.linked_data, skip_functions);
result += "\n\n";
+27 -27
View File
@@ -4,7 +4,7 @@
#include "VuDisassembler.h"
#include "third-party/fmt/core.h"
#include "common/util/print_float.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
@@ -226,7 +226,7 @@ VuDisassembler::VuDisassembler(VuKind kind) : m_kind(kind) {
* Add a VU operation to the decode table
*/
VuDisassembler::OpInfo& VuDisassembler::add_op(VuInstrK kind, const std::string& name) {
assert((int)kind < (int)VuInstrK::INVALID);
ASSERT((int)kind < (int)VuInstrK::INVALID);
auto& elt = m_op_info[(int)kind];
elt.name = name;
elt.known = true;
@@ -291,14 +291,14 @@ VuInstrK VuDisassembler::lower_kind(u32 in) {
return VuInstrK::ERLENG;
}
fmt::print("Unknown lower special: 0b{:b}\n", in);
assert(false);
ASSERT(false);
} else {
assert((op & 0b1000000) == 0);
assert(op < 64);
ASSERT((op & 0b1000000) == 0);
ASSERT(op < 64);
auto elt = m_lower_op6_table[(int)op];
if (!elt.known) {
fmt::print("Invalid lower op6: 0b{:b} 0b{:b} 0x{:x}\n", op, in, in);
assert(false);
ASSERT(false);
}
return elt.kind;
}
@@ -354,20 +354,20 @@ VuInstrK VuDisassembler::upper_kind(u32 in) {
case 0b01011'1111'10:
return VuInstrK::OPMULA;
case 0b01011'1111'11:
assert(upper_dest_mask(in) == 0);
assert(upper_fs(in) == 0);
assert(upper_ft(in) == 0);
ASSERT(upper_dest_mask(in) == 0);
ASSERT(upper_fs(in) == 0);
ASSERT(upper_ft(in) == 0);
return VuInstrK::NOP;
break;
default:
fmt::print("Invalid op11: 0b{:b}\n", upper_op11(in));
assert(false);
ASSERT(false);
}
}
if (!upper_info.known) {
fmt::print("Invalid upper op6: 0b{:b}\n", upper_op6(in));
assert(false);
ASSERT(false);
}
return upper_info.kind;
}
@@ -382,14 +382,14 @@ s32 VuDisassembler::get_instruction_index_mask() {
case VU1:
return (16384 / 8) - 1;
default:
assert(false);
ASSERT(false);
}
}
VuProgram VuDisassembler::disassemble(void* data, int size_bytes, bool debug_print) {
auto bytes = (u8*)data;
// should be 8 byte aligned size.
assert((size_bytes & 0x7) == 0);
ASSERT((size_bytes & 0x7) == 0);
VuProgram prog;
int instruction_count = size_bytes / 8;
for (int i = 0; i < instruction_count; i++) {
@@ -426,14 +426,14 @@ VuInstruction VuDisassembler::decode(VuInstrK kind, u32 data, int instr_idx) {
auto& inst = info(kind);
if (!inst.known) {
fmt::print("instr idx {} is unknown\n", (int)kind);
assert(false);
ASSERT(false);
}
for (auto& step : inst.decode) {
s64 value = -1;
switch (step.field) {
case VuDecodeStep::FieldK::IEMDT:
value = data >> 25;
assert((value & 3) == 0);
ASSERT((value & 3) == 0);
break;
case VuDecodeStep::FieldK::DST_MASK:
value = upper_dest_mask(data);
@@ -485,7 +485,7 @@ VuInstruction VuDisassembler::decode(VuInstrK kind, u32 data, int instr_idx) {
break;
default:
assert(false);
ASSERT(false);
}
switch (step.atom) {
@@ -496,22 +496,22 @@ VuInstruction VuDisassembler::decode(VuInstrK kind, u32 data, int instr_idx) {
instr.mask = value;
break;
case VuDecodeStep::AtomK::DST_VF:
assert(!instr.dst);
ASSERT(!instr.dst);
instr.dst = VuInstructionAtom::make_vf(value);
break;
case VuDecodeStep::AtomK::DST_VI:
assert(!instr.dst);
ASSERT(!instr.dst);
instr.dst = VuInstructionAtom::make_vi(value);
break;
case VuDecodeStep::AtomK::SRC_VF:
instr.src.push_back(VuInstructionAtom::make_vf(value));
break;
case VuDecodeStep::AtomK::BC:
assert(!instr.bc);
ASSERT(!instr.bc);
instr.bc = value;
break;
case VuDecodeStep::AtomK::ASSERT_ZERO:
assert(value == 0);
ASSERT(value == 0);
break;
case VuDecodeStep::AtomK::SRC_VI:
instr.src.push_back(VuInstructionAtom::make_vi(value));
@@ -526,15 +526,15 @@ VuInstruction VuDisassembler::decode(VuInstrK kind, u32 data, int instr_idx) {
instr.src.push_back(VuInstructionAtom::make_imm(value));
break;
case VuDecodeStep::AtomK::DST_ACC:
assert(!instr.dst);
ASSERT(!instr.dst);
instr.dst = VuInstructionAtom::make_acc();
break;
case VuDecodeStep::AtomK::DST_Q:
assert(!instr.dst);
ASSERT(!instr.dst);
instr.dst = VuInstructionAtom::make_q();
break;
case VuDecodeStep::AtomK::DST_P:
assert(!instr.dst);
ASSERT(!instr.dst);
instr.dst = VuInstructionAtom::make_p();
break;
case VuDecodeStep::AtomK::SRC_Q:
@@ -553,7 +553,7 @@ VuInstruction VuDisassembler::decode(VuInstrK kind, u32 data, int instr_idx) {
instr.first_src_field = value;
break;
default:
assert(false);
ASSERT(false);
}
}
@@ -862,7 +862,7 @@ std::string VuDisassembler::to_string(const VuInstruction& instr) const {
auto& in = info(instr.kind);
if (!in.known) {
assert(false);
ASSERT(false);
}
std::string result;
@@ -934,7 +934,7 @@ std::string VuDisassembler::to_string(const VuInstruction& instr) const {
idx++;
}
assert(!close);
ASSERT(!close);
if (comma) {
result.pop_back();
@@ -1046,7 +1046,7 @@ std::string get_label_name(const VuInstructionPair& pair,
return arg.to_string(label_names);
}
}
assert(false);
ASSERT(false);
}
std::string VuDisassembler::to_string_with_cpp(const VuProgram& prog) const {
+2 -2
View File
@@ -3,7 +3,7 @@
#include <unordered_map>
#include "decompiler/VuDisasm/VuProgram.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
@@ -220,7 +220,7 @@ class VuDisassembler {
};
const OpInfo& info(VuInstrK op) const {
assert((int)op < (int)VuInstrK::INVALID);
ASSERT((int)op < (int)VuInstrK::INVALID);
return m_op_info[(int)op];
}
+4 -4
View File
@@ -1,15 +1,15 @@
#include "third-party/fmt/core.h"
#include "VuInstruction.h"
#include "common/util/assert.h"
#include "common/util/Assert.h"
namespace decompiler {
VuInstructionAtom VuInstructionAtom::make_vf(int idx) {
assert(idx >= 0 && idx <= 31);
ASSERT(idx >= 0 && idx <= 31);
return {Kind::VF, idx};
}
VuInstructionAtom VuInstructionAtom::make_vi(int idx) {
assert(idx >= 0 && idx <= 15);
ASSERT(idx >= 0 && idx <= 15);
return {Kind::VI, idx};
}
@@ -82,7 +82,7 @@ std::string VuInstructionAtom::to_string(const std::vector<std::string>& labels)
return fmt::format("vi{:02d}", m_value);
case Kind::INVALID:
default:
assert(false);
ASSERT(false);
}
}
+53 -53
View File
@@ -66,7 +66,7 @@ RegisterAccess make_src_var(Register reg, int idx) {
}
RegisterAccess make_dst_var(const Instruction& i, int idx) {
assert(i.n_dst == 1);
ASSERT(i.n_dst == 1);
return make_dst_var(i.get_dst(0).get_reg(), idx);
}
@@ -203,10 +203,10 @@ std::unique_ptr<AtomicOp> make_standard_store(const Instruction& i0,
SimpleAtom val;
SimpleExpression dst;
if (i0.get_src(0).is_reg(rs7())) {
assert(kind == StoreOp::Kind::INTEGER);
ASSERT(kind == StoreOp::Kind::INTEGER);
val = SimpleAtom::make_sym_val("#f");
} else if (i0.get_src(0).is_reg(rr0())) {
assert(kind == StoreOp::Kind::INTEGER);
ASSERT(kind == StoreOp::Kind::INTEGER);
val = SimpleAtom::make_int_constant(0);
} else {
val = make_src_atom(i0.get_src(0).get_reg(), idx);
@@ -420,7 +420,7 @@ std::unique_ptr<AtomicOp> make_branch(const IR2_Condition& condition,
int dest_label,
int my_idx,
bool force_asm) {
assert(!likely);
ASSERT(!likely);
auto branch_delay = get_branch_delay(delay, my_idx);
if (!force_asm && branch_delay.is_known()) {
return std::make_unique<BranchOp>(likely, condition, dest_label, branch_delay, my_idx);
@@ -438,7 +438,7 @@ std::unique_ptr<AtomicOp> make_asm_branch_no_delay(const IR2_Condition& conditio
bool likely,
int dest_label,
int my_idx) {
assert(likely);
ASSERT(likely);
return std::make_unique<AsmBranchOp>(likely, condition, dest_label, nullptr, my_idx);
}
@@ -450,7 +450,7 @@ std::unique_ptr<AtomicOp> make_branch_no_delay(const IR2_Condition& condition,
if (force_asm_branch) {
return make_asm_branch_no_delay(condition, likely, dest_label, my_idx);
}
assert(likely);
ASSERT(likely);
IR2_BranchDelay delay(IR2_BranchDelay::Kind::NO_DELAY);
return std::make_unique<BranchOp>(likely, condition, dest_label, delay, my_idx);
}
@@ -460,7 +460,7 @@ std::unique_ptr<AtomicOp> make_asm_branch(const IR2_Condition& condition,
bool likely,
int dest_label,
int my_idx) {
assert(!likely);
ASSERT(!likely);
auto delay_op = std::shared_ptr<AtomicOp>(convert_1_allow_asm(delay, my_idx));
if (!delay_op) {
throw std::runtime_error(
@@ -1065,10 +1065,10 @@ std::unique_ptr<AtomicOp> convert_daddiu_2(const Instruction& i0, const Instruct
if (!i0.get_src(0).is_reg(rs7())) {
return nullptr;
}
assert(i0.get_src(0).is_reg(rs7()));
assert(i0.get_src(1).is_imm(8));
assert(i1.get_dst(0).is_reg(dest));
assert(i1.get_src(0).is_reg(rs7()));
ASSERT(i0.get_src(0).is_reg(rs7()));
ASSERT(i0.get_src(1).is_imm(8));
ASSERT(i1.get_dst(0).is_reg(dest));
ASSERT(i1.get_src(0).is_reg(rs7()));
auto kind =
i1.kind == InstructionKind::MOVN ? IR2_Condition::Kind::ZERO : IR2_Condition::Kind::NONZERO;
return std::make_unique<SetVarConditionOp>(make_dst_var(dest, idx),
@@ -1094,7 +1094,7 @@ std::unique_ptr<AtomicOp> convert_lui_2(const Instruction& i0, const Instruction
(s64(i0.get_src(0).get_imm()) << 16));
} else if (i0.get_src(0).is_label() && i1.get_src(1).is_label()) {
auto label = i0.get_src(0).get_label();
assert(label == i1.get_src(1).get_label());
ASSERT(label == i1.get_src(1).get_label());
src = SimpleAtom::make_static_address(label);
}
@@ -1124,9 +1124,9 @@ std::unique_ptr<AtomicOp> convert_slt_2(const Instruction& i0,
if (temp == left) {
return nullptr;
}
assert(temp != left);
assert(temp != right);
assert(left != right);
ASSERT(temp != left);
ASSERT(temp != right);
ASSERT(left != right);
std::unique_ptr<AtomicOp> result;
SimpleExpression::Kind kind;
if (is_gpr_3(i1, InstructionKind::MOVZ, left, right, temp)) {
@@ -1226,10 +1226,10 @@ std::unique_ptr<AtomicOp> convert_lui_3(const Instruction& i0,
// lui temp, <>
// ori dst, temp, <>
// addu dst, fp, dst
assert(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg()); // temp
assert(i0.get_src(0).get_label() == i1.get_src(1).get_label()); // labels
assert(i2.get_dst(0).get_reg() == i2.get_src(1).get_reg()); // dst
assert(i2.get_dst(0).get_reg() == i1.get_dst(0).get_reg()); // dst
ASSERT(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg()); // temp
ASSERT(i0.get_src(0).get_label() == i1.get_src(1).get_label()); // labels
ASSERT(i2.get_dst(0).get_reg() == i2.get_src(1).get_reg()); // dst
ASSERT(i2.get_dst(0).get_reg() == i1.get_dst(0).get_reg()); // dst
auto temp = i0.get_dst(0).get_reg();
auto dst = i2.get_dst(0).get_reg();
auto label = i0.get_src(0).get_label();
@@ -1244,10 +1244,10 @@ std::unique_ptr<AtomicOp> convert_lui_3(const Instruction& i0,
// lui temp, <>
// ori temp, temp, <>
// daddu dst, temp, fp
assert(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg()); // temp
assert(i0.get_src(0).get_label() == i1.get_src(1).get_label()); // labels
assert(i0.get_dst(0).get_reg() == i1.get_dst(0).get_reg()); // temp
assert(i2.get_src(0).get_reg() == i0.get_dst(0).get_reg()); // temp
ASSERT(i0.get_dst(0).get_reg() == i1.get_src(0).get_reg()); // temp
ASSERT(i0.get_src(0).get_label() == i1.get_src(1).get_label()); // labels
ASSERT(i0.get_dst(0).get_reg() == i1.get_dst(0).get_reg()); // temp
ASSERT(i2.get_src(0).get_reg() == i0.get_dst(0).get_reg()); // temp
auto temp = i0.get_dst(0).get_reg();
auto dst = i2.get_dst(0).get_reg();
auto label = i0.get_src(0).get_label();
@@ -1274,12 +1274,12 @@ std::unique_ptr<AtomicOp> convert_dsubu_3(const Instruction& i0,
auto a = i0.get_src(0).get_reg();
auto b = i0.get_src(1).get_reg();
auto dest = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(rs7()));
assert(i1.get_src(1).is_imm(FIX_SYM_TRUE));
assert(i2.get_dst(0).get_reg() == dest);
assert(i2.get_src(0).is_reg(rs7()));
assert(i2.get_src(1).get_reg() == temp);
assert(temp != dest);
ASSERT(i1.get_src(0).is_reg(rs7()));
ASSERT(i1.get_src(1).is_imm(FIX_SYM_TRUE));
ASSERT(i2.get_dst(0).get_reg() == dest);
ASSERT(i2.get_src(0).is_reg(rs7()));
ASSERT(i2.get_src(1).get_reg() == temp);
ASSERT(temp != dest);
auto kind = i2.kind == InstructionKind::MOVN ? IR2_Condition::Kind::EQUAL
: IR2_Condition::Kind::NOT_EQUAL;
std::unique_ptr<AtomicOp> result;
@@ -1332,8 +1332,8 @@ std::unique_ptr<AtomicOp> convert_slt_3(const Instruction& i0,
// delay slot
auto temp = i0.get_dst(0).get_reg();
auto dest = i1.get_src(2).get_label();
assert(i1.get_src(0).get_reg() == temp);
assert(i1.get_src(1).is_reg(rr0()));
ASSERT(i1.get_src(0).get_reg() == temp);
ASSERT(i1.get_src(1).is_reg(rr0()));
IR2_Condition condition;
if (s1 == rr0()) {
@@ -1365,12 +1365,12 @@ std::unique_ptr<AtomicOp> convert_slt_3(const Instruction& i0,
// movz dest, s7, temp
auto temp = i0.get_dst(0).get_reg();
auto dest = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(rs7()));
assert(i1.get_src(1).is_imm(FIX_SYM_TRUE));
assert(i2.get_dst(0).get_reg() == dest);
assert(i2.get_src(0).is_reg(rs7()));
assert(i2.get_src(1).get_reg() == temp);
assert(temp != dest);
ASSERT(i1.get_src(0).is_reg(rs7()));
ASSERT(i1.get_src(1).is_imm(FIX_SYM_TRUE));
ASSERT(i2.get_dst(0).get_reg() == dest);
ASSERT(i2.get_src(0).is_reg(rs7()));
ASSERT(i2.get_src(1).get_reg() == temp);
ASSERT(temp != dest);
IR2_Condition condition;
if (s1 == rr0()) {
auto kind = is_signed ? IR2_Condition::Kind::LESS_THAN_ZERO_SIGNED
@@ -1411,8 +1411,8 @@ std::unique_ptr<AtomicOp> convert_slti_3(const Instruction& i0,
// delay slot
auto temp = i0.get_dst(0).get_reg();
auto dest = i1.get_src(2).get_label();
assert(i1.get_src(0).get_reg() == temp);
assert(i1.get_src(1).is_reg(rr0()));
ASSERT(i1.get_src(0).get_reg() == temp);
ASSERT(i1.get_src(1).is_reg(rr0()));
auto kind =
is_signed ? IR2_Condition::Kind::LESS_THAN_SIGNED : IR2_Condition::Kind::LESS_THAN_UNSIGNED;
auto condition = IR2_Condition(kind, make_src_atom(s0, idx), s1);
@@ -1430,12 +1430,12 @@ std::unique_ptr<AtomicOp> convert_slti_3(const Instruction& i0,
// movz dest, s7, temp
auto temp = i0.get_dst(0).get_reg();
auto dest = i1.get_dst(0).get_reg();
assert(i1.get_src(0).is_reg(rs7()));
assert(i1.get_src(1).is_imm(FIX_SYM_TRUE));
assert(i2.get_dst(0).get_reg() == dest);
assert(i2.get_src(0).is_reg(rs7()));
assert(i2.get_src(1).get_reg() == temp);
assert(temp != dest);
ASSERT(i1.get_src(0).is_reg(rs7()));
ASSERT(i1.get_src(1).is_imm(FIX_SYM_TRUE));
ASSERT(i2.get_dst(0).get_reg() == dest);
ASSERT(i2.get_src(0).is_reg(rs7()));
ASSERT(i2.get_src(1).get_reg() == temp);
ASSERT(temp != dest);
IR2_Condition condition;
auto kind =
@@ -1517,11 +1517,11 @@ std::unique_ptr<AtomicOp> convert_dsll32_4(const Instruction& i0,
if (sa != 30) {
return nullptr;
}
assert(i1.get_dst(0).get_reg() == temp);
assert(i1.get_src(0).get_reg() == temp);
assert(i1.get_src(1).is_reg(rr0()));
assert(i2.get_src(0).get_reg() == temp);
assert(i2.get_src(1).is_reg(rr0()));
ASSERT(i1.get_dst(0).get_reg() == temp);
ASSERT(i1.get_src(0).get_reg() == temp);
ASSERT(i1.get_src(1).is_reg(rr0()));
ASSERT(i2.get_src(0).get_reg() == temp);
ASSERT(i2.get_src(1).is_reg(rr0()));
IR2_Condition condition(IR2_Condition::Kind::IS_NOT_PAIR, make_src_atom(arg, idx));
auto result = make_branch(condition, i3, false, i2.get_src(2).get_label(), idx, false);
@@ -2141,7 +2141,7 @@ int convert_block_to_atomic_ops(int begin_idx,
// instr->to_string(labels));
}
assert(converted && length && op);
ASSERT(converted && length && op);
// add mappings:
container->atomic_op_to_instruction[container->ops.size()] = begin_idx;
for (int i = 0; i < length; i++) {
@@ -2197,8 +2197,8 @@ FunctionAtomicOps convert_function_to_atomic_ops(
}
}
assert(func.basic_blocks.size() == result.block_id_to_end_atomic_op.size());
assert(func.basic_blocks.size() == result.block_id_to_first_atomic_op.size());
ASSERT(func.basic_blocks.size() == result.block_id_to_end_atomic_op.size());
ASSERT(func.basic_blocks.size() == result.block_id_to_first_atomic_op.size());
return result;
}
} // namespace decompiler
+2 -2
View File
@@ -17,9 +17,9 @@ struct FunctionAtomicOps {
std::vector<std::unique_ptr<AtomicOp>> ops;
FunctionEndOp& end_op() const {
assert(!ops.empty());
ASSERT(!ops.empty());
auto end = dynamic_cast<FunctionEndOp*>(ops.back().get());
assert(end);
ASSERT(end);
return *end;
}

Some files were not shown because too many files have changed in this diff Show More