2009-06-22 04:16:42 +08:00
|
|
|
//===- 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 {
|
2009-06-24 12:31:49 +08:00
|
|
|
class MCContext;
|
2009-06-24 02:41:30 +08:00
|
|
|
class MCInst;
|
2009-06-24 08:52:40 +08:00
|
|
|
class MCStreamer;
|
2009-06-22 09:29:09 +08:00
|
|
|
|
2009-06-22 04:16:42 +08:00
|
|
|
class AsmParser {
|
|
|
|
AsmLexer Lexer;
|
2009-06-24 12:31:49 +08:00
|
|
|
MCContext &Ctx;
|
2009-06-24 08:52:40 +08:00
|
|
|
MCStreamer &Out;
|
|
|
|
|
2009-06-22 09:29:09 +08:00
|
|
|
struct X86Operand;
|
2009-06-22 04:16:42 +08:00
|
|
|
|
|
|
|
public:
|
2009-06-24 12:31:49 +08:00
|
|
|
AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
|
|
|
|
: Lexer(SM), Ctx(ctx), Out(OutStr) {}
|
2009-06-22 04:16:42 +08:00
|
|
|
~AsmParser() {}
|
|
|
|
|
|
|
|
bool Run();
|
|
|
|
|
2009-06-22 04:54:55 +08:00
|
|
|
private:
|
|
|
|
bool ParseStatement();
|
|
|
|
|
2009-06-22 05:22:11 +08:00
|
|
|
bool Error(SMLoc L, const char *Msg);
|
|
|
|
bool TokError(const char *Msg);
|
2009-06-22 09:29:09 +08:00
|
|
|
|
|
|
|
void EatToEndOfStatement();
|
|
|
|
|
2009-06-22 13:51:26 +08:00
|
|
|
bool ParseExpression(int64_t &Res);
|
2009-06-22 14:32:03 +08:00
|
|
|
bool ParsePrimaryExpr(int64_t &Res);
|
2009-06-23 13:57:07 +08:00
|
|
|
bool ParseBinOpRHS(unsigned Precedence, int64_t &Res);
|
2009-06-22 14:32:03 +08:00
|
|
|
bool ParseParenExpr(int64_t &Res);
|
2009-06-24 02:41:30 +08:00
|
|
|
|
|
|
|
// X86 specific.
|
|
|
|
bool ParseX86InstOperands(MCInst &Inst);
|
|
|
|
bool ParseX86Operand(X86Operand &Op);
|
|
|
|
bool ParseX86MemOperand(X86Operand &Op);
|
2009-06-24 12:43:34 +08:00
|
|
|
|
|
|
|
// Directive Parsing.
|
|
|
|
bool ParseDirectiveSection();
|
|
|
|
|
2009-06-22 04:16:42 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|