GlobalISel: Add matcher for G_SHL

This commit is contained in:
Matt Arsenault 2020-03-29 13:07:43 -04:00 committed by Matt Arsenault
parent d15723ef06
commit cce3d96bcc
2 changed files with 14 additions and 0 deletions

View File

@ -241,6 +241,12 @@ inline BinaryOp_match<LHS, RHS, TargetOpcode::G_OR, true> m_GOr(const LHS &L,
return BinaryOp_match<LHS, RHS, TargetOpcode::G_OR, true>(L, R);
}
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_SHL, false>
m_GShl(const LHS &L, const RHS &R) {
return BinaryOp_match<LHS, RHS, TargetOpcode::G_SHL, false>(L, R);
}
template <typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, TargetOpcode::G_LSHR, false>
m_GLShr(const LHS &L, const RHS &R) {

View File

@ -137,6 +137,14 @@ TEST_F(AArch64GISelMITest, MatchBinaryOp) {
EXPECT_TRUE(match);
EXPECT_EQ(Src0, Copies[0]);
EXPECT_EQ(Src1, TruncCopy1.getReg(0));
// Match shl, and make sure a different shift amount type works.
auto Shl = B.buildShl(s64, Copies[0], TruncCopy1);
match = mi_match(Shl.getReg(0), *MRI,
m_GShl(m_Reg(Src0), m_Reg(Src1)));
EXPECT_TRUE(match);
EXPECT_EQ(Src0, Copies[0]);
EXPECT_EQ(Src1, TruncCopy1.getReg(0));
}
TEST_F(AArch64GISelMITest, MatchICmp) {