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.
182 MCSymbolWasm *Sym = cast_or_null<MCSymbolWasm>(Ctx.lookupSymbol(Name)); in GetOrCreateFunctionTableSymbol()
185 Ctx.reportError(SMLoc(), "symbol is not a wasm funcref table"); in GetOrCreateFunctionTableSymbol()
187 Sym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(Name)); in GetOrCreateFunctionTableSymbol()
189 // The default function table is synthesized by the linker. in GetOrCreateFunctionTableSymbol()
199 // Much like WebAssemblyAsmPrinter in the backend, we have to own these.
203 // Order of labels, directives and instructions in a .s file have no
204 // syntactical enforcement. This class is a callback from the actual parser,
207 // (the streamer does not enforce this). This "state machine" enum helps
208 // guarantee that correct order.
219 // For ensuring blocks are properly nested.
242 // Don't type check if -no-type-check was set.
249 Lexer(Parser.getLexer()), is64(STI.getTargetTriple().isArch64Bit()), in WebAssemblyAsmParser()
250 TC(Parser, MII, is64), SkipTypeCheck(Options.MCNoTypeCheck) { in WebAssemblyAsmParser()
251 setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits())); in WebAssemblyAsmParser()
253 // instructions without a function/locals decl. in WebAssemblyAsmParser()
254 auto &SM = Parser.getSourceManager(); in WebAssemblyAsmParser()
256 SM.getBufferInfo(SM.getMainFileID()).Buffer->getBufferIdentifier(); in WebAssemblyAsmParser()
271 #include "WebAssemblyGenAsmMatcher.inc"
273 // TODO: This is required to be implemented, but appears unused.
275 llvm_unreachable("parseRegister is not implemented."); in parseRegister()
279 llvm_unreachable("tryParseRegister is not implemented."); in tryParseRegister()
283 return Parser.Error(Tok.getLoc(), Msg + Tok.getString()); in error()
287 return Parser.Error(Loc.isValid() ? Loc : Lexer.getTok().getLoc(), Msg); in error()
291 Signatures.push_back(std::move(Sig)); in addSignature()
296 Names.push_back(std::move(N)); in storeName()
297 return *Names.back(); in storeName()
322 NestingStack.push_back({NT, Sig}); in push()
326 if (NestingStack.empty()) in pop()
328 auto Top = NestingStack.back(); in pop()
329 if (Top.NT != NT1 && Top.NT != NT2) in pop()
331 nestingString(Top.NT).second + ", instead got: " + Ins); in pop()
332 TC.setLastSig(Top.Sig); in pop()
333 NestingStack.pop_back(); in pop()
337 // Pop a NestingType and push a new NestingType with the same signature. Used
338 // for if-else and try-catch(_all).
341 if (NestingStack.empty()) in popAndPushWithSameSignature()
343 auto Sig = NestingStack.back().Sig; in popAndPushWithSameSignature()
351 auto Err = !NestingStack.empty(); in ensureEmptyNestingStack()
352 while (!NestingStack.empty()) { in ensureEmptyNestingStack()
354 nestingString(NestingStack.back().NT).first, in ensureEmptyNestingStack()
356 NestingStack.pop_back(); in ensureEmptyNestingStack()
362 auto Ok = Lexer.is(Kind); in isNext()
364 Parser.Lex(); in isNext()
371 Lexer.getTok()); in expect()
376 if (!Lexer.is(AsmToken::Identifier)) { in expectIdent()
377 error("Expected identifier, got: ", Lexer.getTok()); in expectIdent()
380 auto Name = Lexer.getTok().getString(); in expectIdent()
381 Parser.Lex(); in expectIdent()
386 while (Lexer.is(AsmToken::Identifier)) { in parseRegTypeList()
387 auto Type = WebAssembly::parseType(Lexer.getTok().getString()); in parseRegTypeList()
389 return error("unknown type: ", Lexer.getTok()); in parseRegTypeList()
390 Types.push_back(*Type); in parseRegTypeList()
391 Parser.Lex(); in parseRegTypeList()
399 auto &Int = Lexer.getTok(); in parseSingleInteger()
400 int64_t Val = Int.getIntVal(); in parseSingleInteger()
403 Operands.push_back(std::make_unique<WebAssemblyOperand>( in parseSingleInteger()
404 WebAssemblyOperand::Integer, Int.getLoc(), Int.getEndLoc(), in parseSingleInteger()
406 Parser.Lex(); in parseSingleInteger()
410 auto &Flt = Lexer.getTok(); in parseSingleFloat()
412 if (Flt.getString().getAsDouble(Val, false)) in parseSingleFloat()
416 Operands.push_back(std::make_unique<WebAssemblyOperand>( in parseSingleFloat()
417 WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(), in parseSingleFloat()
419 Parser.Lex(); in parseSingleFloat()
424 if (Lexer.isNot(AsmToken::Identifier)) in parseSpecialFloatMaybe()
426 auto &Flt = Lexer.getTok(); in parseSpecialFloatMaybe()
427 auto S = Flt.getString(); in parseSpecialFloatMaybe()
429 if (S.compare_insensitive("infinity") == 0) { in parseSpecialFloatMaybe()
431 } else if (S.compare_insensitive("nan") == 0) { in parseSpecialFloatMaybe()
438 Operands.push_back(std::make_unique<WebAssemblyOperand>( in parseSpecialFloatMaybe()
439 WebAssemblyOperand::Float, Flt.getLoc(), Flt.getEndLoc(), in parseSpecialFloatMaybe()
441 Parser.Lex(); in parseSpecialFloatMaybe()
446 // FIXME: there is probably a cleaner way to do this. in checkForP2AlignIfLoadStore()
447 auto IsLoadStore = InstName.contains(".load") || in checkForP2AlignIfLoadStore()
448 InstName.contains(".store") || in checkForP2AlignIfLoadStore()
449 InstName.contains("prefetch"); in checkForP2AlignIfLoadStore()
450 auto IsAtomic = InstName.contains("atomic."); in checkForP2AlignIfLoadStore()
459 if (!Lexer.is(AsmToken::Integer)) in checkForP2AlignIfLoadStore()
463 // v128.{load,store}{8,16,32,64}_lane has both a memarg and a lane in checkForP2AlignIfLoadStore()
464 // index. We need to avoid parsing an extra alignment operand for the in checkForP2AlignIfLoadStore()
465 // lane index. in checkForP2AlignIfLoadStore()
466 auto IsLoadStoreLane = InstName.contains("_lane"); in checkForP2AlignIfLoadStore()
467 if (IsLoadStoreLane && Operands.size() == 4) in checkForP2AlignIfLoadStore()
469 // Alignment not specified (or atomics, must use default alignment). in checkForP2AlignIfLoadStore()
472 // up later. in checkForP2AlignIfLoadStore()
473 auto Tok = Lexer.getTok(); in checkForP2AlignIfLoadStore()
474 Operands.push_back(std::make_unique<WebAssemblyOperand>( in checkForP2AlignIfLoadStore()
475 WebAssemblyOperand::Integer, Tok.getLoc(), Tok.getEndLoc(), in checkForP2AlignIfLoadStore()
486 TC.setLastSig(Sig); in addBlockTypeOperand()
487 NestingStack.back().Sig = Sig; in addBlockTypeOperand()
489 Operands.push_back(std::make_unique<WebAssemblyOperand>( in addBlockTypeOperand()
495 auto Tok = Lexer.getTok(); in parseLimits()
496 if (!Tok.is(AsmToken::Integer)) in parseLimits()
498 int64_t Val = Tok.getIntVal(); in parseLimits()
501 Parser.Lex(); in parseLimits()
505 auto Tok = Lexer.getTok(); in parseLimits()
506 if (!Tok.is(AsmToken::Integer)) in parseLimits()
508 int64_t Val = Tok.getIntVal(); in parseLimits()
511 Parser.Lex(); in parseLimits()
519 // operand. To allow the same assembly to be compiled with or without in parseFunctionTableOperand()
521 // default to __indirect_function_table. in parseFunctionTableOperand()
522 auto &Tok = Lexer.getTok(); in parseFunctionTableOperand()
523 if (Tok.is(AsmToken::Identifier)) { in parseFunctionTableOperand()
525 GetOrCreateFunctionTableSymbol(getContext(), Tok.getString()); in parseFunctionTableOperand()
528 WebAssemblyOperand::Symbol, Tok.getLoc(), Tok.getEndLoc(), in parseFunctionTableOperand()
530 Parser.Lex(); in parseFunctionTableOperand()
542 // write a table symbol or issue relocations. Instead we just ensure the in parseFunctionTableOperand()
543 // table is live and write a zero. in parseFunctionTableOperand()
544 getStreamer().emitSymbolAttribute(DefaultFunctionTable, MCSA_NoDeadStrip); in parseFunctionTableOperand()
555 // use NameLoc instead. in ParseInstruction()
556 Name = StringRef(NameLoc.getPointer(), Name.size()); in ParseInstruction()
562 auto &Sep = Lexer.getTok(); in ParseInstruction()
563 if (Sep.getLoc().getPointer() != Name.end() || in ParseInstruction()
564 Sep.getKind() != AsmToken::Slash) in ParseInstruction()
567 Name = StringRef(Name.begin(), Name.size() + Sep.getString().size()); in ParseInstruction()
568 Parser.Lex(); in ParseInstruction()
569 // We must now find another identifier, or error. in ParseInstruction()
570 auto &Id = Lexer.getTok(); in ParseInstruction()
571 if (Id.getKind() != AsmToken::Identifier || in ParseInstruction()
572 Id.getLoc().getPointer() != Name.end()) in ParseInstruction()
574 Name = StringRef(Name.begin(), Name.size() + Id.getString().size()); in ParseInstruction()
575 Parser.Lex(); in ParseInstruction()
578 // Now construct the name as first operand. in ParseInstruction()
579 Operands.push_back(std::make_unique<WebAssemblyOperand>( in ParseInstruction()
580 WebAssemblyOperand::Token, NameLoc, SMLoc::getFromPointer(Name.end()), in ParseInstruction()
584 // proper nesting. in ParseInstruction()
631 // the binary formats. The MC instructions follow the binary format, so in ParseInstruction()
632 // here we stash away the operand and append it later. in ParseInstruction()
638 if (ExpectFuncType || (ExpectBlockType && Lexer.is(AsmToken::LParen))) { in ParseInstruction()
642 // expects to be able to recreate the actual unique-ified type indices. in ParseInstruction()
643 auto Loc = Parser.getTok(); in ParseInstruction()
645 if (parseSignature(Signature.get())) in ParseInstruction()
648 TC.setLastSig(*Signature.get()); in ParseInstruction()
650 NestingStack.back().Sig = *Signature.get(); in ParseInstruction()
653 // The "true" here will cause this to be a nameless symbol. in ParseInstruction()
654 MCSymbol *Sym = Ctx.createTempSymbol("typeindex", true); in ParseInstruction()
656 WasmSym->setSignature(Signature.get()); in ParseInstruction()
661 Operands.push_back(std::make_unique<WebAssemblyOperand>( in ParseInstruction()
662 WebAssemblyOperand::Symbol, Loc.getLoc(), Loc.getEndLoc(), in ParseInstruction()
666 while (Lexer.isNot(AsmToken::EndOfStatement)) { in ParseInstruction()
667 auto &Tok = Lexer.getTok(); in ParseInstruction()
668 switch (Tok.getKind()) { in ParseInstruction()
672 auto &Id = Lexer.getTok(); in ParseInstruction()
674 // Assume this identifier is a block_type. in ParseInstruction()
675 auto BT = WebAssembly::parseBlockType(Id.getString()); in ParseInstruction()
679 Parser.Lex(); in ParseInstruction()
681 // Assume this identifier is a label. in ParseInstruction()
683 SMLoc Start = Id.getLoc(); in ParseInstruction()
685 if (Parser.parseExpression(Val, End)) in ParseInstruction()
686 return error("Cannot parse symbol: ", Lexer.getTok()); in ParseInstruction()
687 Operands.push_back(std::make_unique<WebAssemblyOperand>( in ParseInstruction()
696 Parser.Lex(); in ParseInstruction()
697 if (Lexer.is(AsmToken::Integer)) { in ParseInstruction()
701 } else if (Lexer.is(AsmToken::Real)) { in ParseInstruction()
707 Lexer.getTok()); in ParseInstruction()
721 Parser.Lex(); in ParseInstruction()
723 WebAssemblyOperand::BrList, Tok.getLoc(), Tok.getEndLoc()); in ParseInstruction()
724 if (!Lexer.is(AsmToken::RCurly)) in ParseInstruction()
726 Op->BrL.List.push_back(Lexer.getTok().getIntVal()); in ParseInstruction()
732 Operands.push_back(std::move(Op)); in ParseInstruction()
738 if (Lexer.isNot(AsmToken::EndOfStatement)) { in ParseInstruction()
743 if (ExpectBlockType && Operands.size() == 1) { in ParseInstruction()
744 // Support blocks with no operands as default to void. in ParseInstruction()
748 Operands.push_back(std::move(FunctionTable)); in ParseInstruction()
749 Parser.Lex(); in ParseInstruction()
773 auto WS = cast<MCSectionWasm>(getStreamer().getCurrentSection().first); in CheckDataSection()
774 if (WS && WS->getKind().isText()) in CheckDataSection()
776 Lexer.getTok()); in CheckDataSection()
784 // (see WasmAsmParser).
786 assert(DirectiveID.getKind() == AsmToken::Identifier); in parseDirective()
789 reinterpret_cast<WebAssemblyTargetStreamer &>(*Out.getTargetStreamer()); in parseDirective()
790 auto &Ctx = Out.getContext(); in parseDirective()
792 if (DirectiveID.getString() == ".globaltype") { in parseDirective()
794 if (SymName.empty()) in parseDirective()
798 auto TypeTok = Lexer.getTok(); in parseDirective()
800 if (TypeName.empty()) in parseDirective()
804 return error("Unknown type in .globaltype directive: ", TypeTok); in parseDirective()
805 // Optional mutable modifier. Default to mutable for historical reasons. in parseDirective()
807 // as the modifier to match the `.wat` format. in parseDirective()
810 TypeTok = Lexer.getTok(); in parseDirective()
812 if (Id.empty()) in parseDirective()
818 return error("Unknown type in .globaltype modifier: ", TypeTok); in parseDirective()
820 // Now set this symbol with the correct type. in parseDirective()
821 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
824 // And emit the directive again. in parseDirective()
825 TOut.emitGlobalType(WasmSym); in parseDirective()
829 if (DirectiveID.getString() == ".tabletype") { in parseDirective()
830 // .tabletype SYM, ELEMTYPE[, MINSIZE[, MAXSIZE]] in parseDirective()
832 if (SymName.empty()) in parseDirective()
837 auto ElemTypeTok = Lexer.getTok(); in parseDirective()
839 if (ElemTypeName.empty()) in parseDirective()
844 return error("Unknown type in .tabletype directive: ", ElemTypeTok); in parseDirective()
852 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
856 TOut.emitTableType(WasmSym); in parseDirective()
860 if (DirectiveID.getString() == ".functype") { in parseDirective()
862 // WebAssemblyAsmPrinter::EmitFunctionBodyStart. in parseDirective()
863 // TODO: would be good to factor this into a common function, but the in parseDirective()
865 // parses the locals separately. in parseDirective()
867 if (SymName.empty()) in parseDirective()
869 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
871 // We push 'Function' either when a label is parsed or a .functype in parseDirective()
872 // directive is parsed. The reason it is not easy to do this uniformly in parseDirective()
874 // 1. We can't do this at label parsing time only because there are in parseDirective()
875 // cases we don't have .functype directive before a function label, in parseDirective()
877 // of parsing. in parseDirective()
878 // 2. We can't do this at .functype parsing time only because we want to in parseDirective()
880 // without encountering a .functype directive after the label. in parseDirective()
882 // This .functype indicates a start of a function. in parseDirective()
891 if (parseSignature(Signature.get())) in parseDirective()
893 TC.funcDecl(*Signature); in parseDirective()
894 WasmSym->setSignature(Signature.get()); in parseDirective()
897 TOut.emitFunctionType(WasmSym); in parseDirective()
898 // TODO: backend also calls TOut.emitIndIdx, but that is not implemented. in parseDirective()
902 if (DirectiveID.getString() == ".export_name") { in parseDirective()
904 if (SymName.empty()) in parseDirective()
909 if (ExportName.empty()) in parseDirective()
911 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
913 TOut.emitExportName(WasmSym, ExportName); in parseDirective()
917 if (DirectiveID.getString() == ".import_module") { in parseDirective()
919 if (SymName.empty()) in parseDirective()
924 if (ImportModule.empty()) in parseDirective()
926 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
928 TOut.emitImportModule(WasmSym, ImportModule); in parseDirective()
932 if (DirectiveID.getString() == ".import_name") { in parseDirective()
934 if (SymName.empty()) in parseDirective()
939 if (ImportName.empty()) in parseDirective()
941 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
943 TOut.emitImportName(WasmSym, ImportName); in parseDirective()
947 if (DirectiveID.getString() == ".tagtype") { in parseDirective()
949 if (SymName.empty()) in parseDirective()
951 auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName)); in parseDirective()
955 WasmSym->setSignature(Signature.get()); in parseDirective()
958 TOut.emitTagType(WasmSym); in parseDirective()
959 // TODO: backend also calls TOut.emitIndIdx, but that is not implemented. in parseDirective()
963 if (DirectiveID.getString() == ".local") { in parseDirective()
965 return error(".local directive should follow the start of a function: ", in parseDirective()
966 Lexer.getTok()); in parseDirective()
970 TC.localDecl(Locals); in parseDirective()
971 TOut.emitLocal(Locals); in parseDirective()
976 if (DirectiveID.getString() == ".int8" || in parseDirective()
977 DirectiveID.getString() == ".int16" || in parseDirective()
978 DirectiveID.getString() == ".int32" || in parseDirective()
979 DirectiveID.getString() == ".int64") { in parseDirective()
984 if (Parser.parseExpression(Val, End)) in parseDirective()
985 return error("Cannot parse .int expression: ", Lexer.getTok()); in parseDirective()
987 DirectiveID.getString().drop_front(4).getAsInteger(10, NumBits); in parseDirective()
988 Out.emitValue(Val, NumBits / 8, End); in parseDirective()
992 if (DirectiveID.getString() == ".asciz") { in parseDirective()
996 if (Parser.parseEscapedString(S)) in parseDirective()
997 return error("Cannot parse string constant: ", Lexer.getTok()); in parseDirective()
998 Out.emitBytes(StringRef(S.c_str(), S.length() + 1)); in parseDirective()
1002 return ParseStatus::NoMatch; // We didn't process this directive. in parseDirective()
1005 // Called either when the first instruction is parsed of the function ends.
1008 // We haven't seen a .local directive yet. The streamer requires locals to in ensureLocals()
1010 // locals here. in ensureLocals()
1012 *Out.getTargetStreamer()); in ensureLocals()
1013 TOut.emitLocal(SmallVector<wasm::ValType, 0>()); in ensureLocals()
1023 Inst.setLoc(IDLoc); in MatchAndEmitInstruction()
1030 // Fix unknown p2align operands. in MatchAndEmitInstruction()
1031 auto Align = WebAssembly::GetDefaultP2AlignAny(Inst.getOpcode()); in MatchAndEmitInstruction()
1033 auto &Op0 = Inst.getOperand(0); in MatchAndEmitInstruction()
1034 if (Op0.getImm() == -1) in MatchAndEmitInstruction()
1035 Op0.setImm(Align); in MatchAndEmitInstruction()
1038 // Upgrade 32-bit loads/stores to 64-bit. These mostly differ by having in MatchAndEmitInstruction()
1040 // they're both immediates so don't get selected for. in MatchAndEmitInstruction()
1042 static_cast<uint16_t>(Inst.getOpcode())); in MatchAndEmitInstruction()
1044 Inst.setOpcode(Opc64); in MatchAndEmitInstruction()
1047 if (!SkipTypeCheck && TC.typeCheck(IDLoc, Inst, Operands)) in MatchAndEmitInstruction()
1049 Out.emitInstruction(Inst, getSTI()); in MatchAndEmitInstruction()
1058 assert(MissingFeatures.count() > 0 && "Expected missing features"); in MatchAndEmitInstruction()
1062 for (unsigned i = 0, e = MissingFeatures.size(); i != e; ++i) in MatchAndEmitInstruction()
1063 if (MissingFeatures.test(i)) in MatchAndEmitInstruction()
1065 return Parser.Error(IDLoc, Message); in MatchAndEmitInstruction()
1068 return Parser.Error(IDLoc, "invalid instruction"); in MatchAndEmitInstruction()
1070 return Parser.Error(IDLoc, "ambiguous instruction"); in MatchAndEmitInstruction()
1075 if (ErrorInfo >= Operands.size()) in MatchAndEmitInstruction()
1076 return Parser.Error(IDLoc, "too few operands for instruction"); in MatchAndEmitInstruction()
1081 return Parser.Error(ErrorLoc, "invalid operand for instruction"); in MatchAndEmitInstruction()
1088 // Code below only applies to labels in text sections. in doBeforeLabelEmit()
1089 auto CWS = cast<MCSectionWasm>(getStreamer().getCurrentSection().first); in doBeforeLabelEmit()
1090 if (!CWS || !CWS->getKind().isText()) in doBeforeLabelEmit()
1095 // declared with .type @object). in doBeforeLabelEmit()
1097 Parser.Error(IDLoc, in doBeforeLabelEmit()
1103 // object writer expects each function to have its own section. This way in doBeforeLabelEmit()
1104 // The user can't forget this "convention". in doBeforeLabelEmit()
1106 if (SymName.starts_with(".L")) in doBeforeLabelEmit()
1107 return; // Local Symbol. in doBeforeLabelEmit()
1110 // its name when we create this one. It would be nice to honor their in doBeforeLabelEmit()
1111 // choice, while still ensuring that we create one if they forget. in doBeforeLabelEmit()
1113 auto SecName = ".text." + SymName; in doBeforeLabelEmit()
1116 // If the current section is a COMDAT, also set the flag on the symbol. in doBeforeLabelEmit()
1118 // for importing comdat functions. But there's no way to specify that in in doBeforeLabelEmit()
1119 // assembly currently. in doBeforeLabelEmit()
1123 getContext().getWasmSection(SecName, SectionKind::getText(), 0, Group, in doBeforeLabelEmit()
1125 getStreamer().switchSection(WS); in doBeforeLabelEmit()
1126 // Also generate DWARF for this section if requested. in doBeforeLabelEmit()
1127 if (getContext().getGenDwarfForAssembly()) in doBeforeLabelEmit()
1128 getContext().addGenDwarfSection(WS); in doBeforeLabelEmit()
1132 // lexer's next location will be used, which can be confusing. For in doBeforeLabelEmit()
1136 // ... in doBeforeLabelEmit()
1138 // test1: ; We would like to point to this line for error in doBeforeLabelEmit()
1139 // ... . Not this line, which can contain any instruction in doBeforeLabelEmit()
1149 TC.endOfFunction(ErrorLoc); in onEndOfFunction()
1150 // Reset the type checker state. in onEndOfFunction()
1151 TC.Clear(); in onEndOfFunction()
1158 // Force static initialization.
1167 #include "WebAssemblyGenAsmMatcher.inc"
1172 if (ME.Opcode == Opc) { in GetMnemonic()
1173 return ME.getMnemonic(); in GetMnemonic()