mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 17:56:53 +00:00
GlobalISel: Add matcher for G_LSHR
This commit is contained in:
parent
10fe28f702
commit
529fcd14cb
@ -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_LSHR, false>
|
||||
m_GLShr(const LHS &L, const RHS &R) {
|
||||
return BinaryOp_match<LHS, RHS, TargetOpcode::G_LSHR, false>(L, R);
|
||||
}
|
||||
|
||||
// Helper for unary instructions (G_[ZSA]EXT/G_TRUNC) etc
|
||||
template <typename SrcTy, unsigned Opcode> struct UnaryOp_match {
|
||||
SrcTy L;
|
||||
|
@ -45,6 +45,7 @@ TEST_F(GISelMITest, MatchBinaryOp) {
|
||||
setUp();
|
||||
if (!TM)
|
||||
return;
|
||||
LLT s32 = LLT::scalar(32);
|
||||
LLT s64 = LLT::scalar(64);
|
||||
auto MIBAdd = B.buildAdd(s64, Copies[0], Copies[1]);
|
||||
// Test case for no bind.
|
||||
@ -127,6 +128,15 @@ TEST_F(GISelMITest, MatchBinaryOp) {
|
||||
EXPECT_TRUE(match);
|
||||
EXPECT_EQ(Src0, Copies[0]);
|
||||
EXPECT_EQ(Src1, Copies[1]);
|
||||
|
||||
// Match lshr, and make sure a different shift amount type works.
|
||||
auto TruncCopy1 = B.buildTrunc(s32, Copies[1]);
|
||||
auto LShr = B.buildLShr(s64, Copies[0], TruncCopy1);
|
||||
match = mi_match(LShr.getReg(0), *MRI,
|
||||
m_GLShr(m_Reg(Src0), m_Reg(Src1)));
|
||||
EXPECT_TRUE(match);
|
||||
EXPECT_EQ(Src0, Copies[0]);
|
||||
EXPECT_EQ(Src1, TruncCopy1.getReg(0));
|
||||
}
|
||||
|
||||
TEST_F(GISelMITest, MatchICmp) {
|
||||
|
Loading…
Reference in New Issue
Block a user