Lines Matching +full:gas +full:- +full:preprocessor
1 //===- AsmParser.cpp - Parser for Assembly Files --------------------------===//
8 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
182 /// \brief Are we parsing ms-style inline assembly?
271 /// parseToken - If current token has the specified kind, eat it and
320 /// \brief Undefine a macro. If no such macro was defined, it's a no-op.
417 /// \brief Maps directive name --> DirectiveKind enum, for
520 // Macro-like directives
570 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in AsmParser()
573 switch (Ctx.getObjectFileInfo()->getObjectFileType()) { in AsmParser()
586 PlatformParser->Initialize(*this); in AsmParser()
603 printMessage((*it)->InstantiationLoc, SourceMgr::DK_Note, in printMacroInstantiations()
637 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in enterIncludeFile()
652 getStreamer().EmitBytes(SrcMgr.getMemoryBuffer(NewBuf)->getBuffer()); in processIncbinFile()
658 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer(), in jumpToLoc()
677 while (tok->is(AsmToken::Comment)) { in Lex()
679 Out.addExplicitComment(Twine(tok->getString())); in Lex()
683 if (tok->is(AsmToken::Eof)) { in Lex()
712 if (!Sec->getBeginSymbol()) { in Run()
715 Sec->setBeginSymbol(SectionStartSym); in Run()
750 for (const auto &File : LineTables.begin()->second.getMCDwarfFiles()) { in Run()
769 if (Sym->isTemporary() && !Sym->isVariable() && !Sym->isDefined()) in Run()
775 Sym->getName() + "' not defined"); in Run()
782 if (std::get<2>(LocSym)->isUndefined()) { in Run()
823 return StringRef(Start, End - Start); in parseStringToEndOfStatement()
834 return StringRef(Start, End - Start); in parseStringToComma()
872 /// primaryexpr ::= ~,+,- primaryexpr
959 if (Sym->isVariable() && in parsePrimaryExpr()
960 isa<MCConstantExpr>(Sym->getVariableValue(/*SetUsed*/ false))) { in parsePrimaryExpr()
964 Res = Sym->getVariableValue(/*SetUsed*/ false); in parsePrimaryExpr()
996 if (IDVal == "b" && Sym->isUndefined()) in parsePrimaryExpr()
1027 if (!PlatformParser->HasBracketExpressions()) in parsePrimaryExpr()
1066 switch (E->getKind()) { in applyModifierToExpr()
1074 if (SRE->getKind() != MCSymbolRefExpr::VK_None) { in applyModifierToExpr()
1080 return MCSymbolRefExpr::create(&SRE->getSymbol(), Variant, getContext()); in applyModifierToExpr()
1085 const MCExpr *Sub = applyModifierToExpr(UE->getSubExpr(), Variant); in applyModifierToExpr()
1088 return MCUnaryExpr::create(UE->getOpcode(), Sub, getContext()); in applyModifierToExpr()
1093 const MCExpr *LHS = applyModifierToExpr(BE->getLHS(), Variant); in applyModifierToExpr()
1094 const MCExpr *RHS = applyModifierToExpr(BE->getRHS(), Variant); in applyModifierToExpr()
1100 LHS = BE->getLHS(); in applyModifierToExpr()
1102 RHS = BE->getRHS(); in applyModifierToExpr()
1104 return MCBinaryExpr::create(BE->getOpcode(), LHS, RHS, getContext()); in applyModifierToExpr()
1113 /// expr ::= expr &&,|| expr -> lowest.
1117 /// expr ::= expr +,- expr
1118 /// expr ::= expr *,/,% expr -> highest.
1153 if (Res->evaluateAsAbsolute(Value)) in parseExpression()
1169 for (; ParenDepth > 0; --ParenDepth) { in parseParenExprOfDepth()
1175 if (ParenDepth - 1 > 0) { in parseParenExprOfDepth()
1192 if (!Expr->evaluateAsAbsolute(Res)) in parseAbsoluteExpression()
1215 // FIXME: gas seems to support '!' as an infix operator? in getDarwinBinOpPrecedence()
1255 // High Intermediate Precedence: +, - in getDarwinBinOpPrecedence()
1312 // Low Intermediate Precedence: +, - in getGNUBinOpPrecedence()
1322 // FIXME: gas seems to support '!' as an infix operator? in getGNUBinOpPrecedence()
1409 // Seeing a hash here means that it was an end-of-line comment in in parseStatement()
1422 int64_t LocalLabelVal = -1; in parseStatement()
1466 : DirKindIt->getValue(); in parseStatement()
1519 // identifier ':' -> Label. in parseStatement()
1524 return Error(IDLoc, "invalid use of pseudo-symbol '.' as a label"); in parseStatement()
1532 if (LocalLabelVal == -1) { in parseStatement()
1535 SI->LookupInlineAsmLabel(IDVal, getSourceManager(), IDLoc, true); in parseStatement()
1538 Info.AsmRewrites->emplace_back(AOK_Label, IDLoc, IDVal.size(), in parseStatement()
1546 Sym->redefineIfPossible(); in parseStatement()
1548 if (!Sym->isUndefined() || Sym->isVariable()) in parseStatement()
1554 // here instead of a preprocessor line comment. in parseStatement()
1587 // identifier '=' ... -> assignment statement in parseStatement()
1608 // 1. The target-specific assembly parser. Some directives are target in parseStatement()
1610 // 2. Asm parser extensions. For example, platform-specific parsers in parseStatement()
1617 // First query the target-specific parser. It will return 'true' if it in parseStatement()
1665 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes(); in parseStatement()
1669 bool IsPow2 = !getContext().getAsmInfo()->getAlignmentIsInBytes(); in parseStatement()
1847 Info.AsmRewrites->emplace_back(AOK_EVEN, IDLoc, 4); in parseStatement()
1865 Info.ParsedOperands[i]->print(OS); in parseStatement()
1881 Line = SrcMgr.FindLineNumber(ActiveMacros.front()->InstantiationLoc, in parseStatement()
1882 ActiveMacros.front()->ExitBuffer); in parseStatement()
1906 Line = CppHashInfo.LineNumber - 1 + (Line - CppHashLocLineNo); in parseStatement()
1941 AsmStrRewrites.emplace_back(AOK_Skip, StartLoc, Lexer.getLoc().getPointer() - in parseCurlyBlockScope()
1961 Filename = Filename.substr(1, Filename.size() - 2); in parseCppHashLineFilenameComment()
1981 Parser->SrcMgr.FindBufferContainingLoc(Parser->CppHashInfo.Loc); in DiagHandler()
1986 if (!Parser->SavedDiagHandler && DiagCurBuffer && in DiagHandler()
1995 if (!Parser->CppHashInfo.LineNumber || &DiagSrcMgr != &Parser->SrcMgr || in DiagHandler()
1997 if (Parser->SavedDiagHandler) in DiagHandler()
1998 Parser->SavedDiagHandler(Diag, Parser->SavedDiagContext); in DiagHandler()
2007 const std::string &Filename = Parser->CppHashInfo.Filename; in DiagHandler()
2011 Parser->SrcMgr.FindLineNumber(Parser->CppHashInfo.Loc, CppHashBuf); in DiagHandler()
2013 Parser->CppHashInfo.LineNumber - 1 + (DiagLocLineNo - CppHashLocLineNo); in DiagHandler()
2019 if (Parser->SavedDiagHandler) in DiagHandler()
2020 Parser->SavedDiagHandler(NewDiag, Parser->SavedDiagContext); in DiagHandler()
2044 // gas accepts no arguments and does no substitutions in expandMacro()
2085 // $[0-9] => argument in expandMacro()
2088 unsigned Index = Body[Pos + 1] - '0'; in expandMacro()
2102 // Check for the \@ pseudo-variable. in expandMacro()
2110 StringRef Argument(Begin, I - (Pos + 1)); in expandMacro()
2129 bool VarargParameter = HasVararg && Index == (NParameters - 1); in expandMacro()
2260 --ParenLevel; in parseMacroArgument()
2275 const unsigned NParameters = M ? M->Parameters.size() : 0; in parseMacroArguments()
2283 // - macros defined without any parameters accept an arbitrary number of them in parseMacroArguments()
2284 // - macros defined with parameters accept at most that many of them in parseMacroArguments()
2285 bool HasVararg = NParameters ? M->Parameters.back().Vararg : false; in parseMacroArguments()
2314 bool Vararg = HasVararg && Parameter == (NParameters - 1); in parseMacroArguments()
2322 if (M->Parameters[FAI].Name == FA.Name) in parseMacroArguments()
2329 M->Name + "'"); in parseMacroArguments()
2353 if (M->Parameters[FAI].Required) { in parseMacroArguments()
2356 "'" + M->Parameters[FAI].Name + "' in macro '" + M->Name + "'"); in parseMacroArguments()
2360 if (!M->Parameters[FAI].Value.empty()) in parseMacroArguments()
2361 A[FAI] = M->Parameters[FAI].Value; in parseMacroArguments()
2376 return (I == MacroMap.end()) ? nullptr : &I->getValue(); in lookupMacro()
2398 StringRef Body = M->Body; in handleMacroEntry()
2401 if (expandMacro(OS, Body, M->Parameters, A, true, getTok().getLoc())) in handleMacroEntry()
2421 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in handleMacroEntry()
2429 jumpToLoc(ActiveMacros.back()->ExitLoc, ActiveMacros.back()->ExitBuffer); in handleMacroExit()
2533 if ((unsigned)(Str[i] - '0') <= 7) { in parseEscapedString()
2535 unsigned Value = Str[i] - '0'; in parseEscapedString()
2537 if (i + 1 != e && ((unsigned)(Str[i + 1] - '0')) <= 7) { in parseEscapedString()
2539 Value = Value * 8 + (Str[i] - '0'); in parseEscapedString()
2541 if (i + 1 != e && ((unsigned)(Str[i + 1] - '0')) <= 7) { in parseEscapedString()
2543 Value = Value * 8 + (Str[i] - '0'); in parseEscapedString()
2618 if (!Offset->evaluateAsAbsolute(OffsetValue)) in parseDirectiveReloc()
2641 if (!Expr->evaluateAsRelocatable(Value, nullptr, nullptr)) in parseDirectiveReloc()
2669 uint64_t IntValue = MCE->getValue(); in parseDirectiveValue()
2713 hi = IntValue.getHiBits(IntValue.getBitWidth() - 64).getZExtValue(); in parseDirectiveOctaValue()
2875 Warning(ExprLoc, "'.fill' directive pattern has been truncated to 32-bits"); in parseDirectiveFill()
2968 // for gas compatibility. Alignment of zero is silently rounded in parseDirectiveAlign()
2976 // Diagnose non-sensical max bytes to align. in parseDirectiveAlign()
2995 bool UseCodeAlign = Section->UseCodeAlign(); in parseDirectiveAlign()
3013 int64_t FileNumber = -1; in parseDirectiveFile()
3037 if (FileNumber == -1) in parseDirectiveFile()
3051 if (FileNumber == -1) in parseDirectiveFile()
3054 // If there is -g option as well as debug info from directive file, in parseDirectiveFile()
3055 // we turn off -g option, directly use the existing debug info instead. in parseDirectiveFile()
3092 /// optional items are .loc sub-directives.
3145 int Value = MCE->getValue(); in parseDirectiveLoc()
3162 int Value = MCE->getValue(); in parseDirectiveLoc()
3173 return Error(Loc, "unknown sub-directive in '.loc' directive"); in parseDirectiveLoc()
3231 /// optional items are .loc sub-directives.
3282 IsStmt = MCE->getValue(); in parseDirectiveCVLoc()
3287 return Error(Loc, "unknown sub-directive in '.cv_loc' directive"); in parseDirectiveCVLoc()
3493 Register = getContext().getRegisterInfo()->getDwarfRegNum(RegNo, true); in parseRegisterOrRegisterNumber()
3858 --MacroDepth; in parseDirectiveMacro()
3877 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart); in parseDirectiveMacro()
3886 /// is transitioning from positional parameters. In versions of gas that did
3945 // $[0-9] => argument in checkForBadMacro()
3958 StringRef Argument(Begin, I - (Pos + 1)); in checkForBadMacro()
3996 while (TheCondStack.size() != ActiveMacros.back()->CondStackDepth) { in parseDirectiveExitMacro()
4048 // in the inclusive range 0-30. in parseDirectiveBundleAlignMode()
4181 if (Sym->isTemporary()) in parseDirectiveSymbolAttribute()
4182 return Error(Loc, "non-local symbol required in directive"); in parseDirectiveSymbolAttribute()
4261 if (!Sym->isUndefined()) in parseDirectiveComm()
4511 TheCondState.CondMet = (Sym && !Sym->isUndefined()); in parseDirectiveIfdef()
4513 TheCondState.CondMet = (!Sym || Sym->isUndefined()); in parseDirectiveIfdef()
4819 --NestLevel; in parseMacroLikeBody()
4828 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart); in parseMacroLikeBody()
4850 Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer)->getBuffer()); in instantiateMacroLikeBody()
4863 if (!CountExpr->evaluateAsAbsolute(Count)) { in parseDirectiveRept()
4886 while (Count--) { in parseDirectiveRept()
4888 if (expandMacro(OS, M->Body, None, None, false, getTok().getLoc())) in parseDirectiveRept()
4928 // This is undocumented, but GAS seems to support it. in parseDirectiveIrp()
4929 if (expandMacro(OS, M->Body, Parameter, Arg, true, getTok().getLoc())) in parseDirectiveIrp()
4977 // This is undocumented, but GAS seems to support it. in parseDirectiveIrpc()
4978 if (expandMacro(OS, M->Body, Parameter, Arg, true, getTok().getLoc())) in parseDirectiveIrpc()
5008 uint64_t IntValue = MCE->getValue(); in parseDirectiveMSEmit()
5012 Info.AsmRewrites->emplace_back(AOK_Emit, IDLoc, Len); in parseDirectiveMSEmit()
5024 uint64_t IntValue = MCE->getValue(); in parseDirectiveMSAlign()
5028 Info.AsmRewrites->emplace_back(AOK_Align, IDLoc, 5, Log2_64(IntValue)); in parseDirectiveMSAlign()
5036 if (AsmRewriteA->Loc.getPointer() < AsmRewriteB->Loc.getPointer()) in rewritesSort()
5037 return -1; in rewritesSort()
5038 if (AsmRewriteB->Loc.getPointer() < AsmRewriteA->Loc.getPointer()) in rewritesSort()
5045 if (AsmRewritePrecedence[AsmRewriteA->Kind] > in rewritesSort()
5046 AsmRewritePrecedence[AsmRewriteB->Kind]) in rewritesSort()
5047 return -1; in rewritesSort()
5049 if (AsmRewritePrecedence[AsmRewriteA->Kind] < in rewritesSort()
5050 AsmRewritePrecedence[AsmRewriteB->Kind]) in rewritesSort()
5092 const MCInstrDesc &Desc = MII->get(Info.Opcode); in parseMSInlineAsm()
5154 IP->printRegName(OS, ClobberRegs[I]); in parseMSInlineAsm()
5176 SrcMgr.getMemoryBuffer(SrcMgr.getMainFileID())->getBuffer(); in parseMSInlineAsm()
5189 if (unsigned Len = Loc - AsmStart) in parseMSInlineAsm()
5210 OS << Ctx.getAsmInfo()->getPrivateLabelPrefix() << AR.Label; in parseMSInlineAsm()
5237 if (getContext().getAsmInfo()->getAlignmentIsInBytes()) in parseMSInlineAsm()
5269 OS << StringRef(AsmStart, AsmEnd - AsmStart); in parseMSInlineAsm()
5281 switch (Value->getKind()) { in isSymbolUsedInExpression()
5284 return isSymbolUsedInExpression(Sym, BE->getLHS()) || in isSymbolUsedInExpression()
5285 isSymbolUsedInExpression(Sym, BE->getRHS()); in isSymbolUsedInExpression()
5292 static_cast<const MCSymbolRefExpr *>(Value)->getSymbol(); in isSymbolUsedInExpression()
5299 Sym, static_cast<const MCUnaryExpr *>(Value)->getSubExpr()); in isSymbolUsedInExpression()
5338 else if (Sym->isUndefined(/*SetUsed*/ false) && !Sym->isUsed() && in parseAssignmentExpression()
5339 !Sym->isVariable()) in parseAssignmentExpression()
5341 else if (Sym->isVariable() && !Sym->isUsed() && allow_redef) in parseAssignmentExpression()
5343 else if (!Sym->isUndefined() && (!Sym->isVariable() || !allow_redef)) in parseAssignmentExpression()
5345 else if (!Sym->isVariable()) in parseAssignmentExpression()
5347 else if (!isa<MCConstantExpr>(Sym->getVariableValue())) in parseAssignmentExpression()
5349 "invalid reassignment of non-absolute variable '" + in parseAssignmentExpression()
5357 Sym->setRedefinable(allow_redef); in parseAssignmentExpression()