mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-15 08:19:51 +00:00
[GISel]: Pattern matchers for GFSUB, GFNEG
https://reviews.llvm.org/D47547 Add matching templates for G_FSUB, and G_FNEG. Reviewed by: aemerson. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333685 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e9015c7760
commit
9f5837ba98
@ -221,6 +221,12 @@ m_GFMul(const LHS &L, const RHS &R) {
|
||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_FMUL, true>(L, R);
|
||||
}
|
||||
|
||||
template <typename LHS, typename RHS>
|
||||
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_FSUB, false>
|
||||
m_GFSub(const LHS &L, const RHS &R) {
|
||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_FSUB, false>(L, R);
|
||||
}
|
||||
|
||||
template <typename LHS, typename RHS>
|
||||
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_AND, true>
|
||||
m_GAnd(const LHS &L, const RHS &R) {
|
||||
@ -304,6 +310,11 @@ inline UnaryOp_match<SrcTy, TargetOpcode::G_FABS> m_GFabs(const SrcTy &Src) {
|
||||
return UnaryOp_match<SrcTy, TargetOpcode::G_FABS>(Src);
|
||||
}
|
||||
|
||||
template <typename SrcTy>
|
||||
inline UnaryOp_match<SrcTy, TargetOpcode::G_FNEG> m_GFNeg(const SrcTy &Src) {
|
||||
return UnaryOp_match<SrcTy, TargetOpcode::G_FNEG>(Src);
|
||||
}
|
||||
|
||||
template <typename SrcTy>
|
||||
inline UnaryOp_match<SrcTy, TargetOpcode::COPY> m_Copy(SrcTy &&Src) {
|
||||
return UnaryOp_match<SrcTy, TargetOpcode::COPY>(std::forward<SrcTy>(Src));
|
||||
|
@ -212,6 +212,14 @@ TEST(PatternMatchInstr, MatchBinaryOp) {
|
||||
ASSERT_EQ(Cst, 42);
|
||||
ASSERT_EQ(Src0, Copies[0]);
|
||||
|
||||
// FSUB
|
||||
auto MIBFSub = B.buildInstr(TargetOpcode::G_FSUB, s64, Copies[0],
|
||||
B.buildConstant(s64, 42));
|
||||
match = mi_match(MIBFSub->getOperand(0).getReg(), MRI,
|
||||
m_GFSub(m_Reg(Src0), m_Reg()));
|
||||
ASSERT_TRUE(match);
|
||||
ASSERT_EQ(Src0, Copies[0]);
|
||||
|
||||
// Build AND %0, %1
|
||||
auto MIBAnd = B.buildAnd(s64, Copies[0], Copies[1]);
|
||||
// Try to match AND.
|
||||
@ -283,7 +291,13 @@ TEST(PatternMatchInstr, MatchFPUnaryOp) {
|
||||
auto MIBFabs = B.buildInstr(TargetOpcode::G_FABS, s32, Copy0s32);
|
||||
bool match = mi_match(MIBFabs->getOperand(0).getReg(), MRI, m_GFabs(m_Reg()));
|
||||
ASSERT_TRUE(match);
|
||||
|
||||
unsigned Src;
|
||||
auto MIBFNeg = B.buildInstr(TargetOpcode::G_FNEG, s32, Copy0s32);
|
||||
match = mi_match(MIBFNeg->getOperand(0).getReg(), MRI, m_GFNeg(m_Reg(Src)));
|
||||
ASSERT_TRUE(match);
|
||||
ASSERT_EQ(Src, Copy0s32->getOperand(0).getReg());
|
||||
|
||||
match = mi_match(MIBFabs->getOperand(0).getReg(), MRI, m_GFabs(m_Reg(Src)));
|
||||
ASSERT_TRUE(match);
|
||||
ASSERT_EQ(Src, Copy0s32->getOperand(0).getReg());
|
||||
|
Loading…
x
Reference in New Issue
Block a user