From cbc23f75cd8cd6889fd02f65b63f6c02512460bd Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 24 Jun 2009 00:52:40 +0000 Subject: [PATCH] create an MCStreamer and provide it to AsmParser. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74039 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-mc/AsmParser.h | 5 ++++- tools/llvm-mc/CMakeLists.txt | 2 +- tools/llvm-mc/Makefile | 2 +- tools/llvm-mc/llvm-mc.cpp | 8 +++++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h index c13334579b5..9a2c6dac4d9 100644 --- a/tools/llvm-mc/AsmParser.h +++ b/tools/llvm-mc/AsmParser.h @@ -18,13 +18,16 @@ namespace llvm { class MCInst; +class MCStreamer; class AsmParser { AsmLexer Lexer; + MCStreamer &Out; + struct X86Operand; public: - AsmParser(SourceMgr &SM) : Lexer(SM) {} + AsmParser(SourceMgr &SM, MCStreamer &OutStr) : Lexer(SM), Out(OutStr) {} ~AsmParser() {} bool Run(); diff --git a/tools/llvm-mc/CMakeLists.txt b/tools/llvm-mc/CMakeLists.txt index 369d5223706..2dd878d6e46 100644 --- a/tools/llvm-mc/CMakeLists.txt +++ b/tools/llvm-mc/CMakeLists.txt @@ -1,4 +1,4 @@ -set(LLVM_LINK_COMPONENTS support) +set(LLVM_LINK_COMPONENTS support MC) add_llvm_tool(llvm-mc llvm-mc.cpp diff --git a/tools/llvm-mc/Makefile b/tools/llvm-mc/Makefile index 7b4d9444565..3c327dac1e9 100644 --- a/tools/llvm-mc/Makefile +++ b/tools/llvm-mc/Makefile @@ -9,7 +9,7 @@ LEVEL = ../.. TOOLNAME = llvm-mc -LINK_COMPONENTS := support +LINK_COMPONENTS := support MC # This tool has no plugins, optimize startup time. TOOL_NO_EXPORTS = 1 diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index 52205c48d0f..fe8af10fb8e 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -12,6 +12,9 @@ // //===----------------------------------------------------------------------===// +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCStreamer.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" @@ -136,7 +139,10 @@ static int AssembleInput(const char *ProgName) { // it later. SrcMgr.setIncludeDirs(IncludeDirs); - AsmParser Parser(SrcMgr); + // FIXME: don't leak streamer, own. + MCContext Ctx; + OwningPtr Str(createAsmStreamer(Ctx, outs())); + AsmParser Parser(SrcMgr, *Str.get()); return Parser.Run(); } -- 2.34.1