diff options
Diffstat (limited to 'llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp')
-rw-r--r-- | llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp index 24c1334..9ebb4b1 100644 --- a/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp +++ b/llvm/unittests/CodeGen/GlobalISel/PatternMatchTest.cpp @@ -45,10 +45,10 @@ TEST_F(AArch64GISelMITest, MatchIntConstantRegister) { if (!TM) return; auto MIBCst = B.buildConstant(LLT::scalar(64), 42); - Register Src0; - bool match = mi_match(MIBCst.getReg(0), *MRI, m_ICst(Src0)); + Optional<ValueAndVReg> Src0; + bool match = mi_match(MIBCst.getReg(0), *MRI, m_GCst(Src0)); EXPECT_TRUE(match); - EXPECT_EQ(Src0, MIBCst.getReg(0)); + EXPECT_EQ(Src0->VReg, MIBCst.getReg(0)); } TEST_F(AArch64GISelMITest, MachineInstrPtrBind) { @@ -555,6 +555,25 @@ TEST_F(AArch64GISelMITest, MatchAllOnesInt) { EXPECT_FALSE(mi_match(FortyTwo.getReg(0), *MRI, m_AllOnesInt())); } +TEST_F(AArch64GISelMITest, MatchFPOrIntConst) { + setUp(); + if (!TM) + return; + + Register IntOne = B.buildConstant(LLT::scalar(64), 1).getReg(0); + Register FPOne = B.buildFConstant(LLT::scalar(64), 1.0).getReg(0); + Optional<ValueAndVReg> ValReg; + Optional<FPValueAndVReg> FValReg; + + EXPECT_TRUE(mi_match(IntOne, *MRI, m_GCst(ValReg))); + EXPECT_EQ(IntOne, ValReg->VReg); + EXPECT_FALSE(mi_match(IntOne, *MRI, m_GFCst(FValReg))); + + EXPECT_FALSE(mi_match(FPOne, *MRI, m_GCst(ValReg))); + EXPECT_TRUE(mi_match(FPOne, *MRI, m_GFCst(FValReg))); + EXPECT_EQ(FPOne, FValReg->VReg); +} + TEST_F(AArch64GISelMITest, MatchNeg) { setUp(); if (!TM) |