mirror of
https://github.com/open-goal/jak-project
synced 2026-07-11 07:25:37 -04:00
[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:
@@ -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
|
||||
Reference in New Issue
Block a user