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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
//===- 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"
#include "llvm/MC/MCStreamer.h"
namespace llvm {
class AsmExpr;
class MCContext;
class MCInst;
class MCStreamer;
class MCValue;
class AsmParser {
public:
struct X86Operand;
private:
AsmLexer Lexer;
MCContext &Ctx;
MCStreamer &Out;
public:
AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
: Lexer(SM), Ctx(ctx), Out(OutStr) {}
~AsmParser() {}
bool Run();
private:
bool ParseStatement();
void Warning(SMLoc L, const char *Msg);
bool Error(SMLoc L, const char *Msg);
bool TokError(const char *Msg);
void EatToEndOfStatement();
bool ParseAssignment(const char *Name, bool IsDotSet);
/// ParseExpression - Parse a general assembly expression.
///
/// @param Res - The resulting expression. The pointer value is null on error.
/// @result - False on success.
bool ParseExpression(AsmExpr *&Res);
/// ParseAbsoluteExpression - Parse an expression which must evaluate to an
/// absolute value.
///
/// @param Res - The value of the absolute expression. The result is undefined
/// on error.
/// @result - False on success.
bool ParseAbsoluteExpression(int64_t &Res);
/// ParseRelocatableExpression - Parse an expression which must be
/// relocatable.
///
/// @param Res - The relocatable expression value. The result is undefined on
/// error.
/// @result - False on success.
bool ParseRelocatableExpression(MCValue &Res);
/// ParseParenRelocatableExpression - Parse an expression which must be
/// relocatable, assuming that an initial '(' has already been consumed.
///
/// @param Res - The relocatable expression value. The result is undefined on
/// error.
/// @result - False on success.
///
/// @see ParseRelocatableExpression, ParseParenExpr.
bool ParseParenRelocatableExpression(MCValue &Res);
bool ParsePrimaryExpr(AsmExpr *&Res);
bool ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res);
bool ParseParenExpr(AsmExpr *&Res);
// X86 specific.
bool ParseX86InstOperands(const char *InstName, MCInst &Inst);
bool ParseX86Operand(X86Operand &Op);
bool ParseX86MemOperand(X86Operand &Op);
bool ParseX86Register(X86Operand &Op);
// Directive Parsing.
bool ParseDirectiveDarwinSection(); // Darwin specific ".section".
bool ParseDirectiveSectionSwitch(const char *Section,
const char *Directives = 0);
bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
bool ParseDirectiveFill(); // ".fill"
bool ParseDirectiveSpace(); // ".space"
bool ParseDirectiveSet(); // ".set"
bool ParseDirectiveOrg(); // ".org"
// ".align{,32}", ".p2align{,w,l}"
bool ParseDirectiveAlign(bool IsPow2, unsigned ValueSize);
/// ParseDirectiveSymbolAttribute - Parse a directive like ".globl" which
/// accepts a single symbol (which should be a label or an external).
bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr);
bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc"
bool ParseDirectiveDarwinLsym(); // Darwin specific ".lsym"
bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"
// Darwin specific ".subsections_via_symbols"
bool ParseDirectiveDarwinSubsectionsViaSymbols();
// Darwin specific .dump and .load
bool ParseDirectiveDarwinDumpOrLoad(bool IsDump);
bool ParseDirectiveAbort(); // ".abort"
bool ParseDirectiveInclude(); // ".include"
};
} // end namespace llvm
#endif
|