• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- llvm/unittest/IR/IntrinsicsTest.cpp - ------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/IR/IntrinsicInst.h"
10 #include "gtest/gtest.h"
11 
12 using namespace llvm;
13 
14 namespace {
15 
16 static const char *const NameTable1[] = {
17   "llvm.foo",
18   "llvm.foo.a",
19   "llvm.foo.b",
20   "llvm.foo.b.a",
21   "llvm.foo.c",
22 };
23 
TEST(IntrinNameLookup,Basic)24 TEST(IntrinNameLookup, Basic) {
25   int I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo");
26   EXPECT_EQ(0, I);
27   I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.f64");
28   EXPECT_EQ(0, I);
29   I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.b");
30   EXPECT_EQ(2, I);
31   I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.b.a");
32   EXPECT_EQ(3, I);
33   I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.c");
34   EXPECT_EQ(4, I);
35   I = Intrinsic::lookupLLVMIntrinsicByName(NameTable1, "llvm.foo.c.f64");
36   EXPECT_EQ(4, I);
37 }
38 
39 } // end namespace
40