llvm/unittests/IR/IntrinsicsTest.cpp
Reid Kleckner dc8eb983e7 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258871 91177308-0d34-0410-b5e6-96231b3b80d8
2016-01-26 22:33:19 +00:00

41 lines
1.1 KiB
C++

//===- 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