Lines Matching +full:dcb +full:- +full:algorithm

1 //===- AsmParser.cpp - Parser for Assembly Files --------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
59 #include <algorithm>
179 /// Are we parsing ms-style inline assembly?
550 /// Maps directive name --> DirectiveKind enum, for
563 /// Maps Codeview def_range types --> CVDefRangeType enum, for
646 // ".dcb"
684 // Macro-like directives
709 // .print <double-quotes-string>
718 // Directives to support address-significance tables.
783 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in AsmParser()
817 PlatformParser->Initialize(*this); in AsmParser()
838 printMessage(M->InstantiationLoc, SourceMgr::DK_Note, in printMacroInstantiations()
873 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in enterIncludeFile()
889 StringRef Bytes = SrcMgr.getMemoryBuffer(NewBuf)->getBuffer(); in processIncbinFile()
893 if (!Count->evaluateAsAbsolute(Res, getStreamer().getAssemblerPtr())) in processIncbinFile()
905 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer(), in jumpToLoc()
924 while (tok->is(AsmToken::Comment)) { in Lex()
926 Out.addExplicitComment(Twine(tok->getString())); in Lex()
930 if (tok->is(AsmToken::Eof)) { in Lex()
944 // Check whether the user specified -g. in enabledGenDwarfForAssembly()
986 if (!Sec->getBeginSymbol()) { in Run()
989 Sec->setBeginSymbol(SectionStartSym); in Run()
1033 for (const auto &File : LineTables.begin()->second.getMCDwarfFiles()) { in Run()
1053 if (Sym && Sym->isTemporary() && !Sym->isVariable() && in Run()
1054 !Sym->isDefined()) in Run()
1059 Sym->getName() + "' not defined"); in Run()
1066 if (std::get<2>(LocSym)->isUndefined()) { in Run()
1078 TS->emitConstantPools(); in Run()
1112 return StringRef(Start, End - Start); in parseStringToEndOfStatement()
1123 return StringRef(Start, End - Start); in parseStringToComma()
1157 /// primaryexpr ::= ~,+,- primaryexpr
1258 if (Sym->isVariable()) { in parsePrimaryExpr()
1259 auto V = Sym->getVariableValue(/*SetUsed*/ false); in parsePrimaryExpr()
1262 DoInline = TV->inlineAssignedExpr(); in parsePrimaryExpr()
1266 Res = Sym->getVariableValue(/*SetUsed*/ false); in parsePrimaryExpr()
1299 if (IDVal == "b" && Sym->isUndefined()) in parsePrimaryExpr()
1333 if (!PlatformParser->HasBracketExpressions()) in parsePrimaryExpr()
1408 switch (E->getKind()) { in applyModifierToExpr()
1416 if (SRE->getKind() != MCSymbolRefExpr::VK_None) { in applyModifierToExpr()
1422 return MCSymbolRefExpr::create(&SRE->getSymbol(), Variant, getContext()); in applyModifierToExpr()
1427 const MCExpr *Sub = applyModifierToExpr(UE->getSubExpr(), Variant); in applyModifierToExpr()
1430 return MCUnaryExpr::create(UE->getOpcode(), Sub, getContext()); in applyModifierToExpr()
1435 const MCExpr *LHS = applyModifierToExpr(BE->getLHS(), Variant); in applyModifierToExpr()
1436 const MCExpr *RHS = applyModifierToExpr(BE->getRHS(), Variant); in applyModifierToExpr()
1442 LHS = BE->getLHS(); in applyModifierToExpr()
1444 RHS = BE->getRHS(); in applyModifierToExpr()
1446 return MCBinaryExpr::create(BE->getOpcode(), LHS, RHS, getContext()); in applyModifierToExpr()
1494 /// expr ::= expr &&,|| expr -> lowest.
1498 /// expr ::= expr +,- expr
1499 /// expr ::= expr *,/,% expr -> highest.
1534 if (Res->evaluateAsAbsolute(Value)) in parseExpression()
1550 for (; ParenDepth > 0; --ParenDepth) { in parseParenExprOfDepth()
1556 if (ParenDepth - 1 > 0) { in parseParenExprOfDepth()
1572 if (!Expr->evaluateAsAbsolute(Res, getStreamer().getAssemblerPtr())) in parseAbsoluteExpression()
1633 // High Intermediate Precedence: +, - in getDarwinBinOpPrecedence()
1691 // Low Intermediate Precedence: +, - in getGNUBinOpPrecedence()
1799 int64_t LocalLabelVal = -1; in parseStatement()
1857 : DirKindIt->getValue(); in parseStatement()
1914 return Error(IDLoc, "invalid use of pseudo-symbol '.' as a label"); in parseStatement()
1922 if (LocalLabelVal == -1) { in parseStatement()
1925 SI->LookupInlineAsmLabel(IDVal, getSourceManager(), IDLoc, true); in parseStatement()
1928 Info.AsmRewrites->emplace_back(AOK_Label, IDLoc, IDVal.size(), in parseStatement()
1952 Sym->isExternal() && !cast<MCSymbolMachO>(Sym)->isAltEntry()) in parseStatement()
1953 return Error(StartTokLoc, "non-private labels cannot appear between " in parseStatement()
1995 // 1. The target-specific assembly parser. Some directives are target in parseStatement()
1997 // 2. Asm parser extensions. For example, platform-specific parsers in parseStatement()
2057 IDVal, getContext().getAsmInfo()->getCodePointerSize()); in parseStatement()
2068 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes(); in parseStatement()
2072 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes(); in parseStatement()
2311 Info.AsmRewrites->emplace_back(AOK_EVEN, IDLoc, 4); in parseStatement()
2337 Info.ParsedOperands[i]->print(OS); in parseAndMatchAndEmitTargetInstruction()
2357 Line = SrcMgr.FindLineNumber(ActiveMacros.front()->InstantiationLoc, in parseAndMatchAndEmitTargetInstruction()
2358 ActiveMacros.front()->ExitBuffer); in parseAndMatchAndEmitTargetInstruction()
2370 Line = CppHashInfo.LineNumber - 1 + (Line - CppHashLocLineNo); in parseAndMatchAndEmitTargetInstruction()
2403 AsmStrRewrites.emplace_back(AOK_Skip, StartLoc, Lexer.getLoc().getPointer() - in parseCurlyBlockScope()
2427 Filename = Filename.substr(1, Filename.size() - 2); in parseCppHashLineFilenameComment()
2450 Parser->SrcMgr.FindBufferContainingLoc(Parser->CppHashInfo.Loc); in DiagHandler()
2455 if (!Parser->SavedDiagHandler && DiagCurBuffer && in DiagHandler()
2464 if (!Parser->CppHashInfo.LineNumber || DiagBuf != CppHashBuf) { in DiagHandler()
2465 if (Parser->SavedDiagHandler) in DiagHandler()
2466 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext); in DiagHandler()
2468 Parser->getContext().diagnose(Diag); in DiagHandler()
2475 const std::string &Filename = std::string(Parser->CppHashInfo.Filename); in DiagHandler()
2479 Parser->SrcMgr.FindLineNumber(Parser->CppHashInfo.Loc, CppHashBuf); in DiagHandler()
2481 Parser->CppHashInfo.LineNumber - 1 + (DiagLocLineNo - CppHashLocLineNo); in DiagHandler()
2487 if (Parser->SavedDiagHandler) in DiagHandler()
2488 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext); in DiagHandler()
2490 Parser->getContext().diagnose(NewDiag); in DiagHandler()
2509 bool VarargParameter = HasVararg && Index == (NParameters - 1); in expandMacro()
2561 StringRef Argument(Body.data() + Pos, I - Pos); in expandMacro()
2593 // $[0-9] => argument in expandMacro()
2595 unsigned Index = Body[I + 1] - '0'; in expandMacro()
2613 StringRef Token(Body.data() + Start, I - Start); in expandMacro()
2737 --ParenLevel; in parseMacroArgument()
2752 const unsigned NParameters = M ? M->Parameters.size() : 0; in parseMacroArguments()
2760 // - macros defined without any parameters accept an arbitrary number of them in parseMacroArguments()
2761 // - macros defined with parameters accept at most that many of them in parseMacroArguments()
2762 bool HasVararg = NParameters ? M->Parameters.back().Vararg : false; in parseMacroArguments()
2779 bool Vararg = HasVararg && Parameter == (NParameters - 1); in parseMacroArguments()
2793 if (!AbsoluteExp->evaluateAsAbsolute(Value, in parseMacroArguments()
2799 StringRef(StrChar, EndChar - StrChar), Value); in parseMacroArguments()
2809 StringRef(StrChar, EndChar - StrChar)); in parseMacroArguments()
2818 if (M->Parameters[FAI].Name == FA.Name) in parseMacroArguments()
2824 "' does not exist for macro '" + M->Name + "'"); in parseMacroArguments()
2847 if (M->Parameters[FAI].Required) { in parseMacroArguments()
2850 "'" + M->Parameters[FAI].Name + "' in macro '" + M->Name + "'"); in parseMacroArguments()
2854 if (!M->Parameters[FAI].Value.empty()) in parseMacroArguments()
2855 A[FAI] = M->Parameters[FAI].Value; in parseMacroArguments()
2875 << " Use -asm-macro-max-nesting-depth to increase " in handleMacroEntry()
2889 if ((!IsDarwin || M->Parameters.size()) && M->Parameters.size() != A.size()) in handleMacroEntry()
2891 if (expandMacro(OS, *M, M->Parameters, A, true)) in handleMacroEntry()
2911 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in handleMacroEntry()
2919 jumpToLoc(ActiveMacros.back()->ExitLoc, ActiveMacros.back()->ExitBuffer); in handleMacroExit()
2962 if (Value->getKind() != MCExpr::SymbolRef) in parseAssignment()
3068 if ((unsigned)(Str[i] - '0') <= 7) { in parseEscapedString()
3070 unsigned Value = Str[i] - '0'; in parseEscapedString()
3072 if (i + 1 != e && ((unsigned)(Str[i + 1] - '0')) <= 7) { in parseEscapedString()
3074 Value = Value * 8 + (Str[i] - '0'); in parseEscapedString()
3076 if (i + 1 != e && ((unsigned)(Str[i + 1] - '0')) <= 7) { in parseEscapedString()
3078 Value = Value * 8 + (Str[i] - '0'); in parseEscapedString()
3113 const char *EndChar = EndLoc.getPointer() - 1; in parseAngleBracketString()
3118 Data = angleBracketString(StringRef(StartChar, EndChar - StartChar)); in parseAngleBracketString()
3128 auto parseOp = [&]() -> bool { in parseDirectiveAscii()
3171 if (!Expr->evaluateAsRelocatable(Value, nullptr, nullptr)) in parseDirectiveReloc()
3183 return Error(Err->first ? NameLoc : OffsetLoc, Err->second); in parseDirectiveReloc()
3191 auto parseOp = [&]() -> bool { in parseDirectiveValue()
3199 uint64_t IntValue = MCE->getValue(); in parseDirectiveValue()
3221 hi = IntValue.getHiBits(IntValue.getBitWidth() - 64).getZExtValue(); in parseHexOcta()
3234 auto parseOp = [&]() -> bool { in parseDirectiveOctaValue()
3299 auto parseOp = [&]() -> bool { in parseDirectiveRealValue()
3369 Warning(ExprLoc, "'.fill' directive pattern has been truncated to 32-bits"); in parseDirectiveFill()
3407 auto parseAlign = [&]() -> bool { in parseDirectiveAlign()
3429 // Ignore empty '.p2align' directives for GNU-as compatibility in parseDirectiveAlign()
3467 if (Sec && Sec->isVirtualSection()) { in parseDirectiveAlign()
3469 Warning(FillExprLoc, "ignoring non-zero fill value in " + in parseDirectiveAlign()
3470 Sec->getVirtualSectionKind() + " section '" + in parseDirectiveAlign()
3471 Sec->getName() + "'"); in parseDirectiveAlign()
3476 // Diagnose non-sensical max bytes to align. in parseDirectiveAlign()
3496 bool useCodeAlign = Section->useCodeAlign(); in parseDirectiveAlign()
3512 /// ::= .file number [directory] filename [md5 checksum] [source source-text]
3515 int64_t FileNumber = -1; in parseDirectiveFile()
3535 if (check(FileNumber == -1, in parseDirectiveFile()
3560 if (check(FileNumber == -1, in parseDirectiveFile()
3566 if (check(FileNumber == -1, in parseDirectiveFile()
3577 if (FileNumber == -1) { in parseDirectiveFile()
3581 if (getContext().getAsmInfo()->hasSingleParameterDotFile()) in parseDirectiveFile()
3584 // In case there is a -g option as well as debug info from directive .file, in parseDirectiveFile()
3585 // we turn off the -g option, directly use the existing debug info instead. in parseDirectiveFile()
3596 Sum[i] = uint8_t(MD5Hi >> ((7 - i) * 8)); in parseDirectiveFile()
3597 Sum[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8)); in parseDirectiveFile()
3607 // Upgrade to Version 5 for assembly actions like clang -c a.s. in parseDirectiveFile()
3647 /// optional items are .loc sub-directives.
3679 auto parseLocOp = [&]() -> bool { in parseDirectiveLoc()
3698 int Value = MCE->getValue(); in parseDirectiveLoc()
3715 int Value = MCE->getValue(); in parseDirectiveLoc()
3726 return Error(Loc, "unknown sub-directive in '.loc' directive"); in parseDirectiveLoc()
3889 /// optional items are .loc sub-directives.
3916 auto parseOp = [&]() -> bool { in parseDirectiveCVLoc()
3931 IsStmt = MCE->getValue(); in parseDirectiveCVLoc()
3936 return Error(Loc, "unknown sub-directive in '.cv_loc' directive"); in parseDirectiveCVLoc()
4047 : CVTypeIt->getValue(); in parseDirectiveCVDefRange()
4219 // Tools like llvm-mc on the other hand are not affected by it, and report in parseDirectiveCFIStartProc()
4245 Register = getContext().getRegisterInfo()->getDwarfRegNum(RegNo, true); in parseRegisterOrRegisterNumber()
4636 --MacroDepth; in parseDirectiveMacro()
4657 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart); in parseDirectiveMacro()
4660 DEBUG_WITH_TYPE("asm-macros", dbgs() << "Defining new macro:\n"; in parseDirectiveMacro()
4728 // $[0-9] => argument in checkForBadMacro()
4741 StringRef Argument(Begin, I - (Pos + 1)); in checkForBadMacro()
4779 while (TheCondStack.size() != ActiveMacros.back()->CondStackDepth) { in parseDirectiveExitMacro()
4823 DEBUG_WITH_TYPE("asm-macros", dbgs() in parseDirectivePurgeMacro()
4824 << "Un-defining macro: " << Name << "\n"); in parseDirectivePurgeMacro()
4832 // in the inclusive range 0-30. in parseDirectiveBundleAlignMode()
4900 /// ::= .dcb.{b, l, w} expression, expression
4923 uint64_t IntValue = MCE->getValue(); in parseDirectiveDCB()
4937 /// ::= .dcb.{d, s} expression, expression
4989 auto parseOp = [&]() -> bool { in parseDirectiveLEB128()
5006 auto parseOp = [&]() -> bool { in parseDirectiveSymbolAttribute()
5019 if (Sym->isTemporary() && Attr != MCSA_Memtag) in parseDirectiveSymbolAttribute()
5020 return Error(Loc, "non-local symbol required"); in parseDirectiveSymbolAttribute()
5079 return Error(SizeLoc, "size must be non-negative"); in parseDirectiveComm()
5081 Sym->redefineIfPossible(); in parseDirectiveComm()
5082 if (!Sym->isUndefined()) in parseDirectiveComm()
5317 TheCondState.CondMet = (Sym && !Sym->isUndefined(false)); in parseDirectiveIfdef()
5319 TheCondState.CondMet = (!Sym || Sym->isUndefined(false)); in parseDirectiveIfdef()
5609 DirectiveKindMap[".dcb"] = DK_DCB; in initializeDirectiveKindMap()
5610 DirectiveKindMap[".dcb.b"] = DK_DCB_B; in initializeDirectiveKindMap()
5611 DirectiveKindMap[".dcb.d"] = DK_DCB_D; in initializeDirectiveKindMap()
5612 DirectiveKindMap[".dcb.l"] = DK_DCB_L; in initializeDirectiveKindMap()
5613 DirectiveKindMap[".dcb.s"] = DK_DCB_S; in initializeDirectiveKindMap()
5614 DirectiveKindMap[".dcb.w"] = DK_DCB_W; in initializeDirectiveKindMap()
5615 DirectiveKindMap[".dcb.x"] = DK_DCB_X; in initializeDirectiveKindMap()
5658 --NestLevel; in parseMacroLikeBody()
5668 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart); in parseMacroLikeBody()
5690 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in instantiateMacroLikeBody()
5703 if (!CountExpr->evaluateAsAbsolute(Count, getStreamer().getAssemblerPtr())) { in parseDirectiveRept()
5719 while (Count--) { in parseDirectiveRept()
5824 uint64_t IntValue = MCE->getValue(); in parseDirectiveMSEmit()
5828 Info.AsmRewrites->emplace_back(AOK_Emit, IDLoc, Len); in parseDirectiveMSEmit()
5840 uint64_t IntValue = MCE->getValue(); in parseDirectiveMSAlign()
5844 Info.AsmRewrites->emplace_back(AOK_Align, IDLoc, 5, Log2_64(IntValue)); in parseDirectiveMSAlign()
5945 /// The LTO library emits this directive to discard non-prevailing symbols.
5949 auto ParseOp = [&]() -> bool { in parseDirectiveLTODiscard()
5966 if (AsmRewriteA->Loc.getPointer() < AsmRewriteB->Loc.getPointer()) in rewritesSort()
5967 return -1; in rewritesSort()
5968 if (AsmRewriteB->Loc.getPointer() < AsmRewriteA->Loc.getPointer()) in rewritesSort()
5974 // ensures the sort algorithm is stable. in rewritesSort()
5975 if (AsmRewritePrecedence[AsmRewriteA->Kind] > in rewritesSort()
5976 AsmRewritePrecedence[AsmRewriteB->Kind]) in rewritesSort()
5977 return -1; in rewritesSort()
5979 if (AsmRewritePrecedence[AsmRewriteA->Kind] < in rewritesSort()
5980 AsmRewritePrecedence[AsmRewriteB->Kind]) in rewritesSort()
6027 const MCInstrDesc &Desc = MII->get(Info.Opcode); in parseMSInlineAsm()
6075 if (Desc.operands()[i - 1].isBranchTarget()) in parseMSInlineAsm()
6098 IP->printRegName(OS, ClobberRegs[I]); in parseMSInlineAsm()
6120 SrcMgr.getMemoryBuffer(SrcMgr.getMainFileID())->getBuffer(); in parseMSInlineAsm()
6135 if (unsigned Len = Loc - AsmStart) in parseMSInlineAsm()
6175 } else if (rewrite_it->Kind == AOK_CallInput) { in parseMSInlineAsm()
6177 rewrite_it->Done = true; in parseMSInlineAsm()
6180 rewrite_it->Done = true; in parseMSInlineAsm()
6189 OS << Ctx.getAsmInfo()->getPrivateLabelPrefix() << AR.Label; in parseMSInlineAsm()
6225 if (getContext().getAsmInfo()->getAlignmentIsInBytes()) in parseMSInlineAsm()
6250 OS << StringRef(AsmStart, AsmEnd - AsmStart); in parseMSInlineAsm()
6281 getContext().getAsmInfo()->shouldEmitLabelsInUpperCase() in parseAsHLASMLabel()
6328 // first non-space token as a Label. in parseStatement()
6330 // token), then we attempt to parse the first non-space in parseStatement()
6385 switch (Value->getKind()) { in isSymbolUsedInExpression()
6388 return isSymbolUsedInExpression(Sym, BE->getLHS()) || in isSymbolUsedInExpression()
6389 isSymbolUsedInExpression(Sym, BE->getRHS()); in isSymbolUsedInExpression()
6396 static_cast<const MCSymbolRefExpr *>(Value)->getSymbol(); in isSymbolUsedInExpression()
6403 Sym, static_cast<const MCUnaryExpr *>(Value)->getSubExpr()); in isSymbolUsedInExpression()
6435 else if (Sym->isUndefined(/*SetUsed*/ false) && !Sym->isUsed() && in parseAssignmentExpression()
6436 !Sym->isVariable()) in parseAssignmentExpression()
6438 else if (Sym->isVariable() && !Sym->isUsed() && allow_redef) in parseAssignmentExpression()
6440 else if (!Sym->isUndefined() && (!Sym->isVariable() || !allow_redef)) in parseAssignmentExpression()
6442 else if (!Sym->isVariable()) in parseAssignmentExpression()
6444 else if (!isa<MCConstantExpr>(Sym->getVariableValue())) in parseAssignmentExpression()
6446 "invalid reassignment of non-absolute variable '" + in parseAssignmentExpression()
6454 Sym->setRedefinable(allow_redef); in parseAssignmentExpression()