[TableGen] Avoid emitting a switch that only contains a default.#177391
Merged
[TableGen] Avoid emitting a switch that only contains a default.#177391
Conversation
Addresses post commit feedback from llvm#174471
Member
|
@llvm/pr-subscribers-tablegen @llvm/pr-subscribers-llvm-selectiondag Author: Craig Topper (topperc) ChangesAddresses post commit feedback from #174471 Full diff: https://github.com/llvm/llvm-project/pull/177391.diff 1 Files Affected:
diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
index eaecccf215342..0ab19d686714f 100644
--- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
@@ -1364,19 +1364,23 @@ void MatcherTableEmitter::EmitValueTypeFunction(raw_ostream &OS) {
for (const auto &[VTs, Idx] : ValueTypeMap) {
OS << " case " << (Idx - 1) << ":\n";
- OS << " switch (HwMode) {\n";
- if (!VTs.hasDefault())
- OS << " default:\n return MVT();\n";
- for (const auto [Mode, VT] : VTs) {
- if (Mode == DefaultMode)
- OS << " default:\n";
- else
- OS << " case " << Mode << ":\n";
- OS << " return " << getEnumName(VT) << ";\n";
- }
+ if (VTs.isSimple()) {
+ OS << " return " << getEnumName(VTs.getSimple()) << ";\n";
+ } else {
+ OS << " switch (HwMode) {\n";
+ if (!VTs.hasDefault())
+ OS << " default:\n return MVT();\n";
+ for (const auto [Mode, VT] : VTs) {
+ if (Mode == DefaultMode)
+ OS << " default:\n";
+ else
+ OS << " case " << Mode << ":\n";
+ OS << " return " << getEnumName(VT) << ";\n";
+ }
- OS << " }\n";
- OS << " break;\n";
+ OS << " }\n";
+ OS << " break;\n";
+ }
}
OS << " }\n";
|
arsenm
approved these changes
Jan 22, 2026
Contributor
arsenm
left a comment
There was a problem hiding this comment.
Bad warning to have enabled on generated code but ok
arichardson
approved these changes
Jan 22, 2026
Harrish92
pushed a commit
to Harrish92/llvm-project
that referenced
this pull request
Jan 23, 2026
…m#177391) Addresses post commit feedback from llvm#174471
Harrish92
pushed a commit
to Harrish92/llvm-project
that referenced
this pull request
Jan 24, 2026
…m#177391) Addresses post commit feedback from llvm#174471
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.
Addresses post commit feedback from #174471