38 template<
bool (WasmAsmParser::*HandlerMethod)(StringRef, SMLoc)>
39 void addDirectiveHandler(
StringRef Directive) {
41 this, HandleDirective<WasmAsmParser, HandlerMethod>);
43 getParser().addDirectiveHandler(Directive, Handler);
47 WasmAsmParser() : Parser(nullptr), Lexer(nullptr) {
48 BracketExpressionsSupported =
true;
57 addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveText>(
".text");
58 addDirectiveHandler<&WasmAsmParser::parseSectionDirective>(
".section");
59 addDirectiveHandler<&WasmAsmParser::parseDirectiveSize>(
".size");
60 addDirectiveHandler<&WasmAsmParser::parseDirectiveType>(
".type");
68 auto ok = Lexer->
is(Kind);
75 return Error(std::string(
"Expected ") + KindName +
", instead got: ",
96 return TokError(
"expected identifier in directive");
97 auto Sym = getContext().getOrCreateSymbol(Name);
99 return TokError(
"unexpected token in directive");
105 return TokError(
"unexpected token in directive");
108 getStreamer().emitELFSize(Sym, Expr);
116 return Error(
"Expected label after .type directive, got: ",
118 auto WasmSym = cast<MCSymbolWasm>(
119 getStreamer().getContext().getOrCreateSymbol(
124 return Error(
"Expected label,@type declaration, got: ", Lexer->
getTok());
126 if (TypeName ==
"function")
128 else if (TypeName ==
"global")
131 return Error(
"Unknown WASM symbol type: ", Lexer->
getTok());
142 return new WasmAsmParser;
const AsmToken & getTok() const
Get the current (last) lexed token.
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
This class represents lattice values for constants.
bool is(AsmToken::TokenKind K) const
Check if the current token has kind K.
Generic assembler parser interface, for use by target specific assembly parsers.
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
MCAsmParserExtension * createWasmAsmParser()
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Generic assembler lexer interface, for use by target specific assembly lexers.
Base class for the full range of assembler expressions which are needed for parsing.
Target independent representation for an assembler token.
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
virtual MCAsmLexer & getLexer()=0
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
bool Error(SMLoc L, const Twine &Msg, SMRange Range=None)
Return an error at the location L, with the message Msg.
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
Generic interface for extending the MCAsmParser, which is implemented by target and object file assem...
std::pair< MCAsmParserExtension *, DirectiveHandler > ExtensionDirectiveHandler
StringRef - Represent a constant reference to a string, i.e.
virtual bool parseIdentifier(StringRef &Res)=0
Parse an identifier or string (as a quoted identifier) and set Res to the identifier contents...
Represents a location in source code.