diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.h b/llvm/utils/TableGen/CodeGenDAGPatterns.h --- a/llvm/utils/TableGen/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.h @@ -330,9 +330,9 @@ /// For each overloaded type (i.e. of form *Any), replace it with the /// corresponding subset of legal, specific types. - void expandOverloads(TypeSetByHwMode &VTS); + void expandOverloads(TypeSetByHwMode &VTS) const; void expandOverloads(TypeSetByHwMode::SetType &Out, - const TypeSetByHwMode::SetType &Legal); + const TypeSetByHwMode::SetType &Legal) const; struct ValidateOnExit { ValidateOnExit(const TypeSetByHwMode &T, const TypeInfer &TI) @@ -357,11 +357,11 @@ bool Validate = true; // Indicate whether to validate types. private: - const TypeSetByHwMode &getLegalTypes(); + const TypeSetByHwMode &getLegalTypes() const; /// Cached legal types (in default mode). - bool LegalTypesCached = false; - TypeSetByHwMode LegalCache; + mutable bool LegalTypesCached = false; + mutable TypeSetByHwMode LegalCache; }; /// Set type used to track multiply used variables in patterns diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp --- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp @@ -807,7 +807,7 @@ return Changed; } -void TypeInfer::expandOverloads(TypeSetByHwMode &VTS) { +void TypeInfer::expandOverloads(TypeSetByHwMode &VTS) const { ValidateOnExit _1(VTS, *this); const TypeSetByHwMode &Legal = getLegalTypes(); assert(Legal.isSimple() && "Default-mode only expected"); @@ -818,7 +818,7 @@ } void TypeInfer::expandOverloads(TypeSetByHwMode::SetType &Out, - const TypeSetByHwMode::SetType &Legal) { + const TypeSetByHwMode::SetType &Legal) const { if (Out.count(MVT::iPTRAny)) { Out.erase(MVT::iPTRAny); Out.insert(MVT::iPTR); @@ -857,7 +857,7 @@ } } -const TypeSetByHwMode &TypeInfer::getLegalTypes() { +const TypeSetByHwMode &TypeInfer::getLegalTypes() const { if (!LegalTypesCached) { TypeSetByHwMode::SetType &LegalTypes = LegalCache.getOrCreate(DefaultMode); // Stuff all types from all modes into the default mode.