Lines Matching +full:test1 +full:. +full:good
1 //==- WebAssemblyAsmParser.cpp - Assembler for WebAssembly -*- C++ -*-==//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
10 /// This file is part of the WebAssembly Assembler.
12 /// It contains code to translate a parsed .s file into MCInsts.
16 #include "AsmParser/WebAssemblyAsmTypeCheck.h"
17 #include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
18 #include "MCTargetDesc/WebAssemblyMCTypeUtilities.h"
19 #include "MCTargetDesc/WebAssemblyTargetStreamer.h"
20 #include "TargetInfo/WebAssemblyTargetInfo.h"
21 #include "WebAssembly.h"
22 #include "llvm/MC/MCContext.h"
23 #include "llvm/MC/MCExpr.h"
24 #include "llvm/MC/MCInst.h"
25 #include "llvm/MC/MCInstrInfo.h"
26 #include "llvm/MC/MCParser/MCAsmLexer.h"
27 #include "llvm/MC/MCParser/MCParsedAsmOperand.h"
28 #include "llvm/MC/MCParser/MCTargetAsmParser.h"
29 #include "llvm/MC/MCSectionWasm.h"
30 #include "llvm/MC/MCStreamer.h"
31 #include "llvm/MC/MCSubtargetInfo.h"
32 #include "llvm/MC/MCSymbol.h"
33 #include "llvm/MC/MCSymbolWasm.h"
34 #include "llvm/MC/TargetRegistry.h"
35 #include "llvm/Support/SourceMgr.h"
46 /// parsed Wasm machine instruction.
93 BrL.~BrLOp(); in ~WebAssemblyOperand()
110 return Tok.Tok; in getToken()
117 // Required by the assembly matcher. in addRegOperands()
124 Inst.addOperand(MCOperand::createImm(Int.Val)); in addImmOperands()
126 Inst.addOperand(MCOperand::createExpr(Sym.Exp)); in addImmOperands()
134 Inst.addOperand( in addFPImmf32Operands()
135 MCOperand::createSFPImm(bit_cast<uint32_t>(float(Flt.Val)))); in addFPImmf32Operands()
143 Inst.addOperand(MCOperand::createDFPImm(bit_cast<uint64_t>(Flt.Val))); in addFPImmf64Operands()
150 for (auto Br : BrL.List) in addBrListOperands()
151 Inst.addOperand(MCOperand::createImm(Br)); in addBrListOperands()
157 OS << "Tok:" << Tok.Tok; in print()
160 OS << "Int:" << Int.Val; in print()
163 OS << "Flt:" << Flt.Val; in print()
166 OS << "Sym:" << Sym.Exp; in print()
169 OS << "BrList:" << BrL.List.size(); in print()
175 // Perhaps this should go somewhere common.
183 MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(Name)); in GetOrCreateFunctionTableSymbol()
186 Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table"); in GetOrCreateFunctionTableSymbol()
188 Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(Name)); in GetOrCreateFunctionTableSymbol()
190 // The default function table is synthesized by the linker. in GetOrCreateFunctionTableSymbol()
200 // Order of labels, directives and instructions in a .s file have no
201 // syntactical enforcement. This class is a callback from the actual parser,
204 // (the streamer does not enforce this). This "state machine" enum helps
205 // guarantee that correct order.
216 // For ensuring blocks are properly nested.
239 // Don't type check if -no-type-check was set.
246 Lexer(Parser.getLexer()), is64(STI.getTargetTriple().isArch64Bit()), in WebAssemblyAsmParser()
247 TC(Parser, MII, is64), SkipTypeCheck(Options.MCNoTypeCheck) { in WebAssemblyAsmParser()
248 setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits())); in WebAssemblyAsmParser()
250 // instructions without a function/locals decl. in WebAssemblyAsmParser()
251 auto &SM = Parser.getSourceManager(); in WebAssemblyAsmParser()
253 SM.getBufferInfo(SM.getMainFileID()).Buffer->getBufferIdentifier(); in WebAssemblyAsmParser()
268 #include "WebAssemblyGenAsmMatcher.inc"
270 // TODO: This is required to be implemented, but appears unused.
272 llvm_unreachable("parseRegister is not implemented."); in parseRegister()
276 llvm_unreachable("tryParseRegister is not implemented."); in tryParseRegister()
280 return Parser.Error(Tok.getLoc(), Msg + Tok.getString()); in error()
284 return Parser.Error(Loc.isValid() ? Loc : Lexer.getTok().getLoc(), Msg); in error()
309 NestingStack.push_back({NT, Sig}); in push()
313 if (NestingStack.empty()) in pop()
315 auto Top = NestingStack.back(); in pop()
316 if (Top.NT != NT1 && Top.NT != NT2) in pop()
318 nestingString(Top.NT).second + ", instead got: " + Ins); in pop()
319 TC.setLastSig(Top.Sig); in pop()
320 NestingStack.pop_back(); in pop()
324 // Pop a NestingType and push a new NestingType with the same signature. Used
325 // for if-else and try-catch(_all).
328 if (NestingStack.empty()) in popAndPushWithSameSignature()
330 auto Sig = NestingStack.back().Sig; in popAndPushWithSameSignature()
338 auto Err = !NestingStack.empty(); in ensureEmptyNestingStack()
339 while (!NestingStack.empty()) { in ensureEmptyNestingStack()
341 nestingString(NestingStack.back().NT).first, in ensureEmptyNestingStack()
343 NestingStack.pop_back(); in ensureEmptyNestingStack()
349 auto Ok = Lexer.is(Kind); in isNext()
351 Parser.Lex(); in isNext()
358 Lexer.getTok()); in expect()
363 if (!Lexer.is(AsmToken::Identifier)) { in expectIdent()
364 error("Expected identifier, got: ", Lexer.getTok()); in expectIdent()
367 auto Name = Lexer.getTok().getString(); in expectIdent()
368 Parser.Lex(); in expectIdent()
373 while (Lexer.is(AsmToken::Identifier)) { in parseRegTypeList()
374 auto Type = WebAssembly::parseType(Lexer.getTok().getString()); in parseRegTypeList()
376 return error("unknown type: ", Lexer.getTok()); in parseRegTypeList()
377 Types.push_back(*Type); in parseRegTypeList()
378 Parser.Lex(); in parseRegTypeList()
386 auto &Int = Lexer.getTok(); in parseSingleInteger()
387 int64_t Val = Int.getIntVal(); in parseSingleInteger()
390 Operands.push_back(std::make_unique<WebAssemblyOperand>( in parseSingleInteger()
391 WebAssemblyOperand::Integer, Int.getLoc(), Int.getEndLoc(), in parseSingleInteger()
393 Parser.Lex(); in parseSingleInteger()
397 auto &Flt = Lexer.getTok(); in parseSingleFloat()
399 if (Flt.getString().getAsDouble(Val, false)) in parseSingleFloat()
403 Operands.push_back(std::make_unique<WebAssemblyOperand>( in parseSingleFloat()
404 WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(), in parseSingleFloat()
406 Parser.Lex(); in parseSingleFloat()
411 if (Lexer.isNot(AsmToken::Identifier)) in parseSpecialFloatMaybe()
413 auto &Flt = Lexer.getTok(); in parseSpecialFloatMaybe()
414 auto S = Flt.getString(); in parseSpecialFloatMaybe()
416 if (S.compare_insensitive("infinity") == 0) { in parseSpecialFloatMaybe()
418 } else if (S.compare_insensitive("nan") == 0) { in parseSpecialFloatMaybe()
425 Operands.push_back(std::make_unique<WebAssemblyOperand>( in parseSpecialFloatMaybe()
426 WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(), in parseSpecialFloatMaybe()
428 Parser.Lex(); in parseSpecialFloatMaybe()
433 // FIXME: there is probably a cleaner way to do this. in checkForP2AlignIfLoadStore()
434 auto IsLoadStore = InstName.contains(".load") || in checkForP2AlignIfLoadStore()
435 InstName.contains(".store") || in checkForP2AlignIfLoadStore()
436 InstName.contains("prefetch"); in checkForP2AlignIfLoadStore()
437 auto IsAtomic = InstName.contains("atomic."); in checkForP2AlignIfLoadStore()
446 if (!Lexer.is(AsmToken::Integer)) in checkForP2AlignIfLoadStore()
450 // v128.{load,store}{8,16,32,64}_lane has both a memarg and a lane in checkForP2AlignIfLoadStore()
451 // index. We need to avoid parsing an extra alignment operand for the in checkForP2AlignIfLoadStore()
452 // lane index. in checkForP2AlignIfLoadStore()
453 auto IsLoadStoreLane = InstName.contains("_lane"); in checkForP2AlignIfLoadStore()
454 if (IsLoadStoreLane && Operands.size() == 4) in checkForP2AlignIfLoadStore()
456 // Alignment not specified (or atomics, must use default alignment). in checkForP2AlignIfLoadStore()
459 // up later. in checkForP2AlignIfLoadStore()
460 auto Tok = Lexer.getTok(); in checkForP2AlignIfLoadStore()
461 Operands.push_back(std::make_unique<WebAssemblyOperand>( in checkForP2AlignIfLoadStore()
462 WebAssemblyOperand::Integer, Tok.getLoc(), Tok.getEndLoc(), in checkForP2AlignIfLoadStore()
473 TC.setLastSig(Sig); in addBlockTypeOperand()
474 NestingStack.back().Sig = Sig; in addBlockTypeOperand()
476 Operands.push_back(std::make_unique<WebAssemblyOperand>( in addBlockTypeOperand()
482 auto Tok = Lexer.getTok(); in parseLimits()
483 if (!Tok.is(AsmToken::Integer)) in parseLimits()
485 int64_t Val = Tok.getIntVal(); in parseLimits()
488 Parser.Lex(); in parseLimits()
492 auto Tok = Lexer.getTok(); in parseLimits()
493 if (!Tok.is(AsmToken::Integer)) in parseLimits()
495 int64_t Val = Tok.getIntVal(); in parseLimits()
498 Parser.Lex(); in parseLimits()
506 // operand. To allow the same assembly to be compiled with or without in parseFunctionTableOperand()
508 // default to __indirect_function_table. in parseFunctionTableOperand()
509 auto &Tok = Lexer.getTok(); in parseFunctionTableOperand()
510 if (Tok.is(AsmToken::Identifier)) { in parseFunctionTableOperand()
512 GetOrCreateFunctionTableSymbol(getContext(), Tok.getString(), is64); in parseFunctionTableOperand()
515 WebAssemblyOperand::Symbol, Tok.getLoc(), Tok.getEndLoc(), in parseFunctionTableOperand()
517 Parser.Lex(); in parseFunctionTableOperand()
529 // write a table symbol or issue relocations. Instead we just ensure the in parseFunctionTableOperand()
530 // table is live and write a zero. in parseFunctionTableOperand()
531 getStreamer().emitSymbolAttribute(DefaultFunctionTable, MCSA_NoDeadStrip); in parseFunctionTableOperand()
542 // use NameLoc instead. in ParseInstruction()
543 Name = StringRef(NameLoc.getPointer(), Name.size()); in ParseInstruction()
549 auto &Sep = Lexer.getTok(); in ParseInstruction()
550 if (Sep.getLoc().getPointer() != Name.end() || in ParseInstruction()
551 Sep.getKind() != AsmToken::Slash) in ParseInstruction()
554 Name = StringRef(Name.begin(), Name.size() + Sep.getString().size()); in ParseInstruction()
555 Parser.Lex(); in ParseInstruction()
556 // We must now find another identifier, or error. in ParseInstruction()
557 auto &Id = Lexer.getTok(); in ParseInstruction()
558 if (Id.getKind() != AsmToken::Identifier || in ParseInstruction()
559 Id.getLoc().getPointer() != Name.end()) in ParseInstruction()
561 Name = StringRef(Name.begin(), Name.size() + Id.getString().size()); in ParseInstruction()
562 Parser.Lex(); in ParseInstruction()
565 // Now construct the name as first operand. in ParseInstruction()
566 Operands.push_back(std::make_unique<WebAssemblyOperand>( in ParseInstruction()
567 WebAssemblyOperand::Token, NameLoc, SMLoc::getFromPointer(Name.end()), in ParseInstruction()
571 // proper nesting. in ParseInstruction()
618 // the binary formats. The MC instructions follow the binary format, so in ParseInstruction()
619 // here we stash away the operand and append it later. in ParseInstruction()
625 if (ExpectFuncType || (ExpectBlockType && Lexer.is(AsmToken::LParen))) { in ParseInstruction()
629 // expects to be able to recreate the actual unique-ified type indices. in ParseInstruction()
631 auto Loc = Parser.getTok(); in ParseInstruction()
632 auto Signature = Ctx.createWasmSignature(); in ParseInstruction()
636 TC.setLastSig(*Signature); in ParseInstruction()
638 NestingStack.back().Sig = *Signature; in ParseInstruction()
640 // The "true" here will cause this to be a nameless symbol. in ParseInstruction()
641 MCSymbol *Sym = Ctx.createTempSymbol("typeindex", true); in ParseInstruction()
647 Operands.push_back(std::make_unique<WebAssemblyOperand>( in ParseInstruction()
648 WebAssemblyOperand::Symbol, Loc.getLoc(), Loc.getEndLoc(), in ParseInstruction()
652 while (Lexer.isNot(AsmToken::EndOfStatement)) { in ParseInstruction()
653 auto &Tok = Lexer.getTok(); in ParseInstruction()
654 switch (Tok.getKind()) { in ParseInstruction()
658 auto &Id = Lexer.getTok(); in ParseInstruction()
660 // Assume this identifier is a block_type. in ParseInstruction()
661 auto BT = WebAssembly::parseBlockType(Id.getString()); in ParseInstruction()
665 Parser.Lex(); in ParseInstruction()
667 // Assume this identifier is a label. in ParseInstruction()
669 SMLoc Start = Id.getLoc(); in ParseInstruction()
671 if (Parser.parseExpression(Val, End)) in ParseInstruction()
672 return error("Cannot parse symbol: ", Lexer.getTok()); in ParseInstruction()
673 Operands.push_back(std::make_unique<WebAssemblyOperand>( in ParseInstruction()
682 Parser.Lex(); in ParseInstruction()
683 if (Lexer.is(AsmToken::Integer)) { in ParseInstruction()
687 } else if (Lexer.is(AsmToken::Real)) { in ParseInstruction()
693 Lexer.getTok()); in ParseInstruction()
707 Parser.Lex(); in ParseInstruction()
709 WebAssemblyOperand::BrList, Tok.getLoc(), Tok.getEndLoc()); in ParseInstruction()
710 if (!Lexer.is(AsmToken::RCurly)) in ParseInstruction()
712 Op->BrL.List.push_back(Lexer.getTok().getIntVal()); in ParseInstruction()
718 Operands.push_back(std::move(Op)); in ParseInstruction()
724 if (Lexer.isNot(AsmToken::EndOfStatement)) { in ParseInstruction()
729 if (ExpectBlockType && Operands.size() == 1) { in ParseInstruction()
730 // Support blocks with no operands as default to void. in ParseInstruction()
734 Operands.push_back(std::move(FunctionTable)); in ParseInstruction()
735 Parser.Lex(); in ParseInstruction()
759 auto WS = cast<MCSectionWasm>(getStreamer().getCurrentSectionOnly()); in CheckDataSection()
762 Lexer.getTok()); in CheckDataSection()
770 // (see WasmAsmParser).
772 assert(DirectiveID.getKind() == AsmToken::Identifier); in parseDirective()
775 reinterpret_cast<WebAssemblyTargetStreamer &>(*Out.getTargetStreamer()); in parseDirective()
776 auto &Ctx = Out.getContext(); in parseDirective()
778 if (DirectiveID.getString() == ".globaltype") { in parseDirective()
780 if (SymName.empty()) in parseDirective()
784 auto TypeTok = Lexer.getTok(); in parseDirective()
786 if (TypeName.empty()) in parseDirective()
790 return error("Unknown type in .globaltype directive: ", TypeTok); in parseDirective()
791 // Optional mutable modifier. Default to mutable for historical reasons. in parseDirective()
793 // as the modifier to match the `.wat` format. in parseDirective()
796 TypeTok = Lexer.getTok(); in parseDirective()
798 if (Id.empty()) in parseDirective()
804 return error("Unknown type in .globaltype modifier: ", TypeTok); in parseDirective()
806 // Now set this symbol with the correct type. in parseDirective()
807 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
810 // And emit the directive again. in parseDirective()
811 TOut.emitGlobalType(WasmSym); in parseDirective()
815 if (DirectiveID.getString() == ".tabletype") { in parseDirective()
816 // .tabletype SYM, ELEMTYPE[, MINSIZE[, MAXSIZE]] in parseDirective()
818 if (SymName.empty()) in parseDirective()
823 auto ElemTypeTok = Lexer.getTok(); in parseDirective()
825 if (ElemTypeName.empty()) in parseDirective()
830 return error("Unknown type in .tabletype directive: ", ElemTypeTok); in parseDirective()
838 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
841 Limits.Flags |= wasm::WASM_LIMITS_FLAG_IS_64; in parseDirective()
845 TOut.emitTableType(WasmSym); in parseDirective()
849 if (DirectiveID.getString() == ".functype") { in parseDirective()
851 // WebAssemblyAsmPrinter::EmitFunctionBodyStart. in parseDirective()
852 // TODO: would be good to factor this into a common function, but the in parseDirective()
854 // parses the locals separately. in parseDirective()
856 if (SymName.empty()) in parseDirective()
858 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
860 // We push 'Function' either when a label is parsed or a .functype in parseDirective()
861 // directive is parsed. The reason it is not easy to do this uniformly in parseDirective()
863 // 1. We can't do this at label parsing time only because there are in parseDirective()
864 // cases we don't have .functype directive before a function label, in parseDirective()
866 // of parsing. in parseDirective()
867 // 2. We can't do this at .functype parsing time only because we want to in parseDirective()
869 // without encountering a .functype directive after the label. in parseDirective()
871 // This .functype indicates a start of a function. in parseDirective()
879 auto Signature = Ctx.createWasmSignature(); in parseDirective()
882 TC.funcDecl(*Signature); in parseDirective()
885 TOut.emitFunctionType(WasmSym); in parseDirective()
886 // TODO: backend also calls TOut.emitIndIdx, but that is not implemented. in parseDirective()
890 if (DirectiveID.getString() == ".export_name") { in parseDirective()
892 if (SymName.empty()) in parseDirective()
897 if (ExportName.empty()) in parseDirective()
899 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
900 WasmSym->setExportName(Ctx.allocateString(ExportName)); in parseDirective()
901 TOut.emitExportName(WasmSym, ExportName); in parseDirective()
905 if (DirectiveID.getString() == ".import_module") { in parseDirective()
907 if (SymName.empty()) in parseDirective()
912 if (ImportModule.empty()) in parseDirective()
914 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
915 WasmSym->setImportModule(Ctx.allocateString(ImportModule)); in parseDirective()
916 TOut.emitImportModule(WasmSym, ImportModule); in parseDirective()
920 if (DirectiveID.getString() == ".import_name") { in parseDirective()
922 if (SymName.empty()) in parseDirective()
927 if (ImportName.empty()) in parseDirective()
929 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
930 WasmSym->setImportName(Ctx.allocateString(ImportName)); in parseDirective()
931 TOut.emitImportName(WasmSym, ImportName); in parseDirective()
935 if (DirectiveID.getString() == ".tagtype") { in parseDirective()
937 if (SymName.empty()) in parseDirective()
939 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
940 auto Signature = Ctx.createWasmSignature(); in parseDirective()
945 TOut.emitTagType(WasmSym); in parseDirective()
946 // TODO: backend also calls TOut.emitIndIdx, but that is not implemented. in parseDirective()
950 if (DirectiveID.getString() == ".local") { in parseDirective()
952 return error(".local directive should follow the start of a function: ", in parseDirective()
953 Lexer.getTok()); in parseDirective()
957 TC.localDecl(Locals); in parseDirective()
958 TOut.emitLocal(Locals); in parseDirective()
963 if (DirectiveID.getString() == ".int8" || in parseDirective()
964 DirectiveID.getString() == ".int16" || in parseDirective()
965 DirectiveID.getString() == ".int32" || in parseDirective()
966 DirectiveID.getString() == ".int64") { in parseDirective()
971 if (Parser.parseExpression(Val, End)) in parseDirective()
972 return error("Cannot parse .int expression: ", Lexer.getTok()); in parseDirective()
974 DirectiveID.getString().drop_front(4).getAsInteger(10, NumBits); in parseDirective()
975 Out.emitValue(Val, NumBits / 8, End); in parseDirective()
979 if (DirectiveID.getString() == ".asciz") { in parseDirective()
983 if (Parser.parseEscapedString(S)) in parseDirective()
984 return error("Cannot parse string constant: ", Lexer.getTok()); in parseDirective()
985 Out.emitBytes(StringRef(S.c_str(), S.length() + 1)); in parseDirective()
989 return ParseStatus::NoMatch; // We didn't process this directive. in parseDirective()
992 // Called either when the first instruction is parsed of the function ends.
995 // We haven't seen a .local directive yet. The streamer requires locals to in ensureLocals()
997 // locals here. in ensureLocals()
999 *Out.getTargetStreamer()); in ensureLocals()
1000 TOut.emitLocal(SmallVector<wasm::ValType, 0>()); in ensureLocals()
1010 Inst.setLoc(IDLoc); in MatchAndEmitInstruction()
1017 // Fix unknown p2align operands. in MatchAndEmitInstruction()
1018 auto Align = WebAssembly::GetDefaultP2AlignAny(Inst.getOpcode()); in MatchAndEmitInstruction()
1020 auto &Op0 = Inst.getOperand(0); in MatchAndEmitInstruction()
1021 if (Op0.getImm() == -1) in MatchAndEmitInstruction()
1022 Op0.setImm(Align); in MatchAndEmitInstruction()
1025 // Upgrade 32-bit loads/stores to 64-bit. These mostly differ by having in MatchAndEmitInstruction()
1027 // they're both immediates so don't get selected for. in MatchAndEmitInstruction()
1029 static_cast<uint16_t>(Inst.getOpcode())); in MatchAndEmitInstruction()
1031 Inst.setOpcode(Opc64); in MatchAndEmitInstruction()
1034 if (!SkipTypeCheck && TC.typeCheck(IDLoc, Inst, Operands)) in MatchAndEmitInstruction()
1036 Out.emitInstruction(Inst, getSTI()); in MatchAndEmitInstruction()
1045 assert(MissingFeatures.count() > 0 && "Expected missing features"); in MatchAndEmitInstruction()
1049 for (unsigned i = 0, e = MissingFeatures.size(); i != e; ++i) in MatchAndEmitInstruction()
1050 if (MissingFeatures.test(i)) in MatchAndEmitInstruction()
1052 return Parser.Error(IDLoc, Message); in MatchAndEmitInstruction()
1055 return Parser.Error(IDLoc, "invalid instruction"); in MatchAndEmitInstruction()
1057 return Parser.Error(IDLoc, "ambiguous instruction"); in MatchAndEmitInstruction()
1062 if (ErrorInfo >= Operands.size()) in MatchAndEmitInstruction()
1063 return Parser.Error(IDLoc, "too few operands for instruction"); in MatchAndEmitInstruction()
1068 return Parser.Error(ErrorLoc, "invalid operand for instruction"); in MatchAndEmitInstruction()
1075 // Code below only applies to labels in text sections. in doBeforeLabelEmit()
1076 auto CWS = cast<MCSectionWasm>(getStreamer().getCurrentSectionOnly()); in doBeforeLabelEmit()
1082 // declared with .type @object). in doBeforeLabelEmit()
1084 Parser.Error(IDLoc, in doBeforeLabelEmit()
1090 // object writer expects each function to have its own section. This way in doBeforeLabelEmit()
1091 // The user can't forget this "convention". in doBeforeLabelEmit()
1093 if (SymName.starts_with(".L")) in doBeforeLabelEmit()
1094 return; // Local Symbol. in doBeforeLabelEmit()
1097 // its name when we create this one. It would be nice to honor their in doBeforeLabelEmit()
1098 // choice, while still ensuring that we create one if they forget. in doBeforeLabelEmit()
1100 auto SecName = ".text." + SymName; in doBeforeLabelEmit()
1103 // If the current section is a COMDAT, also set the flag on the symbol. in doBeforeLabelEmit()
1105 // for importing comdat functions. But there's no way to specify that in in doBeforeLabelEmit()
1106 // assembly currently. in doBeforeLabelEmit()
1109 auto *WS = getContext().getWasmSection(SecName, SectionKind::getText(), 0, in doBeforeLabelEmit()
1111 getStreamer().switchSection(WS); in doBeforeLabelEmit()
1112 // Also generate DWARF for this section if requested. in doBeforeLabelEmit()
1113 if (getContext().getGenDwarfForAssembly()) in doBeforeLabelEmit()
1114 getContext().addGenDwarfSection(WS); in doBeforeLabelEmit()
1118 // lexer's next location will be used, which can be confusing. For in doBeforeLabelEmit()
1122 // ... in doBeforeLabelEmit()
1124 // test1: ; We would like to point to this line for error in doBeforeLabelEmit()
1125 // ... . Not this line, which can contain any instruction in doBeforeLabelEmit()
1135 TC.endOfFunction(ErrorLoc); in onEndOfFunction()
1136 // Reset the type checker state. in onEndOfFunction()
1137 TC.Clear(); in onEndOfFunction()
1144 // Force static initialization.
1153 #include "WebAssemblyGenAsmMatcher.inc"
1158 if (ME.Opcode == Opc) { in GetMnemonic()
1159 return ME.getMnemonic(); in GetMnemonic()