mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-01 01:14:12 +00:00
Patches to build EFI with Clang/LLVM. By Carl Norum.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124639 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e361d2eda1
commit
2bffee2ee7
@ -101,7 +101,8 @@ public:
|
||||
|
||||
GNU,
|
||||
GNUEABI,
|
||||
EABI
|
||||
EABI,
|
||||
MachO
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -122,6 +122,7 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
|
||||
case GNU: return "gnu";
|
||||
case GNUEABI: return "gnueabi";
|
||||
case EABI: return "eabi";
|
||||
case MachO: return "macho";
|
||||
}
|
||||
|
||||
return "<invalid>";
|
||||
@ -350,6 +351,8 @@ Triple::EnvironmentType Triple::ParseEnvironment(StringRef EnvironmentName) {
|
||||
return GNUEABI;
|
||||
else if (EnvironmentName.startswith("gnu"))
|
||||
return GNU;
|
||||
else if (EnvironmentName.startswith("macho"))
|
||||
return MachO;
|
||||
else
|
||||
return UnknownEnvironment;
|
||||
}
|
||||
|
@ -414,7 +414,10 @@ TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
|
||||
case Triple::MinGW32:
|
||||
case Triple::Cygwin:
|
||||
case Triple::Win32:
|
||||
return new WindowsX86AsmBackend(T, false);
|
||||
if (Triple(TT).getEnvironment() == Triple::MachO)
|
||||
return new DarwinX86_32AsmBackend(T);
|
||||
else
|
||||
return new WindowsX86AsmBackend(T, false);
|
||||
default:
|
||||
return new ELFX86_32AsmBackend(T, Triple(TT).getOS());
|
||||
}
|
||||
@ -428,7 +431,10 @@ TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
|
||||
case Triple::MinGW64:
|
||||
case Triple::Cygwin:
|
||||
case Triple::Win32:
|
||||
return new WindowsX86AsmBackend(T, true);
|
||||
if (Triple(TT).getEnvironment() == Triple::MachO)
|
||||
return new DarwinX86_64AsmBackend(T);
|
||||
else
|
||||
return new WindowsX86AsmBackend(T, true);
|
||||
default:
|
||||
return new ELFX86_64AsmBackend(T, Triple(TT).getOS());
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ using namespace llvm;
|
||||
bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
SetupMachineFunction(MF);
|
||||
|
||||
if (Subtarget->isTargetCOFF()) {
|
||||
if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho()) {
|
||||
bool Intrn = MF.getFunction()->hasInternalLinkage();
|
||||
OutStreamer.BeginCOFFSymbolDef(CurrentFnSym);
|
||||
OutStreamer.EmitCOFFSymbolStorageClass(Intrn ? COFF::IMAGE_SYM_CLASS_STATIC
|
||||
@ -474,13 +474,13 @@ bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
||||
}
|
||||
|
||||
void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
|
||||
if (Subtarget->isTargetDarwin())
|
||||
if (Subtarget->isTargetEnvMacho())
|
||||
OutStreamer.SwitchSection(getObjFileLowering().getTextSection());
|
||||
}
|
||||
|
||||
|
||||
void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
if (Subtarget->isTargetDarwin()) {
|
||||
if (Subtarget->isTargetEnvMacho()) {
|
||||
// All darwin targets use mach-o.
|
||||
MachineModuleInfoMachO &MMIMacho =
|
||||
MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
||||
@ -581,7 +581,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
||||
OutStreamer.EmitSymbolAttribute(S, MCSA_Global);
|
||||
}
|
||||
|
||||
if (Subtarget->isTargetCOFF()) {
|
||||
if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho()) {
|
||||
X86COFFMachineModuleInfo &COFFMMI =
|
||||
MMI->getObjFileInfo<X86COFFMachineModuleInfo>();
|
||||
|
||||
|
@ -556,7 +556,9 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
// responsible for adjusting the stack pointer. Touching the stack at 4K
|
||||
// increments is necessary to ensure that the guard pages used by the OS
|
||||
// virtual memory manager are allocated in correct sequence.
|
||||
if (NumBytes >= 4096 && (STI.isTargetCygMing() || STI.isTargetWin32())) {
|
||||
if (NumBytes >= 4096 &&
|
||||
(STI.isTargetCygMing() || STI.isTargetWin32()) &&
|
||||
!STI.isTargetEnvMacho()) {
|
||||
// Check whether EAX is livein for this function.
|
||||
bool isEAXAlive = isEAXLiveIn(MF);
|
||||
|
||||
@ -592,7 +594,9 @@ void X86FrameLowering::emitPrologue(MachineFunction &MF) const {
|
||||
StackPtr, false, NumBytes - 4);
|
||||
MBB.insert(MBBI, MI);
|
||||
}
|
||||
} else if (NumBytes >= 4096 && STI.isTargetWin64()) {
|
||||
} else if (NumBytes >= 4096 &&
|
||||
STI.isTargetWin64() &&
|
||||
!STI.isTargetEnvMacho()) {
|
||||
// Sanity check that EAX is not livein for this function. It should
|
||||
// should not be, so throw an assert.
|
||||
assert(!isEAXLiveIn(MF) && "EAX is livein in the Win64 case!");
|
||||
|
@ -61,21 +61,21 @@ static SDValue getMOVL(SelectionDAG &DAG, DebugLoc dl, EVT VT, SDValue V1,
|
||||
SDValue V2);
|
||||
|
||||
static TargetLoweringObjectFile *createTLOF(X86TargetMachine &TM) {
|
||||
|
||||
bool is64Bit = TM.getSubtarget<X86Subtarget>().is64Bit();
|
||||
|
||||
if (TM.getSubtarget<X86Subtarget>().isTargetDarwin()) {
|
||||
const X86Subtarget *Subtarget = &TM.getSubtarget<X86Subtarget>();
|
||||
bool is64Bit = Subtarget->is64Bit();
|
||||
|
||||
if (Subtarget->isTargetEnvMacho()) {
|
||||
if (is64Bit)
|
||||
return new X8664_MachoTargetObjectFile();
|
||||
return new TargetLoweringObjectFileMachO();
|
||||
}
|
||||
|
||||
if (TM.getSubtarget<X86Subtarget>().isTargetELF() ){
|
||||
if (Subtarget->isTargetELF()) {
|
||||
if (is64Bit)
|
||||
return new X8664_ELFTargetObjectFile(TM);
|
||||
return new X8632_ELFTargetObjectFile(TM);
|
||||
}
|
||||
if (TM.getSubtarget<X86Subtarget>().isTargetCOFF())
|
||||
if (Subtarget->isTargetCOFF() && !Subtarget->isTargetEnvMacho())
|
||||
return new TargetLoweringObjectFileCOFF();
|
||||
llvm_unreachable("unknown subtarget type");
|
||||
}
|
||||
|
@ -192,6 +192,10 @@ public:
|
||||
return Is64Bit && (isTargetMingw() || isTargetWindows());
|
||||
}
|
||||
|
||||
bool isTargetEnvMacho() const {
|
||||
return isTargetDarwin() || (TargetTriple.getEnvironment() == Triple::MachO);
|
||||
}
|
||||
|
||||
bool isTargetWin32() const {
|
||||
return !Is64Bit && (isTargetMingw() || isTargetWindows());
|
||||
}
|
||||
|
@ -33,7 +33,10 @@ static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) {
|
||||
case Triple::MinGW64:
|
||||
case Triple::Cygwin:
|
||||
case Triple::Win32:
|
||||
return new X86MCAsmInfoCOFF(TheTriple);
|
||||
if (TheTriple.getEnvironment() == Triple::MachO)
|
||||
return new X86MCAsmInfoDarwin(TheTriple);
|
||||
else
|
||||
return new X86MCAsmInfoCOFF(TheTriple);
|
||||
default:
|
||||
return new X86ELFMCAsmInfo(TheTriple);
|
||||
}
|
||||
@ -53,7 +56,10 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT,
|
||||
case Triple::MinGW64:
|
||||
case Triple::Cygwin:
|
||||
case Triple::Win32:
|
||||
return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
|
||||
if (TheTriple.getEnvironment() == Triple::MachO)
|
||||
return createMachOStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll);
|
||||
else
|
||||
return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll);
|
||||
default:
|
||||
return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll, NoExecStack);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user