Mercurial > hg > CbC > CbC_llvm
comparison unittests/tools/llvm-exegesis/PowerPC/TargetTest.cpp @ 148:63bd29f05246
merged
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 14 Aug 2019 19:46:37 +0900 |
parents | c2174574ed3a |
children |
comparison
equal
deleted
inserted
replaced
146:3fc4d5c3e21e | 148:63bd29f05246 |
---|---|
1 //===-- TargetTest.cpp ---------------------------------------*- C++ -*-===// | |
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 "Target.h" | |
10 | |
11 #include <cassert> | |
12 #include <memory> | |
13 | |
14 #include "MCTargetDesc/PPCMCTargetDesc.h" | |
15 #include "llvm/Support/TargetRegistry.h" | |
16 #include "llvm/Support/TargetSelect.h" | |
17 #include "gmock/gmock.h" | |
18 #include "gtest/gtest.h" | |
19 | |
20 namespace llvm{ | |
21 namespace exegesis { | |
22 | |
23 void InitializePowerPCExegesisTarget(); | |
24 | |
25 namespace { | |
26 | |
27 using testing::NotNull; | |
28 using testing::IsEmpty; | |
29 using testing::Not; | |
30 | |
31 constexpr const char kTriple[] = "powerpc64le-unknown-linux"; | |
32 | |
33 class PowerPCTargetTest : public ::testing::Test { | |
34 protected: | |
35 PowerPCTargetTest() | |
36 : ExegesisTarget_(ExegesisTarget::lookup(llvm::Triple(kTriple))) { | |
37 EXPECT_THAT(ExegesisTarget_, NotNull()); | |
38 std::string error; | |
39 Target_ = llvm::TargetRegistry::lookupTarget(kTriple, error); | |
40 EXPECT_THAT(Target_, NotNull()); | |
41 } | |
42 static void SetUpTestCase() { | |
43 LLVMInitializePowerPCTargetInfo(); | |
44 LLVMInitializePowerPCTarget(); | |
45 LLVMInitializePowerPCTargetMC(); | |
46 InitializePowerPCExegesisTarget(); | |
47 } | |
48 | |
49 const llvm::Target *Target_; | |
50 const ExegesisTarget *const ExegesisTarget_; | |
51 }; | |
52 | |
53 TEST_F(PowerPCTargetTest, SetRegToConstant) { | |
54 const std::unique_ptr<llvm::MCSubtargetInfo> STI( | |
55 Target_->createMCSubtargetInfo(kTriple, "generic", "")); | |
56 const auto Insts = | |
57 ExegesisTarget_->setRegTo(*STI, llvm::PPC::X0, llvm::APInt()); | |
58 EXPECT_THAT(Insts, Not(IsEmpty())); | |
59 } | |
60 | |
61 TEST_F(PowerPCTargetTest, DefaultPfmCounters) { | |
62 const std::string Expected = "CYCLES"; | |
63 EXPECT_EQ(ExegesisTarget_->getPfmCounters("").CycleCounter, Expected); | |
64 EXPECT_EQ(ExegesisTarget_->getPfmCounters("unknown_cpu").CycleCounter, | |
65 Expected); | |
66 } | |
67 | |
68 } // namespace | |
69 } // namespace exegesis | |
70 } // namespace llvm |