40#define DEBUG_TYPE "wasm-asm-parser"
51 SMLoc StartLoc, EndLoc;
70 std::vector<unsigned>
List;
80 std::vector<CaLOpElem>
List;
93 :
Kind(Token), StartLoc(Start), EndLoc(
End), Tok(
T) {}
101 :
Kind(BrList), StartLoc(Start), EndLoc(
End), BrL(
B) {}
103 :
Kind(CatchList), StartLoc(Start), EndLoc(
End), CaL(
C) {}
105 ~WebAssemblyOperand() {
112 bool isToken()
const override {
return Kind == Token; }
114 bool isFPImm()
const {
return Kind ==
Float; }
115 bool isMem()
const override {
return false; }
116 bool isReg()
const override {
return false; }
117 bool isBrList()
const {
return Kind == BrList; }
118 bool isCatchList()
const {
return Kind == CatchList; }
133 void addRegOperands(
MCInst &,
unsigned)
const {
138 void addImmOperands(
MCInst &Inst,
unsigned N)
const {
139 assert(
N == 1 &&
"Invalid number of operands!");
142 else if (Kind == Symbol)
148 void addFPImmf32Operands(
MCInst &Inst,
unsigned N)
const {
149 assert(
N == 1 &&
"Invalid number of operands!");
157 void addFPImmf64Operands(
MCInst &Inst,
unsigned N)
const {
158 assert(
N == 1 &&
"Invalid number of operands!");
165 void addBrListOperands(
MCInst &Inst,
unsigned N)
const {
166 assert(
N == 1 && isBrList() &&
"Invalid BrList!");
167 for (
auto Br : BrL.List)
171 void addCatchListOperands(
MCInst &Inst,
unsigned N)
const {
172 assert(
N == 1 && isCatchList() &&
"Invalid CatchList!");
174 for (
auto Ca : CaL.List) {
186 OS <<
"Tok:" << Tok.Tok;
189 OS <<
"Int:" <<
Int.Val;
192 OS <<
"Flt:" <<
Flt.Val;
195 OS <<
"Sym:" <<
Sym.Exp;
198 OS <<
"BrList:" << BrL.List.size();
201 OS <<
"CaList:" << CaL.List.size();
217 if (!
Sym->isFunctionTable())
221 Sym->setFunctionTable(Is64);
245 } CurrentState = FileStart;
263 std::vector<Nested> NestingStack;
266 MCSymbol *LastFunctionLabel =
nullptr;
278 Lexer(Parser.getLexer()), Is64(STI.getTargetTriple().isArch64Bit()),
279 TC(Parser, MII, Is64), SkipTypeCheck(
Options.MCNoTypeCheck) {
283 if (FBS.
test(WebAssembly::FeatureBulkMemory)) {
284 FBS.
set(WebAssembly::FeatureBulkMemoryOpt);
287 if (FBS.
test(WebAssembly::FeatureReferenceTypes)) {
288 FBS.
set(WebAssembly::FeatureCallIndirectOverlong);
296 SM.
getBufferInfo(SM.getMainFileID()).Buffer->getBufferIdentifier();
297 if (BufferName ==
"<inline asm>")
298 SkipTypeCheck =
true;
305 getContext(),
"__indirect_function_table", Is64);
311#define GET_ASSEMBLER_HEADER
312#include "WebAssemblyGenAsmMatcher.inc"
319 SMLoc &EndLoc)
override {
331 std::pair<StringRef, StringRef> nestingString(NestingType NT) {
334 return {
"function",
"end_function"};
336 return {
"block",
"end_block"};
338 return {
"loop",
"end_loop"};
340 return {
"try",
"end_try/delegate"};
342 return {
"catch_all",
"end_try"};
344 return {
"try_table",
"end_try_table"};
346 return {
"if",
"end_if"};
348 return {
"else",
"end_if"};
355 NestingStack.push_back({
NT, Sig});
358 bool pop(
StringRef Ins, NestingType NT1, NestingType NT2 = Undefined) {
359 if (NestingStack.empty())
360 return error(
Twine(
"End of block construct with no start: ") + Ins);
361 auto Top = NestingStack.back();
362 if (Top.NT != NT1 && Top.NT != NT2)
363 return error(
Twine(
"Block construct type mismatch, expected: ") +
364 nestingString(Top.NT).second +
", instead got: " + Ins);
366 NestingStack.pop_back();
372 bool popAndPushWithSameSignature(
StringRef Ins, NestingType PopNT,
373 NestingType PushNT) {
374 if (NestingStack.empty())
375 return error(
Twine(
"End of block construct with no start: ") + Ins);
376 auto Sig = NestingStack.back().Sig;
383 bool ensureEmptyNestingStack(
SMLoc Loc =
SMLoc()) {
384 auto Err = !NestingStack.empty();
385 while (!NestingStack.empty()) {
386 error(
Twine(
"Unmatched block construct(s) at function end: ") +
387 nestingString(NestingStack.back().NT).first,
389 NestingStack.pop_back();
395 auto Ok = Lexer.
is(Kind);
403 return error(std::string(
"Expected ") + KindName +
", instead got: ",
410 error(
"Expected identifier, got: ", Lexer.
getTok());
433 int64_t Val =
Int.getIntVal();
436 Operands.push_back(std::make_unique<WebAssemblyOperand>(
437 Int.getLoc(),
Int.getEndLoc(), WebAssemblyOperand::IntOp{Val}));
444 if (
Flt.getString().getAsDouble(Val,
false))
445 return error(
"Cannot parse real: ",
Flt);
448 Operands.push_back(std::make_unique<WebAssemblyOperand>(
449 Flt.getLoc(),
Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
458 auto S =
Flt.getString();
460 if (S.compare_insensitive(
"infinity") == 0) {
461 Val = std::numeric_limits<double>::infinity();
462 }
else if (S.compare_insensitive(
"nan") == 0) {
463 Val = std::numeric_limits<double>::quiet_NaN();
469 Operands.push_back(std::make_unique<WebAssemblyOperand>(
470 Flt.getLoc(),
Flt.getEndLoc(), WebAssemblyOperand::FltOp{Val}));
477 auto IsLoadStore = InstName.
contains(
".load") ||
480 auto IsAtomic = InstName.
contains(
"atomic.");
481 if (IsLoadStore || IsAtomic) {
484 auto Id = expectIdent();
486 return error(
"Expected p2align, instead got: " + Id);
490 return error(
"Expected integer constant");
491 parseSingleInteger(
false,
Operands);
496 auto IsLoadStoreLane = InstName.
contains(
"_lane");
497 if (IsLoadStoreLane &&
Operands.size() == 4)
503 auto Tok = Lexer.
getTok();
504 Operands.push_back(std::make_unique<WebAssemblyOperand>(
513 if (
BT == WebAssembly::BlockType::Void) {
518 NestingStack.back().Sig = Sig;
520 Operands.push_back(std::make_unique<WebAssemblyOperand>(
521 NameLoc, NameLoc, WebAssemblyOperand::IntOp{
static_cast<int64_t
>(
BT)}));
525 auto Tok = Lexer.
getTok();
527 return error(
"Expected integer constant, instead got: ", Tok);
535 auto Tok = Lexer.
getTok();
537 return error(
"Expected integer constant, instead got: ", Tok);
546 bool parseFunctionTableOperand(std::unique_ptr<WebAssemblyOperand> *
Op) {
554 auto &Tok = Lexer.
getTok();
559 *
Op = std::make_unique<WebAssemblyOperand>(
566 *
Op = std::make_unique<WebAssemblyOperand>(
567 SMLoc(),
SMLoc(), WebAssemblyOperand::SymOp{Val});
574 *
Op = std::make_unique<WebAssemblyOperand>(
SMLoc(),
SMLoc(),
575 WebAssemblyOperand::IntOp{0});
589 auto &Sep = Lexer.
getTok();
590 if (Sep.getLoc().getPointer() !=
Name.end() ||
599 Id.getLoc().getPointer() !=
Name.end())
600 return error(
"Incomplete instruction name: ", Id);
606 Operands.push_back(std::make_unique<WebAssemblyOperand>(
608 WebAssemblyOperand::TokOp{Name}));
612 bool ExpectBlockType =
false;
613 bool ExpectFuncType =
false;
614 bool ExpectCatchList =
false;
615 std::unique_ptr<WebAssemblyOperand> FunctionTable;
616 if (
Name ==
"block") {
618 ExpectBlockType =
true;
619 }
else if (
Name ==
"loop") {
621 ExpectBlockType =
true;
622 }
else if (
Name ==
"try") {
624 ExpectBlockType =
true;
625 }
else if (
Name ==
"if") {
627 ExpectBlockType =
true;
628 }
else if (
Name ==
"else") {
629 if (popAndPushWithSameSignature(
Name, If, Else))
631 }
else if (
Name ==
"catch") {
632 if (popAndPushWithSameSignature(
Name, Try, Try))
634 }
else if (
Name ==
"catch_all") {
635 if (popAndPushWithSameSignature(
Name, Try, CatchAll))
637 }
else if (
Name ==
"try_table") {
639 ExpectBlockType =
true;
640 ExpectCatchList =
true;
641 }
else if (
Name ==
"end_if") {
642 if (pop(
Name, If, Else))
644 }
else if (
Name ==
"end_try") {
645 if (pop(
Name, Try, CatchAll))
647 }
else if (
Name ==
"end_try_table") {
648 if (pop(
Name, TryTable))
650 }
else if (
Name ==
"delegate") {
653 }
else if (
Name ==
"end_loop") {
656 }
else if (
Name ==
"end_block") {
657 if (pop(
Name, Block))
659 }
else if (
Name ==
"end_function") {
661 CurrentState = EndFunction;
664 }
else if (
Name ==
"call_indirect" ||
Name ==
"return_call_indirect") {
668 if (parseFunctionTableOperand(&FunctionTable))
670 ExpectFuncType =
true;
671 }
else if (
Name ==
"ref.test") {
674 ExpectFuncType =
true;
678 auto PeekCatchList = [&]() {
687 if (ExpectFuncType ||
694 auto Loc = Parser.
getTok();
696 if (parseSignature(Signature))
701 NestingStack.back().Sig = *Signature;
702 ExpectBlockType =
false;
710 Operands.push_back(std::make_unique<WebAssemblyOperand>(
711 Loc.getLoc(), Loc.getEndLoc(), WebAssemblyOperand::SymOp{Expr}));
721 if (ExpectCatchList && PeekCatchList()) {
722 if (ExpectBlockType) {
723 ExpectBlockType =
false;
724 addBlockTypeOperand(
Operands, NameLoc, WebAssembly::BlockType::Void);
728 ExpectCatchList =
false;
732 auto &Tok = Lexer.
getTok();
735 if (!parseSpecialFloatMaybe(
false,
Operands))
738 if (ExpectBlockType) {
741 if (
BT == WebAssembly::BlockType::Invalid)
742 return error(
"Unknown block type: ", Id);
744 ExpectBlockType =
false;
748 if (ExpectCatchList && PeekCatchList()) {
751 ExpectCatchList =
false;
759 return error(
"Cannot parse symbol: ", Lexer.
getTok());
760 Operands.push_back(std::make_unique<WebAssemblyOperand>(
761 Start,
End, WebAssemblyOperand::SymOp{Val}));
774 if (parseSingleFloat(
true,
Operands))
776 }
else if (!parseSpecialFloatMaybe(
true,
Operands)) {
778 return error(
"Expected numeric constant instead got: ",
783 parseSingleInteger(
false,
Operands);
788 if (parseSingleFloat(
false,
Operands))
794 auto Op = std::make_unique<WebAssemblyOperand>(
808 return error(
"Unexpected token in operand: ", Tok);
821 addBlockTypeOperand(
Operands, NameLoc, WebAssembly::BlockType::Void);
824 Operands.push_back(std::make_unique<WebAssemblyOperand>(
825 NameLoc, NameLoc, WebAssemblyOperand::CaLOp{}));
828 Operands.push_back(std::move(FunctionTable));
836 if (parseRegTypeList(Signature->
Params))
844 if (parseRegTypeList(Signature->
Returns))
852 auto Op = std::make_unique<WebAssemblyOperand>(
860 auto CatchStr = expectIdent();
861 if (CatchStr.empty())
870 if (CatchOpcode == 0xff)
872 "Expected catch/catch_ref/catch_all/catch_all_ref, instead got: " +
879 return error(
"Cannot parse symbol: ", Lexer.
getTok());
882 auto &DestTok = Lexer.
getTok();
884 return error(
"Expected integer constant, instead got: ", DestTok);
885 unsigned Dest = DestTok.getIntVal();
892 Op->CaL.List.push_back({CatchOpcode,
Tag, Dest});
900 bool checkDataSection() {
901 if (CurrentState != DataSection) {
904 if (WS && WS->isText())
905 return error(
"data directive must occur in a data segment: ",
908 CurrentState = DataSection;
920 auto &Ctx = Out.getContext();
922 if (DirectiveID.
getString() ==
".globaltype") {
923 auto SymName = expectIdent();
928 auto TypeTok = Lexer.
getTok();
934 return error(
"Unknown type in .globaltype directive: ", TypeTok);
941 auto Id = expectIdent();
944 if (Id ==
"immutable")
948 return error(
"Unknown type in .globaltype modifier: ", TypeTok);
956 TOut.emitGlobalType(WasmSym);
960 if (DirectiveID.
getString() ==
".tabletype") {
962 auto SymName = expectIdent();
968 auto ElemTypeTok = Lexer.
getTok();
969 auto ElemTypeName = expectIdent();
970 if (ElemTypeName.empty())
972 std::optional<wasm::ValType> ElemType =
975 return error(
"Unknown type in .tabletype directive: ", ElemTypeTok);
990 WasmSym->setTableType(
Type);
991 TOut.emitTableType(WasmSym);
995 if (DirectiveID.
getString() ==
".functype") {
1001 auto SymName = expectIdent();
1002 if (SymName.empty())
1006 if (WasmSym->isDefined()) {
1017 if (CurrentState != FunctionLabel) {
1019 if (ensureEmptyNestingStack())
1023 CurrentState = FunctionStart;
1024 LastFunctionLabel = WasmSym;
1027 if (parseSignature(Signature))
1029 if (CurrentState == FunctionStart)
1031 WasmSym->setSignature(Signature);
1033 TOut.emitFunctionType(WasmSym);
1038 if (DirectiveID.
getString() ==
".export_name") {
1039 auto SymName = expectIdent();
1040 if (SymName.empty())
1044 auto ExportName = expectIdent();
1045 if (ExportName.empty())
1050 TOut.emitExportName(WasmSym, ExportName);
1054 if (DirectiveID.
getString() ==
".import_module") {
1055 auto SymName = expectIdent();
1056 if (SymName.empty())
1060 auto ImportModule = expectIdent();
1061 if (ImportModule.empty())
1066 TOut.emitImportModule(WasmSym, ImportModule);
1070 if (DirectiveID.
getString() ==
".import_name") {
1071 auto SymName = expectIdent();
1072 if (SymName.empty())
1076 auto ImportName = expectIdent();
1077 if (ImportName.
empty())
1082 TOut.emitImportName(WasmSym, ImportName);
1086 if (DirectiveID.
getString() ==
".tagtype") {
1087 auto SymName = expectIdent();
1088 if (SymName.empty())
1093 if (parseRegTypeList(Signature->
Params))
1095 WasmSym->setSignature(Signature);
1097 TOut.emitTagType(WasmSym);
1102 if (DirectiveID.
getString() ==
".local") {
1103 if (CurrentState != FunctionStart)
1104 return error(
".local directive should follow the start of a function: ",
1107 if (parseRegTypeList(Locals))
1110 TOut.emitLocal(Locals);
1111 CurrentState = FunctionLocals;
1115 if (DirectiveID.
getString() ==
".int8" ||
1119 if (checkDataSection())
1124 return error(
"Cannot parse .int expression: ", Lexer.
getTok());
1127 Out.emitValue(Val, NumBits / 8,
End);
1131 if (DirectiveID.
getString() ==
".asciz") {
1132 if (checkDataSection())
1136 return error(
"Cannot parse string constant: ", Lexer.
getTok());
1137 Out.emitBytes(
StringRef(S.c_str(), S.length() + 1));
1146 if (CurrentState == FunctionStart) {
1153 CurrentState = FunctionLocals;
1160 bool MatchingInlineAsm)
override {
1164 unsigned MatchResult = MatchInstructionImpl(
1166 switch (MatchResult) {
1173 if (Op0.getImm() == -1)
1189 if (CurrentState == EndFunction) {
1190 onEndOfFunction(IDLoc);
1197 assert(MissingFeatures.
count() > 0 &&
"Expected missing features");
1200 OS <<
"instruction requires:";
1201 for (
unsigned I = 0, E = MissingFeatures.
size();
I != E; ++
I)
1202 if (MissingFeatures.
test(
I))
1204 return Parser.
Error(IDLoc, Message);
1207 return Parser.
Error(IDLoc,
"invalid instruction");
1209 return Parser.
Error(IDLoc,
"ambiguous instruction");
1212 SMLoc ErrorLoc = IDLoc;
1215 return Parser.
Error(IDLoc,
"too few operands for instruction");
1217 if (ErrorLoc ==
SMLoc())
1220 return Parser.
Error(ErrorLoc,
"invalid operand for instruction");
1238 "Wasm doesn\'t support data symbols in text sections");
1245 auto SymName =
Symbol->getName();
1246 if (SymName.starts_with(
".L"))
1253 std::string SecName = (
".text." + SymName).str();
1255 auto *Group = CWS->getGroup();
1261 WasmSym->setComdat(
true);
1269 if (WasmSym->isFunction()) {
1279 ensureEmptyNestingStack(IDLoc);
1280 CurrentState = FunctionLabel;
1281 LastFunctionLabel =
Symbol;
1286 void onEndOfFunction(
SMLoc ErrorLoc) {
1293 void onEndOfFile()
override { ensureEmptyNestingStack(); }
1304#define GET_REGISTER_MATCHER
1305#define GET_SUBTARGET_FEATURE_NAME
1306#define GET_MATCHER_IMPLEMENTATION
1307#include "WebAssemblyGenAsmMatcher.inc"
1311 for (
auto &ME : MatchTable0) {
1312 if (ME.Opcode ==
Opc) {
1313 return ME.getMnemonic();
1316 assert(
false &&
"mnemonic not found");
static const char * getSubtargetFeatureName(uint64_t Val)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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")
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmParser()
StringRef getMnemonic(unsigned Opc)
static const char * getSubtargetFeatureName(uint64_t Val)
This file is part of the WebAssembly Assembler.
This file contains the declaration of the WebAssemblyMCAsmInfo class.
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.
const AsmToken peekTok(bool ShouldSkipSpace=true)
Look ahead at the next token to be lexed.
const AsmToken & getTok() const
Get the current (last) lexed token.
bool is(AsmToken::TokenKind K) const
Check if the current token has kind K.
bool isNot(AsmToken::TokenKind K) const
Check if the current token has kind K.
Target independent representation for an assembler token.
LLVM_ABI SMLoc getLoc() const
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
LLVM_ABI SMLoc getEndLoc() 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.
This class is intended to be used as a base class for asm properties and features specific to the tar...
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.
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.
SourceMgr & getSourceManager()
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.
LLVM_ABI MCSymbol * createTempSymbol()
Create a temporary symbol with a unique name.
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K, unsigned Flags=0)
LLVM_ABI 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.
LLVM_ABI MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
LLVM_ABI void reportError(SMLoc L, const Twine &Msg)
LLVM_ABI 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.
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 bool isToken() const =0
isToken - Is this a token operand?
virtual bool isImm() const =0
isImm - Is this an immediate operand?
virtual void print(raw_ostream &, const MCAsmInfo &) const =0
print - Print a debug representation of the operand to the given stream.
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.
This represents a section on wasm.
static constexpr unsigned NonUniqueID
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.
MCSection * getCurrentSectionOnly() const
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, SMLoc Loc=SMLoc())
void setImportModule(StringRef Name)
void setSignature(wasm::WasmSignature *Sig)
void setImportName(StringRef Name)
void setType(wasm::WasmSymbolType type)
void setExportName(StringRef Name)
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_LIMITS_FLAG_HAS_MAX
@ WASM_SYMBOL_TYPE_GLOBAL
@ WASM_SYMBOL_TYPE_FUNCTION
@ 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