diff options
author | Rahul Joshi <rjoshi@nvidia.com> | 2024-09-23 13:07:31 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-23 13:07:31 -0700 |
commit | 3138eb500c9462bcb6899088d49644adb4d90f62 (patch) | |
tree | 5c2f5e11b02e5158eb0418a032add010d927674c /llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | |
parent | 706e71076e0276747e7ae94e3f8a7f73a45e5b6e (diff) | |
download | llvm-3138eb500c9462bcb6899088d49644adb4d90f62.zip llvm-3138eb500c9462bcb6899088d49644adb4d90f62.tar.gz llvm-3138eb500c9462bcb6899088d49644adb4d90f62.tar.bz2 |
[LLVM][TableGen] Use const record pointers in TableGen/Common files (#109467)
Use const record pointers in TableGen/Common files.
This is a part of effort to have better const correctness in TableGen
backends:
https://discourse.llvm.org/t/psa-planned-changes-to-tablegen-getallderiveddefinitions-api-potential-downstream-breakages/81089
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp')
-rw-r--r-- | llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 158 |
1 files changed, 73 insertions, 85 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index fd80bc6..e8cf7e3 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -910,22 +910,16 @@ bool TreePredicateFn::hasPredCode() const { std::string TreePredicateFn::getPredCode() const { std::string Code; - if (!isLoad() && !isStore() && !isAtomic()) { - Record *MemoryVT = getMemoryVT(); - - if (MemoryVT) - PrintFatalError(getOrigPatFragRecord()->getRecord()->getLoc(), - "MemoryVT requires IsLoad or IsStore"); - } + if (!isLoad() && !isStore() && !isAtomic() && getMemoryVT()) + PrintFatalError(getOrigPatFragRecord()->getRecord()->getLoc(), + "MemoryVT requires IsLoad or IsStore"); if (!isLoad() && !isStore()) { if (isUnindexed()) PrintFatalError(getOrigPatFragRecord()->getRecord()->getLoc(), "IsUnindexed requires IsLoad or IsStore"); - Record *ScalarMemoryVT = getScalarMemoryVT(); - - if (ScalarMemoryVT) + if (getScalarMemoryVT()) PrintFatalError(getOrigPatFragRecord()->getRecord()->getLoc(), "ScalarMemoryVT requires IsLoad or IsStore"); } @@ -1016,15 +1010,15 @@ std::string TreePredicateFn::getPredCode() const { } if (isLoad() || isStore() || isAtomic()) { - if (ListInit *AddressSpaces = getAddressSpaces()) { + if (const ListInit *AddressSpaces = getAddressSpaces()) { Code += "unsigned AddrSpace = cast<MemSDNode>(N)->getAddressSpace();\n" " if ("; ListSeparator LS(" && "); - for (Init *Val : AddressSpaces->getValues()) { + for (const Init *Val : AddressSpaces->getValues()) { Code += LS; - IntInit *IntVal = dyn_cast<IntInit>(Val); + const IntInit *IntVal = dyn_cast<IntInit>(Val); if (!IntVal) { PrintFatalError(getOrigPatFragRecord()->getRecord()->getLoc(), "AddressSpaces element must be integer"); @@ -1043,9 +1037,7 @@ std::string TreePredicateFn::getPredCode() const { Code += "))\nreturn false;\n"; } - Record *MemoryVT = getMemoryVT(); - - if (MemoryVT) + if (const Record *MemoryVT = getMemoryVT()) Code += ("if (cast<MemSDNode>(N)->getMemoryVT() != MVT::" + MemoryVT->getName() + ") return false;\n") .str(); @@ -1129,9 +1121,7 @@ std::string TreePredicateFn::getPredCode() const { " if (!cast<StoreSDNode>(N)->isTruncatingStore()) return false;\n"; } - Record *ScalarMemoryVT = getScalarMemoryVT(); - - if (ScalarMemoryVT) + if (const Record *ScalarMemoryVT = getScalarMemoryVT()) Code += ("if (cast<" + SDNodeName + ">(N)->getMemoryVT().getScalarType() != MVT::" + ScalarMemoryVT->getName() + ") return false;\n") @@ -1254,14 +1244,14 @@ bool TreePredicateFn::isAtomicOrderingWeakerThanRelease() const { return isPredefinedPredicateEqualTo("IsAtomicOrderingReleaseOrStronger", false); } -Record *TreePredicateFn::getMemoryVT() const { +const Record *TreePredicateFn::getMemoryVT() const { const Record *R = getOrigPatFragRecord()->getRecord(); if (R->isValueUnset("MemoryVT")) return nullptr; return R->getValueAsDef("MemoryVT"); } -ListInit *TreePredicateFn::getAddressSpaces() const { +const ListInit *TreePredicateFn::getAddressSpaces() const { const Record *R = getOrigPatFragRecord()->getRecord(); if (R->isValueUnset("AddressSpaces")) return nullptr; @@ -1275,7 +1265,7 @@ int64_t TreePredicateFn::getMinAlignment() const { return R->getValueAsInt("MinAlignment"); } -Record *TreePredicateFn::getScalarMemoryVT() const { +const Record *TreePredicateFn::getScalarMemoryVT() const { const Record *R = getOrigPatFragRecord()->getRecord(); if (R->isValueUnset("ScalarMemoryVT")) return nullptr; @@ -1419,11 +1409,11 @@ std::string TreePredicateFn::getCodeToRunOnSDNode() const { static bool isImmAllOnesAllZerosMatch(const TreePatternNode &P) { if (!P.isLeaf()) return false; - DefInit *DI = dyn_cast<DefInit>(P.getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(P.getLeafValue()); if (!DI) return false; - Record *R = DI->getDef(); + const Record *R = DI->getDef(); return R->getName() == "immAllOnesV" || R->getName() == "immAllZerosV"; } @@ -1483,10 +1473,10 @@ int PatternToMatch::getPatternComplexity(const CodeGenDAGPatterns &CGP) const { } void PatternToMatch::getPredicateRecords( - SmallVectorImpl<Record *> &PredicateRecs) const { - for (Init *I : Predicates->getValues()) { - if (DefInit *Pred = dyn_cast<DefInit>(I)) { - Record *Def = Pred->getDef(); + SmallVectorImpl<const Record *> &PredicateRecs) const { + for (const Init *I : Predicates->getValues()) { + if (const DefInit *Pred = dyn_cast<DefInit>(I)) { + const Record *Def = Pred->getDef(); if (!Def->isSubClassOf("Predicate")) { #ifndef NDEBUG Def->dump(); @@ -1506,13 +1496,13 @@ void PatternToMatch::getPredicateRecords( /// pattern's predicates concatenated with "&&" operators. /// std::string PatternToMatch::getPredicateCheck() const { - SmallVector<Record *, 4> PredicateRecs; + SmallVector<const Record *, 4> PredicateRecs; getPredicateRecords(PredicateRecs); SmallString<128> PredicateCheck; raw_svector_ostream OS(PredicateCheck); ListSeparator LS(" && "); - for (Record *Pred : PredicateRecs) { + for (const Record *Pred : PredicateRecs) { StringRef CondString = Pred->getValueAsString("CondString"); if (CondString.empty()) continue; @@ -1659,7 +1649,7 @@ bool SDTypeConstraint::ApplyTypeConstraint(TreePatternNode &N, TP.error(N.getOperator()->getName() + " expects a VT operand!"); return false; } - DefInit *DI = cast<DefInit>(NodeToApply.getLeafValue()); + const DefInit *DI = cast<DefInit>(NodeToApply.getLeafValue()); const CodeGenTarget &T = TP.getDAGPatterns().getTargetInfo(); auto VVT = getValueTypeByHwMode(DI->getDef(), T.getHwModes()); TypeSetByHwMode TypeListTmp(VVT); @@ -1731,7 +1721,7 @@ bool TreePatternNode::UpdateNodeTypeFromInst(unsigned ResNo, // The Operand class specifies a type directly. if (Operand->isSubClassOf("Operand")) { - Record *R = Operand->getValueAsDef("Type"); + const Record *R = Operand->getValueAsDef("Type"); const CodeGenTarget &T = TP.getDAGPatterns().getTargetInfo(); return UpdateNodeType(ResNo, getValueTypeByHwMode(R, T.getHwModes()), TP); } @@ -1802,7 +1792,7 @@ bool TreePatternNode::setDefaultMode(unsigned Mode) { SDNodeInfo::SDNodeInfo(const Record *R, const CodeGenHwModes &CGH) : Def(R) { EnumName = R->getValueAsString("Opcode"); SDClassName = R->getValueAsString("SDClass"); - Record *TypeProfile = R->getValueAsDef("TypeProfile"); + const Record *TypeProfile = R->getValueAsDef("TypeProfile"); NumResults = TypeProfile->getValueAsInt("NumResults"); NumOperands = TypeProfile->getValueAsInt("NumOperands"); @@ -1810,9 +1800,7 @@ SDNodeInfo::SDNodeInfo(const Record *R, const CodeGenHwModes &CGH) : Def(R) { Properties = parseSDPatternOperatorProperties(R); // Parse the type constraints. - std::vector<Record *> ConstraintList = - TypeProfile->getValueAsListOfDefs("Constraints"); - for (Record *R : ConstraintList) + for (const Record *R : TypeProfile->getValueAsListOfDefs("Constraints")) TypeConstraints.emplace_back(R, CGH); } @@ -1872,13 +1860,13 @@ static unsigned GetNumNodeResults(const Record *Operator, return NumResults; } - ListInit *LI = Operator->getValueAsListInit("Fragments"); + const ListInit *LI = Operator->getValueAsListInit("Fragments"); assert(LI && "Invalid Fragment"); unsigned NumResults = 0; - for (Init *I : LI->getValues()) { - Record *Op = nullptr; - if (DagInit *Dag = dyn_cast<DagInit>(I)) - if (DefInit *DI = dyn_cast<DefInit>(Dag->getOperator())) + for (const Init *I : LI->getValues()) { + const Record *Op = nullptr; + if (const DagInit *Dag = dyn_cast<DagInit>(I)) + if (const DefInit *DI = dyn_cast<DefInit>(Dag->getOperator())) Op = DI->getDef(); assert(Op && "Invalid Fragment"); NumResults = std::max(NumResults, GetNumNodeResults(Op, CDP)); @@ -1986,8 +1974,8 @@ bool TreePatternNode::isIsomorphicTo(const TreePatternNode &N, return false; if (isLeaf()) { - if (DefInit *DI = dyn_cast<DefInit>(getLeafValue())) { - if (DefInit *NDI = dyn_cast<DefInit>(N.getLeafValue())) { + if (const DefInit *DI = dyn_cast<DefInit>(getLeafValue())) { + if (const DefInit *NDI = dyn_cast<DefInit>(N.getLeafValue())) { return ((DI->getDef() == NDI->getDef()) && (!DepVars.contains(getName()) || getName() == N.getName())); } @@ -2044,7 +2032,7 @@ void TreePatternNode::SubstituteFormalArguments( for (unsigned i = 0, e = getNumChildren(); i != e; ++i) { TreePatternNode &Child = getChild(i); if (Child.isLeaf()) { - Init *Val = Child.getLeafValue(); + const Init *Val = Child.getLeafValue(); // Note that, when substituting into an output pattern, Val might be an // UnsetInit. if (isa<UnsetInit>(Val) || @@ -2217,7 +2205,7 @@ void TreePatternNode::InlinePatternFragments( /// When Unnamed is false, return the type of a named DAG operand such as the /// GPR:$src operand above. /// -static TypeSetByHwMode getImplicitType(Record *R, unsigned ResNo, +static TypeSetByHwMode getImplicitType(const Record *R, unsigned ResNo, bool NotRegisters, bool Unnamed, TreePattern &TP) { CodeGenDAGPatterns &CDP = TP.getDAGPatterns(); @@ -2227,7 +2215,7 @@ static TypeSetByHwMode getImplicitType(Record *R, unsigned ResNo, assert(ResNo == 0 && "Regoperand ref only has one result!"); if (NotRegisters) return TypeSetByHwMode(); // Unknown. - Record *RegClass = R->getValueAsDef("RegClass"); + const Record *RegClass = R->getValueAsDef("RegClass"); const CodeGenTarget &T = TP.getDAGPatterns().getTargetInfo(); return TypeSetByHwMode(T.getRegisterClass(RegClass).getValueTypes()); } @@ -2316,7 +2304,7 @@ static TypeSetByHwMode getImplicitType(Record *R, unsigned ResNo, if (R->isSubClassOf("Operand")) { const CodeGenHwModes &CGH = CDP.getTargetInfo().getHwModes(); - Record *T = R->getValueAsDef("Type"); + const Record *T = R->getValueAsDef("Type"); return TypeSetByHwMode(getValueTypeByHwMode(T, CGH)); } @@ -2343,7 +2331,7 @@ const ComplexPattern * TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const { const Record *Rec; if (isLeaf()) { - DefInit *DI = dyn_cast<DefInit>(getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(getLeafValue()); if (!DI) return nullptr; Rec = DI->getDef(); @@ -2362,9 +2350,9 @@ unsigned TreePatternNode::getNumMIResults(const CodeGenDAGPatterns &CGP) const { // If MIOperandInfo is specified, that gives the count. if (isLeaf()) { - DefInit *DI = dyn_cast<DefInit>(getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(getLeafValue()); if (DI && DI->getDef()->isSubClassOf("Operand")) { - DagInit *MIOps = DI->getDef()->getValueAsDag("MIOperandInfo"); + const DagInit *MIOps = DI->getDef()->getValueAsDag("MIOperandInfo"); if (MIOps->getNumArgs()) return MIOps->getNumArgs(); } @@ -2423,7 +2411,7 @@ static bool isOperandClass(const TreePatternNode &N, StringRef Class) { if (!N.isLeaf()) return N.getOperator()->isSubClassOf(Class); - DefInit *DI = dyn_cast<DefInit>(N.getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(N.getLeafValue()); if (DI && DI->getDef()->isSubClassOf(Class)) return true; @@ -2451,7 +2439,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { CodeGenDAGPatterns &CDP = TP.getDAGPatterns(); if (isLeaf()) { - if (DefInit *DI = dyn_cast<DefInit>(getLeafValue())) { + if (const DefInit *DI = dyn_cast<DefInit>(getLeafValue())) { // If it's a regclass or something else known, include the type. bool MadeChange = false; for (unsigned i = 0, e = Types.size(); i != e; ++i) @@ -2461,7 +2449,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { return MadeChange; } - if (IntInit *II = dyn_cast<IntInit>(getLeafValue())) { + if (const IntInit *II = dyn_cast<IntInit>(getLeafValue())) { assert(Types.size() == 1 && "Invalid IntInit"); // Int inits are always integers. :) @@ -2658,7 +2646,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { if (Child->getNumMIResults(CDP) < NumArgs) { // Match first sub-operand against the child we already have. - Record *SubRec = cast<DefInit>(MIOpInfo->getArg(0))->getDef(); + const Record *SubRec = cast<DefInit>(MIOpInfo->getArg(0))->getDef(); MadeChange |= Child->UpdateNodeTypeFromInst(ChildResNo, SubRec, TP); // And the remaining sub-operands against subsequent children. @@ -2794,8 +2782,8 @@ bool TreePatternNode::canPatternMatch(std::string &Reason, // TreePattern implementation // -TreePattern::TreePattern(const Record *TheRec, ListInit *RawPat, bool isInput, - CodeGenDAGPatterns &cdp) +TreePattern::TreePattern(const Record *TheRec, const ListInit *RawPat, + bool isInput, CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp), isInputPattern(isInput), HasError(false), Infer(*this) { for (Init *I : RawPat->getValues()) @@ -2840,8 +2828,10 @@ void TreePattern::ComputeNamedNodes(TreePatternNode &N) { TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName) { RecordKeeper &RK = TheInit->getRecordKeeper(); + // Here, we are creating new records (BitsInit->InitInit), so const_cast + // TheInit back to non-const pointer. if (DefInit *DI = dyn_cast<DefInit>(TheInit)) { - Record *R = DI->getDef(); + const Record *R = DI->getDef(); // Direct reference to a leaf DagNode or PatFrag? Turn it into a // TreePatternNode of its own. For example: @@ -2901,7 +2891,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, error("Pattern has unexpected operator type!"); return nullptr; } - Record *Operator = OpDef->getDef(); + const Record *Operator = OpDef->getDef(); if (Operator->isSubClassOf("ValueType")) { // If the operator is a ValueType, then this must be "type cast" of a leaf @@ -2996,7 +2986,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(Init *TheInit, // Check that the ComplexPattern uses are consistent: "(MY_PAT $a, $b)" // and "(MY_PAT $b, $a)" should not be allowed in the same pattern; // neither should "(MY_PAT_1 $a, $b)" and "(MY_PAT_2 $a, $b)". - auto OperandId = std::pair(Operator, i); + auto OperandId = std::make_pair(Operator, i); auto PrevOp = ComplexPatternOperands.find(Child->getName()); if (PrevOp != ComplexPatternOperands.end()) { if (PrevOp->getValue() != OperandId) @@ -3094,7 +3084,7 @@ bool TreePattern::InferAllTypes( // us to match things like: // def : Pat<(v1i64 (bitconvert(v2i32 DPR:$src))), (v1i64 DPR:$src)>; if (Node == Trees[0].get() && Node->isLeaf()) { - DefInit *DI = dyn_cast<DefInit>(Node->getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(Node->getLeafValue()); if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || DI->getDef()->isSubClassOf("RegisterOperand"))) continue; @@ -3188,11 +3178,10 @@ CodeGenDAGPatterns::CodeGenDAGPatterns(const RecordKeeper &R, VerifyInstructionFlags(); } -Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const { - Record *N = Records.getDef(Name); +const Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const { + const Record *N = Records.getDef(Name); if (!N || !N->isSubClassOf("SDNode")) PrintFatalError("Error getting SDNode '" + Name + "'!"); - return N; } @@ -3286,7 +3275,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) { // If there is a node transformation corresponding to this, keep track of // it. - Record *Transform = Frag->getValueAsDef("OperandTransform"); + const Record *Transform = Frag->getValueAsDef("OperandTransform"); if (!getSDNodeTransform(Transform).second.empty()) // not noop xform? for (const auto &T : P->getTrees()) T->setTransformFn(Transform); @@ -3369,7 +3358,7 @@ static bool HandleUse(TreePattern &I, TreePatternNodePtr Pat, // No name -> not interesting. if (Pat->getName().empty()) { if (Pat->isLeaf()) { - DefInit *DI = dyn_cast<DefInit>(Pat->getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(Pat->getLeafValue()); if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || DI->getDef()->isSubClassOf("RegisterOperand"))) I.error("Input " + DI->getDef()->getName() + " must be named!"); @@ -3379,7 +3368,7 @@ static bool HandleUse(TreePattern &I, TreePatternNodePtr Pat, const Record *Rec; if (Pat->isLeaf()) { - DefInit *DI = dyn_cast<DefInit>(Pat->getLeafValue()); + const DefInit *DI = dyn_cast<DefInit>(Pat->getLeafValue()); if (!DI) I.error("Input $" + Pat->getName() + " must be an identifier!"); Rec = DI->getDef(); @@ -3423,8 +3412,7 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs( std::map<std::string, TreePatternNodePtr> &InstInputs, MapVector<std::string, TreePatternNodePtr, std::map<std::string, unsigned>> &InstResults, - std::vector<Record *> &InstImpResults) { - + std::vector<const Record *> &InstImpResults) { // The instruction pattern still has unresolved fragments. For *named* // nodes we must resolve those here. This may not result in multiple // alternatives. @@ -3448,7 +3436,7 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs( if (!Dest.isLeaf()) I.error("implicitly defined value should be a register!"); - DefInit *Val = dyn_cast<DefInit>(Dest.getLeafValue()); + const DefInit *Val = dyn_cast<DefInit>(Dest.getLeafValue()); if (!Val || !Val->getDef()->isSubClassOf("Register")) I.error("implicitly defined value should be a register!"); if (Val) @@ -3496,7 +3484,7 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs( if (!Dest->isLeaf()) I.error("set destination should be a register!"); - DefInit *Val = dyn_cast<DefInit>(Dest->getLeafValue()); + const DefInit *Val = dyn_cast<DefInit>(Dest->getLeafValue()); if (!Val) { I.error("set destination should be a register!"); continue; @@ -3571,8 +3559,8 @@ private: public: void AnalyzeNode(const TreePatternNode &N) { if (N.isLeaf()) { - if (DefInit *DI = dyn_cast<DefInit>(N.getLeafValue())) { - Record *LeafRec = DI->getDef(); + if (const DefInit *DI = dyn_cast<DefInit>(N.getLeafValue())) { + const Record *LeafRec = DI->getDef(); // Handle ComplexPattern leaves. if (LeafRec->isSubClassOf("ComplexPattern")) { const ComplexPattern &CP = CDP.getComplexPattern(LeafRec); @@ -3729,7 +3717,8 @@ static void getInstructionsInTree(TreePatternNode &Tree, /// Check the class of a pattern leaf node against the instruction operand it /// represents. -static bool checkOperandClass(CGIOperandList::OperandInfo &OI, Record *Leaf) { +static bool checkOperandClass(CGIOperandList::OperandInfo &OI, + const Record *Leaf) { if (OI.Rec == Leaf) return true; @@ -3746,7 +3735,7 @@ static bool checkOperandClass(CGIOperandList::OperandInfo &OI, Record *Leaf) { } void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI, - ListInit *Pat, + const ListInit *Pat, DAGInstMap &DAGInsts) { assert(!DAGInsts.count(CGI.TheDef) && "Instruction already parsed!"); @@ -3763,7 +3752,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI, MapVector<std::string, TreePatternNodePtr, std::map<std::string, unsigned>> InstResults; - std::vector<Record *> InstImpResults; + std::vector<const Record *> InstImpResults; // Verify that the top-level forms in the instruction are of void type, and // fill in the InstResults map. @@ -3821,7 +3810,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI, I.error("Operand $" + OpName + " does not exist in operand list!"); TreePatternNodePtr RNode = InstResultIter->second; - Record *R = cast<DefInit>(RNode->getLeafValue())->getDef(); + const Record *R = cast<DefInit>(RNode->getLeafValue())->getDef(); ResNodes.push_back(std::move(RNode)); if (!R) I.error("Operand $" + OpName + @@ -3869,7 +3858,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI, InstInputs.erase(OpName); // It occurred, remove from map. if (InVal->isLeaf() && isa<DefInit>(InVal->getLeafValue())) { - Record *InRec = cast<DefInit>(InVal->getLeafValue())->getDef(); + const Record *InRec = cast<DefInit>(InVal->getLeafValue())->getDef(); if (!checkOperandClass(Op, InRec)) { I.error("Operand $" + OpName + "'s register class disagrees" @@ -3886,7 +3875,7 @@ void CodeGenDAGPatterns::parseInstructionPattern(CodeGenInstruction &CGI, OpNode->clearPredicateCalls(); // Promote the xform function to be an explicit node if set. - if (Record *Xform = OpNode->getTransformFn()) { + if (const Record *Xform = OpNode->getTransformFn()) { OpNode->setTransformFn(nullptr); std::vector<TreePatternNodePtr> Children; Children.push_back(OpNode); @@ -3965,7 +3954,7 @@ void CodeGenDAGPatterns::ParseInstructions() { // Create and insert the instruction. Instructions.try_emplace(Instr, std::move(Results), std::move(Operands), - std::vector<Record *>()); + std::vector<const Record *>()); continue; // no pattern. } @@ -4211,7 +4200,7 @@ static bool ForceArbitraryInstResultType(TreePatternNode &N, TreePattern &TP) { // Promote xform function to be an explicit node wherever set. static TreePatternNodePtr PromoteXForms(TreePatternNodePtr N) { - if (Record *Xform = N->getTransformFn()) { + if (const Record *Xform = N->getTransformFn()) { N->setTransformFn(nullptr); std::vector<TreePatternNodePtr> Children; Children.push_back(PromoteXForms(N)); @@ -4229,8 +4218,7 @@ static TreePatternNodePtr PromoteXForms(TreePatternNodePtr N) { void CodeGenDAGPatterns::ParseOnePattern( const Record *TheDef, TreePattern &Pattern, TreePattern &Result, - const std::vector<Record *> &InstImpResults, bool ShouldIgnore) { - + ArrayRef<const Record *> InstImpResults, bool ShouldIgnore) { // Inline pattern fragments and expand multiple alternatives. Pattern.InlinePatternFragments(); Result.InlinePatternFragments(); @@ -4354,7 +4342,7 @@ void CodeGenDAGPatterns::ParsePatterns() { std::map<std::string, TreePatternNodePtr> InstInputs; MapVector<std::string, TreePatternNodePtr, std::map<std::string, unsigned>> InstResults; - std::vector<Record *> InstImpResults; + std::vector<const Record *> InstImpResults; for (unsigned j = 0, ee = Pattern.getNumTrees(); j != ee; ++j) FindPatternInputsAndOutputs(Pattern, Pattern.getTree(j), InstInputs, InstResults, InstImpResults); @@ -4682,8 +4670,8 @@ static void GenerateVariantsOf(TreePatternNodePtr N, for (; i != e; ++i) { TreePatternNode &Child = N->getChild(i); if (Child.isLeaf()) - if (DefInit *DI = dyn_cast<DefInit>(Child.getLeafValue())) { - Record *RR = DI->getDef(); + if (const DefInit *DI = dyn_cast<DefInit>(Child.getLeafValue())) { + const Record *RR = DI->getDef(); if (RR->isSubClassOf("Register")) NoRegisters = false; } |