Make serialising Yk IR instructions more flexible. #137
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.
Initially, each LLVM IR instruction had to be lowered to exactly one Yk IR instruction. Why? Because it was easy to implement.
Later we realised we needed to skip certain LLVM instructions (e.g. debug calls).
At this point we added complexity. Due to the way the deserialiser works, we need to emit an instruction count field before emitting the instructions themselves. Therefore we had to first count how many instructions would be emitted in an initial loop, emit this count, then emit the instructions themselves in a second loop.
This change removes the need for the first loop by "patching up" a placeholder instruction count field once the number of instructions is known.
In turn this simplifies the code quite a bit, making it easier to maintain, but also will make it easier for one LLVM instruction to be lowered to more than one Yk IR instruction. For example, we might opt to lower an LLVM switch instruction into a series of Yk IR conditional instructions.
No functional change. No runtime changes required.