fix ld error with -no-undefined switch, which is undefined on darwin8
[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 #include "llvm/MC/MCStreamer.h"
19
20 namespace llvm {
21 class AsmExpr;
22 class MCContext;
23 class MCInst;
24 class MCStreamer;
25 class MCValue;
26
27 class AsmParser {
28 public:
29   struct X86Operand;
30
31 private:  
32   AsmLexer Lexer;
33   MCContext &Ctx;
34   MCStreamer &Out;
35   
36 public:
37   AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
38     : Lexer(SM), Ctx(ctx), Out(OutStr) {}
39   ~AsmParser() {}
40   
41   bool Run();
42   
43 private:
44   bool ParseStatement();
45
46   void Warning(SMLoc L, const char *Msg);
47   bool Error(SMLoc L, const char *Msg);
48   bool TokError(const char *Msg);
49   
50   void EatToEndOfStatement();
51   
52   bool ParseAssignment(const char *Name, bool IsDotSet);
53
54   /// ParseExpression - Parse a general assembly expression.
55   ///
56   /// @param Res - The resulting expression. The pointer value is null on error.
57   /// @result - False on success.
58   bool ParseExpression(AsmExpr *&Res);
59
60   /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
61   /// absolute value.
62   ///
63   /// @param Res - The value of the absolute expression. The result is undefined
64   /// on error.
65   /// @result - False on success.
66   bool ParseAbsoluteExpression(int64_t &Res);
67
68   /// ParseRelocatableExpression - Parse an expression which must be
69   /// relocatable.
70   ///
71   /// @param Res - The relocatable expression value. The result is undefined on
72   /// error.  
73   /// @result - False on success.
74   bool ParseRelocatableExpression(MCValue &Res);
75
76   bool ParsePrimaryExpr(AsmExpr *&Res);
77   bool ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res);
78   bool ParseParenExpr(AsmExpr *&Res);
79   
80   // X86 specific.
81   bool ParseX86InstOperands(const char *InstName, MCInst &Inst);
82   bool ParseX86Operand(X86Operand &Op);
83   bool ParseX86MemOperand(X86Operand &Op);
84   
85   // Directive Parsing.
86   bool ParseDirectiveDarwinSection(); // Darwin specific ".section".
87   bool ParseDirectiveSectionSwitch(const char *Section,
88                                    const char *Directives = 0);
89   bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
90   bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
91   bool ParseDirectiveFill(); // ".fill"
92   bool ParseDirectiveSpace(); // ".space"
93   bool ParseDirectiveSet(); // ".set"
94   bool ParseDirectiveOrg(); // ".org"
95   // ".align{,32}", ".p2align{,w,l}"
96   bool ParseDirectiveAlign(bool IsPow2, unsigned ValueSize);
97
98   /// ParseDirectiveSymbolAttribute - Parse a directive like ".globl" which
99   /// accepts a single symbol (which should be a label or an external).
100   bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr);
101   
102 };
103
104 } // end namespace llvm
105
106 #endif