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) {
127 return TokError(
"expected group name");
133 return TokError(
"invalid group name");
140 if (Linkage !=
"comdat")
141 return TokError(
"Linkage must be 'comdat'");
149 return TokError(
"expected identifier in directive");
155 return error(
"expected string in directive, instead got: ", Lexer->
getTok());
172 bool Passive =
false;
185 if (Group && parseGroup(GroupName))
196 Parser->
Error(loc,
"changed section flags for " +
Name +
202 return Parser->
Error(loc,
"Only data sections can be passive");
215 return TokError(
"expected identifier in directive");
224 auto WasmSym = cast<MCSymbolWasm>(
Sym);
225 if (WasmSym->isFunction()) {
228 Warning(Loc,
".size directive ignored for function symbols");
239 return error(
"Expected label after .type directive, got: ",
241 auto WasmSym = cast<MCSymbolWasm>(
247 return error(
"Expected label,@type declaration, got: ", Lexer->
getTok());
249 if (TypeName ==
"function") {
252 cast<MCSectionWasm>(
getStreamer().getCurrentSection().first);
253 if (Current->getGroup())
254 WasmSym->setComdat(
true);
255 }
else if (TypeName ==
"global")
257 else if (TypeName ==
"object")
260 return error(
"Unknown WASM symbol type: ", Lexer->
getTok());
270 return TokError(
"unexpected token in '.ident' directive");
274 return TokError(
"unexpected token in '.ident' directive");
296 return TokError(
"expected identifier in directive");
302 return TokError(
"unexpected token in directive");
316 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
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
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, const MCExpr *Subsection=nullptr)
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.