13 #ifndef LLVM_GMIR_PATTERNMATCH_H 14 #define LLVM_GMIR_PATTERNMATCH_H 22 namespace MIPatternMatch {
24 template <
typename Reg,
typename Pattern>
26 return P.match(MRI, R);
34 template <
typename OpTy>
36 return MRI.
hasOneUse(Reg) && SubPat.match(MRI, Reg);
40 template <
typename SubPat>
74 template <
typename... Preds>
struct And {
75 template <
typename MatchSrc>
81 template <
typename Pred,
typename... Preds>
82 struct And<Pred, Preds...> :
And<Preds...> {
84 And(Pred &&p, Preds &&... preds)
85 :
And<Preds...>(
std::forward<Preds>(preds)...), P(
std::forward<Pred>(p)) {
87 template <
typename MatchSrc>
93 template <
typename... Preds>
struct Or {
94 template <
typename MatchSrc>
100 template <
typename Pred,
typename... Preds>
101 struct Or<Pred, Preds...> :
Or<Preds...> {
103 Or(Pred &&p, Preds &&... preds)
104 :
Or<Preds...>(
std::forward<Preds>(preds)...), P(
std::forward<Pred>(p)) {}
105 template <
typename MatchSrc>
111 template <
typename... Preds>
And<Preds...>
m_all_of(Preds &&... preds) {
112 return And<Preds...>(std::forward<Preds>(preds)...);
115 template <
typename... Preds>
Or<Preds...>
m_any_of(Preds &&... preds) {
116 return Or<Preds...>(std::forward<Preds>(preds)...);
173 template <
typename LHS_P,
typename RHS_P,
unsigned Opcode,
194 template <
typename LHS,
typename RHS>
200 template <
typename LHS,
typename RHS>
206 template <
typename LHS,
typename RHS>
212 template <
typename LHS,
typename RHS>
218 template <
typename LHS,
typename RHS>
224 template <
typename LHS,
typename RHS>
230 template <
typename LHS,
typename RHS>
236 template <
typename LHS,
typename RHS>
258 template <
typename SrcTy>
264 template <
typename SrcTy>
269 template <
typename SrcTy>
274 template <
typename SrcTy>
279 template <
typename SrcTy>
284 template <
typename SrcTy>
290 template <
typename SrcTy>
296 template <
typename SrcTy>
302 template <
typename SrcTy>
308 template <
typename SrcTy>
313 template <
typename SrcTy>
318 template <
typename SrcTy>
BinaryOp_match< LHS, RHS, TargetOpcode::G_FMUL, true > m_GFMul(const LHS &L, const RHS &R)
UnaryOp_match< SrcTy, TargetOpcode::G_INTTOPTR > m_GIntToPtr(const SrcTy &Src)
BinaryOp_match(const LHS_P &LHS, const RHS_P &RHS)
bool match(MachineRegisterInfo &MRI, MatchSrc &&src)
bind_ty< MachineInstr * > m_MInstr(MachineInstr *&MI)
UnaryOp_match< SrcTy, TargetOpcode::G_ANYEXT > m_GAnyExt(const SrcTy &Src)
static bool bind(const MachineRegisterInfo &MRI, BindTy &VR, BindTy &V)
This class represents lattice values for constants.
static bool bind(const MachineRegisterInfo &MRI, LLT &Ty, unsigned Reg)
const ConstantFP * getConstantFPVRegVal(unsigned VReg, const MachineRegisterInfo &MRI)
bool match(const MachineRegisterInfo &MRI, MachineOperand *MO)
unsigned getReg() const
getReg - Returns the register number.
UnaryOp_match< SrcTy, TargetOpcode::G_ZEXT > m_GZExt(const SrcTy &Src)
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
Or(Pred &&p, Preds &&... preds)
bool match(const MachineRegisterInfo &MRI, ITy &&V)
static bool bind(const MachineRegisterInfo &MRI, const ConstantFP *&F, unsigned Reg)
BinaryOp_match< LHS, RHS, TargetOpcode::G_ADD, true > m_GAdd(const LHS &L, const RHS &R)
Or< Preds... > m_any_of(Preds &&... preds)
UnaryOp_match< SrcTy, TargetOpcode::G_FPTRUNC > m_GFPTrunc(const SrcTy &Src)
unsigned getNumOperands() const
Retuns the total number of operands.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
This file implements a class to represent arbitrary precision integral constant values and operations...
bool mi_match(Reg R, MachineRegisterInfo &MRI, Pattern &&P)
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
ConstantMatch(int64_t &C)
BinaryOp_match< LHS, RHS, TargetOpcode::G_FSUB, false > m_GFSub(const LHS &L, const RHS &R)
UnaryOp_match< SrcTy, TargetOpcode::COPY > m_Copy(SrcTy &&Src)
And< Preds... > m_all_of(Preds &&... preds)
And(Pred &&p, Preds &&... preds)
bool match(MachineRegisterInfo &MRI, unsigned Reg)
UnaryOp_match< SrcTy, TargetOpcode::G_BITCAST > m_GBitcast(const SrcTy &Src)
bind_ty< LLT > m_Type(LLT &Ty)
bool match(MachineRegisterInfo &MRI, MatchSrc &&src)
UnaryOp_match< SrcTy, TargetOpcode::G_FPEXT > m_GFPExt(const SrcTy &Src)
OneUse_match< SubPat > m_OneUse(const SubPat &SP)
bool match(MachineRegisterInfo &MRI, MatchSrc &&src)
OneUse_match(const SubPatternT &SP)
BinaryOp_match< LHS, RHS, TargetOpcode::G_AND, true > m_GAnd(const LHS &L, const RHS &R)
unsigned const MachineRegisterInfo * MRI
bool match(const MachineRegisterInfo &MRI, unsigned Reg)
BinaryOp_match< LHS, RHS, TargetOpcode::G_SUB > m_GSub(const LHS &L, const RHS &R)
ConstantFP - Floating Point Values [float, double].
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static bool bind(const MachineRegisterInfo &MRI, MachineInstr *&MI, unsigned Reg)
UnaryOp_match< SrcTy, TargetOpcode::G_FNEG > m_GFNeg(const SrcTy &Src)
bool match(const MachineRegisterInfo &MRI, unsigned Reg)
MachineOperand class - Representation of each machine instruction operand.
CheckType m_SpecificType(LLT Ty)
Optional< int64_t > getConstantVRegVal(unsigned VReg, const MachineRegisterInfo &MRI)
UnaryOp_match< SrcTy, TargetOpcode::G_SEXT > m_GSExt(const SrcTy &Src)
UnaryOp_match< SrcTy, TargetOpcode::G_TRUNC > m_GTrunc(const SrcTy &Src)
UnaryOp_match< SrcTy, TargetOpcode::G_FABS > m_GFabs(const SrcTy &Src)
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
BinaryOp_match< LHS, RHS, TargetOpcode::G_MUL, true > m_GMul(const LHS &L, const RHS &R)
Representation of each machine instruction.
bool match(MachineRegisterInfo &MRI, OpTy &&Op)
bool hasOneUse(unsigned RegNo) const
hasOneUse - Return true if there is exactly one instruction using the specified register.
ConstantMatch m_ICst(int64_t &Cst)
bool match(const MachineRegisterInfo &MRI, unsigned Reg)
UnaryOp_match< SrcTy, TargetOpcode::G_PTRTOINT > m_GPtrToInt(const SrcTy &Src)
bind_ty< const ConstantFP * > m_GFCst(const ConstantFP *&C)
BinaryOp_match< LHS, RHS, TargetOpcode::G_FADD, true > m_GFAdd(const LHS &L, const RHS &R)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
operand_type_match m_Reg()
BinaryOp_match< LHS, RHS, TargetOpcode::G_OR, true > m_GOr(const LHS &L, const RHS &R)
const MachineOperand & getOperand(unsigned i) const
bool match(MachineRegisterInfo &MRI, MatchSrc &&src)
bool match(MachineRegisterInfo &MRI, OpTy &&Op)
UnaryOp_match(const SrcTy &LHS)