MC: Parse .org directives.
[oota-llvm.git] / tools / llvm-mc / AsmParser.h
1 //===- AsmParser.h - Parser for Assembly Files ------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This class declares the parser for assembly files.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef ASMPARSER_H
15 #define ASMPARSER_H
16
17 #include "AsmLexer.h"
18
19 namespace llvm {
20 class MCContext;
21 class MCInst;
22 class MCStreamer;
23   
24 class AsmParser {
25   AsmLexer Lexer;
26   MCContext &Ctx;
27   MCStreamer &Out;
28   
29   struct X86Operand;
30   
31 public:
32   AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
33     : Lexer(SM), Ctx(ctx), Out(OutStr) {}
34   ~AsmParser() {}
35   
36   bool Run();
37   
38 private:
39   bool ParseStatement();
40   
41   bool Error(SMLoc L, const char *Msg);
42   bool TokError(const char *Msg);
43   
44   void EatToEndOfStatement();
45   
46   bool ParseAssignment(const char *Name, bool IsDotSet);
47   bool ParseExpression(int64_t &Res);
48   bool ParsePrimaryExpr(int64_t &Res);
49   bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
50   bool ParseParenExpr(int64_t &Res);
51   
52   // X86 specific.
53   bool ParseX86InstOperands(MCInst &Inst);
54   bool ParseX86Operand(X86Operand &Op);
55   bool ParseX86MemOperand(X86Operand &Op);
56   
57   // Directive Parsing.
58   bool ParseDirectiveDarwinSection(); // Darwin specific ".section".
59   bool ParseDirectiveSectionSwitch(const char *Section,
60                                    const char *Directives = 0);
61   bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
62   bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
63   bool ParseDirectiveFill(); // ".fill"
64   bool ParseDirectiveSpace(); // ".space"
65   bool ParseDirectiveSet(); // ".set"
66   bool ParseDirectiveOrg(); // ".org"
67   
68 };
69
70 } // end namespace llvm
71
72 #endif