[llvm] f69baa4 - [TableGen] Minor tweak to AssemblerCondDag evaluation to be more consistent with other dags. NFC
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 28 21:27:21 PST 2023
Author: Craig Topper
Date: 2023-02-28T21:26:57-08:00
New Revision: f69baa419a63039e36587cf608c04077c6d9cc88
URL: https://github.com/llvm/llvm-project/commit/f69baa419a63039e36587cf608c04077c6d9cc88
DIFF: https://github.com/llvm/llvm-project/commit/f69baa419a63039e36587cf608c04077c6d9cc88.diff
LOG: [TableGen] Minor tweak to AssemblerCondDag evaluation to be more consistent with other dags. NFC
Instead of using getAsString on the dag operator, check if the operator
is a DefInit and then get the name of the Def.
Added:
Modified:
llvm/utils/TableGen/AsmWriterEmitter.cpp
llvm/utils/TableGen/SubtargetFeatureInfo.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp
index 6c1a2df1fa793..f905993ac78b6 100644
--- a/llvm/utils/TableGen/AsmWriterEmitter.cpp
+++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp
@@ -996,7 +996,10 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
for (Record *const R : ReqFeatures) {
const DagInit *D = R->getValueAsDag("AssemblerCondDag");
- std::string CombineType = D->getOperator()->getAsString();
+ auto *Op = dyn_cast<DefInit>(D->getOperator());
+ if (!Op)
+ PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!");
+ StringRef CombineType = Op->getDef()->getName();
if (CombineType != "any_of" && CombineType != "all_of")
PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!");
if (D->getNumArgs() == 0)
diff --git a/llvm/utils/TableGen/SubtargetFeatureInfo.cpp b/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
index 1abcf485f8564..7579fabfbb2c2 100644
--- a/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
+++ b/llvm/utils/TableGen/SubtargetFeatureInfo.cpp
@@ -117,16 +117,19 @@ static bool emitFeaturesAux(StringRef TargetName, const Init &Val,
return false;
}
if (auto *D = dyn_cast<DagInit>(&Val)) {
- std::string Op = D->getOperator()->getAsString();
- if (Op == "not" && D->getNumArgs() == 1) {
+ auto *Op = dyn_cast<DefInit>(D->getOperator());
+ if (!Op)
+ return true;
+ StringRef OpName = Op->getDef()->getName();
+ if (OpName == "not" && D->getNumArgs() == 1) {
OS << '!';
return emitFeaturesAux(TargetName, *D->getArg(0), true, OS);
}
- if ((Op == "any_of" || Op == "all_of") && D->getNumArgs() > 0) {
+ if ((OpName == "any_of" || OpName == "all_of") && D->getNumArgs() > 0) {
bool Paren = D->getNumArgs() > 1 && std::exchange(ParenIfBinOp, true);
if (Paren)
OS << '(';
- ListSeparator LS(Op == "any_of" ? " || " : " && ");
+ ListSeparator LS(OpName == "any_of" ? " || " : " && ");
for (auto *Arg : D->getArgs()) {
OS << LS;
if (emitFeaturesAux(TargetName, *Arg, ParenIfBinOp, OS))
More information about the llvm-commits
mailing list