blob: 95154485cdae68d2a45a4838821da45b5edb6130 [file] [log] [blame]
Chris Lattner27aa7d22009-06-21 20:16:42 +00001//===- 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
19namespace llvm {
Chris Lattnerc69485e2009-06-24 04:31:49 +000020class MCContext;
Chris Lattner29dfe7c2009-06-23 18:41:30 +000021class MCInst;
Chris Lattnercbc23f72009-06-24 00:52:40 +000022class MCStreamer;
Chris Lattner2cf5f142009-06-22 01:29:09 +000023
Chris Lattner27aa7d22009-06-21 20:16:42 +000024class AsmParser {
25 AsmLexer Lexer;
Chris Lattnerc69485e2009-06-24 04:31:49 +000026 MCContext &Ctx;
Chris Lattnercbc23f72009-06-24 00:52:40 +000027 MCStreamer &Out;
28
Chris Lattner2cf5f142009-06-22 01:29:09 +000029 struct X86Operand;
Chris Lattner27aa7d22009-06-21 20:16:42 +000030
31public:
Chris Lattnerc69485e2009-06-24 04:31:49 +000032 AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
33 : Lexer(SM), Ctx(ctx), Out(OutStr) {}
Chris Lattner27aa7d22009-06-21 20:16:42 +000034 ~AsmParser() {}
35
36 bool Run();
37
Chris Lattnerb0789ed2009-06-21 20:54:55 +000038private:
39 bool ParseStatement();
40
Chris Lattner14ee48a2009-06-21 21:22:11 +000041 bool Error(SMLoc L, const char *Msg);
42 bool TokError(const char *Msg);
Chris Lattner2cf5f142009-06-22 01:29:09 +000043
44 void EatToEndOfStatement();
45
Chris Lattnerc4193832009-06-22 05:51:26 +000046 bool ParseExpression(int64_t &Res);
Chris Lattner74ec1a32009-06-22 06:32:03 +000047 bool ParsePrimaryExpr(int64_t &Res);
Chris Lattner8dfbe6c2009-06-23 05:57:07 +000048 bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
Chris Lattner74ec1a32009-06-22 06:32:03 +000049 bool ParseParenExpr(int64_t &Res);
Chris Lattner29dfe7c2009-06-23 18:41:30 +000050
51 // X86 specific.
52 bool ParseX86InstOperands(MCInst &Inst);
53 bool ParseX86Operand(X86Operand &Op);
54 bool ParseX86MemOperand(X86Operand &Op);
Chris Lattner27aa7d22009-06-21 20:16:42 +000055};
56
57} // end namespace llvm
58
59#endif