#include "Target.h"
#include <cassert>
#include <memory>
#include "MCTargetDesc/X86MCTargetDesc.h"
#include "MmapUtils.h"
#include "SubprocessMemory.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "llvm/MC/MCInstPrinter.h"
#ifdef __linux__
#include <sys/mman.h>
#include <sys/syscall.h>
#endif
namespace llvm {
bool operator==(const MCOperand &a, const MCOperand &b) { … }
bool operator==(const MCInst &a, const MCInst &b) { … }
}
namespace llvm {
namespace exegesis {
void InitializeX86ExegesisTarget();
namespace {
AllOf;
ElementsAre;
ElementsAreArray;
Eq;
IsEmpty;
Matcher;
Property;
Matcher<MCOperand> IsImm(int64_t Value) { … }
Matcher<MCOperand> IsReg(unsigned Reg) { … }
Matcher<MCInst> OpcodeIs(unsigned Opcode) { … }
Matcher<MCInst> IsMovImmediate(unsigned Opcode, int64_t Reg, int64_t Value) { … }
#ifdef __linux__
Matcher<MCInst> IsMovRegToReg(unsigned Opcode, int64_t Reg1, int64_t Reg2) { … }
#endif
Matcher<MCInst> IsMovValueToStack(unsigned Opcode, int64_t Value,
size_t Offset) { … }
Matcher<MCInst> IsMovValueFromStack(unsigned Opcode, unsigned Reg) { … }
Matcher<MCInst> IsStackAllocate(unsigned Size) { … }
Matcher<MCInst> IsStackDeallocate(unsigned Size) { … }
constexpr const char kTriple[] = …;
class X86TargetTest : public ::testing::Test { … };
class X86Core2TargetTest : public X86TargetTest { … };
class X86Core2AvxTargetTest : public X86TargetTest { … };
class X86Core2Avx512TargetTest : public X86TargetTest { … };
class X86Core2Avx512DQTargetTest : public X86TargetTest { … };
class X86Core2Avx512BWTargetTest : public X86TargetTest { … };
class X86Core2Avx512DQBWTargetTest : public X86TargetTest { … };
TEST_F(X86Core2TargetTest, NoHighByteRegs) { … }
TEST_F(X86Core2TargetTest, SetFlags) { … }
TEST_F(X86Core2TargetTest, SetRegToGR8Value) { … }
TEST_F(X86Core2TargetTest, SetRegToGR16Value) { … }
TEST_F(X86Core2TargetTest, SetRegToGR32Value) { … }
TEST_F(X86Core2TargetTest, SetRegToGR64Value) { … }
TEST_F(X86Core2TargetTest, SetRegToVR64Value) { … }
TEST_F(X86Core2TargetTest, SetRegToVR128Value_Use_MOVDQUrm) { … }
TEST_F(X86Core2AvxTargetTest, SetRegToVR128Value_Use_VMOVDQUrm) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToVR128Value_Use_VMOVDQU32Z128rm) { … }
TEST_F(X86Core2AvxTargetTest, SetRegToVR256Value_Use_VMOVDQUYrm) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToVR256Value_Use_VMOVDQU32Z256rm) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToVR512Value) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToK0_16Bits) { … }
TEST_F(X86Core2Avx512DQTargetTest, SetRegToK0_16Bits) { … }
TEST_F(X86Core2Avx512BWTargetTest, SetRegToK0_16Bits) { … }
TEST_F(X86Core2Avx512DQBWTargetTest, SetRegToK0_16Bits) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToK0_8Bits) { … }
TEST_F(X86Core2Avx512DQTargetTest, SetRegToK0_8Bits) { … }
TEST_F(X86Core2Avx512BWTargetTest, SetRegToK0_8Bits) { … }
TEST_F(X86Core2Avx512DQBWTargetTest, SetRegToK0_8Bits) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToK0_32Bits) { … }
TEST_F(X86Core2Avx512DQTargetTest, SetRegToK0_32Bits) { … }
TEST_F(X86Core2Avx512BWTargetTest, SetRegToK0_32Bits) { … }
TEST_F(X86Core2Avx512DQBWTargetTest, SetRegToK0_32Bits) { … }
TEST_F(X86Core2Avx512TargetTest, SetRegToK0_64Bits) { … }
TEST_F(X86Core2Avx512DQTargetTest, SetRegToK0_64Bits) { … }
TEST_F(X86Core2Avx512BWTargetTest, SetRegToK0_64Bits) { … }
TEST_F(X86Core2Avx512DQBWTargetTest, SetRegToK0_64Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToST0_32Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToST1_32Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToST0_64Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToST0_80Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToFP0_80Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToFP1_32Bits) { … }
TEST_F(X86Core2TargetTest, SetRegToFP1_4Bits) { … }
TEST_F(X86Core2Avx512TargetTest, FillMemoryOperands_ADD64rm) { … }
TEST_F(X86Core2Avx512TargetTest, FillMemoryOperands_VGATHERDPSZ128rm) { … }
TEST_F(X86Core2TargetTest, AllowAsBackToBack) { … }
#ifdef __linux__
TEST_F(X86Core2TargetTest, GenerateLowerMunmapTest) { … }
#ifdef __arm__
static constexpr const uintptr_t VAddressSpaceCeiling = 0xC0000000;
#else
static constexpr const uintptr_t VAddressSpaceCeiling = …;
#endif
TEST_F(X86Core2TargetTest, GenerateUpperMunmapTest) { … }
TEST_F(X86Core2TargetTest, GenerateExitSyscallTest) { … }
TEST_F(X86Core2TargetTest, GenerateMmapTest) { … }
TEST_F(X86Core2TargetTest, GenerateMmapAuxMemTest) { … }
TEST_F(X86Core2TargetTest, MoveArgumentRegistersTest) { … }
#endif
}
}
}