#ifndef LLVM_CODEGEN_GLOBALISEL_MIPATTERNMATCH_H
#define LLVM_CODEGEN_GLOBALISEL_MIPATTERNMATCH_H
#include "llvm/ADT/APInt.h"
#include "llvm/CodeGen/GlobalISel/Utils.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/InstrTypes.h"
namespace llvm {
namespace MIPatternMatch {
template <typename Reg, typename Pattern>
[[nodiscard]] bool mi_match(Reg R, const MachineRegisterInfo &MRI,
Pattern &&P) { … }
template <typename Pattern>
[[nodiscard]] bool mi_match(MachineInstr &MI, const MachineRegisterInfo &MRI,
Pattern &&P) { … }
template <typename SubPatternT> struct OneUse_match { … };
template <typename SubPat>
inline OneUse_match<SubPat> m_OneUse(const SubPat &SP) { … }
template <typename SubPatternT> struct OneNonDBGUse_match { … };
template <typename SubPat>
inline OneNonDBGUse_match<SubPat> m_OneNonDBGUse(const SubPat &SP) { … }
template <typename ConstT>
inline std::optional<ConstT> matchConstant(Register,
const MachineRegisterInfo &);
template <>
inline std::optional<APInt> matchConstant(Register Reg,
const MachineRegisterInfo &MRI) { … }
template <>
inline std::optional<int64_t> matchConstant(Register Reg,
const MachineRegisterInfo &MRI) { … }
template <typename ConstT> struct ConstantMatch { … };
inline ConstantMatch<APInt> m_ICst(APInt &Cst) { … }
inline ConstantMatch<int64_t> m_ICst(int64_t &Cst) { … }
template <typename ConstT>
inline std::optional<ConstT> matchConstantSplat(Register,
const MachineRegisterInfo &);
template <>
inline std::optional<APInt> matchConstantSplat(Register Reg,
const MachineRegisterInfo &MRI) { … }
template <>
inline std::optional<int64_t>
matchConstantSplat(Register Reg, const MachineRegisterInfo &MRI) { … }
template <typename ConstT> struct ICstOrSplatMatch { … };
inline ICstOrSplatMatch<APInt> m_ICstOrSplat(APInt &Cst) { … }
inline ICstOrSplatMatch<int64_t> m_ICstOrSplat(int64_t &Cst) { … }
struct GCstAndRegMatch { … };
inline GCstAndRegMatch m_GCst(std::optional<ValueAndVReg> &ValReg) { … }
struct GFCstAndRegMatch { … };
inline GFCstAndRegMatch m_GFCst(std::optional<FPValueAndVReg> &FPValReg) { … }
struct GFCstOrSplatGFCstMatch { … };
inline GFCstOrSplatGFCstMatch
m_GFCstOrSplat(std::optional<FPValueAndVReg> &FPValReg) { … }
struct SpecificConstantMatch { … };
inline SpecificConstantMatch m_SpecificICst(int64_t RequestedValue) { … }
struct SpecificConstantSplatMatch { … };
inline SpecificConstantSplatMatch m_SpecificICstSplat(int64_t RequestedValue) { … }
struct SpecificConstantOrSplatMatch { … };
inline SpecificConstantOrSplatMatch
m_SpecificICstOrSplat(int64_t RequestedValue) { … }
inline SpecificConstantMatch m_ZeroInt() { … }
inline SpecificConstantMatch m_AllOnesInt() { … }
struct SpecificRegisterMatch { … };
inline SpecificRegisterMatch m_SpecificReg(Register RequestedReg) { … }
struct operand_type_match { … };
inline operand_type_match m_Reg() { … }
template <typename... Preds> struct And { … };
And<Pred, Preds...>;
template <typename... Preds> struct Or { … };
Or<Pred, Preds...>;
template <typename... Preds> And<Preds...> m_all_of(Preds &&... preds) { … }
template <typename... Preds> Or<Preds...> m_any_of(Preds &&... preds) { … }
template <typename BindTy> struct bind_helper { … };
template <> struct bind_helper<MachineInstr *> { … };
template <> struct bind_helper<LLT> { … };
template <> struct bind_helper<const ConstantFP *> { … };
template <typename Class> struct bind_ty { … };
inline bind_ty<Register> m_Reg(Register &R) { … }
inline bind_ty<MachineInstr *> m_MInstr(MachineInstr *&MI) { … }
inline bind_ty<LLT> m_Type(LLT Ty) { … }
inline bind_ty<CmpInst::Predicate> m_Pred(CmpInst::Predicate &P) { … }
inline operand_type_match m_Pred() { … }
struct ImplicitDefMatch { … };
inline ImplicitDefMatch m_GImplicitDef() { … }
inline bind_ty<const ConstantFP *> m_GFCst(const ConstantFP *&C) { … }
template <typename LHS_P, typename RHS_P, unsigned Opcode,
bool Commutable = false>
struct BinaryOp_match { … };
template <typename LHS_P, typename RHS_P, bool Commutable = false>
struct BinaryOpc_match { … };
template <typename LHS, typename RHS>
inline BinaryOpc_match<LHS, RHS, false> m_BinOp(unsigned Opcode, const LHS &L,
const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOpc_match<LHS, RHS, true>
m_CommutativeBinOp(unsigned Opcode, const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_ADD, true>
m_GAdd(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_BUILD_VECTOR, false>
m_GBuildVector(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_BUILD_VECTOR_TRUNC, false>
m_GBuildVectorTrunc(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_PTR_ADD, false>
m_GPtrAdd(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SUB> m_GSub(const LHS &L,
const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_MUL, true>
m_GMul(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FADD, true>
m_GFAdd(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FMUL, true>
m_GFMul(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FSUB, false>
m_GFSub(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_AND, true>
m_GAnd(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_XOR, true>
m_GXor(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_OR, true> m_GOr(const LHS &L,
const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SHL, false>
m_GShl(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_LSHR, false>
m_GLShr(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_ASHR, false>
m_GAShr(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SMAX, false>
m_GSMax(const LHS &L, const RHS &R) { … }
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SMIN, false>
m_GSMin(const LHS &L, const RHS &R) { … }
template <typename SrcTy, unsigned Opcode> struct UnaryOp_match { … };
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_ANYEXT>
m_GAnyExt(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_SEXT> m_GSExt(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_ZEXT> m_GZExt(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_FPEXT> m_GFPExt(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_TRUNC> m_GTrunc(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_BITCAST>
m_GBitcast(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_PTRTOINT>
m_GPtrToInt(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_INTTOPTR>
m_GIntToPtr(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_FPTRUNC>
m_GFPTrunc(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_FABS> m_GFabs(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_FNEG> m_GFNeg(const SrcTy &Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::COPY> m_Copy(SrcTy &&Src) { … }
template <typename SrcTy>
inline UnaryOp_match<SrcTy, TargetOpcode::G_FSQRT> m_GFSqrt(const SrcTy &Src) { … }
template <typename Pred_P, typename LHS_P, typename RHS_P, unsigned Opcode,
bool Commutable = false>
struct CompareOp_match { … };
template <typename Pred, typename LHS, typename RHS>
inline CompareOp_match<Pred, LHS, RHS, TargetOpcode::G_ICMP>
m_GICmp(const Pred &P, const LHS &L, const RHS &R) { … }
template <typename Pred, typename LHS, typename RHS>
inline CompareOp_match<Pred, LHS, RHS, TargetOpcode::G_FCMP>
m_GFCmp(const Pred &P, const LHS &L, const RHS &R) { … }
template <typename Pred, typename LHS, typename RHS>
inline CompareOp_match<Pred, LHS, RHS, TargetOpcode::G_ICMP, true>
m_c_GICmp(const Pred &P, const LHS &L, const RHS &R) { … }
template <typename Pred, typename LHS, typename RHS>
inline CompareOp_match<Pred, LHS, RHS, TargetOpcode::G_FCMP, true>
m_c_GFCmp(const Pred &P, const LHS &L, const RHS &R) { … }
struct CheckType { … };
inline CheckType m_SpecificType(LLT Ty) { … }
template <typename Src0Ty, typename Src1Ty, typename Src2Ty, unsigned Opcode>
struct TernaryOp_match { … };
template <typename Src0Ty, typename Src1Ty, typename Src2Ty>
inline TernaryOp_match<Src0Ty, Src1Ty, Src2Ty,
TargetOpcode::G_INSERT_VECTOR_ELT>
m_GInsertVecElt(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2) { … }
template <typename Src0Ty, typename Src1Ty, typename Src2Ty>
inline TernaryOp_match<Src0Ty, Src1Ty, Src2Ty, TargetOpcode::G_SELECT>
m_GISelect(const Src0Ty &Src0, const Src1Ty &Src1, const Src2Ty &Src2) { … }
template <typename SrcTy>
inline BinaryOp_match<SpecificConstantMatch, SrcTy, TargetOpcode::G_SUB>
m_Neg(const SrcTy &&Src) { … }
template <typename SrcTy>
inline BinaryOp_match<SrcTy, SpecificConstantMatch, TargetOpcode::G_XOR, true>
m_Not(const SrcTy &&Src) { … }
}
}
#endif