40 template<
bool (WasmAsmParser::*HandlerMethod)(StringRef, SMLoc)>
43 this, HandleDirective<WasmAsmParser, HandlerMethod>);
49 WasmAsmParser() { BracketExpressionsSupported =
true; }
57 addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveText>(
".text");
58 addDirectiveHandler<&WasmAsmParser::parseSectionDirectiveData>(
".data");
59 addDirectiveHandler<&WasmAsmParser::parseSectionDirective>(
".section");
60 addDirectiveHandler<&WasmAsmParser::parseDirectiveSize>(
".size");
61 addDirectiveHandler<&WasmAsmParser::parseDirectiveType>(
".type");
62 addDirectiveHandler<&WasmAsmParser::ParseDirectiveIdent>(
".ident");
64 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".weak");
66 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".local");
68 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".internal");
70 &WasmAsmParser::ParseDirectiveSymbolAttribute>(
".hidden");
78 auto Ok = Lexer->
is(Kind);
86 return error(std::string(
"Expected ") + KindName +
", instead got: ",
104 for (
char C : FlagStr) {
130 return TokError(
"expected group name");
136 return TokError(
"invalid group name");
143 if (Linkage !=
"comdat")
144 return TokError(
"Linkage must be 'comdat'");
152 return TokError(
"expected identifier in directive");
158 return error(
"expected string in directive, instead got: ", Lexer->
getTok());
175 bool Passive =
false;
188 if (Group && parseGroup(GroupName))
199 Parser->
Error(loc,
"changed section flags for " +
Name +
205 return Parser->
Error(loc,
"Only data sections can be passive");
218 return TokError(
"expected identifier in directive");
227 auto WasmSym = cast<MCSymbolWasm>(
Sym);
228 if (WasmSym->isFunction()) {
231 Warning(Loc,
".size directive ignored for function symbols");
242 return error(
"Expected label after .type directive, got: ",
244 auto WasmSym = cast<MCSymbolWasm>(
250 return error(
"Expected label,@type declaration, got: ", Lexer->
getTok());
252 if (TypeName ==
"function") {
255 cast<MCSectionWasm>(
getStreamer().getCurrentSectionOnly());
256 if (Current->getGroup())
257 WasmSym->setComdat(
true);
258 }
else if (TypeName ==
"global")
260 else if (TypeName ==
"object")
263 return error(
"Unknown WASM symbol type: ", Lexer->
getTok());
273 return TokError(
"unexpected token in '.ident' directive");
277 return TokError(
"unexpected token in '.ident' directive");
299 return TokError(
"expected identifier in directive");
305 return TokError(
"unexpected token in directive");
319 return new WasmAsmParser;
static bool isNot(const MachineRegisterInfo &MRI, const MachineInstr &MI)
static unsigned parseSectionFlags(const Triple &TT, StringRef flagsStr, bool *UseLastGroup)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Target independent representation for an assembler token.
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
Generic assembler lexer interface, for use by target specific assembly lexers.
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
const AsmToken & getTok() const
Get the current (last) lexed token.
bool is(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...
const AsmToken & getTok()
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
bool TokError(const Twine &Msg)
MCStreamer & getStreamer()
MCAsmParser & getParser()
Generic assembler parser interface, for use by target specific assembly parsers.
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
virtual bool parseIdentifier(StringRef &Res)=0
Parse an identifier or string (as a quoted identifier) and set Res to the identifier contents.
std::pair< MCAsmParserExtension *, DirectiveHandler > ExtensionDirectiveHandler
virtual MCAsmLexer & getLexer()=0
virtual void addDirectiveHandler(StringRef Directive, ExtensionDirectiveHandler Handler)=0
bool Error(SMLoc L, const Twine &Msg, SMRange Range=std::nullopt)
Return an error at the location L, with the message Msg.
const MCObjectFileInfo * getObjectFileInfo() const
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
Base class for the full range of assembler expressions which are needed for parsing.
MCSection * getDataSection() const
This represents a section on wasm.
void setPassive(bool V=true)
unsigned getSegmentFlags() const
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
virtual void emitELFSize(MCSymbol *Symbol, const MCExpr *Value)
Emit an ELF .size directive.
virtual void emitIdent(StringRef IdentString)
Emit the "identifiers" directive.
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Represents a location in source code.
static SectionKind getThreadData()
static SectionKind getMetadata()
static SectionKind getText()
static SectionKind getData()
static SectionKind getBSS()
static SectionKind getThreadBSS()
static SectionKind getReadOnly()
StringRef - Represent a constant reference to a string, i.e.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
@ C
The default llvm calling convention, compatible with C.
Linkage
Describes symbol linkage. This can be used to resolve definition clashes.
@ WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_FUNCTION
This is an optimization pass for GlobalISel generic memory operations.
MCAsmParserExtension * createWasmAsmParser()
@ Default
The result values are uniform if and only if all operands are uniform.
@ MCSA_Protected
.protected (ELF)
@ MCSA_Internal
.internal (ELF)
@ MCSA_Hidden
.hidden (ELF)
@ MCSA_Invalid
Not a valid directive.