38#define DEBUG_TYPE "wasm-asm-parser"
49 SMLoc StartLoc, EndLoc;
68 std::vector<unsigned>
List;
78 std::vector<CaLOpElem>
List;
91 :
Kind(Token), StartLoc(Start), EndLoc(
End), Tok(
T) {}
99 :
Kind(BrList), StartLoc(Start), EndLoc(
End), BrL(
B) {}
101 :
Kind(CatchList), StartLoc(Start), EndLoc(
End), CaL(
C) {}
103 ~WebAssemblyOperand() {
110 bool isToken()
const override {
return Kind == Token; }
112 bool isFPImm()
const {
return Kind ==
Float; }
113 bool isMem()
const override {
return false; }
114 bool isReg()
const override {
return false; }
115 bool isBrList()
const {
return Kind == BrList; }
116 bool isCatchList()
const {
return Kind == CatchList; }
131 void addRegOperands(
MCInst &,
unsigned)
const {
136 void addImmOperands(
MCInst &Inst,
unsigned N)
const {
137 assert(
N == 1 &&
"Invalid number of operands!");
140 else if (Kind == Symbol)
146 void addFPImmf32Operands(
MCInst &Inst,
unsigned N)
const {
147 assert(
N == 1 &&
"Invalid number of operands!");
155 void addFPImmf64Operands(
MCInst &Inst,
unsigned N)
const {
156 assert(
N == 1 &&
"Invalid number of operands!");
163 void addBrListOperands(
MCInst &Inst,
unsigned N)
const {
164 assert(
N == 1 && isBrList() &&
"Invalid BrList!");
165 for (
auto Br : BrL.List)
169 void addCatchListOperands(
MCInst &Inst,
unsigned N)
const {
170 assert(
N == 1 && isCatchList() &&
"Invalid CatchList!");
172 for (
auto Ca : CaL.List) {
184 OS <<
"Tok:" << Tok.Tok;
187 OS <<
"Int:" <<
Int.Val;
190 OS <<
"Flt:" <<
Flt.Val;
193 OS <<
"Sym:" <<
Sym.Exp;
196 OS <<
"BrList:" << BrL.List.size();
199 OS <<
"CaList:" << CaL.List.size();
215 if (!
Sym->isFunctionTable())
219 Sym->setFunctionTable(Is64);
244 } CurrentState = FileStart;
262 std::vector<Nested> NestingStack;
265 MCSymbol *LastFunctionLabel =
nullptr;
277 Lexer(Parser.getLexer()), Is64(STI.getTargetTriple().isArch64Bit()),
278 TC(Parser, MII, Is64), SkipTypeCheck(
Options.MCNoTypeCheck) {
282 if (FBS.
test(WebAssembly::FeatureBulkMemory)) {
283 FBS.
set(WebAssembly::FeatureBulkMemoryOpt);
286 if (FBS.
test(WebAssembly::FeatureReferenceTypes)) {
287 FBS.
set(WebAssembly::FeatureCallIndirectOverlong);
295 SM.
getBufferInfo(SM.getMainFileID()).Buffer->getBufferIdentifier();
296 if (BufferName ==
"<inline asm>")
297 SkipTypeCheck =
true;
304 getContext(),
"__indirect_function_table", Is64);
310#define GET_ASSEMBLER_HEADER
311#include "WebAssemblyGenAsmMatcher.inc"
318 SMLoc &EndLoc)
override {
330 std::pair<StringRef, StringRef> nestingString(NestingType NT) {
333 return {
"function",
"end_function"};
335 return {
"block",
"end_block"};
337 return {
"loop",
"end_loop"};
339 return {
"try",
"end_try/delegate"};
341 return {
"catch_all",
"end_try"};
343 return {
"try_table",
"end_try_table"};
345 return {
"if",
"end_if"};
347 return {
"else",
"end_if"};
354 NestingStack.push_back({
NT, Sig});
357 bool pop(
StringRef Ins, NestingType NT1, NestingType NT2 = Undefined) {
358 if (NestingStack.empty())
359 return error(
Twine(
"End of block construct with no start: ") + Ins);
360 auto Top = NestingStack.back();
361 if (Top.NT != NT1 && Top.NT != NT2)
362 return error(
Twine(
"Block construct type mismatch, expected: ") +
363 nestingString(Top.NT).second +
", instead got: " + Ins);
365 NestingStack.pop_back();
371 bool popAndPushWithSameSignature(
StringRef Ins, NestingType PopNT,
372 NestingType PushNT) {
373 if (NestingStack.empty())
374 return error(
Twine(
"End of block construct with no start: ") + Ins);
375 auto Sig = NestingStack.back().Sig;
382 bool ensureEmptyNestingStack(
SMLoc Loc =
SMLoc()) {
383 auto Err = !NestingStack.empty();
384 while (!NestingStack.empty()) {
385 error(
Twine(
"Unmatched block construct(s) at function end: ") +
386 nestingString(NestingStack.back().NT).first,
388 NestingStack.pop_back();
394 auto Ok = Lexer.
is(Kind);
402 return error(std::string(
"Expected ") + KindName +
", instead got: ",
409 error(
"Expected identifier, got: ", Lexer.
getTok());
432 int64_t Val =
Int.getIntVal();
435 Operands.push_back(std::make_unique<WebAssemblyOperand>(
436 Int.getLoc(),
Int.getEndLoc(), WebAssemblyOperand::IntOp{Val}));
443 if (
Flt.getString().getAsDouble(Val,
false))
444 return error(
"Cannot parse real: ",
Flt);
447 Operands.push_back(std::make_unique<WebAssemblyOperand>(
448 Flt.getLoc(),
Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
457 auto S =
Flt.getString();
459 if (S.compare_insensitive(
"infinity") == 0) {
460 Val = std::numeric_limits<double>::infinity();
461 }
else if (S.compare_insensitive(
"nan") == 0) {
462 Val = std::numeric_limits<double>::quiet_NaN();
468 Operands.push_back(std::make_unique<WebAssemblyOperand>(
469 Flt.getLoc(),
Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
476 auto IsLoadStore = InstName.
contains(
".load") ||
479 auto IsAtomic = InstName.
contains(
"atomic.");
480 if (IsLoadStore || IsAtomic) {
483 auto Id = expectIdent();
485 return error(
"Expected p2align, instead got: " + Id);
489 return error(
"Expected integer constant");
490 parseSingleInteger(
false,
Operands);
495 auto IsLoadStoreLane = InstName.
contains(
"_lane");
496 if (IsLoadStoreLane &&
Operands.size() == 4)
502 auto Tok = Lexer.
getTok();
503 Operands.push_back(std::make_unique<WebAssemblyOperand>(
512 if (
BT == WebAssembly::BlockType::Void) {
517 NestingStack.back().Sig = Sig;
519 Operands.push_back(std::make_unique<WebAssemblyOperand>(
520 NameLoc, NameLoc, WebAssemblyOperand::IntOp{
static_cast<int64_t
>(
BT)}));
524 auto Tok = Lexer.
getTok();
526 return error(
"Expected integer constant, instead got: ", Tok);
534 auto Tok = Lexer.
getTok();
536 return error(
"Expected integer constant, instead got: ", Tok);
545 bool parseFunctionTableOperand(std::unique_ptr<WebAssemblyOperand> *
Op) {
553 auto &Tok = Lexer.
getTok();
558 *
Op = std::make_unique<WebAssemblyOperand>(
565 *
Op = std::make_unique<WebAssemblyOperand>(
566 SMLoc(),
SMLoc(), WebAssemblyOperand::SymOp{Val});
573 *
Op = std::make_unique<WebAssemblyOperand>(
SMLoc(),
SMLoc(),
574 WebAssemblyOperand::IntOp{0});
588 auto &Sep = Lexer.
getTok();
589 if (Sep.getLoc().getPointer() !=
Name.end() ||
598 Id.getLoc().getPointer() !=
Name.end())
599 return error(
"Incomplete instruction name: ", Id);
605 Operands.push_back(std::make_unique<WebAssemblyOperand>(
607 WebAssemblyOperand::TokOp{Name}));
611 bool ExpectBlockType =
false;
612 bool ExpectFuncType =
false;
613 bool ExpectCatchList =
false;
614 std::unique_ptr<WebAssemblyOperand> FunctionTable;
615 if (
Name ==
"block") {
617 ExpectBlockType =
true;
618 }
else if (
Name ==
"loop") {
620 ExpectBlockType =
true;
621 }
else if (
Name ==
"try") {
623 ExpectBlockType =
true;
624 }
else if (
Name ==
"if") {
626 ExpectBlockType =
true;
627 }
else if (
Name ==
"else") {
628 if (popAndPushWithSameSignature(
Name, If, Else))
630 }
else if (
Name ==
"catch") {
631 if (popAndPushWithSameSignature(
Name, Try, Try))
633 }
else if (
Name ==
"catch_all") {
634 if (popAndPushWithSameSignature(
Name, Try, CatchAll))
636 }
else if (
Name ==
"try_table") {
638 ExpectBlockType =
true;
639 ExpectCatchList =
true;
640 }
else if (
Name ==
"end_if") {
641 if (pop(
Name, If, Else))
643 }
else if (
Name ==
"end_try") {
644 if (pop(
Name, Try, CatchAll))
646 }
else if (
Name ==
"end_try_table") {
647 if (pop(
Name, TryTable))
649 }
else if (
Name ==
"delegate") {
652 }
else if (
Name ==
"end_loop") {
655 }
else if (
Name ==
"end_block") {
656 if (pop(
Name, Block))
658 }
else if (
Name ==
"end_function") {
660 CurrentState = EndFunction;
663 }
else if (
Name ==
"call_indirect" ||
Name ==
"return_call_indirect") {
667 if (parseFunctionTableOperand(&FunctionTable))
669 ExpectFuncType =
true;
673 auto PeekCatchList = [&]() {
682 if (ExpectFuncType ||
689 auto Loc = Parser.
getTok();
691 if (parseSignature(Signature))
696 NestingStack.back().Sig = *Signature;
697 ExpectBlockType =
false;
700 auto *WasmSym = cast<MCSymbolWasm>(
Sym);
701 WasmSym->setSignature(Signature);
705 Operands.push_back(std::make_unique<WebAssemblyOperand>(
706 Loc.getLoc(), Loc.getEndLoc(), WebAssemblyOperand::SymOp{Expr}));
716 if (ExpectCatchList && PeekCatchList()) {
717 if (ExpectBlockType) {
718 ExpectBlockType =
false;
719 addBlockTypeOperand(
Operands, NameLoc, WebAssembly::BlockType::Void);
723 ExpectCatchList =
false;
727 auto &Tok = Lexer.
getTok();
730 if (!parseSpecialFloatMaybe(
false,
Operands))
733 if (ExpectBlockType) {
736 if (
BT == WebAssembly::BlockType::Invalid)
737 return error(
"Unknown block type: ", Id);
739 ExpectBlockType =
false;
743 if (ExpectCatchList && PeekCatchList()) {
746 ExpectCatchList =
false;
754 return error(
"Cannot parse symbol: ", Lexer.
getTok());
755 Operands.push_back(std::make_unique<WebAssemblyOperand>(
756 Start,
End, WebAssemblyOperand::SymOp{Val}));
769 if (parseSingleFloat(
true,
Operands))
771 }
else if (!parseSpecialFloatMaybe(
true,
Operands)) {
773 return error(
"Expected numeric constant instead got: ",
778 parseSingleInteger(
false,
Operands);
783 if (parseSingleFloat(
false,
Operands))
789 auto Op = std::make_unique<WebAssemblyOperand>(
803 return error(
"Unexpected token in operand: ", Tok);
816 addBlockTypeOperand(
Operands, NameLoc, WebAssembly::BlockType::Void);
819 Operands.push_back(std::make_unique<WebAssemblyOperand>(
820 NameLoc, NameLoc, WebAssemblyOperand::CaLOp{}));
823 Operands.push_back(std::move(FunctionTable));
831 if (parseRegTypeList(Signature->
Params))
839 if (parseRegTypeList(Signature->
Returns))
847 auto Op = std::make_unique<WebAssemblyOperand>(
855 auto CatchStr = expectIdent();
856 if (CatchStr.empty())
865 if (CatchOpcode == 0xff)
867 "Expected catch/catch_ref/catch_all/catch_all_ref, instead got: " +
874 return error(
"Cannot parse symbol: ", Lexer.
getTok());
877 auto &DestTok = Lexer.
getTok();
879 return error(
"Expected integer constant, instead got: ", DestTok);
880 unsigned Dest = DestTok.getIntVal();
887 Op->CaL.List.push_back({CatchOpcode,
Tag, Dest});
895 bool checkDataSection() {
896 if (CurrentState != DataSection) {
897 auto *WS = cast<MCSectionWasm>(
getStreamer().getCurrentSectionOnly());
898 if (WS && WS->isText())
899 return error(
"data directive must occur in a data segment: ",
902 CurrentState = DataSection;
914 auto &Ctx = Out.getContext();
916 if (DirectiveID.
getString() ==
".globaltype") {
917 auto SymName = expectIdent();
922 auto TypeTok = Lexer.
getTok();
928 return error(
"Unknown type in .globaltype directive: ", TypeTok);
935 auto Id = expectIdent();
938 if (Id ==
"immutable")
942 return error(
"Unknown type in .globaltype modifier: ", TypeTok);
949 TOut.emitGlobalType(WasmSym);
953 if (DirectiveID.
getString() ==
".tabletype") {
955 auto SymName = expectIdent();
961 auto ElemTypeTok = Lexer.
getTok();
962 auto ElemTypeName = expectIdent();
963 if (ElemTypeName.empty())
965 std::optional<wasm::ValType> ElemType =
968 return error(
"Unknown type in .tabletype directive: ", ElemTypeTok);
982 WasmSym->setTableType(
Type);
983 TOut.emitTableType(WasmSym);
987 if (DirectiveID.
getString() ==
".functype") {
993 auto SymName = expectIdent();
997 if (WasmSym->isDefined()) {
1008 if (CurrentState != FunctionLabel) {
1010 if (ensureEmptyNestingStack())
1014 CurrentState = FunctionStart;
1015 LastFunctionLabel = WasmSym;
1018 if (parseSignature(Signature))
1020 if (CurrentState == FunctionStart)
1022 WasmSym->setSignature(Signature);
1024 TOut.emitFunctionType(WasmSym);
1029 if (DirectiveID.
getString() ==
".export_name") {
1030 auto SymName = expectIdent();
1031 if (SymName.empty())
1035 auto ExportName = expectIdent();
1036 if (ExportName.empty())
1040 TOut.emitExportName(WasmSym, ExportName);
1044 if (DirectiveID.
getString() ==
".import_module") {
1045 auto SymName = expectIdent();
1046 if (SymName.empty())
1050 auto ImportModule = expectIdent();
1051 if (ImportModule.empty())
1055 TOut.emitImportModule(WasmSym, ImportModule);
1059 if (DirectiveID.
getString() ==
".import_name") {
1060 auto SymName = expectIdent();
1061 if (SymName.empty())
1065 auto ImportName = expectIdent();
1066 if (ImportName.
empty())
1070 TOut.emitImportName(WasmSym, ImportName);
1074 if (DirectiveID.
getString() ==
".tagtype") {
1075 auto SymName = expectIdent();
1076 if (SymName.empty())
1080 if (parseRegTypeList(Signature->
Params))
1082 WasmSym->setSignature(Signature);
1084 TOut.emitTagType(WasmSym);
1089 if (DirectiveID.
getString() ==
".local") {
1090 if (CurrentState != FunctionStart)
1091 return error(
".local directive should follow the start of a function: ",
1094 if (parseRegTypeList(Locals))
1097 TOut.emitLocal(Locals);
1098 CurrentState = FunctionLocals;
1102 if (DirectiveID.
getString() ==
".int8" ||
1106 if (checkDataSection())
1111 return error(
"Cannot parse .int expression: ", Lexer.
getTok());
1114 Out.emitValue(Val, NumBits / 8,
End);
1118 if (DirectiveID.
getString() ==
".asciz") {
1119 if (checkDataSection())
1123 return error(
"Cannot parse string constant: ", Lexer.
getTok());
1124 Out.emitBytes(
StringRef(S.c_str(), S.length() + 1));
1133 if (CurrentState == FunctionStart) {
1140 CurrentState = FunctionLocals;
1147 bool MatchingInlineAsm)
override {
1151 unsigned MatchResult = MatchInstructionImpl(
1153 switch (MatchResult) {
1160 if (Op0.getImm() == -1)
1176 if (CurrentState == EndFunction) {
1177 onEndOfFunction(IDLoc);
1184 assert(MissingFeatures.
count() > 0 &&
"Expected missing features");
1187 OS <<
"instruction requires:";
1188 for (
unsigned I = 0, E = MissingFeatures.
size();
I != E; ++
I)
1189 if (MissingFeatures.
test(
I))
1191 return Parser.
Error(IDLoc, Message);
1194 return Parser.
Error(IDLoc,
"invalid instruction");
1196 return Parser.
Error(IDLoc,
"ambiguous instruction");
1199 SMLoc ErrorLoc = IDLoc;
1202 return Parser.
Error(IDLoc,
"too few operands for instruction");
1204 if (ErrorLoc ==
SMLoc())
1207 return Parser.
Error(ErrorLoc,
"invalid operand for instruction");
1215 auto *CWS = cast<MCSectionWasm>(
getStreamer().getCurrentSectionOnly());
1219 auto *WasmSym = cast<MCSymbolWasm>(Symbol);
1224 "Wasm doesn\'t support data symbols in text sections");
1231 auto SymName =
Symbol->getName();
1232 if (SymName.starts_with(
".L"))
1239 std::string SecName = (
".text." + SymName).str();
1241 auto *Group = CWS->getGroup();
1247 WasmSym->setComdat(
true);
1255 if (WasmSym->isFunction()) {
1265 ensureEmptyNestingStack(IDLoc);
1266 CurrentState = FunctionLabel;
1267 LastFunctionLabel =
Symbol;
1272 void onEndOfFunction(
SMLoc ErrorLoc) {
1279 void onEndOfFile()
override { ensureEmptyNestingStack(); }
1289#define GET_REGISTER_MATCHER
1290#define GET_SUBTARGET_FEATURE_NAME
1291#define GET_MATCHER_IMPLEMENTATION
1292#include "WebAssemblyGenAsmMatcher.inc"
1296 for (
auto &ME : MatchTable0) {
1297 if (ME.Opcode == Opc) {
1298 return ME.getMnemonic();
1301 assert(
false &&
"mnemonic not found");
static const char * getSubtargetFeatureName(uint64_t Val)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
mir Rename Register Operands
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef getMnemonic(unsigned Opc)
static const char * getSubtargetFeatureName(uint64_t Val)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmParser()
This file is part of the WebAssembly Assembler.
This file provides WebAssembly-specific target descriptions.
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
This file registers the WebAssembly target.
This file declares WebAssembly-specific target streamer classes.
Target independent representation for an assembler token.
int64_t getIntVal() const
StringRef getString() const
Get the string for the current token, this includes all characters (for example, the quotes on string...
bool is(TokenKind K) const
TokenKind getKind() const
StringRef getIdentifier() const
Get the identifier string for the current token, which should be an identifier or a string.
This class represents an Operation in the Expression.
Base class for user error types.
Container class for subtarget features.
constexpr bool test(unsigned I) const
constexpr size_t size() const
Represents a single loop in the control flow graph.
Generic assembler lexer interface, for use by target specific assembly lexers.
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
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.
virtual void Initialize(MCAsmParser &Parser)
Initialize the extension for parsing using the given Parser.
MCStreamer & getStreamer()
Generic assembler parser interface, for use by target specific assembly parsers.
virtual bool parseEscapedString(std::string &Data)=0
Parse the current token as a string which may include escaped characters and return the string conten...
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc)=0
Parse an arbitrary expression.
virtual SourceMgr & getSourceManager()=0
const AsmToken & getTok() const
Get the current AsmToken from the stream.
virtual const AsmToken & Lex()=0
Get the next AsmToken in the stream, possibly handling file inclusion first.
bool Error(SMLoc L, const Twine &Msg, SMRange Range=std::nullopt)
Return an error at the location L, with the message Msg.
Context object for machine code objects.
MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
wasm::WasmSignature * createWasmSignature()
Allocates and returns a new WasmSignature instance (with empty parameter and return type lists).
bool addGenDwarfSection(MCSection *Sec)
StringRef allocateString(StringRef s)
Allocates a copy of the given string on the allocator managed by this context and returns the result.
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
void reportError(SMLoc L, const Twine &Msg)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
@ GenericSectionID
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Base class for the full range of assembler expressions which are needed for parsing.
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
Interface to description of machine instruction set.
static MCOperand createExpr(const MCExpr *Val)
static MCOperand createSFPImm(uint32_t Val)
static MCOperand createImm(int64_t Val)
static MCOperand createDFPImm(uint64_t Val)
MCParsedAsmOperand - This abstract class represents a source-level assembly instruction operand.
virtual SMLoc getStartLoc() const =0
getStartLoc - Get the location of the first token of this operand.
virtual bool isReg() const =0
isReg - Is this a register operand?
virtual bool isMem() const =0
isMem - Is this a memory operand?
virtual MCRegister getReg() const =0
virtual void print(raw_ostream &OS) const =0
print - Print a debug representation of the operand to the given stream.
virtual bool isToken() const =0
isToken - Is this a token operand?
virtual bool isImm() const =0
isImm - Is this an immediate operand?
virtual SMLoc getEndLoc() const =0
getEndLoc - Get the location of the last token of this operand.
Wrapper class representing physical registers. Should be passed by value.
Streaming machine code generation interface.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
virtual bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
Add the given Attribute to Symbol.
MCTargetStreamer * getTargetStreamer()
virtual void switchSection(MCSection *Section, uint32_t Subsec=0)
Set the current section where code is being emitted to Section.
Generic base class for all target subtargets.
bool checkFeatures(StringRef FS) const
Check whether the subtarget features are enabled/disabled as per the provided string,...
const FeatureBitset & getFeatureBits() const
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
void setOmitFromLinkingSection()
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
MCTargetAsmParser - Generic interface to target specific assembly parsers.
virtual ParseStatus parseDirective(AsmToken DirectiveID)
Parses a target-specific assembler directive.
virtual bool parseInstruction(ParseInstructionInfo &Info, StringRef Name, SMLoc NameLoc, OperandVector &Operands)=0
Parse one assembly instruction.
@ Match_InvalidTiedOperand
virtual bool parseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc)=0
virtual ParseStatus tryParseRegister(MCRegister &Reg, SMLoc &StartLoc, SMLoc &EndLoc)=0
tryParseRegister - parse one register if possible
virtual bool matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode, OperandVector &Operands, MCStreamer &Out, uint64_t &ErrorInfo, bool MatchingInlineAsm)=0
Recognize a series of operands of a parsed instruction as an actual MCInst and emit it to the specifi...
virtual void onEndOfFile()
void setAvailableFeatures(const FeatureBitset &Value)
const MCSubtargetInfo & getSTI() const
virtual void doBeforeLabelEmit(MCSymbol *Symbol, SMLoc IDLoc)
Ternary parse status returned by various parse* methods.
static constexpr StatusTy Failure
static constexpr StatusTy NoMatch
Represents a location in source code.
static SMLoc getFromPointer(const char *Ptr)
constexpr const char * getPointer() const
static SectionKind getText()
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const SrcBuffer & getBufferInfo(unsigned i) const
StringRef - Represent a constant reference to a string, i.e.
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
empty - Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool endOfFunction(SMLoc ErrorLoc, bool ExactMatch)
void funcDecl(const wasm::WasmSignature &Sig)
void setLastSig(const wasm::WasmSignature &Sig)
void localDecl(const SmallVectorImpl< wasm::ValType > &Locals)
bool typeCheck(SMLoc ErrorLoc, const MCInst &Inst, OperandVector &Operands)
WebAssembly-specific streamer interface, to implement support WebAssembly-specific assembly directive...
virtual void emitLocal(ArrayRef< wasm::ValType > Types)=0
.local
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char TypeName[]
Key for Kernel::Arg::Metadata::mTypeName.
@ C
The default llvm calling convention, compatible with C.
int getWasm64Opcode(unsigned short Opcode)
MCSymbolWasm * getOrCreateFunctionTableSymbol(MCContext &Ctx, const WebAssemblySubtarget *Subtarget)
Returns the __indirect_function_table, for use in call_indirect and in function bitcasts.
BlockType parseBlockType(StringRef Type)
BlockType
Used as immediate MachineOperands for block signatures.
unsigned GetDefaultP2AlignAny(unsigned Opc)
Return the default p2align value for a load or store with the given opcode.
std::optional< wasm::ValType > parseType(StringRef Type)
@ WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_FUNCTION
@ WASM_LIMITS_FLAG_HAS_MAX
@ WASM_OPCODE_CATCH_ALL_REF
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheWebAssemblyTarget32()
Target & getTheWebAssemblyTarget64()
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
This struct is a compact representation of a valid (non-zero power of two) alignment.
RegisterMCAsmParser - Helper template for registering a target specific assembly parser,...
SmallVector< ValType, 1 > Returns
SmallVector< ValType, 4 > Params