Path: blob/main/contrib/llvm-project/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h
35290 views
//===- CodeGenDAGPatterns.h - Read DAG patterns from .td file ---*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file declares the CodeGenDAGPatterns class, which is used to read and9// represent the patterns present in a .td file for instructions.10//11//===----------------------------------------------------------------------===//1213#ifndef LLVM_UTILS_TABLEGEN_CODEGENDAGPATTERNS_H14#define LLVM_UTILS_TABLEGEN_CODEGENDAGPATTERNS_H1516#include "Basic/CodeGenIntrinsics.h"17#include "Basic/SDNodeProperties.h"18#include "CodeGenTarget.h"19#include "llvm/ADT/IntrusiveRefCntPtr.h"20#include "llvm/ADT/MapVector.h"21#include "llvm/ADT/PointerUnion.h"22#include "llvm/ADT/SmallVector.h"23#include "llvm/ADT/StringMap.h"24#include "llvm/ADT/StringSet.h"25#include "llvm/ADT/Twine.h"26#include "llvm/Support/ErrorHandling.h"27#include "llvm/Support/MathExtras.h"28#include "llvm/TableGen/Record.h"29#include <algorithm>30#include <array>31#include <functional>32#include <map>33#include <numeric>34#include <vector>3536namespace llvm {3738class Init;39class ListInit;40class DagInit;41class SDNodeInfo;42class TreePattern;43class TreePatternNode;44class CodeGenDAGPatterns;4546/// Shared pointer for TreePatternNode.47using TreePatternNodePtr = IntrusiveRefCntPtr<TreePatternNode>;4849/// This represents a set of MVTs. Since the underlying type for the MVT50/// is uint8_t, there are at most 256 values. To reduce the number of memory51/// allocations and deallocations, represent the set as a sequence of bits.52/// To reduce the allocations even further, make MachineValueTypeSet own53/// the storage and use std::array as the bit container.54struct MachineValueTypeSet {55static_assert(std::is_same<std::underlying_type_t<MVT::SimpleValueType>,56uint8_t>::value,57"Change uint8_t here to the SimpleValueType's type");58static unsigned constexpr Capacity = std::numeric_limits<uint8_t>::max() + 1;59using WordType = uint64_t;60static unsigned constexpr WordWidth = CHAR_BIT * sizeof(WordType);61static unsigned constexpr NumWords = Capacity / WordWidth;62static_assert(NumWords * WordWidth == Capacity,63"Capacity should be a multiple of WordWidth");6465LLVM_ATTRIBUTE_ALWAYS_INLINE66MachineValueTypeSet() { clear(); }6768LLVM_ATTRIBUTE_ALWAYS_INLINE69unsigned size() const {70unsigned Count = 0;71for (WordType W : Words)72Count += llvm::popcount(W);73return Count;74}75LLVM_ATTRIBUTE_ALWAYS_INLINE76void clear() { std::memset(Words.data(), 0, NumWords * sizeof(WordType)); }77LLVM_ATTRIBUTE_ALWAYS_INLINE78bool empty() const {79for (WordType W : Words)80if (W != 0)81return false;82return true;83}84LLVM_ATTRIBUTE_ALWAYS_INLINE85unsigned count(MVT T) const {86return (Words[T.SimpleTy / WordWidth] >> (T.SimpleTy % WordWidth)) & 1;87}88std::pair<MachineValueTypeSet &, bool> insert(MVT T) {89bool V = count(T.SimpleTy);90Words[T.SimpleTy / WordWidth] |= WordType(1) << (T.SimpleTy % WordWidth);91return {*this, V};92}93MachineValueTypeSet &insert(const MachineValueTypeSet &S) {94for (unsigned i = 0; i != NumWords; ++i)95Words[i] |= S.Words[i];96return *this;97}98LLVM_ATTRIBUTE_ALWAYS_INLINE99void erase(MVT T) {100Words[T.SimpleTy / WordWidth] &= ~(WordType(1) << (T.SimpleTy % WordWidth));101}102103void writeToStream(raw_ostream &OS) const;104105struct const_iterator {106// Some implementations of the C++ library require these traits to be107// defined.108using iterator_category = std::forward_iterator_tag;109using value_type = MVT;110using difference_type = ptrdiff_t;111using pointer = const MVT *;112using reference = const MVT &;113114LLVM_ATTRIBUTE_ALWAYS_INLINE115MVT operator*() const {116assert(Pos != Capacity);117return MVT::SimpleValueType(Pos);118}119LLVM_ATTRIBUTE_ALWAYS_INLINE120const_iterator(const MachineValueTypeSet *S, bool End) : Set(S) {121Pos = End ? Capacity : find_from_pos(0);122}123LLVM_ATTRIBUTE_ALWAYS_INLINE124const_iterator &operator++() {125assert(Pos != Capacity);126Pos = find_from_pos(Pos + 1);127return *this;128}129130LLVM_ATTRIBUTE_ALWAYS_INLINE131bool operator==(const const_iterator &It) const {132return Set == It.Set && Pos == It.Pos;133}134LLVM_ATTRIBUTE_ALWAYS_INLINE135bool operator!=(const const_iterator &It) const { return !operator==(It); }136137private:138unsigned find_from_pos(unsigned P) const {139unsigned SkipWords = P / WordWidth;140unsigned SkipBits = P % WordWidth;141unsigned Count = SkipWords * WordWidth;142143// If P is in the middle of a word, process it manually here, because144// the trailing bits need to be masked off to use findFirstSet.145if (SkipBits != 0) {146WordType W = Set->Words[SkipWords];147W &= maskLeadingOnes<WordType>(WordWidth - SkipBits);148if (W != 0)149return Count + llvm::countr_zero(W);150Count += WordWidth;151SkipWords++;152}153154for (unsigned i = SkipWords; i != NumWords; ++i) {155WordType W = Set->Words[i];156if (W != 0)157return Count + llvm::countr_zero(W);158Count += WordWidth;159}160return Capacity;161}162163const MachineValueTypeSet *Set;164unsigned Pos;165};166167LLVM_ATTRIBUTE_ALWAYS_INLINE168const_iterator begin() const { return const_iterator(this, false); }169LLVM_ATTRIBUTE_ALWAYS_INLINE170const_iterator end() const { return const_iterator(this, true); }171172LLVM_ATTRIBUTE_ALWAYS_INLINE173bool operator==(const MachineValueTypeSet &S) const {174return Words == S.Words;175}176LLVM_ATTRIBUTE_ALWAYS_INLINE177bool operator!=(const MachineValueTypeSet &S) const { return !operator==(S); }178179private:180friend struct const_iterator;181std::array<WordType, NumWords> Words;182};183184raw_ostream &operator<<(raw_ostream &OS, const MachineValueTypeSet &T);185186struct TypeSetByHwMode : public InfoByHwMode<MachineValueTypeSet> {187using SetType = MachineValueTypeSet;188unsigned AddrSpace = std::numeric_limits<unsigned>::max();189190TypeSetByHwMode() = default;191TypeSetByHwMode(const TypeSetByHwMode &VTS) = default;192TypeSetByHwMode &operator=(const TypeSetByHwMode &) = default;193TypeSetByHwMode(MVT::SimpleValueType VT)194: TypeSetByHwMode(ValueTypeByHwMode(VT)) {}195TypeSetByHwMode(ValueTypeByHwMode VT)196: TypeSetByHwMode(ArrayRef<ValueTypeByHwMode>(&VT, 1)) {}197TypeSetByHwMode(ArrayRef<ValueTypeByHwMode> VTList);198199SetType &getOrCreate(unsigned Mode) { return Map[Mode]; }200201bool isValueTypeByHwMode(bool AllowEmpty) const;202ValueTypeByHwMode getValueTypeByHwMode() const;203204LLVM_ATTRIBUTE_ALWAYS_INLINE205bool isMachineValueType() const {206return isSimple() && getSimple().size() == 1;207}208209LLVM_ATTRIBUTE_ALWAYS_INLINE210MVT getMachineValueType() const {211assert(isMachineValueType());212return *getSimple().begin();213}214215bool isPossible() const;216217bool isPointer() const { return getValueTypeByHwMode().isPointer(); }218219unsigned getPtrAddrSpace() const {220assert(isPointer());221return getValueTypeByHwMode().PtrAddrSpace;222}223224bool insert(const ValueTypeByHwMode &VVT);225bool constrain(const TypeSetByHwMode &VTS);226template <typename Predicate> bool constrain(Predicate P);227template <typename Predicate>228bool assign_if(const TypeSetByHwMode &VTS, Predicate P);229230void writeToStream(raw_ostream &OS) const;231232bool operator==(const TypeSetByHwMode &VTS) const;233bool operator!=(const TypeSetByHwMode &VTS) const { return !(*this == VTS); }234235void dump() const;236bool validate() const;237238private:239unsigned PtrAddrSpace = std::numeric_limits<unsigned>::max();240/// Intersect two sets. Return true if anything has changed.241bool intersect(SetType &Out, const SetType &In);242};243244raw_ostream &operator<<(raw_ostream &OS, const TypeSetByHwMode &T);245246struct TypeInfer {247TypeInfer(TreePattern &T) : TP(T) {}248249bool isConcrete(const TypeSetByHwMode &VTS, bool AllowEmpty) const {250return VTS.isValueTypeByHwMode(AllowEmpty);251}252ValueTypeByHwMode getConcrete(const TypeSetByHwMode &VTS,253bool AllowEmpty) const {254assert(VTS.isValueTypeByHwMode(AllowEmpty));255return VTS.getValueTypeByHwMode();256}257258/// The protocol in the following functions (Merge*, force*, Enforce*,259/// expand*) is to return "true" if a change has been made, "false"260/// otherwise.261262bool MergeInTypeInfo(TypeSetByHwMode &Out, const TypeSetByHwMode &In) const;263bool MergeInTypeInfo(TypeSetByHwMode &Out, MVT::SimpleValueType InVT) const {264return MergeInTypeInfo(Out, TypeSetByHwMode(InVT));265}266bool MergeInTypeInfo(TypeSetByHwMode &Out, ValueTypeByHwMode InVT) const {267return MergeInTypeInfo(Out, TypeSetByHwMode(InVT));268}269270/// Reduce the set \p Out to have at most one element for each mode.271bool forceArbitrary(TypeSetByHwMode &Out);272273/// The following four functions ensure that upon return the set \p Out274/// will only contain types of the specified kind: integer, floating-point,275/// scalar, or vector.276/// If \p Out is empty, all legal types of the specified kind will be added277/// to it. Otherwise, all types that are not of the specified kind will be278/// removed from \p Out.279bool EnforceInteger(TypeSetByHwMode &Out);280bool EnforceFloatingPoint(TypeSetByHwMode &Out);281bool EnforceScalar(TypeSetByHwMode &Out);282bool EnforceVector(TypeSetByHwMode &Out);283284/// If \p Out is empty, fill it with all legal types. Otherwise, leave it285/// unchanged.286bool EnforceAny(TypeSetByHwMode &Out);287/// Make sure that for each type in \p Small, there exists a larger type288/// in \p Big. \p SmallIsVT indicates that this is being called for289/// SDTCisVTSmallerThanOp. In that case the TypeSetByHwMode is re-created for290/// each call and needs special consideration in how we detect changes.291bool EnforceSmallerThan(TypeSetByHwMode &Small, TypeSetByHwMode &Big,292bool SmallIsVT = false);293/// 1. Ensure that for each type T in \p Vec, T is a vector type, and that294/// for each type U in \p Elem, U is a scalar type.295/// 2. Ensure that for each (scalar) type U in \p Elem, there exists a296/// (vector) type T in \p Vec, such that U is the element type of T.297bool EnforceVectorEltTypeIs(TypeSetByHwMode &Vec, TypeSetByHwMode &Elem);298bool EnforceVectorEltTypeIs(TypeSetByHwMode &Vec,299const ValueTypeByHwMode &VVT);300/// Ensure that for each type T in \p Sub, T is a vector type, and there301/// exists a type U in \p Vec such that U is a vector type with the same302/// element type as T and at least as many elements as T.303bool EnforceVectorSubVectorTypeIs(TypeSetByHwMode &Vec, TypeSetByHwMode &Sub);304/// 1. Ensure that \p V has a scalar type iff \p W has a scalar type.305/// 2. Ensure that for each vector type T in \p V, there exists a vector306/// type U in \p W, such that T and U have the same number of elements.307/// 3. Ensure that for each vector type U in \p W, there exists a vector308/// type T in \p V, such that T and U have the same number of elements309/// (reverse of 2).310bool EnforceSameNumElts(TypeSetByHwMode &V, TypeSetByHwMode &W);311/// 1. Ensure that for each type T in \p A, there exists a type U in \p B,312/// such that T and U have equal size in bits.313/// 2. Ensure that for each type U in \p B, there exists a type T in \p A314/// such that T and U have equal size in bits (reverse of 1).315bool EnforceSameSize(TypeSetByHwMode &A, TypeSetByHwMode &B);316317/// For each overloaded type (i.e. of form *Any), replace it with the318/// corresponding subset of legal, specific types.319void expandOverloads(TypeSetByHwMode &VTS) const;320void expandOverloads(TypeSetByHwMode::SetType &Out,321const TypeSetByHwMode::SetType &Legal) const;322323struct ValidateOnExit {324ValidateOnExit(const TypeSetByHwMode &T, const TypeInfer &TI)325: Infer(TI), VTS(T) {}326~ValidateOnExit();327const TypeInfer &Infer;328const TypeSetByHwMode &VTS;329};330331struct SuppressValidation {332SuppressValidation(TypeInfer &TI) : Infer(TI), SavedValidate(TI.Validate) {333Infer.Validate = false;334}335~SuppressValidation() { Infer.Validate = SavedValidate; }336TypeInfer &Infer;337bool SavedValidate;338};339340TreePattern &TP;341bool Validate = true; // Indicate whether to validate types.342343private:344const TypeSetByHwMode &getLegalTypes() const;345346/// Cached legal types (in default mode).347mutable bool LegalTypesCached = false;348mutable TypeSetByHwMode LegalCache;349};350351/// Set type used to track multiply used variables in patterns352typedef StringSet<> MultipleUseVarSet;353354/// SDTypeConstraint - This is a discriminated union of constraints,355/// corresponding to the SDTypeConstraint tablegen class in Target.td.356struct SDTypeConstraint {357SDTypeConstraint(Record *R, const CodeGenHwModes &CGH);358359unsigned OperandNo; // The operand # this constraint applies to.360enum {361SDTCisVT,362SDTCisPtrTy,363SDTCisInt,364SDTCisFP,365SDTCisVec,366SDTCisSameAs,367SDTCisVTSmallerThanOp,368SDTCisOpSmallerThanOp,369SDTCisEltOfVec,370SDTCisSubVecOfVec,371SDTCVecEltisVT,372SDTCisSameNumEltsAs,373SDTCisSameSizeAs374} ConstraintType;375376union { // The discriminated union.377struct {378unsigned OtherOperandNum;379} SDTCisSameAs_Info;380struct {381unsigned OtherOperandNum;382} SDTCisVTSmallerThanOp_Info;383struct {384unsigned BigOperandNum;385} SDTCisOpSmallerThanOp_Info;386struct {387unsigned OtherOperandNum;388} SDTCisEltOfVec_Info;389struct {390unsigned OtherOperandNum;391} SDTCisSubVecOfVec_Info;392struct {393unsigned OtherOperandNum;394} SDTCisSameNumEltsAs_Info;395struct {396unsigned OtherOperandNum;397} SDTCisSameSizeAs_Info;398} x;399400// The VT for SDTCisVT and SDTCVecEltisVT.401// Must not be in the union because it has a non-trivial destructor.402ValueTypeByHwMode VVT;403404/// ApplyTypeConstraint - Given a node in a pattern, apply this type405/// constraint to the nodes operands. This returns true if it makes a406/// change, false otherwise. If a type contradiction is found, an error407/// is flagged.408bool ApplyTypeConstraint(TreePatternNode &N, const SDNodeInfo &NodeInfo,409TreePattern &TP) const;410};411412/// ScopedName - A name of a node associated with a "scope" that indicates413/// the context (e.g. instance of Pattern or PatFrag) in which the name was414/// used. This enables substitution of pattern fragments while keeping track415/// of what name(s) were originally given to various nodes in the tree.416class ScopedName {417unsigned Scope;418std::string Identifier;419420public:421ScopedName(unsigned Scope, StringRef Identifier)422: Scope(Scope), Identifier(std::string(Identifier)) {423assert(Scope != 0 &&424"Scope == 0 is used to indicate predicates without arguments");425}426427unsigned getScope() const { return Scope; }428const std::string &getIdentifier() const { return Identifier; }429430bool operator==(const ScopedName &o) const;431bool operator!=(const ScopedName &o) const;432};433434/// SDNodeInfo - One of these records is created for each SDNode instance in435/// the target .td file. This represents the various dag nodes we will be436/// processing.437class SDNodeInfo {438Record *Def;439StringRef EnumName;440StringRef SDClassName;441unsigned Properties;442unsigned NumResults;443int NumOperands;444std::vector<SDTypeConstraint> TypeConstraints;445446public:447// Parse the specified record.448SDNodeInfo(Record *R, const CodeGenHwModes &CGH);449450unsigned getNumResults() const { return NumResults; }451452/// getNumOperands - This is the number of operands required or -1 if453/// variadic.454int getNumOperands() const { return NumOperands; }455Record *getRecord() const { return Def; }456StringRef getEnumName() const { return EnumName; }457StringRef getSDClassName() const { return SDClassName; }458459const std::vector<SDTypeConstraint> &getTypeConstraints() const {460return TypeConstraints;461}462463/// getKnownType - If the type constraints on this node imply a fixed type464/// (e.g. all stores return void, etc), then return it as an465/// MVT::SimpleValueType. Otherwise, return MVT::Other.466MVT::SimpleValueType getKnownType(unsigned ResNo) const;467468/// hasProperty - Return true if this node has the specified property.469///470bool hasProperty(enum SDNP Prop) const { return Properties & (1 << Prop); }471472/// ApplyTypeConstraints - Given a node in a pattern, apply the type473/// constraints for this node to the operands of the node. This returns474/// true if it makes a change, false otherwise. If a type contradiction is475/// found, an error is flagged.476bool ApplyTypeConstraints(TreePatternNode &N, TreePattern &TP) const;477};478479/// TreePredicateFn - This is an abstraction that represents the predicates on480/// a PatFrag node. This is a simple one-word wrapper around a pointer to481/// provide nice accessors.482class TreePredicateFn {483/// PatFragRec - This is the TreePattern for the PatFrag that we484/// originally came from.485TreePattern *PatFragRec;486487public:488/// TreePredicateFn constructor. Here 'N' is a subclass of PatFrag.489TreePredicateFn(TreePattern *N);490491TreePattern *getOrigPatFragRecord() const { return PatFragRec; }492493/// isAlwaysTrue - Return true if this is a noop predicate.494bool isAlwaysTrue() const;495496bool isImmediatePattern() const { return hasImmCode(); }497498/// getImmediatePredicateCode - Return the code that evaluates this pattern if499/// this is an immediate predicate. It is an error to call this on a500/// non-immediate pattern.501std::string getImmediatePredicateCode() const {502std::string Result = getImmCode();503assert(!Result.empty() && "Isn't an immediate pattern!");504return Result;505}506507bool operator==(const TreePredicateFn &RHS) const {508return PatFragRec == RHS.PatFragRec;509}510511bool operator!=(const TreePredicateFn &RHS) const { return !(*this == RHS); }512513/// Return the name to use in the generated code to reference this, this is514/// "Predicate_foo" if from a pattern fragment "foo".515std::string getFnName() const;516517/// getCodeToRunOnSDNode - Return the code for the function body that518/// evaluates this predicate. The argument is expected to be in "Node",519/// not N. This handles casting and conversion to a concrete node type as520/// appropriate.521std::string getCodeToRunOnSDNode() const;522523/// Get the data type of the argument to getImmediatePredicateCode().524StringRef getImmType() const;525526/// Get a string that describes the type returned by getImmType() but is527/// usable as part of an identifier.528StringRef getImmTypeIdentifier() const;529530// Predicate code uses the PatFrag's captured operands.531bool usesOperands() const;532533// Check if the HasNoUse predicate is set.534bool hasNoUse() const;535// Check if the HasOneUse predicate is set.536bool hasOneUse() const;537538// Is the desired predefined predicate for a load?539bool isLoad() const;540// Is the desired predefined predicate for a store?541bool isStore() const;542// Is the desired predefined predicate for an atomic?543bool isAtomic() const;544545/// Is this predicate the predefined unindexed load predicate?546/// Is this predicate the predefined unindexed store predicate?547bool isUnindexed() const;548/// Is this predicate the predefined non-extending load predicate?549bool isNonExtLoad() const;550/// Is this predicate the predefined any-extend load predicate?551bool isAnyExtLoad() const;552/// Is this predicate the predefined sign-extend load predicate?553bool isSignExtLoad() const;554/// Is this predicate the predefined zero-extend load predicate?555bool isZeroExtLoad() const;556/// Is this predicate the predefined non-truncating store predicate?557bool isNonTruncStore() const;558/// Is this predicate the predefined truncating store predicate?559bool isTruncStore() const;560561/// Is this predicate the predefined monotonic atomic predicate?562bool isAtomicOrderingMonotonic() const;563/// Is this predicate the predefined acquire atomic predicate?564bool isAtomicOrderingAcquire() const;565/// Is this predicate the predefined release atomic predicate?566bool isAtomicOrderingRelease() const;567/// Is this predicate the predefined acquire-release atomic predicate?568bool isAtomicOrderingAcquireRelease() const;569/// Is this predicate the predefined sequentially consistent atomic predicate?570bool isAtomicOrderingSequentiallyConsistent() const;571572/// Is this predicate the predefined acquire-or-stronger atomic predicate?573bool isAtomicOrderingAcquireOrStronger() const;574/// Is this predicate the predefined weaker-than-acquire atomic predicate?575bool isAtomicOrderingWeakerThanAcquire() const;576577/// Is this predicate the predefined release-or-stronger atomic predicate?578bool isAtomicOrderingReleaseOrStronger() const;579/// Is this predicate the predefined weaker-than-release atomic predicate?580bool isAtomicOrderingWeakerThanRelease() const;581582/// If non-null, indicates that this predicate is a predefined memory VT583/// predicate for a load/store and returns the ValueType record for the memory584/// VT.585Record *getMemoryVT() const;586/// If non-null, indicates that this predicate is a predefined memory VT587/// predicate (checking only the scalar type) for load/store and returns the588/// ValueType record for the memory VT.589Record *getScalarMemoryVT() const;590591ListInit *getAddressSpaces() const;592int64_t getMinAlignment() const;593594// If true, indicates that GlobalISel-based C++ code was supplied.595bool hasGISelPredicateCode() const;596std::string getGISelPredicateCode() const;597598private:599bool hasPredCode() const;600bool hasImmCode() const;601std::string getPredCode() const;602std::string getImmCode() const;603bool immCodeUsesAPInt() const;604bool immCodeUsesAPFloat() const;605606bool isPredefinedPredicateEqualTo(StringRef Field, bool Value) const;607};608609struct TreePredicateCall {610TreePredicateFn Fn;611612// Scope -- unique identifier for retrieving named arguments. 0 is used when613// the predicate does not use named arguments.614unsigned Scope;615616TreePredicateCall(const TreePredicateFn &Fn, unsigned Scope)617: Fn(Fn), Scope(Scope) {}618619bool operator==(const TreePredicateCall &o) const {620return Fn == o.Fn && Scope == o.Scope;621}622bool operator!=(const TreePredicateCall &o) const { return !(*this == o); }623};624625class TreePatternNode : public RefCountedBase<TreePatternNode> {626/// The type of each node result. Before and during type inference, each627/// result may be a set of possible types. After (successful) type inference,628/// each is a single concrete type.629std::vector<TypeSetByHwMode> Types;630631/// The index of each result in results of the pattern.632std::vector<unsigned> ResultPerm;633634/// OperatorOrVal - The Record for the operator if this is an interior node635/// (not a leaf) or the init value (e.g. the "GPRC" record, or "7") for a636/// leaf.637PointerUnion<Record *, Init *> OperatorOrVal;638639/// Name - The name given to this node with the :$foo notation.640///641std::string Name;642643std::vector<ScopedName> NamesAsPredicateArg;644645/// PredicateCalls - The predicate functions to execute on this node to check646/// for a match. If this list is empty, no predicate is involved.647std::vector<TreePredicateCall> PredicateCalls;648649/// TransformFn - The transformation function to execute on this node before650/// it can be substituted into the resulting instruction on a pattern match.651Record *TransformFn;652653std::vector<TreePatternNodePtr> Children;654655/// If this was instantiated from a PatFrag node, and the PatFrag was derived656/// from "GISelFlags": the original Record derived from GISelFlags.657const Record *GISelFlags = nullptr;658659public:660TreePatternNode(Record *Op, std::vector<TreePatternNodePtr> Ch,661unsigned NumResults)662: OperatorOrVal(Op), TransformFn(nullptr), Children(std::move(Ch)) {663Types.resize(NumResults);664ResultPerm.resize(NumResults);665std::iota(ResultPerm.begin(), ResultPerm.end(), 0);666}667TreePatternNode(Init *val, unsigned NumResults) // leaf ctor668: OperatorOrVal(val), TransformFn(nullptr) {669Types.resize(NumResults);670ResultPerm.resize(NumResults);671std::iota(ResultPerm.begin(), ResultPerm.end(), 0);672}673674bool hasName() const { return !Name.empty(); }675const std::string &getName() const { return Name; }676void setName(StringRef N) { Name.assign(N.begin(), N.end()); }677678const std::vector<ScopedName> &getNamesAsPredicateArg() const {679return NamesAsPredicateArg;680}681void setNamesAsPredicateArg(const std::vector<ScopedName> &Names) {682NamesAsPredicateArg = Names;683}684void addNameAsPredicateArg(const ScopedName &N) {685NamesAsPredicateArg.push_back(N);686}687688bool isLeaf() const { return isa<Init *>(OperatorOrVal); }689690// Type accessors.691unsigned getNumTypes() const { return Types.size(); }692ValueTypeByHwMode getType(unsigned ResNo) const {693return Types[ResNo].getValueTypeByHwMode();694}695const std::vector<TypeSetByHwMode> &getExtTypes() const { return Types; }696const TypeSetByHwMode &getExtType(unsigned ResNo) const {697return Types[ResNo];698}699TypeSetByHwMode &getExtType(unsigned ResNo) { return Types[ResNo]; }700void setType(unsigned ResNo, const TypeSetByHwMode &T) { Types[ResNo] = T; }701MVT::SimpleValueType getSimpleType(unsigned ResNo) const {702return Types[ResNo].getMachineValueType().SimpleTy;703}704705bool hasConcreteType(unsigned ResNo) const {706return Types[ResNo].isValueTypeByHwMode(false);707}708bool isTypeCompletelyUnknown(unsigned ResNo, TreePattern &TP) const {709return Types[ResNo].empty();710}711712unsigned getNumResults() const { return ResultPerm.size(); }713unsigned getResultIndex(unsigned ResNo) const { return ResultPerm[ResNo]; }714void setResultIndex(unsigned ResNo, unsigned RI) { ResultPerm[ResNo] = RI; }715716Init *getLeafValue() const {717assert(isLeaf());718return cast<Init *>(OperatorOrVal);719}720Record *getOperator() const {721assert(!isLeaf());722return cast<Record *>(OperatorOrVal);723}724725unsigned getNumChildren() const { return Children.size(); }726const TreePatternNode &getChild(unsigned N) const {727return *Children[N].get();728}729TreePatternNode &getChild(unsigned N) { return *Children[N].get(); }730const TreePatternNodePtr &getChildShared(unsigned N) const {731return Children[N];732}733TreePatternNodePtr &getChildSharedPtr(unsigned N) { return Children[N]; }734void setChild(unsigned i, TreePatternNodePtr N) { Children[i] = N; }735736/// hasChild - Return true if N is any of our children.737bool hasChild(const TreePatternNode *N) const {738for (unsigned i = 0, e = Children.size(); i != e; ++i)739if (Children[i].get() == N)740return true;741return false;742}743744bool hasProperTypeByHwMode() const;745bool hasPossibleType() const;746bool setDefaultMode(unsigned Mode);747748bool hasAnyPredicate() const { return !PredicateCalls.empty(); }749750const std::vector<TreePredicateCall> &getPredicateCalls() const {751return PredicateCalls;752}753void clearPredicateCalls() { PredicateCalls.clear(); }754void setPredicateCalls(const std::vector<TreePredicateCall> &Calls) {755assert(PredicateCalls.empty() && "Overwriting non-empty predicate list!");756PredicateCalls = Calls;757}758void addPredicateCall(const TreePredicateCall &Call) {759assert(!Call.Fn.isAlwaysTrue() && "Empty predicate string!");760assert(!is_contained(PredicateCalls, Call) &&761"predicate applied recursively");762PredicateCalls.push_back(Call);763}764void addPredicateCall(const TreePredicateFn &Fn, unsigned Scope) {765assert((Scope != 0) == Fn.usesOperands());766addPredicateCall(TreePredicateCall(Fn, Scope));767}768769Record *getTransformFn() const { return TransformFn; }770void setTransformFn(Record *Fn) { TransformFn = Fn; }771772/// getIntrinsicInfo - If this node corresponds to an intrinsic, return the773/// CodeGenIntrinsic information for it, otherwise return a null pointer.774const CodeGenIntrinsic *getIntrinsicInfo(const CodeGenDAGPatterns &CDP) const;775776/// getComplexPatternInfo - If this node corresponds to a ComplexPattern,777/// return the ComplexPattern information, otherwise return null.778const ComplexPattern *779getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const;780781/// Returns the number of MachineInstr operands that would be produced by this782/// node if it mapped directly to an output Instruction's783/// operand. ComplexPattern specifies this explicitly; MIOperandInfo gives it784/// for Operands; otherwise 1.785unsigned getNumMIResults(const CodeGenDAGPatterns &CGP) const;786787/// NodeHasProperty - Return true if this node has the specified property.788bool NodeHasProperty(SDNP Property, const CodeGenDAGPatterns &CGP) const;789790/// TreeHasProperty - Return true if any node in this tree has the specified791/// property.792bool TreeHasProperty(SDNP Property, const CodeGenDAGPatterns &CGP) const;793794/// isCommutativeIntrinsic - Return true if the node is an intrinsic which is795/// marked isCommutative.796bool isCommutativeIntrinsic(const CodeGenDAGPatterns &CDP) const;797798void setGISelFlagsRecord(const Record *R) { GISelFlags = R; }799const Record *getGISelFlagsRecord() const { return GISelFlags; }800801void print(raw_ostream &OS) const;802void dump() const;803804public: // Higher level manipulation routines.805/// clone - Return a new copy of this tree.806///807TreePatternNodePtr clone() const;808809/// RemoveAllTypes - Recursively strip all the types of this tree.810void RemoveAllTypes();811812/// isIsomorphicTo - Return true if this node is recursively isomorphic to813/// the specified node. For this comparison, all of the state of the node814/// is considered, except for the assigned name. Nodes with differing names815/// that are otherwise identical are considered isomorphic.816bool isIsomorphicTo(const TreePatternNode &N,817const MultipleUseVarSet &DepVars) const;818819/// SubstituteFormalArguments - Replace the formal arguments in this tree820/// with actual values specified by ArgMap.821void822SubstituteFormalArguments(std::map<std::string, TreePatternNodePtr> &ArgMap);823824/// InlinePatternFragments - If \p T pattern refers to any pattern825/// fragments, return the set of inlined versions (this can be more than826/// one if a PatFrags record has multiple alternatives).827void InlinePatternFragments(TreePattern &TP,828std::vector<TreePatternNodePtr> &OutAlternatives);829830/// ApplyTypeConstraints - Apply all of the type constraints relevant to831/// this node and its children in the tree. This returns true if it makes a832/// change, false otherwise. If a type contradiction is found, flag an error.833bool ApplyTypeConstraints(TreePattern &TP, bool NotRegisters);834835/// UpdateNodeType - Set the node type of N to VT if VT contains836/// information. If N already contains a conflicting type, then flag an837/// error. This returns true if any information was updated.838///839bool UpdateNodeType(unsigned ResNo, const TypeSetByHwMode &InTy,840TreePattern &TP);841bool UpdateNodeType(unsigned ResNo, MVT::SimpleValueType InTy,842TreePattern &TP);843bool UpdateNodeType(unsigned ResNo, ValueTypeByHwMode InTy, TreePattern &TP);844845// Update node type with types inferred from an instruction operand or result846// def from the ins/outs lists.847// Return true if the type changed.848bool UpdateNodeTypeFromInst(unsigned ResNo, Record *Operand, TreePattern &TP);849850/// ContainsUnresolvedType - Return true if this tree contains any851/// unresolved types.852bool ContainsUnresolvedType(TreePattern &TP) const;853854/// canPatternMatch - If it is impossible for this pattern to match on this855/// target, fill in Reason and return false. Otherwise, return true.856bool canPatternMatch(std::string &Reason, const CodeGenDAGPatterns &CDP);857};858859inline raw_ostream &operator<<(raw_ostream &OS, const TreePatternNode &TPN) {860TPN.print(OS);861return OS;862}863864/// TreePattern - Represent a pattern, used for instructions, pattern865/// fragments, etc.866///867class TreePattern {868/// Trees - The list of pattern trees which corresponds to this pattern.869/// Note that PatFrag's only have a single tree.870///871std::vector<TreePatternNodePtr> Trees;872873/// NamedNodes - This is all of the nodes that have names in the trees in this874/// pattern.875StringMap<SmallVector<TreePatternNode *, 1>> NamedNodes;876877/// TheRecord - The actual TableGen record corresponding to this pattern.878///879Record *TheRecord;880881/// Args - This is a list of all of the arguments to this pattern (for882/// PatFrag patterns), which are the 'node' markers in this pattern.883std::vector<std::string> Args;884885/// CDP - the top-level object coordinating this madness.886///887CodeGenDAGPatterns &CDP;888889/// isInputPattern - True if this is an input pattern, something to match.890/// False if this is an output pattern, something to emit.891bool isInputPattern;892893/// hasError - True if the currently processed nodes have unresolvable types894/// or other non-fatal errors895bool HasError;896897/// It's important that the usage of operands in ComplexPatterns is898/// consistent: each named operand can be defined by at most one899/// ComplexPattern. This records the ComplexPattern instance and the operand900/// number for each operand encountered in a ComplexPattern to aid in that901/// check.902StringMap<std::pair<Record *, unsigned>> ComplexPatternOperands;903904TypeInfer Infer;905906public:907/// TreePattern constructor - Parse the specified DagInits into the908/// current record.909TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,910CodeGenDAGPatterns &ise);911TreePattern(Record *TheRec, DagInit *Pat, bool isInput,912CodeGenDAGPatterns &ise);913TreePattern(Record *TheRec, TreePatternNodePtr Pat, bool isInput,914CodeGenDAGPatterns &ise);915916/// getTrees - Return the tree patterns which corresponds to this pattern.917///918const std::vector<TreePatternNodePtr> &getTrees() const { return Trees; }919unsigned getNumTrees() const { return Trees.size(); }920const TreePatternNodePtr &getTree(unsigned i) const { return Trees[i]; }921void setTree(unsigned i, TreePatternNodePtr Tree) { Trees[i] = Tree; }922const TreePatternNodePtr &getOnlyTree() const {923assert(Trees.size() == 1 && "Doesn't have exactly one pattern!");924return Trees[0];925}926927const StringMap<SmallVector<TreePatternNode *, 1>> &getNamedNodesMap() {928if (NamedNodes.empty())929ComputeNamedNodes();930return NamedNodes;931}932933/// getRecord - Return the actual TableGen record corresponding to this934/// pattern.935///936Record *getRecord() const { return TheRecord; }937938unsigned getNumArgs() const { return Args.size(); }939const std::string &getArgName(unsigned i) const {940assert(i < Args.size() && "Argument reference out of range!");941return Args[i];942}943std::vector<std::string> &getArgList() { return Args; }944945CodeGenDAGPatterns &getDAGPatterns() const { return CDP; }946947/// InlinePatternFragments - If this pattern refers to any pattern948/// fragments, inline them into place, giving us a pattern without any949/// PatFrags references. This may increase the number of trees in the950/// pattern if a PatFrags has multiple alternatives.951void InlinePatternFragments() {952std::vector<TreePatternNodePtr> Copy;953Trees.swap(Copy);954for (const TreePatternNodePtr &C : Copy)955C->InlinePatternFragments(*this, Trees);956}957958/// InferAllTypes - Infer/propagate as many types throughout the expression959/// patterns as possible. Return true if all types are inferred, false960/// otherwise. Bail out if a type contradiction is found.961bool InferAllTypes(962const StringMap<SmallVector<TreePatternNode *, 1>> *NamedTypes = nullptr);963964/// error - If this is the first error in the current resolution step,965/// print it and set the error flag. Otherwise, continue silently.966void error(const Twine &Msg);967bool hasError() const { return HasError; }968void resetError() { HasError = false; }969970TypeInfer &getInfer() { return Infer; }971972void print(raw_ostream &OS) const;973void dump() const;974975private:976TreePatternNodePtr ParseTreePattern(Init *DI, StringRef OpName);977void ComputeNamedNodes();978void ComputeNamedNodes(TreePatternNode &N);979};980981inline bool TreePatternNode::UpdateNodeType(unsigned ResNo,982const TypeSetByHwMode &InTy,983TreePattern &TP) {984TypeSetByHwMode VTS(InTy);985TP.getInfer().expandOverloads(VTS);986return TP.getInfer().MergeInTypeInfo(Types[ResNo], VTS);987}988989inline bool TreePatternNode::UpdateNodeType(unsigned ResNo,990MVT::SimpleValueType InTy,991TreePattern &TP) {992TypeSetByHwMode VTS(InTy);993TP.getInfer().expandOverloads(VTS);994return TP.getInfer().MergeInTypeInfo(Types[ResNo], VTS);995}996997inline bool TreePatternNode::UpdateNodeType(unsigned ResNo,998ValueTypeByHwMode InTy,999TreePattern &TP) {1000TypeSetByHwMode VTS(InTy);1001TP.getInfer().expandOverloads(VTS);1002return TP.getInfer().MergeInTypeInfo(Types[ResNo], VTS);1003}10041005/// DAGDefaultOperand - One of these is created for each OperandWithDefaultOps1006/// that has a set ExecuteAlways / DefaultOps field.1007struct DAGDefaultOperand {1008std::vector<TreePatternNodePtr> DefaultOps;1009};10101011class DAGInstruction {1012std::vector<Record *> Results;1013std::vector<Record *> Operands;1014std::vector<Record *> ImpResults;1015TreePatternNodePtr SrcPattern;1016TreePatternNodePtr ResultPattern;10171018public:1019DAGInstruction(std::vector<Record *> &&results,1020std::vector<Record *> &&operands,1021std::vector<Record *> &&impresults,1022TreePatternNodePtr srcpattern = nullptr,1023TreePatternNodePtr resultpattern = nullptr)1024: Results(std::move(results)), Operands(std::move(operands)),1025ImpResults(std::move(impresults)), SrcPattern(srcpattern),1026ResultPattern(resultpattern) {}10271028unsigned getNumResults() const { return Results.size(); }1029unsigned getNumOperands() const { return Operands.size(); }1030unsigned getNumImpResults() const { return ImpResults.size(); }1031const std::vector<Record *> &getImpResults() const { return ImpResults; }10321033Record *getResult(unsigned RN) const {1034assert(RN < Results.size());1035return Results[RN];1036}10371038Record *getOperand(unsigned ON) const {1039assert(ON < Operands.size());1040return Operands[ON];1041}10421043Record *getImpResult(unsigned RN) const {1044assert(RN < ImpResults.size());1045return ImpResults[RN];1046}10471048TreePatternNodePtr getSrcPattern() const { return SrcPattern; }1049TreePatternNodePtr getResultPattern() const { return ResultPattern; }1050};10511052/// PatternToMatch - Used by CodeGenDAGPatterns to keep tab of patterns1053/// processed to produce isel.1054class PatternToMatch {1055Record *SrcRecord; // Originating Record for the pattern.1056ListInit *Predicates; // Top level predicate conditions to match.1057TreePatternNodePtr SrcPattern; // Source pattern to match.1058TreePatternNodePtr DstPattern; // Resulting pattern.1059std::vector<Record *> Dstregs; // Physical register defs being matched.1060std::string HwModeFeatures;1061int AddedComplexity; // Add to matching pattern complexity.1062bool GISelShouldIgnore; // Should GlobalISel ignore importing this pattern.1063unsigned ID; // Unique ID for the record.10641065public:1066PatternToMatch(Record *srcrecord, ListInit *preds, TreePatternNodePtr src,1067TreePatternNodePtr dst, std::vector<Record *> dstregs,1068int complexity, unsigned uid, bool ignore,1069const Twine &hwmodefeatures = "")1070: SrcRecord(srcrecord), Predicates(preds), SrcPattern(src),1071DstPattern(dst), Dstregs(std::move(dstregs)),1072HwModeFeatures(hwmodefeatures.str()), AddedComplexity(complexity),1073GISelShouldIgnore(ignore), ID(uid) {}10741075Record *getSrcRecord() const { return SrcRecord; }1076ListInit *getPredicates() const { return Predicates; }1077TreePatternNode &getSrcPattern() const { return *SrcPattern; }1078TreePatternNodePtr getSrcPatternShared() const { return SrcPattern; }1079TreePatternNode &getDstPattern() const { return *DstPattern; }1080TreePatternNodePtr getDstPatternShared() const { return DstPattern; }1081const std::vector<Record *> &getDstRegs() const { return Dstregs; }1082StringRef getHwModeFeatures() const { return HwModeFeatures; }1083int getAddedComplexity() const { return AddedComplexity; }1084bool getGISelShouldIgnore() const { return GISelShouldIgnore; }1085unsigned getID() const { return ID; }10861087std::string getPredicateCheck() const;1088void getPredicateRecords(SmallVectorImpl<Record *> &PredicateRecs) const;10891090/// Compute the complexity metric for the input pattern. This roughly1091/// corresponds to the number of nodes that are covered.1092int getPatternComplexity(const CodeGenDAGPatterns &CGP) const;1093};10941095class CodeGenDAGPatterns {1096RecordKeeper &Records;1097CodeGenTarget Target;1098CodeGenIntrinsicTable Intrinsics;10991100std::map<Record *, SDNodeInfo, LessRecordByID> SDNodes;1101std::map<Record *, std::pair<Record *, std::string>, LessRecordByID>1102SDNodeXForms;1103std::map<Record *, ComplexPattern, LessRecordByID> ComplexPatterns;1104std::map<Record *, std::unique_ptr<TreePattern>, LessRecordByID>1105PatternFragments;1106std::map<Record *, DAGDefaultOperand, LessRecordByID> DefaultOperands;1107std::map<Record *, DAGInstruction, LessRecordByID> Instructions;11081109// Specific SDNode definitions:1110Record *intrinsic_void_sdnode;1111Record *intrinsic_w_chain_sdnode, *intrinsic_wo_chain_sdnode;11121113/// PatternsToMatch - All of the things we are matching on the DAG. The first1114/// value is the pattern to match, the second pattern is the result to1115/// emit.1116std::vector<PatternToMatch> PatternsToMatch;11171118TypeSetByHwMode LegalVTS;11191120using PatternRewriterFn = std::function<void(TreePattern *)>;1121PatternRewriterFn PatternRewriter;11221123unsigned NumScopes = 0;11241125public:1126CodeGenDAGPatterns(RecordKeeper &R,1127PatternRewriterFn PatternRewriter = nullptr);11281129CodeGenTarget &getTargetInfo() { return Target; }1130const CodeGenTarget &getTargetInfo() const { return Target; }1131const TypeSetByHwMode &getLegalTypes() const { return LegalVTS; }11321133Record *getSDNodeNamed(StringRef Name) const;11341135const SDNodeInfo &getSDNodeInfo(Record *R) const {1136auto F = SDNodes.find(R);1137assert(F != SDNodes.end() && "Unknown node!");1138return F->second;1139}11401141// Node transformation lookups.1142typedef std::pair<Record *, std::string> NodeXForm;1143const NodeXForm &getSDNodeTransform(Record *R) const {1144auto F = SDNodeXForms.find(R);1145assert(F != SDNodeXForms.end() && "Invalid transform!");1146return F->second;1147}11481149const ComplexPattern &getComplexPattern(Record *R) const {1150auto F = ComplexPatterns.find(R);1151assert(F != ComplexPatterns.end() && "Unknown addressing mode!");1152return F->second;1153}11541155const CodeGenIntrinsic &getIntrinsic(Record *R) const {1156for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)1157if (Intrinsics[i].TheDef == R)1158return Intrinsics[i];1159llvm_unreachable("Unknown intrinsic!");1160}11611162const CodeGenIntrinsic &getIntrinsicInfo(unsigned IID) const {1163if (IID - 1 < Intrinsics.size())1164return Intrinsics[IID - 1];1165llvm_unreachable("Bad intrinsic ID!");1166}11671168unsigned getIntrinsicID(Record *R) const {1169for (unsigned i = 0, e = Intrinsics.size(); i != e; ++i)1170if (Intrinsics[i].TheDef == R)1171return i;1172llvm_unreachable("Unknown intrinsic!");1173}11741175const DAGDefaultOperand &getDefaultOperand(Record *R) const {1176auto F = DefaultOperands.find(R);1177assert(F != DefaultOperands.end() && "Isn't an analyzed default operand!");1178return F->second;1179}11801181// Pattern Fragment information.1182TreePattern *getPatternFragment(Record *R) const {1183auto F = PatternFragments.find(R);1184assert(F != PatternFragments.end() && "Invalid pattern fragment request!");1185return F->second.get();1186}1187TreePattern *getPatternFragmentIfRead(Record *R) const {1188auto F = PatternFragments.find(R);1189if (F == PatternFragments.end())1190return nullptr;1191return F->second.get();1192}11931194typedef std::map<Record *, std::unique_ptr<TreePattern>,1195LessRecordByID>::const_iterator pf_iterator;1196pf_iterator pf_begin() const { return PatternFragments.begin(); }1197pf_iterator pf_end() const { return PatternFragments.end(); }1198iterator_range<pf_iterator> ptfs() const { return PatternFragments; }11991200// Patterns to match information.1201typedef std::vector<PatternToMatch>::const_iterator ptm_iterator;1202ptm_iterator ptm_begin() const { return PatternsToMatch.begin(); }1203ptm_iterator ptm_end() const { return PatternsToMatch.end(); }1204iterator_range<ptm_iterator> ptms() const { return PatternsToMatch; }12051206/// Parse the Pattern for an instruction, and insert the result in DAGInsts.1207typedef std::map<Record *, DAGInstruction, LessRecordByID> DAGInstMap;1208void parseInstructionPattern(CodeGenInstruction &CGI, ListInit *Pattern,1209DAGInstMap &DAGInsts);12101211const DAGInstruction &getInstruction(Record *R) const {1212auto F = Instructions.find(R);1213assert(F != Instructions.end() && "Unknown instruction!");1214return F->second;1215}12161217Record *get_intrinsic_void_sdnode() const { return intrinsic_void_sdnode; }1218Record *get_intrinsic_w_chain_sdnode() const {1219return intrinsic_w_chain_sdnode;1220}1221Record *get_intrinsic_wo_chain_sdnode() const {1222return intrinsic_wo_chain_sdnode;1223}12241225unsigned allocateScope() { return ++NumScopes; }12261227bool operandHasDefault(Record *Op) const {1228return Op->isSubClassOf("OperandWithDefaultOps") &&1229!getDefaultOperand(Op).DefaultOps.empty();1230}12311232private:1233void ParseNodeInfo();1234void ParseNodeTransforms();1235void ParseComplexPatterns();1236void ParsePatternFragments(bool OutFrags = false);1237void ParseDefaultOperands();1238void ParseInstructions();1239void ParsePatterns();1240void ExpandHwModeBasedTypes();1241void InferInstructionFlags();1242void GenerateVariants();1243void VerifyInstructionFlags();12441245void ParseOnePattern(Record *TheDef, TreePattern &Pattern,1246TreePattern &Result,1247const std::vector<Record *> &InstImpResults,1248bool ShouldIgnore = false);1249void AddPatternToMatch(TreePattern *Pattern, PatternToMatch &&PTM);1250void FindPatternInputsAndOutputs(1251TreePattern &I, TreePatternNodePtr Pat,1252std::map<std::string, TreePatternNodePtr> &InstInputs,1253MapVector<std::string, TreePatternNodePtr,1254std::map<std::string, unsigned>> &InstResults,1255std::vector<Record *> &InstImpResults);1256};12571258inline bool SDNodeInfo::ApplyTypeConstraints(TreePatternNode &N,1259TreePattern &TP) const {1260bool MadeChange = false;1261for (unsigned i = 0, e = TypeConstraints.size(); i != e; ++i)1262MadeChange |= TypeConstraints[i].ApplyTypeConstraint(N, *this, TP);1263return MadeChange;1264}12651266} // end namespace llvm12671268#endif126912701271