[PATCH] D117448: [NFC][SDNode] Use `StringSwitch` instead of `if`
Shao-Ce SUN via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 16 18:52:57 PST 2022
achieveartificialintelligence created this revision.
achieveartificialintelligence added reviewers: bogner, aditya_nandakumar, volkan, aemerson, paquette, nhaehnle.
achieveartificialintelligence requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117448
Files:
llvm/utils/TableGen/SDNodeProperties.cpp
Index: llvm/utils/TableGen/SDNodeProperties.cpp
===================================================================
--- llvm/utils/TableGen/SDNodeProperties.cpp
+++ llvm/utils/TableGen/SDNodeProperties.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "SDNodeProperties.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/TableGen/Error.h"
#include "llvm/TableGen/Record.h"
@@ -15,34 +16,22 @@
unsigned llvm::parseSDPatternOperatorProperties(Record *R) {
unsigned Properties = 0;
for (Record *Property : R->getValueAsListOfDefs("Properties")) {
- if (Property->getName() == "SDNPCommutative") {
- Properties |= 1 << SDNPCommutative;
- } else if (Property->getName() == "SDNPAssociative") {
- Properties |= 1 << SDNPAssociative;
- } else if (Property->getName() == "SDNPHasChain") {
- Properties |= 1 << SDNPHasChain;
- } else if (Property->getName() == "SDNPOutGlue") {
- Properties |= 1 << SDNPOutGlue;
- } else if (Property->getName() == "SDNPInGlue") {
- Properties |= 1 << SDNPInGlue;
- } else if (Property->getName() == "SDNPOptInGlue") {
- Properties |= 1 << SDNPOptInGlue;
- } else if (Property->getName() == "SDNPMayStore") {
- Properties |= 1 << SDNPMayStore;
- } else if (Property->getName() == "SDNPMayLoad") {
- Properties |= 1 << SDNPMayLoad;
- } else if (Property->getName() == "SDNPSideEffect") {
- Properties |= 1 << SDNPSideEffect;
- } else if (Property->getName() == "SDNPMemOperand") {
- Properties |= 1 << SDNPMemOperand;
- } else if (Property->getName() == "SDNPVariadic") {
- Properties |= 1 << SDNPVariadic;
- } else {
+ Properties |= 1 << StringSwitch<unsigned>(Property->getName())
+ .Case("SDNPCommutative", SDNPCommutative)
+ .Case("SDNPAssociative", SDNPAssociative)
+ .Case("SDNPHasChain", SDNPHasChain)
+ .Case("SDNPOutGlue", SDNPOutGlue)
+ .Case("SDNPInGlue", SDNPInGlue)
+ .Case("SDNPOptInGlue", SDNPOptInGlue)
+ .Case("SDNPMayStore", SDNPMayStore)
+ .Case("SDNPMayLoad", SDNPMayLoad)
+ .Case("SDNPSideEffect", SDNPSideEffect)
+ .Case("SDNPMemOperand", SDNPMemOperand)
+ .Case("SDNPVariadic", SDNPVariadic);
+ if (!Properties)
PrintFatalError(R->getLoc(), "Unknown SD Node property '" +
Property->getName() + "' on node '" +
R->getName() + "'!");
- }
}
-
return Properties;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117448.400417.patch
Type: text/x-patch
Size: 2765 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220117/7461bb63/attachment.bin>
More information about the llvm-commits
mailing list