aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-01-27 22:06:42 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-01-27 22:06:42 +0000
commit6f8fc217eaa12bf657be1c6468ed9938d10168b3 (patch)
treea1fd89b864d9b93e2ad68fe1dcf7afee2e3c8d76 /llvm/utils/TableGen
parent77fc4c146f0870ffb09c1afb823ccbe742c5e6ff (diff)
Diffstat (limited to 'llvm/utils/TableGen')
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.cpp2
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.h3
-rw-r--r--llvm/utils/TableGen/CodeGenIntrinsics.h1
-rw-r--r--llvm/utils/TableGen/CodeGenSchedule.h1
-rw-r--r--llvm/utils/TableGen/DAGISelMatcherOpt.cpp2
-rw-r--r--llvm/utils/TableGen/GlobalISel/GIMatchDag.h4
-rw-r--r--llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.h2
-rw-r--r--llvm/utils/TableGen/GlobalISel/GIMatchDagPredicateDependencyEdge.h1
-rw-r--r--llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp1
-rw-r--r--llvm/utils/TableGen/GlobalISel/GIMatchTree.h2
-rw-r--r--llvm/utils/TableGen/GlobalISelEmitter.cpp4
-rw-r--r--llvm/utils/TableGen/InstrInfoEmitter.cpp4
-rw-r--r--llvm/utils/TableGen/PredicateExpander.h2
-rw-r--r--llvm/utils/TableGen/RegisterBankEmitter.cpp2
-rw-r--r--llvm/utils/TableGen/SDNodeProperties.cpp42
-rw-r--r--llvm/utils/TableGen/SearchableTableEmitter.cpp6
-rw-r--r--llvm/utils/TableGen/X86DisassemblerTables.cpp2
-rw-r--r--llvm/utils/TableGen/X86ModRMFilters.h22
18 files changed, 40 insertions, 63 deletions
diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp
index 3933ce6e1106..78b698c31b2b 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/CodeGenInstruction.cpp
@@ -342,7 +342,7 @@ static void ParseConstraints(StringRef CStr, CGIOperandList &Ops, Record *Rec) {
}
void CGIOperandList::ProcessDisableEncoding(StringRef DisableEncoding) {
- while (1) {
+ while (true) {
StringRef OpName;
std::tie(OpName, DisableEncoding) = getToken(DisableEncoding, " ,\t");
if (OpName.empty()) break;
diff --git a/llvm/utils/TableGen/CodeGenInstruction.h b/llvm/utils/TableGen/CodeGenInstruction.h
index e35d2191ea45..e0ce5d433602 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.h
+++ b/llvm/utils/TableGen/CodeGenInstruction.h
@@ -13,6 +13,7 @@
#ifndef LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H
#define LLVM_UTILS_TABLEGEN_CODEGENINSTRUCTION_H
+#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MachineValueType.h"
#include "llvm/Support/SMLoc.h"
@@ -106,7 +107,7 @@ template <typename T> class ArrayRef;
/// DoNotEncode - Bools are set to true in this vector for each operand in
/// the DisableEncoding list. These should not be emitted by the code
/// emitter.
- std::vector<bool> DoNotEncode;
+ BitVector DoNotEncode;
/// MIOperandInfo - Default MI operand type. Note an operand may be made
/// up of multiple MI operands.
diff --git a/llvm/utils/TableGen/CodeGenIntrinsics.h b/llvm/utils/TableGen/CodeGenIntrinsics.h
index dbfad3bf6b17..b005a5866f80 100644
--- a/llvm/utils/TableGen/CodeGenIntrinsics.h
+++ b/llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -21,7 +21,6 @@
namespace llvm {
class Record;
class RecordKeeper;
-class CodeGenTarget;
struct CodeGenIntrinsic {
Record *TheDef; // The actual record defining this intrinsic.
diff --git a/llvm/utils/TableGen/CodeGenSchedule.h b/llvm/utils/TableGen/CodeGenSchedule.h
index 9020447c940b..a331a30b51a8 100644
--- a/llvm/utils/TableGen/CodeGenSchedule.h
+++ b/llvm/utils/TableGen/CodeGenSchedule.h
@@ -28,7 +28,6 @@ namespace llvm {
class CodeGenTarget;
class CodeGenSchedModels;
class CodeGenInstruction;
-class CodeGenRegisterClass;
using RecVec = std::vector<Record*>;
using RecIter = std::vector<Record*>::const_iterator;
diff --git a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
index 6746fdd676a7..4273bd69b87d 100644
--- a/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/llvm/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -250,7 +250,7 @@ static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) {
// current sets of nodes and this node don't matter. Look past it to see if
// we can merge anything else into this matching group.
unsigned Scan = OptionIdx;
- while (1) {
+ while (true) {
// If we ran out of stuff to scan, we're done.
if (Scan == e) break;
diff --git a/llvm/utils/TableGen/GlobalISel/GIMatchDag.h b/llvm/utils/TableGen/GlobalISel/GIMatchDag.h
index 567580540877..37570648cad1 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchDag.h
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchDag.h
@@ -84,9 +84,7 @@ protected:
bool HasPostMatchPredicate = false;
public:
- GIMatchDag(GIMatchDagContext &Ctx)
- : Ctx(Ctx), InstrNodes(), PredicateNodes(), Edges(),
- PredicateDependencies() {}
+ GIMatchDag(GIMatchDagContext &Ctx) : Ctx(Ctx) {}
GIMatchDag(const GIMatchDag &) = delete;
GIMatchDagContext &getContext() const { return Ctx; }
diff --git a/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.h b/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.h
index 4a07767a2e19..0c39b50442b4 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.h
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchDagInstr.h
@@ -61,7 +61,7 @@ protected:
/// For debugging purposes, it's helpful to have access to a description of
/// the Opcode. However, this object shouldn't use it for more than debugging
/// output since predicates are expected to be handled outside the DAG.
- CodeGenInstruction *OpcodeAnnotation = 0;
+ CodeGenInstruction *OpcodeAnnotation = nullptr;
/// When true, this instruction will be a starting point for a match attempt.
bool IsMatchRoot = false;
diff --git a/llvm/utils/TableGen/GlobalISel/GIMatchDagPredicateDependencyEdge.h b/llvm/utils/TableGen/GlobalISel/GIMatchDagPredicateDependencyEdge.h
index 865455fe4e4d..9552adc5c625 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchDagPredicateDependencyEdge.h
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchDagPredicateDependencyEdge.h
@@ -14,7 +14,6 @@
namespace llvm {
class GIMatchDag;
class GIMatchDagInstr;
-class GIMatchDagEdge;
class GIMatchDagPredicate;
/// Represents a dependency that must be met to evaluate a predicate.
diff --git a/llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp b/llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
index d08a83333c30..00d57404b069 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchTree.cpp
@@ -82,7 +82,6 @@ GIMatchTreeBuilderLeafInfo::GIMatchTreeBuilderLeafInfo(
GIMatchTreeBuilder &Builder, StringRef Name, unsigned RootIdx,
const GIMatchDag &MatchDag, void *Data)
: Builder(Builder), Info(Name, RootIdx, Data), MatchDag(MatchDag),
- InstrNodeToInfo(),
RemainingInstrNodes(BitVector(MatchDag.getNumInstrNodes(), true)),
RemainingEdges(BitVector(MatchDag.getNumEdges(), true)),
RemainingPredicates(BitVector(MatchDag.getNumPredicates(), true)),
diff --git a/llvm/utils/TableGen/GlobalISel/GIMatchTree.h b/llvm/utils/TableGen/GlobalISel/GIMatchTree.h
index bf41a2e0e234..56df37731c09 100644
--- a/llvm/utils/TableGen/GlobalISel/GIMatchTree.h
+++ b/llvm/utils/TableGen/GlobalISel/GIMatchTree.h
@@ -588,7 +588,7 @@ class GIMatchTreeVRegDefPartitioner : public GIMatchTreePartitioner {
unsigned OpIdx;
std::vector<BitVector> TraversedEdges;
DenseMap<unsigned, unsigned> ResultToPartition;
- std::vector<bool> PartitionToResult;
+ BitVector PartitionToResult;
void addToPartition(bool Result, unsigned LeafIdx);
diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp
index 7b1bd41a951b..25bc0adc2a81 100644
--- a/llvm/utils/TableGen/GlobalISelEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp
@@ -883,9 +883,7 @@ protected:
public:
RuleMatcher(ArrayRef<SMLoc> SrcLoc)
- : Matchers(), Actions(), InsnVariableIDs(), MutatableInsns(),
- DefinedOperands(), NextInsnVarID(0), NextOutputInsnID(0),
- NextTempRegID(0), SrcLoc(SrcLoc), ComplexSubOperands(),
+ : NextInsnVarID(0), NextOutputInsnID(0), NextTempRegID(0), SrcLoc(SrcLoc),
RuleID(NextRuleID++) {}
RuleMatcher(RuleMatcher &&Other) = default;
RuleMatcher &operator=(RuleMatcher &&Other) = default;
diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp
index aee887a906e5..3c92aa0cc27a 100644
--- a/llvm/utils/TableGen/InstrInfoEmitter.cpp
+++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp
@@ -863,13 +863,13 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
OS << "#ifdef GET_INSTRINFO_HELPER_DECLS\n";
OS << "#undef GET_INSTRINFO_HELPER_DECLS\n\n";
- emitTIIHelperMethods(OS, TargetName, /* ExpandDefintion = */false);
+ emitTIIHelperMethods(OS, TargetName, /* ExpandDefinition = */ false);
OS << "\n";
OS << "#endif // GET_INSTRINFO_HELPER_DECLS\n\n";
OS << "#ifdef GET_INSTRINFO_HELPERS\n";
OS << "#undef GET_INSTRINFO_HELPERS\n\n";
- emitTIIHelperMethods(OS, TargetName, /* ExpandDefintion = */true);
+ emitTIIHelperMethods(OS, TargetName, /* ExpandDefinition = */ true);
OS << "#endif // GET_INSTRINFO_HELPERS\n\n";
OS << "#ifdef GET_INSTRINFO_CTOR_DTOR\n";
diff --git a/llvm/utils/TableGen/PredicateExpander.h b/llvm/utils/TableGen/PredicateExpander.h
index 29cca92d902c..9e7a4a3925ac 100644
--- a/llvm/utils/TableGen/PredicateExpander.h
+++ b/llvm/utils/TableGen/PredicateExpander.h
@@ -111,7 +111,7 @@ class STIPredicateExpander : public PredicateExpander {
public:
STIPredicateExpander(StringRef Target)
- : PredicateExpander(Target), ClassPrefix(), ExpandDefinition(false) {}
+ : PredicateExpander(Target), ExpandDefinition(false) {}
bool shouldExpandDefinition() const { return ExpandDefinition; }
StringRef getClassPrefix() const { return ClassPrefix; }
diff --git a/llvm/utils/TableGen/RegisterBankEmitter.cpp b/llvm/utils/TableGen/RegisterBankEmitter.cpp
index 0725657150f8..61f71309b6fb 100644
--- a/llvm/utils/TableGen/RegisterBankEmitter.cpp
+++ b/llvm/utils/TableGen/RegisterBankEmitter.cpp
@@ -42,7 +42,7 @@ private:
public:
RegisterBank(const Record &TheDef)
- : TheDef(TheDef), RCs(), RCWithLargestRegsSize(nullptr) {}
+ : TheDef(TheDef), RCWithLargestRegsSize(nullptr) {}
/// Get the human-readable name for the bank.
StringRef getName() const { return TheDef.getValueAsString("Name"); }
diff --git a/llvm/utils/TableGen/SDNodeProperties.cpp b/llvm/utils/TableGen/SDNodeProperties.cpp
index 1843a78aa3cf..2aec41aac625 100644
--- a/llvm/utils/TableGen/SDNodeProperties.cpp
+++ b/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,25 @@ using namespace llvm;
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 {
+ auto Offset = 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)
+ .Default(-1u);
+ if (Offset != -1u)
+ Properties |= 1 << Offset;
+ else
PrintFatalError(R->getLoc(), "Unknown SD Node property '" +
Property->getName() + "' on node '" +
R->getName() + "'!");
- }
}
-
return Properties;
}
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp
index 7803848aafc4..327b90d59db6 100644
--- a/llvm/utils/TableGen/SearchableTableEmitter.cpp
+++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp
@@ -649,6 +649,12 @@ void SearchableTableEmitter::collectTableEntries(
Field.IsInstruction = true;
}
}
+
+ SearchIndex Idx;
+ std::copy(Table.Fields.begin(), Table.Fields.end(),
+ std::back_inserter(Idx.Fields));
+ std::sort(Table.Entries.begin(), Table.Entries.end(),
+ [&](Record *LHS, Record *RHS) { return compareBy(LHS, RHS, Idx); });
}
void SearchableTableEmitter::run(raw_ostream &OS) {
diff --git a/llvm/utils/TableGen/X86DisassemblerTables.cpp b/llvm/utils/TableGen/X86DisassemblerTables.cpp
index d1a9ecb06a2b..90e71a354d17 100644
--- a/llvm/utils/TableGen/X86DisassemblerTables.cpp
+++ b/llvm/utils/TableGen/X86DisassemblerTables.cpp
@@ -657,7 +657,7 @@ static const char* stringForDecisionType(ModRMDecisionType dt) {
}
DisassemblerTables::DisassemblerTables() {
- for (unsigned i = 0; i < array_lengthof(Tables); i++)
+ for (unsigned i = 0; i < llvm::array_lengthof(Tables); i++)
Tables[i] = std::make_unique<ContextDecision>();
HasConflicts = false;
diff --git a/llvm/utils/TableGen/X86ModRMFilters.h b/llvm/utils/TableGen/X86ModRMFilters.h
index f0b8af5fb82a..e2d0907b4f8b 100644
--- a/llvm/utils/TableGen/X86ModRMFilters.h
+++ b/llvm/utils/TableGen/X86ModRMFilters.h
@@ -73,10 +73,7 @@ public:
/// otherwise. The name r derives from the fact that the mod
/// bits indicate whether the R/M bits [bits 2-0] signify a
/// register or a memory operand.
- ModFilter(bool r) :
- ModRMFilter(),
- R(r) {
- }
+ ModFilter(bool r) : R(r) {}
bool accepts(uint8_t modRM) const override {
return (R == ((modRM & 0xc0) == 0xc0));
@@ -95,11 +92,7 @@ public:
/// \param r True if the mod field must be set to 11; false otherwise.
/// The name is explained at ModFilter.
/// \param nnn The required value of the nnn field.
- ExtendedFilter(bool r, uint8_t nnn) :
- ModRMFilter(),
- R(r),
- NNN(nnn) {
- }
+ ExtendedFilter(bool r, uint8_t nnn) : R(r), NNN(nnn) {}
bool accepts(uint8_t modRM) const override {
return (((R && ((modRM & 0xc0) == 0xc0)) ||
@@ -120,11 +113,7 @@ public:
/// \param r True if the mod field must be set to 11; false otherwise.
/// The name is explained at ModFilter.
/// \param nnn The required value of the nnn field.
- ExtendedRMFilter(bool r, uint8_t nnn) :
- ModRMFilter(),
- R(r),
- NNN(nnn) {
- }
+ ExtendedRMFilter(bool r, uint8_t nnn) : R(r), NNN(nnn) {}
bool accepts(uint8_t modRM) const override {
return ((R && ((modRM & 0xc0) == 0xc0)) &&
@@ -140,10 +129,7 @@ public:
/// Constructor
///
/// \param modRM The required value of the full ModR/M byte.
- ExactFilter(uint8_t modRM) :
- ModRMFilter(),
- ModRM(modRM) {
- }
+ ExactFilter(uint8_t modRM) : ModRM(modRM) {}
bool accepts(uint8_t modRM) const override {
return (ModRM == modRM);