Changeset View
Changeset View
Standalone View
Standalone View
llvm/include/llvm/CodeGen/GlobalISel/MIPatternMatch.h
Show First 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
inline bind_ty<Register> m_Reg(Register &R) { return R; } | inline bind_ty<Register> m_Reg(Register &R) { return R; } | ||||
inline bind_ty<MachineInstr *> m_MInstr(MachineInstr *&MI) { return MI; } | inline bind_ty<MachineInstr *> m_MInstr(MachineInstr *&MI) { return MI; } | ||||
inline bind_ty<LLT> m_Type(LLT Ty) { return Ty; } | inline bind_ty<LLT> m_Type(LLT Ty) { return Ty; } | ||||
inline bind_ty<CmpInst::Predicate> m_Pred(CmpInst::Predicate &P) { return P; } | inline bind_ty<CmpInst::Predicate> m_Pred(CmpInst::Predicate &P) { return P; } | ||||
inline operand_type_match m_Pred() { return operand_type_match(); } | inline operand_type_match m_Pred() { return operand_type_match(); } | ||||
struct ImplicitDefMatch { | |||||
bool match(const MachineRegisterInfo &MRI, Register Reg) { | |||||
MachineInstr *TmpMI; | |||||
if (mi_match(Reg, MRI, m_MInstr(TmpMI))) | |||||
return TmpMI->getOpcode() == TargetOpcode::G_IMPLICIT_DEF; | |||||
return false; | |||||
} | |||||
}; | |||||
inline ImplicitDefMatch m_GImplicitDef() { return ImplicitDefMatch(); } | |||||
// Helper for matching G_FCONSTANT | // Helper for matching G_FCONSTANT | ||||
inline bind_ty<const ConstantFP *> m_GFCst(const ConstantFP *&C) { return C; } | inline bind_ty<const ConstantFP *> m_GFCst(const ConstantFP *&C) { return C; } | ||||
// General helper for all the binary generic MI such as G_ADD/G_SUB etc | // General helper for all the binary generic MI such as G_ADD/G_SUB etc | ||||
template <typename LHS_P, typename RHS_P, unsigned Opcode, | template <typename LHS_P, typename RHS_P, unsigned Opcode, | ||||
bool Commutable = false> | bool Commutable = false> | ||||
struct BinaryOp_match { | struct BinaryOp_match { | ||||
LHS_P L; | LHS_P L; | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
template <typename LHS, typename RHS> | template <typename LHS, typename RHS> | ||||
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_ADD, true> | inline BinaryOp_match<LHS, RHS, TargetOpcode::G_ADD, true> | ||||
m_GAdd(const LHS &L, const RHS &R) { | m_GAdd(const LHS &L, const RHS &R) { | ||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_ADD, true>(L, R); | return BinaryOp_match<LHS, RHS, TargetOpcode::G_ADD, true>(L, R); | ||||
} | } | ||||
template <typename LHS, typename RHS> | template <typename LHS, typename RHS> | ||||
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_BUILD_VECTOR, false> | |||||
m_GBuildVector(const LHS &L, const RHS &R) { | |||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_BUILD_VECTOR, false>(L, 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) { | |||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_BUILD_VECTOR_TRUNC, false>(L, | |||||
R); | |||||
} | |||||
template <typename LHS, typename RHS> | |||||
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_PTR_ADD, false> | inline BinaryOp_match<LHS, RHS, TargetOpcode::G_PTR_ADD, false> | ||||
m_GPtrAdd(const LHS &L, const RHS &R) { | m_GPtrAdd(const LHS &L, const RHS &R) { | ||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_PTR_ADD, false>(L, R); | return BinaryOp_match<LHS, RHS, TargetOpcode::G_PTR_ADD, false>(L, R); | ||||
} | } | ||||
template <typename LHS, typename RHS> | template <typename LHS, typename RHS> | ||||
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SUB> m_GSub(const LHS &L, | inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SUB> m_GSub(const LHS &L, | ||||
const RHS &R) { | const RHS &R) { | ||||
▲ Show 20 Lines • Show All 269 Lines • Show Last 20 Lines |