-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit 5e1ca5c
committed
[region-isolation] Make instruction translation use a covered visitor and add a TranslationSemantics enum to guide users updating the code.
More specifically this patch does the following:
* Rather than having a large switch with misc code, I changed the partition op
translator to use a visitor that defines a declaration for all SILInstructions
and in translateSILInstruction visits all such instructions. This ensures via
the linker that when ever a new SILInstruction is added, a link error occurs.
* Rather than just have misc translation code from the switch in the visitor, I
created a new enum called TranslationSemantics that describes the semantics for
instructions and made it so that the visitor methods return an instance of the
enum. This enum is then switched over to determine the action to perform. This
handles the vast majority of cases and allows for a reader of the translation
code to read a small amount of code (< 20-30 lines) to understand at a glance
the available semantics rather than having to read a huge switch. To make it
easy to implement the constant semantics that most instructions have, I followed
what we did in OperandOwnership (the model that I followed here) by using
preprocessor macros to define explicitly the semantics for each instruction. In
the case where special handling is needed, we can create a custom method, handle
the translation by hand, and then return TranslationSemantics::Special to signal
to the handling loop to just not do anything.1 parent 9858f39 commit 5e1ca5cCopy full SHA for 5e1ca5c
File tree
Expand file treeCollapse file tree
1 file changed
+638
-316
lines changedFilter options
- lib/SILOptimizer/Mandatory
Expand file treeCollapse file tree
1 file changed
+638
-316
lines changed
0 commit comments