[Decompiler] WIP Conversion to SSA and variable naming (#195)

* begin ssa algorithm

* ssa based splitting appears to work

* add merge pass

* finish basic implementation

* better output

* bug fix
This commit is contained in:
water111
2021-01-16 10:54:09 -05:00
committed by GitHub
parent 8f86f0f00e
commit 1071ff6003
18 changed files with 932 additions and 62 deletions
+5 -3
View File
@@ -162,7 +162,9 @@ void DecompilerTypeSystem::add_symbol(const std::string& name, const TypeSpec& t
/*!
* Compute the least common ancestor of two TP Types.
*/
TP_Type DecompilerTypeSystem::tp_lca(const TP_Type& existing, const TP_Type& add, bool* changed) {
TP_Type DecompilerTypeSystem::tp_lca(const TP_Type& existing,
const TP_Type& add,
bool* changed) const {
// starting from most vague to most specific
// simplist case, no difference.
@@ -302,7 +304,7 @@ bool DecompilerTypeSystem::tp_lca(TypeState* combined, const TypeState& add) {
return result;
}
int DecompilerTypeSystem::get_format_arg_count(const std::string& str) {
int DecompilerTypeSystem::get_format_arg_count(const std::string& str) const {
int arg_count = 0;
for (size_t i = 0; i < str.length(); i++) {
if (str.at(i) == '~') {
@@ -317,7 +319,7 @@ int DecompilerTypeSystem::get_format_arg_count(const std::string& str) {
return arg_count;
}
int DecompilerTypeSystem::get_format_arg_count(const TP_Type& type) {
int DecompilerTypeSystem::get_format_arg_count(const TP_Type& type) const {
if (type.is_constant_string()) {
return get_format_arg_count(type.get_string());
} else {
+3 -4
View File
@@ -38,11 +38,10 @@ class DecompilerTypeSystem {
std::string dump_symbol_types();
std::string lookup_parent_from_inspects(const std::string& child) const;
bool lookup_flags(const std::string& type, u64* dest) const;
TP_Type tp_lca(const TP_Type& existing, const TP_Type& add, bool* changed);
TP_Type tp_lca_no_simplify(const TP_Type& existing, const TP_Type& add, bool* changed);
TP_Type tp_lca(const TP_Type& existing, const TP_Type& add, bool* changed) const;
bool tp_lca(TypeState* combined, const TypeState& add);
int get_format_arg_count(const std::string& str);
int get_format_arg_count(const TP_Type& type);
int get_format_arg_count(const std::string& str) const;
int get_format_arg_count(const TP_Type& type) const;
struct {
bool allow_pair;
std::string current_method_type;
+2
View File
@@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <cassert>
#include "common/log/log.h"
#include "common/type_system/TypeSpec.h"
#include "common/common_types.h"
#include "decompiler/Disasm/Register.h"
@@ -190,6 +191,7 @@ struct TypeState {
case Reg::FPR:
return fpr_types[r.get_fpr()];
default:
lg::die("Cannot use register {} with TypeState.", r.to_charp());
assert(false);
}
}