DescriptionCodeGen: rewrite implementation [3/3]
This is a complete rewrite of CodeGen from scratch, taking advantage
of the fact that a while back we changed PolicyCompiler to not require
modifying instructions after they're created. In particular, we no
longer need topological sorting because the MakeInstruction call order
implicitly sorts instructions for us. Additionally, we no longer need
to compute basic blocks even because they were only needed for
sorting.
It turns out that a simple greedy algorithm with basic memoization
suffices for flattening the instruction graph, and we only really need
to worry about inserting "jump" instructions when the targets are too
far away. With just this, we're able to emit programs that are just
as efficient as the old CodeGen implementation did.
As a bonus, the new code generator is now fully deterministic because
it doesn't create any sets or maps using pointer values as keys.
BUG=414363
Committed: https://crrev.com/1fe9104fec2241de3cb547f0580ebb24edc13613
Cr-Commit-Position: refs/heads/master@{#304977}
Patch Set 1 #Patch Set 2 : Refresh #Patch Set 3 : Undo spurious comment change #Patch Set 4 : Sync and add extra code folding unit test #Patch Set 5 : Might as well use ProgramTest here too #Patch Set 6 : Use size_t instead of uint32_t as semantically appropriate #
Total comments: 10
Patch Set 7 : Respond to rickyz feedback #
Total comments: 17
Patch Set 8 : Moar comments #
Total comments: 12
Patch Set 9 : Respond to jln feedback #
Messages
Total messages: 14 (2 generated)
|