1 //===- AsmParser.h - Parser for Assembly Files ------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This class declares the parser for assembly files.
12 //===----------------------------------------------------------------------===//
18 #include "llvm/MC/MCStreamer.h"
37 AsmParser(SourceMgr &SM, MCContext &ctx, MCStreamer &OutStr)
38 : Lexer(SM), Ctx(ctx), Out(OutStr) {}
44 bool ParseStatement();
46 void Warning(SMLoc L, const char *Msg);
47 bool Error(SMLoc L, const char *Msg);
48 bool TokError(const char *Msg);
50 void EatToEndOfStatement();
52 bool ParseAssignment(const char *Name, bool IsDotSet);
54 /// ParseExpression - Parse a general assembly expression.
56 /// @param Res - The resulting expression. The pointer value is null on error.
57 /// @result - False on success.
58 bool ParseExpression(AsmExpr *&Res);
60 /// ParseAbsoluteExpression - Parse an expression which must evaluate to an
63 /// @param Res - The value of the absolute expression. The result is undefined
65 /// @result - False on success.
66 bool ParseAbsoluteExpression(int64_t &Res);
68 /// ParseRelocatableExpression - Parse an expression which must be
71 /// @param Res - The relocatable expression value. The result is undefined on
73 /// @result - False on success.
74 bool ParseRelocatableExpression(MCValue &Res);
76 /// ParseParenRelocatableExpression - Parse an expression which must be
77 /// relocatable, assuming that an initial '(' has already been consumed.
79 /// @param Res - The relocatable expression value. The result is undefined on
81 /// @result - False on success.
83 /// @see ParseRelocatableExpression, ParseParenExpr.
84 bool ParseParenRelocatableExpression(MCValue &Res);
86 bool ParsePrimaryExpr(AsmExpr *&Res);
87 bool ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res);
88 bool ParseParenExpr(AsmExpr *&Res);
91 bool ParseX86InstOperands(const char *InstName, MCInst &Inst);
92 bool ParseX86Operand(X86Operand &Op);
93 bool ParseX86MemOperand(X86Operand &Op);
94 bool ParseX86Register(X86Operand &Op);
97 bool ParseDirectiveDarwinSection(); // Darwin specific ".section".
98 bool ParseDirectiveSectionSwitch(const char *Section,
99 const char *Directives = 0);
100 bool ParseDirectiveAscii(bool ZeroTerminated); // ".ascii", ".asciiz"
101 bool ParseDirectiveValue(unsigned Size); // ".byte", ".long", ...
102 bool ParseDirectiveFill(); // ".fill"
103 bool ParseDirectiveSpace(); // ".space"
104 bool ParseDirectiveSet(); // ".set"
105 bool ParseDirectiveOrg(); // ".org"
106 // ".align{,32}", ".p2align{,w,l}"
107 bool ParseDirectiveAlign(bool IsPow2, unsigned ValueSize);
109 /// ParseDirectiveSymbolAttribute - Parse a directive like ".globl" which
110 /// accepts a single symbol (which should be a label or an external).
111 bool ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr);
112 bool ParseDirectiveDarwinSymbolDesc(); // Darwin specific ".desc"
114 bool ParseDirectiveComm(bool IsLocal); // ".comm" and ".lcomm"
115 bool ParseDirectiveDarwinZerofill(); // Darwin specific ".zerofill"
117 // Darwin specific ".subsections_via_symbols"
118 bool ParseDirectiveDarwinSubsectionsViaSymbols();
120 bool ParseDirectiveAbort(); // ".abort"
123 } // end namespace llvm