Rewrite MIR#170
Draft
dcbaker wants to merge 120 commits into
Draft
Conversation
Let's just try again, with a new attempt to write an SSA based intermediate IR, with some of the knowledge gleaned from the previous attempt.
This will give us a way to represent the state of the IR at each pass in a way that is both relatively human readable, and also in a format that a machine could (in theory) de-serialize
Message is a distinct enough type of thing in Meson it gets it's own implementation. It's might be a pure side effect (print this message), it might also cause the program to abort.
I'm not sure how I feel about this, I kinda want to keep the `InstructionType` variant small and simple.
So we don't leak parser internals
None of this works, yeah
This prints prettier code
I'm going to represent this as a function instead
The idea here is that as we can identify the namespace of the function, we can set this enum and then use it to quickly look up what the function is by using case statements instead of having to do complex string matching. The names remain because they are nice for human readability
These can be written as `not x == y` and `not x in y`, which saves us some opcodes in our FunctionId
We need the shared pointers sometimes, and the only way to get that is from the CFG itself. This also removes the Node iterator, which was broken when not called from the root node anyway
This is the first step to allowing us to iterate from any point on the graph.
This will allow us to write a faster and more flexible iterator
Using our depth we can iterate from any point on the graph, since we have the depth to know when we have reached a peer or predecessor level node of our starting point. We should also now be able to implement a reverse iterator very easily.
This time I have a different idea. If the owning structure is a vector, then we can sort that vector. This means we can actually do a linear walk iteration by sorting ahead of time, and this walk would work in both the forward and backward direction, while not requiring as much special handling, maybe not even needing the special end node. The trick to this is that we then have to keep the vector in order, top to bottom, left to right.
The BasicBlock was only holding a list of instructions, It just didn't make sense to have it anymore.
BasicBlock is dead, long live BasicBlock!
Because this will make use-def and def-use chains much simpler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There's a whole bunch of issues with the current MIR implementation, this is an attempt to rewrite MIR to fix that.
Currently this is enough that most projects can be converted to MIR, and most concepts can be represented. There are still a number of missing things: