Refactor InstKind to move metadata from macros to the type. #4119
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.
This adds
DefinitionInfo
forDefine
-based configuration so that parameters are optional. It also makes it easier to provide the equivalent functions on bothDefinition
andDefine
.A common pattern used here is to change from a
switch
with in-linecase
s to instead havecase
s that call an overloaded function. What's happening here is that the instruction type is used to select an overload, and if an overload is not defined, a compiler error would result. Meanwhile, clusters of overloads are being defined usingrequires
-based templating, so that equivalent implementations are not copied. This addresses a limitation of a vanillaswitch
approach where it's hard to have redundant cases using conditional logic, while also getting compiler errors when adding newInstKind
entries, which had been a significant part of why we used macros previously.This starts hitting some odd clang-format edge cases causing
CARBON_KIND_SWITCH(inst){
(missing space), which I haven't seen before. AddingCARBON_KIND_SWITCH
to .clang-format works around it.