[Decompiler] WIP: Stack Spills (#382)

* set up types

* cleaned up type analysis and got things working through atomic ops

* expression working, need types

* improved types and names

* getting close

* finish up dma-disasm

* fix
This commit is contained in:
water111
2021-04-25 14:48:54 -04:00
committed by GitHub
parent 54ccc9db97
commit 2002db359a
43 changed files with 3187 additions and 99 deletions
+25
View File
@@ -723,4 +723,29 @@ FormElement* FunctionEndOp::get_as_form(FormPool& pool, const Env&) const {
FormElement* AsmBranchOp::get_as_form(FormPool& pool, const Env&) const {
return pool.alloc_element<AtomicOpElement>(this);
}
FormElement* StackSpillLoadOp::get_as_form(FormPool& pool, const Env& env) const {
TypeSpec type("object");
auto kv = env.stack_slot_entries.find(m_offset);
if (kv != env.stack_slot_entries.end()) {
type = kv->second.typespec;
}
return pool.alloc_element<SetVarElement>(m_dst,
pool.alloc_single_element_form<StackSpillValueElement>(
nullptr, m_size, m_offset, m_is_signed),
true, type);
}
FormElement* StackSpillStoreOp::get_as_form(FormPool& pool, const Env& env) const {
auto& slot_type = env.stack_slot_entries.at(m_offset).typespec;
auto src_type = env.get_types_before_op(m_my_idx).get(m_value.reg()).typespec();
std::optional<TypeSpec> cast_type;
if (!env.dts->ts.tc(slot_type, src_type)) {
// we fail the typecheck for a normal set!, so add a cast.
cast_type = slot_type;
}
return pool.alloc_element<StackSpillStoreElement>(m_value, m_size, m_offset, cast_type);
}
} // namespace decompiler