diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2022-07-14 18:50:02 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2022-07-14 18:50:02 +0000 |
| commit | 1f917f69ff07f09b6dbb670971f57f8efe718b84 (patch) | |
| tree | 99293cbc1411737cd995dac10a99b2c40ef0944c /llvm/lib/MC | |
| parent | 145449b1e420787bb99721a429341fa6be3adfb6 (diff) | |
Diffstat (limited to 'llvm/lib/MC')
| -rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 14 | ||||
| -rw-r--r-- | llvm/lib/MC/MCContext.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/MC/MCDisassembler/MCDisassembler.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/MC/MCParser/MasmParser.cpp | 92 | ||||
| -rw-r--r-- | llvm/lib/MC/MCSchedule.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/MC/MCSectionELF.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/MC/MCSectionXCOFF.cpp | 4 |
8 files changed, 54 insertions, 76 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index eda495693595..78204ffe4c3b 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -145,7 +145,7 @@ struct ELFWriter { uint64_t align(unsigned Alignment); bool maybeWriteCompression(uint64_t Size, - SmallVectorImpl<char> &CompressedContents, + SmallVectorImpl<uint8_t> &CompressedContents, bool ZLibStyle, unsigned Alignment); public: @@ -819,7 +819,7 @@ MCSectionELF *ELFWriter::createRelocationSection(MCContext &Ctx, // Include the debug info compression header. bool ELFWriter::maybeWriteCompression( - uint64_t Size, SmallVectorImpl<char> &CompressedContents, bool ZLibStyle, + uint64_t Size, SmallVectorImpl<uint8_t> &CompressedContents, bool ZLibStyle, unsigned Alignment) { if (ZLibStyle) { uint64_t HdrSize = @@ -875,9 +875,11 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec, raw_svector_ostream VecOS(UncompressedData); Asm.writeSectionData(VecOS, &Section, Layout); - SmallVector<char, 128> CompressedContents; - zlib::compress(StringRef(UncompressedData.data(), UncompressedData.size()), - CompressedContents); + SmallVector<uint8_t, 128> CompressedContents; + compression::zlib::compress( + makeArrayRef(reinterpret_cast<uint8_t *>(UncompressedData.data()), + UncompressedData.size()), + CompressedContents); bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z; if (!maybeWriteCompression(UncompressedData.size(), CompressedContents, @@ -896,7 +898,7 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec, // Add "z" prefix to section name. This is zlib-gnu style. MC.renameELFSection(&Section, (".z" + SectionName.drop_front(1)).str()); } - W.OS << CompressedContents; + W.OS << toStringRef(CompressedContents); } void ELFWriter::WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags, diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp index 4be84ca7feb5..d312e3521c9e 100644 --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -773,7 +773,7 @@ MCSectionXCOFF *MCContext::getXCOFFSection( // Do the lookup. If we have a hit, return it. auto IterBool = XCOFFUniquingMap.insert(std::make_pair( IsDwarfSec - ? XCOFFSectionKey(Section.str(), DwarfSectionSubtypeFlags.getValue()) + ? XCOFFSectionKey(Section.str(), DwarfSectionSubtypeFlags.value()) : XCOFFSectionKey(Section.str(), CsectProp->MappingClass), nullptr)); auto &Entry = *IterBool.first; @@ -806,7 +806,7 @@ MCSectionXCOFF *MCContext::getXCOFFSection( if (IsDwarfSec) Result = new (XCOFFAllocator.Allocate()) MCSectionXCOFF(QualName->getUnqualifiedName(), Kind, QualName, - DwarfSectionSubtypeFlags.getValue(), Begin, CachedName, + DwarfSectionSubtypeFlags.value(), Begin, CachedName, MultiSymbolsAllowed); else Result = new (XCOFFAllocator.Allocate()) diff --git a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp index 0c041186936d..cf98cb8ff59f 100644 --- a/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/MCDisassembler.cpp @@ -88,8 +88,8 @@ bool XCOFFSymbolInfo::operator<(const XCOFFSymbolInfo &SymInfo) const { return SymInfo.StorageMappingClass.has_value(); if (StorageMappingClass) { - return getSMCPriority(StorageMappingClass.getValue()) < - getSMCPriority(SymInfo.StorageMappingClass.getValue()); + return getSMCPriority(StorageMappingClass.value()) < + getSMCPriority(SymInfo.StorageMappingClass.value()); } return false; diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 04a234be3b47..563d3487ef50 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -660,6 +660,8 @@ EndStmt: Type = ELF::SHT_LLVM_SYMPART; else if (TypeName == "llvm_bb_addr_map") Type = ELF::SHT_LLVM_BB_ADDR_MAP; + else if (TypeName == "llvm_offloading") + Type = ELF::SHT_LLVM_OFFLOADING; else if (TypeName.getAsInteger(0, Type)) return TokError("unknown section type"); } diff --git a/llvm/lib/MC/MCParser/MasmParser.cpp b/llvm/lib/MC/MCParser/MasmParser.cpp index 8c582d225e30..694ea395fdec 100644 --- a/llvm/lib/MC/MCParser/MasmParser.cpp +++ b/llvm/lib/MC/MCParser/MasmParser.cpp @@ -1585,6 +1585,16 @@ bool MasmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc, Res = MCUnaryExpr::createNot(Res, getContext(), FirstTokenLoc); return false; } + // Parse directional local label references. + if (Identifier.equals_insensitive("@b") || + Identifier.equals_insensitive("@f")) { + bool Before = Identifier.equals_insensitive("@b"); + MCSymbol *Sym = getContext().getDirectionalLocalSymbol(0, Before); + if (Before && Sym->isUndefined()) + return Error(FirstTokenLoc, "Expected @@ label before @B reference"); + Res = MCSymbolRefExpr::create(Sym, getContext()); + return false; + } // Parse symbol variant. std::pair<StringRef, StringRef> Split; if (!MAI.useParensForSymbolVariant()) { @@ -1714,34 +1724,10 @@ bool MasmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc, case AsmToken::BigNum: return TokError("literal value out of range for directive"); case AsmToken::Integer: { - SMLoc Loc = getTok().getLoc(); int64_t IntVal = getTok().getIntVal(); Res = MCConstantExpr::create(IntVal, getContext()); EndLoc = Lexer.getTok().getEndLoc(); Lex(); // Eat token. - // Look for 'b' or 'f' following an Integer as a directional label. - if (Lexer.getKind() == AsmToken::Identifier) { - StringRef IDVal = getTok().getString(); - // Look up the symbol variant if used. - std::pair<StringRef, StringRef> Split = IDVal.split('@'); - MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; - if (Split.first.size() != IDVal.size()) { - Variant = MCSymbolRefExpr::getVariantKindForName(Split.second); - if (Variant == MCSymbolRefExpr::VK_Invalid) - return TokError("invalid variant '" + Split.second + "'"); - IDVal = Split.first; - } - if (IDVal == "f" || IDVal == "b") { - MCSymbol *Sym = - Ctx.getDirectionalLocalSymbol(IntVal, IDVal == "b"); - Res = MCSymbolRefExpr::create(Sym, Variant, getContext()); - if (IDVal == "b" && Sym->isUndefined()) - return Error(Loc, "directional label undefined"); - DirLabels.push_back(std::make_tuple(Loc, CppHashInfo, Sym)); - EndLoc = Lexer.getTok().getEndLoc(); - Lex(); // Eat identifier. - } - } return false; } case AsmToken::String: { @@ -2042,6 +2028,9 @@ bool MasmParser::parseBinOpRHS(unsigned Precedence, const MCExpr *&Res, .CaseLower("and", AsmToken::Amp) .CaseLower("not", AsmToken::Exclaim) .CaseLower("or", AsmToken::Pipe) + .CaseLower("xor", AsmToken::Caret) + .CaseLower("shl", AsmToken::LessLess) + .CaseLower("shr", AsmToken::GreaterGreater) .CaseLower("eq", AsmToken::EqualEqual) .CaseLower("ne", AsmToken::ExclaimEqual) .CaseLower("lt", AsmToken::Less) @@ -2110,29 +2099,9 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info, AsmToken ID = getTok(); SMLoc IDLoc = ID.getLoc(); StringRef IDVal; - int64_t LocalLabelVal = -1; if (Lexer.is(AsmToken::HashDirective)) return parseCppHashLineFilenameComment(IDLoc); - // Allow an integer followed by a ':' as a directional local label. - if (Lexer.is(AsmToken::Integer)) { - LocalLabelVal = getTok().getIntVal(); - if (LocalLabelVal < 0) { - if (!TheCondState.Ignore) { - Lex(); // always eat a token - return Error(IDLoc, "unexpected token at start of statement"); - } - IDVal = ""; - } else { - IDVal = getTok().getString(); - Lex(); // Consume the integer token to be used as an identifier token. - if (Lexer.getKind() != AsmToken::Colon) { - if (!TheCondState.Ignore) { - Lex(); // always eat a token - return Error(IDLoc, "unexpected token at start of statement"); - } - } - } - } else if (Lexer.is(AsmToken::Dot)) { + if (Lexer.is(AsmToken::Dot)) { // Treat '.' as a valid identifier in this context. Lex(); IDVal = "."; @@ -2257,19 +2226,22 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info, // FIXME: This doesn't diagnose assignment to a symbol which has been // implicitly marked as external. MCSymbol *Sym; - if (LocalLabelVal == -1) { - if (ParsingMSInlineAsm && SI) { - StringRef RewrittenLabel = - SI->LookupInlineAsmLabel(IDVal, getSourceManager(), IDLoc, true); - assert(!RewrittenLabel.empty() && - "We should have an internal name here."); - Info.AsmRewrites->emplace_back(AOK_Label, IDLoc, IDVal.size(), - RewrittenLabel); - IDVal = RewrittenLabel; - } + if (ParsingMSInlineAsm && SI) { + StringRef RewrittenLabel = + SI->LookupInlineAsmLabel(IDVal, getSourceManager(), IDLoc, true); + assert(!RewrittenLabel.empty() && + "We should have an internal name here."); + Info.AsmRewrites->emplace_back(AOK_Label, IDLoc, IDVal.size(), + RewrittenLabel); + IDVal = RewrittenLabel; + } + // Handle directional local labels + if (IDVal == "@@") { + Sym = Ctx.createDirectionalLocalSymbol(0); + } else { Sym = getContext().getOrCreateSymbol(IDVal); - } else - Sym = Ctx.createDirectionalLocalSymbol(LocalLabelVal); + } + // End of Labels should be treated as end of line for lexing // purposes but that information is not available to the Lexer who // does not understand Labels. This may cause us to see a Hash @@ -4241,7 +4213,7 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure, size_t FieldIndex = 0; if (EndToken) { // Initialize all fields with given initializers. - while (getTok().isNot(EndToken.getValue()) && + while (getTok().isNot(EndToken.value()) && FieldIndex < Structure.Fields.size()) { const FieldInfo &Field = Structure.Fields[FieldIndex++]; if (parseOptionalToken(AsmToken::Comma)) { @@ -4273,10 +4245,10 @@ bool MasmParser::parseStructInitializer(const StructInfo &Structure, } if (EndToken) { - if (EndToken.getValue() == AsmToken::Greater) + if (EndToken.value() == AsmToken::Greater) return parseAngleBracketClose(); - return parseToken(EndToken.getValue()); + return parseToken(EndToken.value()); } return false; diff --git a/llvm/lib/MC/MCSchedule.cpp b/llvm/lib/MC/MCSchedule.cpp index 98eb7eada064..71c8e6f02f8e 100644 --- a/llvm/lib/MC/MCSchedule.cpp +++ b/llvm/lib/MC/MCSchedule.cpp @@ -96,10 +96,10 @@ MCSchedModel::getReciprocalThroughput(const MCSubtargetInfo &STI, continue; unsigned NumUnits = SM.getProcResource(I->ProcResourceIdx)->NumUnits; double Temp = NumUnits * 1.0 / I->Cycles; - Throughput = Throughput ? std::min(Throughput.getValue(), Temp) : Temp; + Throughput = Throughput ? std::min(Throughput.value(), Temp) : Temp; } if (Throughput) - return 1.0 / Throughput.getValue(); + return 1.0 / Throughput.value(); // If no throughput value was calculated, assume that we can execute at the // maximum issue width scaled by number of micro-ops for the schedule class. @@ -140,10 +140,10 @@ MCSchedModel::getReciprocalThroughput(unsigned SchedClass, if (!I->getCycles()) continue; double Temp = countPopulation(I->getUnits()) * 1.0 / I->getCycles(); - Throughput = Throughput ? std::min(Throughput.getValue(), Temp) : Temp; + Throughput = Throughput ? std::min(Throughput.value(), Temp) : Temp; } if (Throughput) - return 1.0 / Throughput.getValue(); + return 1.0 / Throughput.value(); // If there are no execution resources specified for this class, then assume // that it can execute at the maximum default issue width. diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index 27dc1826819b..077cee132338 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -167,6 +167,8 @@ void MCSectionELF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, OS << "llvm_bb_addr_map"; else if (Type == ELF::SHT_LLVM_BB_ADDR_MAP_V0) OS << "llvm_bb_addr_map_v0"; + else if (Type == ELF::SHT_LLVM_OFFLOADING) + OS << "llvm_offloading"; else report_fatal_error("unsupported type 0x" + Twine::utohexstr(Type) + " for section " + getName()); diff --git a/llvm/lib/MC/MCSectionXCOFF.cpp b/llvm/lib/MC/MCSectionXCOFF.cpp index ee8fa04c421f..9a35ac69c47c 100644 --- a/llvm/lib/MC/MCSectionXCOFF.cpp +++ b/llvm/lib/MC/MCSectionXCOFF.cpp @@ -110,8 +110,8 @@ void MCSectionXCOFF::printSwitchToSection(const MCAsmInfo &MAI, const Triple &T, // XCOFF debug sections. if (getKind().isMetadata() && isDwarfSect()) { - OS << "\n\t.dwsect " - << format("0x%" PRIx32, getDwarfSubtypeFlags().getValue()) << '\n'; + OS << "\n\t.dwsect " << format("0x%" PRIx32, getDwarfSubtypeFlags().value()) + << '\n'; OS << MAI.getPrivateLabelPrefix() << getName() << ':' << '\n'; return; } |
