aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/LLVMTargetMachine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-02 23:37:42 +0000
committerChris Lattner <sabre@nondot.org>2010-02-02 23:37:42 +0000
commit56591ab218639d8a6e4c756ca37adaf20215c3b6 (patch)
treee5b0843d0c8a5259a3b6b640c6a43ff8e7ddc440 /lib/CodeGen/LLVMTargetMachine.cpp
parent9f34dd305b7d9d54904a28774e93ac8d81b211fc (diff)
refactor code so that LLVMTargetMachine creates the asmstreamer and
mccontext instead of having AsmPrinter do it. This allows other types of MCStreamer's to be passed in. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95155 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LLVMTargetMachine.cpp')
-rw-r--r--lib/CodeGen/LLVMTargetMachine.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp
index a4f313938d..f4065924b1 100644
--- a/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/lib/CodeGen/LLVMTargetMachine.cpp
@@ -21,6 +21,9 @@
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCStreamer.h"
+#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/CommandLine.h"
@@ -121,10 +124,24 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
case CGFT_ObjectFile:
return CGFT_ErrorOccurred;
case CGFT_AssemblyFile: {
+ MCContext *Context = new MCContext();
+ MCStreamer *AsmStreamer =
+ createAsmStreamer(*Context, Out, *getMCAsmInfo(),
+ getTargetData()->isLittleEndian(),
+ getVerboseAsm(),
+ /*instprinter*/0,
+ /*codeemitter*/0);
+
+ // Create the AsmPrinter, which takes ownership of Context and AsmStreamer
+ // if successful.
FunctionPass *Printer =
- getTarget().createAsmPrinter(Out, *this, getMCAsmInfo(),
- getVerboseAsm());
- if (Printer == 0) return CGFT_ErrorOccurred;
+ getTarget().createAsmPrinter(Out, *this, *Context, *AsmStreamer,
+ getMCAsmInfo());
+ if (Printer == 0) {
+ delete AsmStreamer;
+ delete Context;
+ return CGFT_ErrorOccurred;
+ }
PM.add(Printer);
break;
}