2012-02-18 12:03:15 +00:00
|
|
|
//===-- X86MCTargetDesc.cpp - X86 Target Descriptions ---------------------===//
|
2011-06-24 01:44:41 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file provides X86 specific target descriptions.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-07-06 22:01:53 +00:00
|
|
|
#include "X86MCTargetDesc.h"
|
2011-07-25 21:20:24 +00:00
|
|
|
#include "InstPrinter/X86ATTInstPrinter.h"
|
|
|
|
#include "InstPrinter/X86IntelInstPrinter.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "X86MCAsmInfo.h"
|
|
|
|
#include "llvm/ADT/Triple.h"
|
2011-08-23 20:15:21 +00:00
|
|
|
#include "llvm/MC/MCCodeGenInfo.h"
|
|
|
|
#include "llvm/MC/MCInstrAnalysis.h"
|
2011-06-28 20:07:07 +00:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2011-06-24 01:44:41 +00:00
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
2011-07-25 19:33:48 +00:00
|
|
|
#include "llvm/MC/MCStreamer.h"
|
2011-07-01 22:25:04 +00:00
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/MC/MachineLocation.h"
|
2012-02-05 07:21:30 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/Support/Host.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2011-06-27 18:32:37 +00:00
|
|
|
|
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "X86GenRegisterInfo.inc"
|
2011-06-28 20:07:07 +00:00
|
|
|
|
|
|
|
#define GET_INSTRINFO_MC_DESC
|
|
|
|
#include "X86GenInstrInfo.inc"
|
|
|
|
|
2011-07-01 22:25:04 +00:00
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
2011-07-01 22:36:09 +00:00
|
|
|
#include "X86GenSubtargetInfo.inc"
|
2011-07-01 22:25:04 +00:00
|
|
|
|
2012-03-01 22:42:52 +00:00
|
|
|
#if _MSC_VER
|
|
|
|
#include <intrin.h>
|
|
|
|
#endif
|
|
|
|
|
2011-06-24 01:44:41 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2011-07-07 21:06:52 +00:00
|
|
|
|
|
|
|
std::string X86_MC::ParseX86Triple(StringRef TT) {
|
|
|
|
Triple TheTriple(TT);
|
2011-09-05 21:51:43 +00:00
|
|
|
std::string FS;
|
2011-07-07 21:06:52 +00:00
|
|
|
if (TheTriple.getArch() == Triple::x86_64)
|
2011-09-05 21:51:43 +00:00
|
|
|
FS = "+64bit-mode";
|
|
|
|
else
|
|
|
|
FS = "-64bit-mode";
|
|
|
|
return FS;
|
2011-07-07 21:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
|
|
|
|
/// specified arguments. If we can't run cpuid on the host, return true.
|
|
|
|
bool X86_MC::GetCpuIDAndInfo(unsigned value, unsigned *rEAX,
|
|
|
|
unsigned *rEBX, unsigned *rECX, unsigned *rEDX) {
|
|
|
|
#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
// gcc doesn't know cpuid would clobber ebx/rbx. Preseve it manually.
|
|
|
|
asm ("movq\t%%rbx, %%rsi\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"xchgq\t%%rbx, %%rsi\n\t"
|
|
|
|
: "=a" (*rEAX),
|
|
|
|
"=S" (*rEBX),
|
|
|
|
"=c" (*rECX),
|
|
|
|
"=d" (*rEDX)
|
|
|
|
: "a" (value));
|
|
|
|
return false;
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
int registers[4];
|
|
|
|
__cpuid(registers, value);
|
|
|
|
*rEAX = registers[0];
|
|
|
|
*rEBX = registers[1];
|
|
|
|
*rECX = registers[2];
|
|
|
|
*rEDX = registers[3];
|
|
|
|
return false;
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
|
|
|
return true;
|
2011-07-07 21:06:52 +00:00
|
|
|
#endif
|
|
|
|
#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
asm ("movl\t%%ebx, %%esi\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"xchgl\t%%ebx, %%esi\n\t"
|
|
|
|
: "=a" (*rEAX),
|
|
|
|
"=S" (*rEBX),
|
|
|
|
"=c" (*rECX),
|
|
|
|
"=d" (*rEDX)
|
|
|
|
: "a" (value));
|
|
|
|
return false;
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
__asm {
|
|
|
|
mov eax,value
|
|
|
|
cpuid
|
|
|
|
mov esi,rEAX
|
|
|
|
mov dword ptr [esi],eax
|
|
|
|
mov esi,rEBX
|
|
|
|
mov dword ptr [esi],ebx
|
|
|
|
mov esi,rECX
|
|
|
|
mov dword ptr [esi],ecx
|
|
|
|
mov esi,rEDX
|
|
|
|
mov dword ptr [esi],edx
|
|
|
|
}
|
|
|
|
return false;
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
|
|
|
return true;
|
2011-07-07 21:06:52 +00:00
|
|
|
#endif
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
2011-07-07 21:06:52 +00:00
|
|
|
return true;
|
2012-01-20 21:51:11 +00:00
|
|
|
#endif
|
2011-10-16 00:21:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// GetCpuIDAndInfoEx - Execute the specified cpuid with subleaf and return the
|
|
|
|
/// 4 values in the specified arguments. If we can't run cpuid on the host,
|
|
|
|
/// return true.
|
|
|
|
bool X86_MC::GetCpuIDAndInfoEx(unsigned value, unsigned subleaf, unsigned *rEAX,
|
|
|
|
unsigned *rEBX, unsigned *rECX, unsigned *rEDX) {
|
|
|
|
#if defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
// gcc desn't know cpuid would clobber ebx/rbx. Preseve it manually.
|
|
|
|
asm ("movq\t%%rbx, %%rsi\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"xchgq\t%%rbx, %%rsi\n\t"
|
|
|
|
: "=a" (*rEAX),
|
|
|
|
"=S" (*rEBX),
|
|
|
|
"=c" (*rECX),
|
|
|
|
"=d" (*rEDX)
|
|
|
|
: "a" (value),
|
|
|
|
"c" (subleaf));
|
|
|
|
return false;
|
|
|
|
#elif defined(_MSC_VER)
|
2011-10-17 05:33:10 +00:00
|
|
|
// __cpuidex was added in MSVC++ 9.0 SP1
|
|
|
|
#if (_MSC_VER > 1500) || (_MSC_VER == 1500 && _MSC_FULL_VER >= 150030729)
|
|
|
|
int registers[4];
|
|
|
|
__cpuidex(registers, value, subleaf);
|
|
|
|
*rEAX = registers[0];
|
|
|
|
*rEBX = registers[1];
|
|
|
|
*rECX = registers[2];
|
|
|
|
*rEDX = registers[3];
|
|
|
|
return false;
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
|
|
|
return true;
|
2011-10-17 05:33:10 +00:00
|
|
|
#endif
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
|
|
|
return true;
|
2011-10-16 00:21:51 +00:00
|
|
|
#endif
|
|
|
|
#elif defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)
|
|
|
|
#if defined(__GNUC__)
|
|
|
|
asm ("movl\t%%ebx, %%esi\n\t"
|
|
|
|
"cpuid\n\t"
|
|
|
|
"xchgl\t%%ebx, %%esi\n\t"
|
|
|
|
: "=a" (*rEAX),
|
|
|
|
"=S" (*rEBX),
|
|
|
|
"=c" (*rECX),
|
|
|
|
"=d" (*rEDX)
|
|
|
|
: "a" (value),
|
|
|
|
"c" (subleaf));
|
|
|
|
return false;
|
|
|
|
#elif defined(_MSC_VER)
|
|
|
|
__asm {
|
|
|
|
mov eax,value
|
|
|
|
mov ecx,subleaf
|
|
|
|
cpuid
|
|
|
|
mov esi,rEAX
|
|
|
|
mov dword ptr [esi],eax
|
|
|
|
mov esi,rEBX
|
|
|
|
mov dword ptr [esi],ebx
|
|
|
|
mov esi,rECX
|
|
|
|
mov dword ptr [esi],ecx
|
|
|
|
mov esi,rEDX
|
|
|
|
mov dword ptr [esi],edx
|
|
|
|
}
|
|
|
|
return false;
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
|
|
|
return true;
|
2011-10-16 00:21:51 +00:00
|
|
|
#endif
|
2012-01-20 21:51:11 +00:00
|
|
|
#else
|
2011-10-16 00:21:51 +00:00
|
|
|
return true;
|
2012-01-20 21:51:11 +00:00
|
|
|
#endif
|
2011-07-07 21:06:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void X86_MC::DetectFamilyModel(unsigned EAX, unsigned &Family,
|
|
|
|
unsigned &Model) {
|
|
|
|
Family = (EAX >> 8) & 0xf; // Bits 8 - 11
|
|
|
|
Model = (EAX >> 4) & 0xf; // Bits 4 - 7
|
|
|
|
if (Family == 6 || Family == 0xf) {
|
|
|
|
if (Family == 0xf)
|
|
|
|
// Examine extended family ID if family ID is F.
|
|
|
|
Family += (EAX >> 20) & 0xff; // Bits 20 - 27
|
|
|
|
// Examine extended model ID if family ID is 6 or F.
|
|
|
|
Model += ((EAX >> 16) & 0xf) << 4; // Bits 16 - 19
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-18 20:57:22 +00:00
|
|
|
unsigned X86_MC::getDwarfRegFlavour(StringRef TT, bool isEH) {
|
|
|
|
Triple TheTriple(TT);
|
|
|
|
if (TheTriple.getArch() == Triple::x86_64)
|
|
|
|
return DWARFFlavour::X86_64;
|
|
|
|
|
|
|
|
if (TheTriple.isOSDarwin())
|
|
|
|
return isEH ? DWARFFlavour::X86_32_DarwinEH : DWARFFlavour::X86_32_Generic;
|
|
|
|
if (TheTriple.getOS() == Triple::MinGW32 ||
|
|
|
|
TheTriple.getOS() == Triple::Cygwin)
|
|
|
|
// Unsupported by now, just quick fallback
|
|
|
|
return DWARFFlavour::X86_32_Generic;
|
|
|
|
return DWARFFlavour::X86_32_Generic;
|
|
|
|
}
|
|
|
|
|
|
|
|
void X86_MC::InitLLVM2SEHRegisterMapping(MCRegisterInfo *MRI) {
|
|
|
|
// FIXME: TableGen these.
|
|
|
|
for (unsigned Reg = X86::NoRegister+1; Reg < X86::NUM_TARGET_REGS; ++Reg) {
|
2012-10-04 19:50:43 +00:00
|
|
|
unsigned SEH = MRI->getEncodingValue(Reg);
|
2011-07-18 20:57:22 +00:00
|
|
|
MRI->mapLLVMRegToSEHReg(Reg, SEH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-08 01:53:10 +00:00
|
|
|
MCSubtargetInfo *X86_MC::createX86MCSubtargetInfo(StringRef TT, StringRef CPU,
|
|
|
|
StringRef FS) {
|
2011-07-07 21:06:52 +00:00
|
|
|
std::string ArchFS = X86_MC::ParseX86Triple(TT);
|
|
|
|
if (!FS.empty()) {
|
|
|
|
if (!ArchFS.empty())
|
|
|
|
ArchFS = ArchFS + "," + FS.str();
|
|
|
|
else
|
|
|
|
ArchFS = FS;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CPUName = CPU;
|
2011-07-08 21:14:14 +00:00
|
|
|
if (CPUName.empty()) {
|
2012-01-30 23:10:32 +00:00
|
|
|
#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86)\
|
|
|
|
|| defined(__x86_64__) || defined(_M_AMD64) || defined (_M_X64)
|
2011-07-07 21:06:52 +00:00
|
|
|
CPUName = sys::getHostCPUName();
|
2011-07-08 21:14:14 +00:00
|
|
|
#else
|
|
|
|
CPUName = "generic";
|
|
|
|
#endif
|
|
|
|
}
|
2011-07-07 21:06:52 +00:00
|
|
|
|
2011-07-01 22:25:04 +00:00
|
|
|
MCSubtargetInfo *X = new MCSubtargetInfo();
|
2011-07-11 03:57:24 +00:00
|
|
|
InitX86MCSubtargetInfo(X, TT, CPUName, ArchFS);
|
2011-07-08 01:53:10 +00:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-14 23:50:31 +00:00
|
|
|
static MCInstrInfo *createX86MCInstrInfo() {
|
|
|
|
MCInstrInfo *X = new MCInstrInfo();
|
|
|
|
InitX86MCInstrInfo(X);
|
2011-07-01 22:25:04 +00:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-18 20:57:22 +00:00
|
|
|
static MCRegisterInfo *createX86MCRegisterInfo(StringRef TT) {
|
|
|
|
Triple TheTriple(TT);
|
|
|
|
unsigned RA = (TheTriple.getArch() == Triple::x86_64)
|
|
|
|
? X86::RIP // Should have dwarf #16.
|
|
|
|
: X86::EIP; // Should have dwarf #8.
|
|
|
|
|
2011-07-14 23:50:31 +00:00
|
|
|
MCRegisterInfo *X = new MCRegisterInfo();
|
2011-07-18 20:57:22 +00:00
|
|
|
InitX86MCRegisterInfo(X, RA,
|
|
|
|
X86_MC::getDwarfRegFlavour(TT, false),
|
2012-12-19 23:38:53 +00:00
|
|
|
X86_MC::getDwarfRegFlavour(TT, true),
|
|
|
|
RA);
|
2011-07-18 20:57:22 +00:00
|
|
|
X86_MC::InitLLVM2SEHRegisterMapping(X);
|
2011-07-14 23:50:31 +00:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2013-05-13 01:16:13 +00:00
|
|
|
static MCAsmInfo *createX86MCAsmInfo(const MCRegisterInfo &MRI, StringRef TT) {
|
2011-07-14 23:50:31 +00:00
|
|
|
Triple TheTriple(TT);
|
2011-07-18 22:29:13 +00:00
|
|
|
bool is64Bit = TheTriple.getArch() == Triple::x86_64;
|
2011-07-14 23:50:31 +00:00
|
|
|
|
2011-07-18 22:29:13 +00:00
|
|
|
MCAsmInfo *MAI;
|
2011-07-14 23:50:31 +00:00
|
|
|
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) {
|
2011-07-18 22:29:13 +00:00
|
|
|
if (is64Bit)
|
|
|
|
MAI = new X86_64MCAsmInfoDarwin(TheTriple);
|
2011-07-14 23:50:31 +00:00
|
|
|
else
|
2011-07-18 22:29:13 +00:00
|
|
|
MAI = new X86MCAsmInfoDarwin(TheTriple);
|
2012-10-02 18:38:34 +00:00
|
|
|
} else if (TheTriple.getEnvironment() == Triple::ELF) {
|
|
|
|
// Force the use of an ELF container.
|
|
|
|
MAI = new X86ELFMCAsmInfo(TheTriple);
|
2011-11-29 18:00:06 +00:00
|
|
|
} else if (TheTriple.getOS() == Triple::Win32) {
|
|
|
|
MAI = new X86MCAsmInfoMicrosoft(TheTriple);
|
|
|
|
} else if (TheTriple.getOS() == Triple::MinGW32 || TheTriple.getOS() == Triple::Cygwin) {
|
|
|
|
MAI = new X86MCAsmInfoGNUCOFF(TheTriple);
|
2011-07-18 22:29:13 +00:00
|
|
|
} else {
|
2012-10-02 18:38:34 +00:00
|
|
|
// The default is ELF.
|
2011-07-18 22:29:13 +00:00
|
|
|
MAI = new X86ELFMCAsmInfo(TheTriple);
|
2011-07-14 23:50:31 +00:00
|
|
|
}
|
|
|
|
|
2011-07-18 22:29:13 +00:00
|
|
|
// Initialize initial frame state.
|
|
|
|
// Calculate amount of bytes used for return address storing
|
|
|
|
int stackGrowth = is64Bit ? -8 : -4;
|
2011-07-14 23:50:31 +00:00
|
|
|
|
2011-07-18 22:29:13 +00:00
|
|
|
// Initial state of the frame pointer is esp+stackGrowth.
|
2013-05-13 01:16:13 +00:00
|
|
|
unsigned StackPtr = is64Bit ? X86::RSP : X86::ESP;
|
|
|
|
MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(
|
|
|
|
0, MRI.getDwarfRegNum(StackPtr, true), -stackGrowth);
|
|
|
|
MAI->addInitialFrameState(Inst);
|
2011-07-18 22:29:13 +00:00
|
|
|
|
|
|
|
// Add return address to move list
|
2013-05-13 01:16:13 +00:00
|
|
|
unsigned InstPtr = is64Bit ? X86::RIP : X86::EIP;
|
|
|
|
MCCFIInstruction Inst2 = MCCFIInstruction::createOffset(
|
|
|
|
0, MRI.getDwarfRegNum(InstPtr, true), stackGrowth);
|
|
|
|
MAI->addInitialFrameState(Inst2);
|
2011-07-18 22:29:13 +00:00
|
|
|
|
|
|
|
return MAI;
|
2011-07-14 23:50:31 +00:00
|
|
|
}
|
|
|
|
|
2011-07-23 00:01:04 +00:00
|
|
|
static MCCodeGenInfo *createX86MCCodeGenInfo(StringRef TT, Reloc::Model RM,
|
2011-11-16 08:38:26 +00:00
|
|
|
CodeModel::Model CM,
|
|
|
|
CodeGenOpt::Level OL) {
|
2011-07-19 06:37:02 +00:00
|
|
|
MCCodeGenInfo *X = new MCCodeGenInfo();
|
|
|
|
|
|
|
|
Triple T(TT);
|
|
|
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
|
|
|
|
|
|
|
if (RM == Reloc::Default) {
|
|
|
|
// Darwin defaults to PIC in 64 bit mode and dynamic-no-pic in 32 bit mode.
|
|
|
|
// Win64 requires rip-rel addressing, thus we force it to PIC. Otherwise we
|
|
|
|
// use static relocation model by default.
|
|
|
|
if (T.isOSDarwin()) {
|
|
|
|
if (is64Bit)
|
|
|
|
RM = Reloc::PIC_;
|
|
|
|
else
|
|
|
|
RM = Reloc::DynamicNoPIC;
|
|
|
|
} else if (T.isOSWindows() && is64Bit)
|
|
|
|
RM = Reloc::PIC_;
|
|
|
|
else
|
|
|
|
RM = Reloc::Static;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ELF and X86-64 don't have a distinct DynamicNoPIC model. DynamicNoPIC
|
|
|
|
// is defined as a model for code which may be used in static or dynamic
|
|
|
|
// executables but not necessarily a shared library. On X86-32 we just
|
|
|
|
// compile in -static mode, in x86-64 we use PIC.
|
|
|
|
if (RM == Reloc::DynamicNoPIC) {
|
|
|
|
if (is64Bit)
|
|
|
|
RM = Reloc::PIC_;
|
|
|
|
else if (!T.isOSDarwin())
|
|
|
|
RM = Reloc::Static;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we are on Darwin, disallow static relocation model in X86-64 mode, since
|
|
|
|
// the Mach-O file format doesn't support it.
|
|
|
|
if (RM == Reloc::Static && T.isOSDarwin() && is64Bit)
|
|
|
|
RM = Reloc::PIC_;
|
|
|
|
|
2011-07-20 07:51:56 +00:00
|
|
|
// For static codegen, if we're not already set, use Small codegen.
|
|
|
|
if (CM == CodeModel::Default)
|
|
|
|
CM = CodeModel::Small;
|
|
|
|
else if (CM == CodeModel::JITDefault)
|
|
|
|
// 64-bit JIT places everything in the same buffer except external funcs.
|
|
|
|
CM = is64Bit ? CodeModel::Large : CodeModel::Small;
|
|
|
|
|
2011-11-16 08:38:26 +00:00
|
|
|
X->InitMCCodeGenInfo(RM, CM, OL);
|
2011-07-19 06:37:02 +00:00
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2011-07-26 00:42:34 +00:00
|
|
|
static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
|
2011-07-25 23:24:55 +00:00
|
|
|
MCContext &Ctx, MCAsmBackend &MAB,
|
2011-07-25 19:33:48 +00:00
|
|
|
raw_ostream &_OS,
|
|
|
|
MCCodeEmitter *_Emitter,
|
|
|
|
bool RelaxAll,
|
|
|
|
bool NoExecStack) {
|
|
|
|
Triple TheTriple(TT);
|
|
|
|
|
|
|
|
if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
|
2011-07-25 23:24:55 +00:00
|
|
|
return createMachOStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll);
|
2011-07-25 19:33:48 +00:00
|
|
|
|
2012-10-02 18:38:34 +00:00
|
|
|
if (TheTriple.isOSWindows() && TheTriple.getEnvironment() != Triple::ELF)
|
2011-07-25 23:24:55 +00:00
|
|
|
return createWinCOFFStreamer(Ctx, MAB, *_Emitter, _OS, RelaxAll);
|
2011-07-25 19:33:48 +00:00
|
|
|
|
2011-07-25 23:24:55 +00:00
|
|
|
return createELFStreamer(Ctx, MAB, _OS, _Emitter, RelaxAll, NoExecStack);
|
2011-07-25 19:33:48 +00:00
|
|
|
}
|
|
|
|
|
2011-07-25 21:20:24 +00:00
|
|
|
static MCInstPrinter *createX86MCInstPrinter(const Target &T,
|
|
|
|
unsigned SyntaxVariant,
|
2011-09-07 17:24:38 +00:00
|
|
|
const MCAsmInfo &MAI,
|
2012-04-02 06:09:36 +00:00
|
|
|
const MCInstrInfo &MII,
|
2012-03-05 19:33:20 +00:00
|
|
|
const MCRegisterInfo &MRI,
|
2011-09-07 17:24:38 +00:00
|
|
|
const MCSubtargetInfo &STI) {
|
2011-07-25 21:20:24 +00:00
|
|
|
if (SyntaxVariant == 0)
|
2012-04-02 06:09:36 +00:00
|
|
|
return new X86ATTInstPrinter(MAI, MII, MRI);
|
2011-07-25 21:20:24 +00:00
|
|
|
if (SyntaxVariant == 1)
|
2012-04-02 06:09:36 +00:00
|
|
|
return new X86IntelInstPrinter(MAI, MII, MRI);
|
2011-07-25 21:20:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-08-23 20:15:21 +00:00
|
|
|
static MCInstrAnalysis *createX86MCInstrAnalysis(const MCInstrInfo *Info) {
|
|
|
|
return new MCInstrAnalysis(Info);
|
|
|
|
}
|
|
|
|
|
2011-07-22 21:58:54 +00:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeX86TargetMC() {
|
|
|
|
// Register the MC asm info.
|
|
|
|
RegisterMCAsmInfoFn A(TheX86_32Target, createX86MCAsmInfo);
|
|
|
|
RegisterMCAsmInfoFn B(TheX86_64Target, createX86MCAsmInfo);
|
|
|
|
|
|
|
|
// Register the MC codegen info.
|
|
|
|
RegisterMCCodeGenInfoFn C(TheX86_32Target, createX86MCCodeGenInfo);
|
|
|
|
RegisterMCCodeGenInfoFn D(TheX86_64Target, createX86MCCodeGenInfo);
|
|
|
|
|
|
|
|
// Register the MC instruction info.
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(TheX86_32Target, createX86MCInstrInfo);
|
|
|
|
TargetRegistry::RegisterMCInstrInfo(TheX86_64Target, createX86MCInstrInfo);
|
|
|
|
|
|
|
|
// Register the MC register info.
|
|
|
|
TargetRegistry::RegisterMCRegInfo(TheX86_32Target, createX86MCRegisterInfo);
|
|
|
|
TargetRegistry::RegisterMCRegInfo(TheX86_64Target, createX86MCRegisterInfo);
|
|
|
|
|
|
|
|
// Register the MC subtarget info.
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(TheX86_32Target,
|
|
|
|
X86_MC::createX86MCSubtargetInfo);
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(TheX86_64Target,
|
|
|
|
X86_MC::createX86MCSubtargetInfo);
|
2011-07-25 19:33:48 +00:00
|
|
|
|
2011-08-23 20:15:21 +00:00
|
|
|
// Register the MC instruction analyzer.
|
|
|
|
TargetRegistry::RegisterMCInstrAnalysis(TheX86_32Target,
|
|
|
|
createX86MCInstrAnalysis);
|
|
|
|
TargetRegistry::RegisterMCInstrAnalysis(TheX86_64Target,
|
|
|
|
createX86MCInstrAnalysis);
|
|
|
|
|
2011-07-25 19:33:48 +00:00
|
|
|
// Register the code emitter.
|
2011-07-26 00:42:34 +00:00
|
|
|
TargetRegistry::RegisterMCCodeEmitter(TheX86_32Target,
|
|
|
|
createX86MCCodeEmitter);
|
|
|
|
TargetRegistry::RegisterMCCodeEmitter(TheX86_64Target,
|
|
|
|
createX86MCCodeEmitter);
|
2011-07-25 19:33:48 +00:00
|
|
|
|
|
|
|
// Register the asm backend.
|
2011-07-25 23:24:55 +00:00
|
|
|
TargetRegistry::RegisterMCAsmBackend(TheX86_32Target,
|
|
|
|
createX86_32AsmBackend);
|
|
|
|
TargetRegistry::RegisterMCAsmBackend(TheX86_64Target,
|
|
|
|
createX86_64AsmBackend);
|
2011-07-25 19:33:48 +00:00
|
|
|
|
|
|
|
// Register the object streamer.
|
2011-07-26 00:42:34 +00:00
|
|
|
TargetRegistry::RegisterMCObjectStreamer(TheX86_32Target,
|
|
|
|
createMCStreamer);
|
|
|
|
TargetRegistry::RegisterMCObjectStreamer(TheX86_64Target,
|
|
|
|
createMCStreamer);
|
2011-07-25 21:20:24 +00:00
|
|
|
|
|
|
|
// Register the MCInstPrinter.
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(TheX86_32Target,
|
|
|
|
createX86MCInstPrinter);
|
|
|
|
TargetRegistry::RegisterMCInstPrinter(TheX86_64Target,
|
|
|
|
createX86MCInstPrinter);
|
2011-07-19 06:37:02 +00:00
|
|
|
}
|