summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-01-26 22:33:19 +0000
committerReid Kleckner <rnk@google.com>2016-01-26 22:33:19 +0000
commitc2752daa6bf70786ebbb448208af8fb62a431ecc (patch)
tree30f5d3485a097097f1b05b97a178e64753b9a89d /llvm/unittests/IR
parent7da47b8ef5efc16caef8cbd45f495baf9b383370 (diff)
downloadbcm5719-llvm-c2752daa6bf70786ebbb448208af8fb62a431ecc.tar.gz
bcm5719-llvm-c2752daa6bf70786ebbb448208af8fb62a431ecc.zip
Handle more edge cases in intrinsic name binary search
I tried to make the AMDGPU intrinsic info table use this instead of another StringMatcher, and some issues arose. llvm-svn: 258871
Diffstat (limited to 'llvm/unittests/IR')
-rw-r--r--llvm/unittests/IR/CMakeLists.txt1
-rw-r--r--llvm/unittests/IR/IntrinsicsTest.cpp40
2 files changed, 41 insertions, 0 deletions
diff --git a/llvm/unittests/IR/CMakeLists.txt b/llvm/unittests/IR/CMakeLists.txt
index 5aad8edc913..667fcc34c17 100644
--- a/llvm/unittests/IR/CMakeLists.txt
+++ b/llvm/unittests/IR/CMakeLists.txt
@@ -14,6 +14,7 @@ set(IRSources
DominatorTreeTest.cpp
IRBuilderTest.cpp
InstructionsTest.cpp
+ IntrinsicsTest.cpp
LegacyPassManagerTest.cpp
MDBuilderTest.cpp
MetadataTest.cpp
diff --git a/llvm/unittests/IR/IntrinsicsTest.cpp b/llvm/unittests/IR/IntrinsicsTest.cpp
new file mode 100644
index 00000000000..0d12126b1fc
--- /dev/null
+++ b/llvm/unittests/IR/IntrinsicsTest.cpp
@@ -0,0 +1,40 @@
+//===- llvm/unittest/IR/IntrinsicsTest.cpp - ------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/IntrinsicInst.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+
+static const char *const NameTable1[] = {
+ "llvm.foo",
+ "llvm.foo.a",
+ "llvm.foo.b",
+ "llvm.foo.b.a",
+ "llvm.foo.c",
+};
+
+TEST(IntrinNameLookup, Basic) {
+ int I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo");
+ EXPECT_EQ(0, I);
+ I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.f64");
+ EXPECT_EQ(0, I);
+ I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.b");
+ EXPECT_EQ(2, I);
+ I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.b.a");
+ EXPECT_EQ(3, I);
+ I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.c");
+ EXPECT_EQ(4, I);
+ I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.c.f64");
+ EXPECT_EQ(4, I);
+}
+
+} // end namespace
OpenPOWER on IntegriCloud