This PR includes two things: labels and limit refactor. Let's start with the meat of the issue.
Labels
Labels are allocated the same way you would allocate a new register, but instead of incrementing, you decrement.
Insn that depend on a label are appended to the list of that label (unresolved_insns).
The list of dependent insn are accesed through label.abs - 1 (label_to_index helper).
List of dependents is cleared once resolved to ensure we don't resolve more than once.
O(1)
Added some extra type definitions to help distinguish parts like BranchOffset which can be negative and InsnReference which is a index to the list of insns.
Api
the api is quite simple
allocate_label() -> creates a new label with empty list of dependents
add_labe(label, InsnReference) -> add insn dependent on label
resolve_label(label, BranchOffset) -> switch labels to the input offset
Limit refactor
Now limit information is gathered on a centralized struct (LimitInfo)instead of sparse variables that confused the flow. If this is LimitInfo, do stuff with it.
This PR includes two things: labels and limit refactor. Let's start with the meat of the issue.
Labels
unresolved_insns
).label.abs - 1
(label_to_index
helper).Added some extra type definitions to help distinguish parts like
BranchOffset
which can be negative andInsnReference
which is a index to the list ofinsns
.Api
the api is quite simple
Limit refactor
Now limit information is gathered on a centralized struct (
LimitInfo
)instead of sparse variables that confused the flow. If this is LimitInfo, do stuff with it.