summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-02 23:57:42 +0000
committerChris Lattner <sabre@nondot.org>2010-02-02 23:57:42 +0000
commit8856a67e4191cf3c18b914e106bd04eedf521fa4 (patch)
treeb9416c64e272aa15edbe0059a0f5a8d6bf7609fe /llvm/lib/CodeGen
parentd0a2f52f8fd1e59ede4d6a239e9ac7ac2f37dc80 (diff)
downloadbcm5719-llvm-8856a67e4191cf3c18b914e106bd04eedf521fa4.tar.gz
bcm5719-llvm-8856a67e4191cf3c18b914e106bd04eedf521fa4.zip
Hook up -filetype=obj through the MachO streamer. Here's a demo:
$ cat t.ll @g = global i32 42 $ llc t.ll -o t.o -filetype=obj $ nm t.o 00000000 D _g There is still a ton of work left. Instructions are not being encoded yet apparently. llvm-svn: 95162
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index d255492ef8f..af33776c3a6 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -124,23 +124,30 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
OwningPtr<MCStreamer> AsmStreamer;
switch (FileType) {
- default:
- case CGFT_ObjectFile:
- return CGFT_ErrorOccurred;
- case CGFT_AssemblyFile: {
+ default: return CGFT_ErrorOccurred;
+ case CGFT_AssemblyFile:
AsmStreamer.reset(createAsmStreamer(*Context, Out, *getMCAsmInfo(),
getTargetData()->isLittleEndian(),
getVerboseAsm(), /*instprinter*/0,
/*codeemitter*/0));
break;
+ case CGFT_ObjectFile: {
+ // Create the code emitter for the target if it exists. If not, .o file
+ // emission fails.
+ MCCodeEmitter *MCE = getTarget().createCodeEmitter(*this);
+ if (MCE == 0)
+ return CGFT_ErrorOccurred;
+
+ AsmStreamer.reset(createMachOStreamer(*Context, Out, MCE));
+ break;
}
}
// Create the AsmPrinter, which takes ownership of Context and AsmStreamer
// if successful.
FunctionPass *Printer =
- getTarget().createAsmPrinter(Out, *this, *Context, *AsmStreamer,
- getMCAsmInfo());
+ getTarget().createAsmPrinter(Out, *this, *Context, *AsmStreamer,
+ getMCAsmInfo());
if (Printer == 0)
return CGFT_ErrorOccurred;
OpenPOWER on IntegriCloud