Initial checkin of the Mach-O emitter. There's plenty of fixmes, but it
does emit linkable .o files in very simple cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29850 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp
index deb479a..e360f37 100644
--- a/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -109,11 +109,11 @@
/// addPassesToEmitFile - Add passes to the specified pass manager to implement
/// a static compiler for this target.
///
-bool PPCTargetMachine::addPassesToEmitFile(PassManager &PM,
- std::ostream &Out,
+bool PPCTargetMachine::addPassesToEmitFile(PassManager &PM, std::ostream &Out,
CodeGenFileType FileType,
bool Fast) {
- if (FileType != TargetMachine::AssemblyFile) return true;
+ if (FileType != TargetMachine::AssemblyFile &&
+ FileType != TargetMachine::ObjectFile) return true;
// Run loop strength reduction before anything else.
if (!Fast) PM.add(createLoopStrengthReducePass(&TLInfo));
@@ -146,7 +146,11 @@
// Must run branch selection immediately preceding the asm printer
PM.add(createPPCBranchSelectionPass());
- PM.add(createDarwinAsmPrinter(Out, *this));
+ if (FileType == TargetMachine::AssemblyFile)
+ PM.add(createDarwinAsmPrinter(Out, *this));
+ else
+ // FIXME: support PPC ELF files at some point
+ addPPCMachOObjectWriterPass(PM, Out, *this);
PM.add(createMachineCodeDeleter());
return false;
@@ -184,3 +188,17 @@
PM.add(createMachineFunctionPrinterPass(&std::cerr));
}
+/// addPassesToEmitMachineCode - Add passes to the specified pass manager to get
+/// machine code emitted. This uses a MachineCodeEmitter object to handle
+/// actually outputting the machine code and resolving things like the address
+/// of functions. This method should returns true if machine code emission is
+/// not supported.
+///
+bool PPCTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
+ MachineCodeEmitter &MCE) {
+ // Machine code emitter pass for PowerPC
+ PM.add(createPPCCodeEmitterPass(*this, MCE));
+ // Delete machine code for this function after emitting it
+ PM.add(createMachineCodeDeleter());
+ return false;
+}