Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions llvm/unittests/tools/llvm-exegesis/PowerPC/TargetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <memory>

#include "MCTargetDesc/PPCMCTargetDesc.h"
#include "TestBase.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "gmock/gmock.h"
Expand All @@ -30,7 +31,7 @@ using testing::Not;

constexpr const char kTriple[] = "powerpc64le-unknown-linux";

class PowerPCTargetTest : public ::testing::Test {
class PowerPCTargetTest : public PPCTestBase {
protected:
PowerPCTargetTest()
: ExegesisTarget_(ExegesisTarget::lookup(Triple(kTriple))) {
Expand All @@ -39,12 +40,6 @@ class PowerPCTargetTest : public ::testing::Test {
Target_ = TargetRegistry::lookupTarget(kTriple, error);
EXPECT_THAT(Target_, NotNull());
}
static void SetUpTestCase() {
LLVMInitializePowerPCTargetInfo();
LLVMInitializePowerPCTarget();
LLVMInitializePowerPCTargetMC();
InitializePowerPCExegesisTarget();
}

const Target *Target_;
const ExegesisTarget *const ExegesisTarget_;
Expand Down
17 changes: 3 additions & 14 deletions llvm/unittests/tools/llvm-exegesis/X86/TargetTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "MCTargetDesc/X86MCTargetDesc.h"
#include "MmapUtils.h"
#include "SubprocessMemory.h"
#include "TestBase.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "gmock/gmock.h"
Expand Down Expand Up @@ -112,19 +113,9 @@ Matcher<MCInst> IsStackDeallocate(unsigned Size) {
ElementsAre(IsReg(X86::RSP), IsReg(X86::RSP), IsImm(Size)));
}

constexpr const char kTriple[] = "x86_64-unknown-linux";

class X86TargetTest : public ::testing::Test {
class X86TargetTest : public X86TestBase {
protected:
X86TargetTest(const char *Features)
: State(cantFail(LLVMState::Create(kTriple, "core2", Features))) {}

static void SetUpTestCase() {
LLVMInitializeX86TargetInfo();
LLVMInitializeX86Target();
LLVMInitializeX86TargetMC();
InitializeX86ExegesisTarget();
}
X86TargetTest(const char *Features) : X86TestBase("core2", Features) {}

std::vector<MCInst> setRegTo(unsigned Reg, const APInt &Value) {
return State.getExegesisTarget().setRegTo(State.getSubtargetInfo(), Reg,
Expand All @@ -134,8 +125,6 @@ class X86TargetTest : public ::testing::Test {
const Instruction &getInstr(unsigned OpCode) {
return State.getIC().getInstr(OpCode);
}

LLVMState State;
};

class X86Core2TargetTest : public X86TargetTest {
Expand Down
6 changes: 4 additions & 2 deletions llvm/unittests/tools/llvm-exegesis/X86/TestBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ namespace exegesis {

void InitializeX86ExegesisTarget();

constexpr const char kTriple[] = "x86_64-unknown-linux";

class X86TestBase : public ::testing::Test {
protected:
X86TestBase()
: State(cantFail(LLVMState::Create("x86_64-unknown-linux", "haswell"))) {}
X86TestBase(std::string CPUName = "haswell", const char *Features = "")
: State(cantFail(LLVMState::Create(kTriple, CPUName, Features))) {}

static void SetUpTestCase() {
LLVMInitializeX86TargetInfo();
Expand Down
Loading