aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp')
-rw-r--r--llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp49
1 files changed, 24 insertions, 25 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 4582478..a77e247 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -1255,28 +1255,28 @@ bool TreePredicateFn::isAtomicOrderingWeakerThanRelease() const {
false);
}
Record *TreePredicateFn::getMemoryVT() const {
- Record *R = getOrigPatFragRecord()->getRecord();
+ const Record *R = getOrigPatFragRecord()->getRecord();
if (R->isValueUnset("MemoryVT"))
return nullptr;
return R->getValueAsDef("MemoryVT");
}
ListInit *TreePredicateFn::getAddressSpaces() const {
- Record *R = getOrigPatFragRecord()->getRecord();
+ const Record *R = getOrigPatFragRecord()->getRecord();
if (R->isValueUnset("AddressSpaces"))
return nullptr;
return R->getValueAsListInit("AddressSpaces");
}
int64_t TreePredicateFn::getMinAlignment() const {
- Record *R = getOrigPatFragRecord()->getRecord();
+ const Record *R = getOrigPatFragRecord()->getRecord();
if (R->isValueUnset("MinAlignment"))
return 0;
return R->getValueAsInt("MinAlignment");
}
Record *TreePredicateFn::getScalarMemoryVT() const {
- Record *R = getOrigPatFragRecord()->getRecord();
+ const Record *R = getOrigPatFragRecord()->getRecord();
if (R->isValueUnset("ScalarMemoryVT"))
return nullptr;
return R->getValueAsDef("ScalarMemoryVT");
@@ -1390,7 +1390,7 @@ std::string TreePredicateFn::getCodeToRunOnSDNode() const {
if (Tree->isLeaf())
TreeClassName = "SDNode";
else {
- Record *Op = Tree->getOperator();
+ const Record *Op = Tree->getOperator();
const SDNodeInfo &Info = PatFragRec->getDAGPatterns().getSDNodeInfo(Op);
TreeClassName = Info.getSDClassName();
}
@@ -1848,7 +1848,8 @@ MVT::SimpleValueType SDNodeInfo::getKnownType(unsigned ResNo) const {
// TreePatternNode implementation
//
-static unsigned GetNumNodeResults(Record *Operator, CodeGenDAGPatterns &CDP) {
+static unsigned GetNumNodeResults(const Record *Operator,
+ CodeGenDAGPatterns &CDP) {
if (Operator->getName() == "set" || Operator->getName() == "implicit")
return 0; // All return nothing.
@@ -2077,7 +2078,7 @@ void TreePatternNode::InlinePatternFragments(
return;
}
- Record *Op = getOperator();
+ const Record *Op = getOperator();
if (!Op->isSubClassOf("PatFrags")) {
if (getNumChildren() == 0) {
@@ -2340,7 +2341,7 @@ TreePatternNode::getIntrinsicInfo(const CodeGenDAGPatterns &CDP) const {
/// return the ComplexPattern information, otherwise return null.
const ComplexPattern *
TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const {
- Record *Rec;
+ const Record *Rec;
if (isLeaf()) {
DefInit *DI = dyn_cast<DefInit>(getLeafValue());
if (!DI)
@@ -2793,7 +2794,7 @@ bool TreePatternNode::canPatternMatch(std::string &Reason,
// TreePattern implementation
//
-TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
+TreePattern::TreePattern(const Record *TheRec, ListInit *RawPat, bool isInput,
CodeGenDAGPatterns &cdp)
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false),
Infer(*this) {
@@ -2801,15 +2802,15 @@ TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
Trees.push_back(ParseTreePattern(I, ""));
}
-TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput,
+TreePattern::TreePattern(const Record *TheRec, DagInit *Pat, bool isInput,
CodeGenDAGPatterns &cdp)
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false),
Infer(*this) {
Trees.push_back(ParseTreePattern(Pat, ""));
}
-TreePattern::TreePattern(Record *TheRec, TreePatternNodePtr Pat, bool isInput,
- CodeGenDAGPatterns &cdp)
+TreePattern::TreePattern(const Record *TheRec, TreePatternNodePtr Pat,
+ bool isInput, CodeGenDAGPatterns &cdp)
: TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false),
Infer(*this) {
Trees.push_back(Pat);
@@ -3389,7 +3390,7 @@ static bool HandleUse(TreePattern &I, TreePatternNodePtr Pat,
return false;
}
- Record *Rec;
+ const Record *Rec;
if (Pat->isLeaf()) {
DefInit *DI = dyn_cast<DefInit>(Pat->getLeafValue());
if (!DI)
@@ -3408,7 +3409,7 @@ static bool HandleUse(TreePattern &I, TreePatternNodePtr Pat,
Slot = Pat;
return true;
}
- Record *SlotRec;
+ const Record *SlotRec;
if (Slot->isLeaf()) {
SlotRec = cast<DefInit>(Slot->getLeafValue())->getDef();
} else {
@@ -3633,7 +3634,8 @@ public:
};
static bool InferFromPattern(CodeGenInstruction &InstInfo,
- const InstAnalyzer &PatInfo, Record *PatDef) {
+ const InstAnalyzer &PatInfo,
+ const Record *PatDef) {
bool Error = false;
// Remember where InstInfo got its flags.
@@ -3729,7 +3731,7 @@ static bool hasNullFragReference(ListInit *LI) {
/// Get all the instructions in a tree.
static void getInstructionsInTree(TreePatternNode &Tree,
- SmallVectorImpl<Record *> &Instrs) {
+ SmallVectorImpl<const Record *> &Instrs) {
if (Tree.isLeaf())
return;
if (Tree.getOperator()->isSubClassOf("Instruction"))
@@ -3935,8 +3937,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI,
// Create and insert the instruction.
// FIXME: InstImpResults should not be part of DAGInstruction.
- Record *R = I.getRecord();
- DAGInsts.try_emplace(R, std::move(Results), std::move(Operands),
+ DAGInsts.try_emplace(I.getRecord(), std::move(Results), std::move(Operands),
std::move(InstImpResults), SrcPattern, ResultPattern);
LLVM_DEBUG(I.dump());
@@ -3989,9 +3990,7 @@ void CodeGenDAGPatterns::ParseInstructions() {
}
// If we can, convert the instructions to be patterns that are matched!
- for (auto &Entry : Instructions) {
- Record *Instr = Entry.first;
- DAGInstruction &TheInst = Entry.second;
+ for (const auto &[Instr, TheInst] : Instructions) {
TreePatternNodePtr SrcPattern = TheInst.getSrcPattern();
TreePatternNodePtr ResultPattern = TheInst.getResultPattern();
@@ -4078,7 +4077,7 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
for (const PatternToMatch &PTM : ptms()) {
// We can only infer from single-instruction patterns, otherwise we won't
// know which instruction should get the flags.
- SmallVector<Record *, 8> PatInstrs;
+ SmallVector<const Record *, 8> PatInstrs;
getInstructionsInTree(PTM.getDstPattern(), PatInstrs);
if (PatInstrs.size() != 1)
continue;
@@ -4135,7 +4134,7 @@ void CodeGenDAGPatterns::InferInstructionFlags() {
void CodeGenDAGPatterns::VerifyInstructionFlags() {
unsigned Errors = 0;
for (const PatternToMatch &PTM : ptms()) {
- SmallVector<Record *, 8> Instrs;
+ SmallVector<const Record *, 8> Instrs;
getInstructionsInTree(PTM.getDstPattern(), Instrs);
if (Instrs.empty())
continue;
@@ -4245,7 +4244,7 @@ static TreePatternNodePtr PromoteXForms(TreePatternNodePtr N) {
}
void CodeGenDAGPatterns::ParseOnePattern(
- Record *TheDef, TreePattern &Pattern, TreePattern &Result,
+ const Record *TheDef, TreePattern &Pattern, TreePattern &Result,
const std::vector<Record *> &InstImpResults, bool ShouldIgnore) {
// Inline pattern fragments and expand multiple alternatives.
@@ -4591,7 +4590,7 @@ GatherChildrenOfAssociativeOpcode(TreePatternNodePtr N,
std::vector<TreePatternNodePtr> &Children) {
assert(N->getNumChildren() == 2 &&
"Associative but doesn't have 2 children!");
- Record *Operator = N->getOperator();
+ const Record *Operator = N->getOperator();
// Only permit raw nodes.
if (!N->getName().empty() || !N->getPredicateCalls().empty() ||