[llvm-exegesis] Adjust AArch64 unit test
authorJohn Brawn <john.brawn@arm.com>
Tue, 3 Jul 2018 10:52:20 +0000 (10:52 +0000)
committerJohn Brawn <john.brawn@arm.com>
Tue, 3 Jul 2018 10:52:20 +0000 (10:52 +0000)
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.

llvm-svn: 336188

llvm/unittests/tools/llvm-exegesis/AArch64/TargetTest.cpp

index 7d1f2e4..cf3c11a 100644 (file)
@@ -4,6 +4,8 @@
 #include <memory>
 
 #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<llvm::MCSubtargetInfo> 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));
 }