38 template<
bool (WasmAsmParser::*HandlerMethod)(StringRef, SMLoc)>
41 this, HandleDirective<WasmAsmParser, HandlerMethod>);
43 getParser().addDirectiveHandler(Directive, Handler);
47 WasmAsmParser() { BracketExpressionsSupported =
true; }
55 addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveText>(
".text");
56 addDirectiveHandler<&WasmAsmParser::parseSectionDirective>(
".section");
57 addDirectiveHandler<&WasmAsmParser::parseDirectiveSize>(
".size");
58 addDirectiveHandler<&WasmAsmParser::parseDirectiveType>(
".type");
59 addDirectiveHandler<&WasmAsmParser::ParseDirectiveIdent>(
".ident");
61 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".weak");
63 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".local");
65 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".internal");
67 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".hidden");
75 auto Ok = Lexer->
is(Kind);
83 return error(std::string(
"Expected ") + KindName +
", instead got: ",
96 FlagStr.
split(Flags,
",", -1,
false);
97 for (
auto &
Flag : Flags) {
98 if (
Flag ==
"passive")
101 return error(
"Expected section flags, instead got: ", Lexer->
getTok());
109 return TokError(
"expected identifier in directive");
115 return error(
"expected string in directive, instead got: ", Lexer->
getTok());
128 if (!Kind.hasValue())
129 return Parser->
Error(Lexer->
getLoc(),
"unknown section kind: " +
Name);
134 bool Passive =
false;
140 return Parser->
Error(getTok().getLoc(),
141 "Only data sections can be passive");
151 auto WS = getContext().getWasmSection(Name, Kind.getValue());
152 getStreamer().SwitchSection(WS);
161 return TokError(
"expected identifier in directive");
162 auto Sym = getContext().getOrCreateSymbol(Name);
172 getStreamer().emitELFSize(Sym, Expr);
180 return error(
"Expected label after .type directive, got: ",
182 auto WasmSym = cast<MCSymbolWasm>(
183 getStreamer().getContext().getOrCreateSymbol(
188 return error(
"Expected label,@type declaration, got: ", Lexer->
getTok());
190 if (TypeName ==
"function")
192 else if (TypeName ==
"global")
194 else if (TypeName ==
"object")
197 return error(
"Unknown WASM symbol type: ", Lexer->
getTok());
207 return TokError(
"unexpected token in '.ident' directive");
211 return TokError(
"unexpected token in '.ident' directive");
213 getStreamer().EmitIdent(Data);
232 if (getParser().parseIdentifier(Name))
233 return TokError(
"expected identifier in directive");
234 MCSymbol *Sym = getContext().getOrCreateSymbol(Name);
235 getStreamer().EmitSymbolAttribute(Sym, Attr);
239 return TokError(
"unexpected token in directive");
253 return new WasmAsmParser;
static SectionKind getData()
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.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Generic assembler parser interface, for use by target specific assembly parsers.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
MCAsmParserExtension * createWasmAsmParser()
static unsigned parseSectionFlags(StringRef flagsStr, bool *UseLastGroup)
StringSwitch & Case(StringLiteral S, T Value)
SMLoc getLoc() const
Get the current source location.
static SectionKind getBSS()
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.
LLVM_NODISCARD R Default(T Value)
Target independent representation for an assembler token.
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
Directive
IDs for all OpenMP directives.
void setPassive(bool V=true)
Flag
These should be considered private to the implementation of the MCInstrDesc class.
A switch()-like statement whose cases are string literals.
This represents a section on wasm.
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static SectionKind getMetadata()
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
static SectionKind getReadOnly()
static SectionKind getText()