diff options
| author | 2017-01-24 08:32:59 +0000 | |
|---|---|---|
| committer | 2017-01-24 08:32:59 +0000 | |
| commit | 53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch) | |
| tree | 7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/unittests/IR/PatternMatch.cpp | |
| parent | In preparation of compiling our kernels with -ffreestanding, explicitly map (diff) | |
| download | wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip | |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/unittests/IR/PatternMatch.cpp')
| -rw-r--r-- | gnu/llvm/unittests/IR/PatternMatch.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gnu/llvm/unittests/IR/PatternMatch.cpp b/gnu/llvm/unittests/IR/PatternMatch.cpp index 1121d6554db..2d1321def7e 100644 --- a/gnu/llvm/unittests/IR/PatternMatch.cpp +++ b/gnu/llvm/unittests/IR/PatternMatch.cpp @@ -295,4 +295,31 @@ TEST_F(PatternMatchTest, OverflowingBinOps) { EXPECT_FALSE(m_NUWShl(m_Value(), m_Value()).match(IRB.CreateNUWAdd(L, R))); } +template <typename T> struct MutableConstTest : PatternMatchTest { }; + +typedef ::testing::Types<std::tuple<Value*, Instruction*>, + std::tuple<const Value*, const Instruction *>> + MutableConstTestTypes; +TYPED_TEST_CASE(MutableConstTest, MutableConstTestTypes); + +TYPED_TEST(MutableConstTest, ICmp) { + auto &IRB = PatternMatchTest::IRB; + + typedef typename std::tuple_element<0, TypeParam>::type ValueType; + typedef typename std::tuple_element<1, TypeParam>::type InstructionType; + + Value *L = IRB.getInt32(1); + Value *R = IRB.getInt32(2); + ICmpInst::Predicate Pred = ICmpInst::ICMP_UGT; + + ValueType MatchL; + ValueType MatchR; + ICmpInst::Predicate MatchPred; + + EXPECT_TRUE(m_ICmp(MatchPred, m_Value(MatchL), m_Value(MatchR)) + .match((InstructionType)IRB.CreateICmp(Pred, L, R))); + EXPECT_EQ(L, MatchL); + EXPECT_EQ(R, MatchR); +} + } // anonymous namespace. |
