summaryrefslogtreecommitdiff
path: root/tools/llvm-mc/AsmParser.h
blob: 9e432e861f89de661f8e3a9d35f5eb12c6b30ee9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//===- AsmParser.h - Parser for Assembly Files ------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This class declares the parser for assembly files.
//
//===----------------------------------------------------------------------===//

#ifndef ASMPARSER_H
#define ASMPARSER_H

#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, MCContext &ctx, MCStreamer &OutStr)
    : Lexer(SM), Ctx(ctx), Out(OutStr) {}
  ~AsmParser() {}
  
  bool Run();
  
private:
  bool ParseStatement();
  
  bool Error(SMLoc L, const char *Msg);
  bool TokError(const char *Msg);
  
  void EatToEndOfStatement();
  
  bool ParseExpression(int64_t &Res);
  bool ParsePrimaryExpr(int64_t &Res);
  bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
  bool ParseParenExpr(int64_t &Res);
  
  // X86 specific.
  bool ParseX86InstOperands(MCInst &Inst);
  bool ParseX86Operand(X86Operand &Op);
  bool ParseX86MemOperand(X86Operand &Op);
  
  // Directive Parsing.
  bool ParseDirectiveSection();
  
};

} // end namespace llvm

#endif