diff options
author | Chris Lattner <sabre@nondot.org> | 2009-06-24 04:31:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-06-24 04:31:49 +0000 |
commit | c69485e34d57e17fe2c3acab64e519d6a6945197 (patch) | |
tree | 26910e29853b269ea7cd8ee87dc65b8f3381280d /tools | |
parent | 98d5982e0020e0c18d2847798ba2f40c4711af5a (diff) | |
download | external_llvm-c69485e34d57e17fe2c3acab64e519d6a6945197.zip external_llvm-c69485e34d57e17fe2c3acab64e519d6a6945197.tar.gz external_llvm-c69485e34d57e17fe2c3acab64e519d6a6945197.tar.bz2 |
add trivial support for passing label definitions through the MCStreamer.
This is suboptimal in several aspects, see the commented out assertion.
I need to talk to Daniel about this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 6 | ||||
-rw-r--r-- | tools/llvm-mc/AsmParser.h | 5 | ||||
-rw-r--r-- | tools/llvm-mc/llvm-mc.cpp | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 4dd136d..ca0b933 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -185,6 +185,12 @@ bool AsmParser::ParseStatement() { if (Lexer.Lex() == asmtok::Colon) { // identifier ':' -> Label. Lexer.Lex(); + + // Since we saw a label, create a symbol and emit it. + // FIXME: If the label starts with L it is an assembler temporary label. + // Why does the client of this api need to know this? + Out.EmitLabel(Ctx.GetOrCreateSymbol(IDVal)); + return ParseStatement(); } diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h index 9a2c6da..9515448 100644 --- a/tools/llvm-mc/AsmParser.h +++ b/tools/llvm-mc/AsmParser.h @@ -17,17 +17,20 @@ #include "AsmLexer.h" namespace llvm { +class MCContext; class MCInst; class MCStreamer; class AsmParser { AsmLexer Lexer; + MCContext &Ctx; MCStreamer &Out; struct X86Operand; public: - AsmParser(SourceMgr &SM, MCStreamer &OutStr) : Lexer(SM), Out(OutStr) {} + AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr) + : Lexer(SM), Ctx(ctx), Out(OutStr) {} ~AsmParser() {} bool Run(); diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index fe8af10..b999109 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -139,10 +139,9 @@ static int AssembleInput(const char *ProgName) { // it later. SrcMgr.setIncludeDirs(IncludeDirs); - // FIXME: don't leak streamer, own. MCContext Ctx; OwningPtr<MCStreamer> Str(createAsmStreamer(Ctx, outs())); - AsmParser Parser(SrcMgr, *Str.get()); + AsmParser Parser(SrcMgr, Ctx, *Str.get()); return Parser.Run(); } |