From ed0d4dabbee72bd62b0ac8fa3493ae1960ad8a34 Mon Sep 17 00:00:00 2001 From: John Brawn Date: Tue, 3 Jul 2018 10:52:20 +0000 Subject: [PATCH] [llvm-exegesis] Adjust AArch64 unit test The signature of setRegToConstant changed in r336171, so adjust the AArch64 unit test in a similar way to how the X86 unit test was changed in that commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336188 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../tools/llvm-exegesis/AArch64/TargetTest.cpp | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp b/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp index 7d1f2e4804e..cf3c11a9fde 100644 --- a/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp +++ b/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp @@ -4,6 +4,8 @@ #include #include "MCTargetDesc/AArch64MCTargetDesc.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -17,20 +19,33 @@ using testing::Gt; using testing::NotNull; using testing::SizeIs; +constexpr const char kTriple[] = "aarch64-unknown-linux"; + class AArch64TargetTest : public ::testing::Test { protected: AArch64TargetTest() - : Target_(ExegesisTarget::lookup(llvm::Triple("aarch64-unknown-linux"))) { + : ExegesisTarget_(ExegesisTarget::lookup(llvm::Triple(kTriple))) { + EXPECT_THAT(ExegesisTarget_, NotNull()); + std::string error; + Target_ = llvm::TargetRegistry::lookupTarget(kTriple, error); EXPECT_THAT(Target_, NotNull()); } - static void SetUpTestCase() { InitializeAArch64ExegesisTarget(); } + static void SetUpTestCase() { + LLVMInitializeAArch64TargetInfo(); + LLVMInitializeAArch64Target(); + LLVMInitializeAArch64TargetMC(); + InitializeAArch64ExegesisTarget(); + } - const ExegesisTarget *const Target_; + const llvm::Target *Target_; + const ExegesisTarget *const ExegesisTarget_; }; TEST_F(AArch64TargetTest, SetRegToConstant) { + const std::unique_ptr STI( + Target_->createMCSubtargetInfo(kTriple, "generic", "")); // The AArch64 target currently doesn't know how to set register values - const auto Insts = Target_->setRegToConstant(llvm::AArch64::X0); + const auto Insts = ExegesisTarget_->setRegToConstant(*STI, llvm::AArch64::X0); EXPECT_THAT(Insts, SizeIs(0)); } -- 2.11.0