diff --git a/bolt/docs/BAT.md b/bolt/docs/BAT.md index 186b0e5ea89d3..436593478a398 100644 --- a/bolt/docs/BAT.md +++ b/bolt/docs/BAT.md @@ -90,11 +90,12 @@ current function. ### Address translation table Delta encoding means that only the difference with the previous corresponding entry is encoded. Input offsets implicitly start at zero. -| Entry | Encoding | Description | -| ------ | ------| ----------- | -| `OutputOffset` | Continuous, Delta, ULEB128 | Function offset in output binary | -| `InputOffset` | Optional, Delta, SLEB128 | Function offset in input binary with `BRANCHENTRY` LSB bit | -| `BBHash` | Optional, 8b | Basic block entries only: basic block hash in input binary | +| Entry | Encoding | Description | Branch/BB | +| ------ | ------| ----------- | ------ | +| `OutputOffset` | Continuous, Delta, ULEB128 | Function offset in output binary | Both | +| `InputOffset` | Optional, Delta, SLEB128 | Function offset in input binary with `BRANCHENTRY` LSB bit | Both | +| `BBHash` | Optional, 8b | Basic block hash in input binary | BB | +| `BBIdx` | Optional, Delta, ULEB128 | Basic block index in input binary | BB | `BRANCHENTRY` bit denotes whether a given offset pair is a control flow source (branch or call instruction). If not set, it signifies a control flow target diff --git a/bolt/include/bolt/Profile/BoltAddressTranslation.h b/bolt/include/bolt/Profile/BoltAddressTranslation.h index 1f53f6d344ad7..eda2b318f0d0a 100644 --- a/bolt/include/bolt/Profile/BoltAddressTranslation.h +++ b/bolt/include/bolt/Profile/BoltAddressTranslation.h @@ -122,6 +122,10 @@ class BoltAddressTranslation { /// Returns BF hash by function output address (after BOLT). size_t getBFHash(uint64_t OutputAddress) const; + /// Returns BB index by function output address (after BOLT) and basic block + /// input offset. + unsigned getBBIndex(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const; + /// True if a given \p Address is a function with translation table entry. bool isBATFunction(uint64_t Address) const { return Maps.count(Address); } @@ -154,7 +158,8 @@ class BoltAddressTranslation { std::map Maps; - using BBHashMap = std::unordered_map; + /// Map basic block input offset to a basic block index and hash pair. + using BBHashMap = std::unordered_map>; std::unordered_map> FuncHashes; /// Links outlined cold bocks to their original function diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 1d61a1b735b40..8fe976cc00e53 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -45,6 +45,8 @@ void BoltAddressTranslation::writeEntriesForBB(MapTy &Map, LLVM_DEBUG(dbgs() << formatv(" Hash: {0:x}\n", getBBHash(HotFuncAddress, BBInputOffset))); (void)HotFuncAddress; + LLVM_DEBUG(dbgs() << formatv(" Index: {0}\n", + getBBIndex(HotFuncAddress, BBInputOffset))); // In case of conflicts (same Key mapping to different Vals), the last // update takes precedence. Of course it is not ideal to have conflicts and // those happen when we have an empty BB that either contained only @@ -217,6 +219,7 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, } size_t Index = 0; uint64_t InOffset = 0; + size_t PrevBBIndex = 0; // Output and Input addresses and delta-encoded for (std::pair &KeyVal : Map) { const uint64_t OutputAddress = KeyVal.first + Address; @@ -226,11 +229,15 @@ void BoltAddressTranslation::writeMaps(std::map &Maps, encodeSLEB128(KeyVal.second - InOffset, OS); InOffset = KeyVal.second; // Keeping InOffset as if BRANCHENTRY is encoded if ((InOffset & BRANCHENTRY) == 0) { - // Basic block hash - size_t BBHash = FuncHashPair.second[InOffset >> 1]; + unsigned BBIndex; + size_t BBHash; + std::tie(BBIndex, BBHash) = FuncHashPair.second[InOffset >> 1]; OS.write(reinterpret_cast(&BBHash), 8); - LLVM_DEBUG(dbgs() << formatv("{0:x} -> {1:x} {2:x}\n", KeyVal.first, - InOffset >> 1, BBHash)); + // Basic block index in the input binary + encodeULEB128(BBIndex - PrevBBIndex, OS); + PrevBBIndex = BBIndex; + LLVM_DEBUG(dbgs() << formatv("{0:x} -> {1:x} {2:x} {3}\n", KeyVal.first, + InOffset >> 1, BBHash, BBIndex)); } } } @@ -316,6 +323,7 @@ void BoltAddressTranslation::parseMaps(std::vector &HotFuncs, LLVM_DEBUG(dbgs() << "Parsing " << NumEntries << " entries for 0x" << Twine::utohexstr(Address) << "\n"); uint64_t InputOffset = 0; + size_t BBIndex = 0; for (uint32_t J = 0; J < NumEntries; ++J) { const uint64_t OutputDelta = DE.getULEB128(&Offset, &Err); const uint64_t OutputAddress = PrevAddress + OutputDelta; @@ -330,19 +338,25 @@ void BoltAddressTranslation::parseMaps(std::vector &HotFuncs, } Map.insert(std::pair(OutputOffset, InputOffset)); size_t BBHash = 0; + size_t BBIndexDelta = 0; const bool IsBranchEntry = InputOffset & BRANCHENTRY; if (!IsBranchEntry) { BBHash = DE.getU64(&Offset, &Err); + BBIndexDelta = DE.getULEB128(&Offset, &Err); + BBIndex += BBIndexDelta; // Map basic block hash to hot fragment by input offset - FuncHashes[HotAddress].second.emplace(InputOffset >> 1, BBHash); + FuncHashes[HotAddress].second.emplace(InputOffset >> 1, + std::pair(BBIndex, BBHash)); } LLVM_DEBUG({ dbgs() << formatv( "{0:x} -> {1:x} ({2}/{3}b -> {4}/{5}b), {6:x}", OutputOffset, InputOffset, OutputDelta, getULEB128Size(OutputDelta), InputDelta, (J < EqualElems) ? 0 : getSLEB128Size(InputDelta), OutputAddress); - if (BBHash) - dbgs() << formatv(" {0:x}", BBHash); + if (!IsBranchEntry) { + dbgs() << formatv(" {0:x} {1}/{2}b", BBHash, BBIndex, + getULEB128Size(BBIndexDelta)); + } dbgs() << '\n'; }); } @@ -494,14 +508,19 @@ void BoltAddressTranslation::saveMetadata(BinaryContext &BC) { FuncHashes[BF.getAddress()].first = BF.computeHash(); BF.computeBlockHashes(); for (const BinaryBasicBlock &BB : BF) - FuncHashes[BF.getAddress()].second.emplace(BB.getInputOffset(), - BB.getHash()); + FuncHashes[BF.getAddress()].second.emplace( + BB.getInputOffset(), std::pair(BB.getIndex(), BB.getHash())); } } +unsigned BoltAddressTranslation::getBBIndex(uint64_t FuncOutputAddress, + uint32_t BBInputOffset) const { + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).first; +} + size_t BoltAddressTranslation::getBBHash(uint64_t FuncOutputAddress, uint32_t BBInputOffset) const { - return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset); + return FuncHashes.at(FuncOutputAddress).second.at(BBInputOffset).second; } size_t BoltAddressTranslation::getBFHash(uint64_t OutputAddress) const { diff --git a/bolt/test/X86/bolt-address-translation-yaml.test b/bolt/test/X86/bolt-address-translation-yaml.test index 25ff4e7fbfcc5..4516a662697ac 100644 --- a/bolt/test/X86/bolt-address-translation-yaml.test +++ b/bolt/test/X86/bolt-address-translation-yaml.test @@ -18,7 +18,7 @@ RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes -WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 344 +WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 376 READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries diff --git a/bolt/test/X86/bolt-address-translation.test b/bolt/test/X86/bolt-address-translation.test index 4277b4e0d0fef..5c1db89e3c6b2 100644 --- a/bolt/test/X86/bolt-address-translation.test +++ b/bolt/test/X86/bolt-address-translation.test @@ -37,7 +37,7 @@ # CHECK: BOLT: 3 out of 7 functions were overwritten. # CHECK: BOLT-INFO: Wrote 6 BAT maps # CHECK: BOLT-INFO: Wrote 3 function and 58 basic block hashes -# CHECK: BOLT-INFO: BAT section size (bytes): 816 +# CHECK: BOLT-INFO: BAT section size (bytes): 920 # # usqrt mappings (hot part). We match against any key (left side containing # the bolted binary offsets) because BOLT may change where it puts instructions diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 86a287db72a4e..bc9cc8ce6cf5a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5863,8 +5863,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, } else if (Triple.getArch() == llvm::Triple::x86_64) { Ok = llvm::is_contained({"small", "kernel", "medium", "large", "tiny"}, CM); - } else if (Triple.isNVPTX() || Triple.isAMDGPU() || Triple.isSPIRV()) { - // NVPTX/AMDGPU/SPIRV does not care about the code model and will accept + } else if (Triple.isNVPTX() || Triple.isAMDGPU()) { + // NVPTX/AMDGPU does not care about the code model and will accept // whatever works for the host. Ok = true; } else if (Triple.isSPARC64()) { diff --git a/clang/test/Driver/unsupported-option-gpu.c b/clang/test/Driver/unsupported-option-gpu.c index 5618b2cba72e1..f23cb71ebfb08 100644 --- a/clang/test/Driver/unsupported-option-gpu.c +++ b/clang/test/Driver/unsupported-option-gpu.c @@ -2,5 +2,4 @@ // DEFINE: %{check} = %clang -### --target=x86_64-linux-gnu -c -mcmodel=medium // RUN: %{check} -x cuda %s --cuda-path=%S/Inputs/CUDA/usr/local/cuda --offload-arch=sm_60 --no-cuda-version-check -fbasic-block-sections=all -// RUN: %{check} -x hip %s --offload=spirv64 -nogpulib -nogpuinc // RUN: %{check} -x hip %s --rocm-path=%S/Inputs/rocm -nogpulib -nogpuinc diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index 919a14b8bcf08..36248925d65ad 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -612,7 +612,7 @@ static void replaceCommonSymbols() { if (!osec) osec = ConcatOutputSection::getOrCreateForInput(isec); isec->parent = osec; - addInputSection(isec); + inputSections.push_back(isec); // FIXME: CommonSymbol should store isReferencedDynamically, noDeadStrip // and pass them on here. @@ -1220,18 +1220,53 @@ static void createFiles(const InputArgList &args) { static void gatherInputSections() { TimeTraceScope timeScope("Gathering input sections"); + int inputOrder = 0; for (const InputFile *file : inputFiles) { for (const Section *section : file->sections) { // Compact unwind entries require special handling elsewhere. (In // contrast, EH frames are handled like regular ConcatInputSections.) if (section->name == section_names::compactUnwind) continue; - for (const Subsection &subsection : section->subsections) - addInputSection(subsection.isec); + ConcatOutputSection *osec = nullptr; + for (const Subsection &subsection : section->subsections) { + if (auto *isec = dyn_cast(subsection.isec)) { + if (isec->isCoalescedWeak()) + continue; + if (config->emitInitOffsets && + sectionType(isec->getFlags()) == S_MOD_INIT_FUNC_POINTERS) { + in.initOffsets->addInput(isec); + continue; + } + isec->outSecOff = inputOrder++; + if (!osec) + osec = ConcatOutputSection::getOrCreateForInput(isec); + isec->parent = osec; + inputSections.push_back(isec); + } else if (auto *isec = + dyn_cast(subsection.isec)) { + if (isec->getName() == section_names::objcMethname) { + if (in.objcMethnameSection->inputOrder == UnspecifiedInputOrder) + in.objcMethnameSection->inputOrder = inputOrder++; + in.objcMethnameSection->addInput(isec); + } else { + if (in.cStringSection->inputOrder == UnspecifiedInputOrder) + in.cStringSection->inputOrder = inputOrder++; + in.cStringSection->addInput(isec); + } + } else if (auto *isec = + dyn_cast(subsection.isec)) { + if (in.wordLiteralSection->inputOrder == UnspecifiedInputOrder) + in.wordLiteralSection->inputOrder = inputOrder++; + in.wordLiteralSection->addInput(isec); + } else { + llvm_unreachable("unexpected input section kind"); + } + } } if (!file->objCImageInfo.empty()) in.objCImageInfo->addFile(file); } + assert(inputOrder <= UnspecifiedInputOrder); } static void foldIdenticalLiterals() { @@ -1387,7 +1422,6 @@ bool link(ArrayRef argsArr, llvm::raw_ostream &stdoutOS, concatOutputSections.clear(); inputFiles.clear(); inputSections.clear(); - inputSectionsOrder = 0; loadedArchives.clear(); loadedObjectFrameworks.clear(); missingAutolinkWarnings.clear(); diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp index 22930d52dd1db..8f5affb1dc21d 100644 --- a/lld/MachO/InputSection.cpp +++ b/lld/MachO/InputSection.cpp @@ -37,44 +37,6 @@ static_assert(sizeof(void *) != 8 || "instances of it"); std::vector macho::inputSections; -int macho::inputSectionsOrder = 0; - -// Call this function to add a new InputSection and have it routed to the -// appropriate container. Depending on its type and current config, it will -// either be added to 'inputSections' vector or to a synthetic section. -void lld::macho::addInputSection(InputSection *inputSection) { - if (auto *isec = dyn_cast(inputSection)) { - if (isec->isCoalescedWeak()) - return; - if (config->emitInitOffsets && - sectionType(isec->getFlags()) == S_MOD_INIT_FUNC_POINTERS) { - in.initOffsets->addInput(isec); - return; - } - isec->outSecOff = inputSectionsOrder++; - auto *osec = ConcatOutputSection::getOrCreateForInput(isec); - isec->parent = osec; - inputSections.push_back(isec); - } else if (auto *isec = dyn_cast(inputSection)) { - if (isec->getName() == section_names::objcMethname) { - if (in.objcMethnameSection->inputOrder == UnspecifiedInputOrder) - in.objcMethnameSection->inputOrder = inputSectionsOrder++; - in.objcMethnameSection->addInput(isec); - } else { - if (in.cStringSection->inputOrder == UnspecifiedInputOrder) - in.cStringSection->inputOrder = inputSectionsOrder++; - in.cStringSection->addInput(isec); - } - } else if (auto *isec = dyn_cast(inputSection)) { - if (in.wordLiteralSection->inputOrder == UnspecifiedInputOrder) - in.wordLiteralSection->inputOrder = inputSectionsOrder++; - in.wordLiteralSection->addInput(isec); - } else { - llvm_unreachable("unexpected input section kind"); - } - - assert(inputSectionsOrder <= UnspecifiedInputOrder); -} uint64_t InputSection::getFileSize() const { return isZeroFill(getFlags()) ? 0 : getSize(); diff --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h index 694bdf734907b..b25f0638f4c6c 100644 --- a/lld/MachO/InputSection.h +++ b/lld/MachO/InputSection.h @@ -302,8 +302,6 @@ bool isEhFrameSection(const InputSection *); bool isGccExceptTabSection(const InputSection *); extern std::vector inputSections; -// This is used as a counter for specyfing input order for input sections -extern int inputSectionsOrder; namespace section_names { @@ -371,7 +369,6 @@ constexpr const char addrSig[] = "__llvm_addrsig"; } // namespace section_names -void addInputSection(InputSection *inputSection); } // namespace macho std::string toString(const macho::InputSection *); diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp index 5902b82d30f55..40df2243b26f0 100644 --- a/lld/MachO/ObjC.cpp +++ b/lld/MachO/ObjC.cpp @@ -790,7 +790,7 @@ void ObjcCategoryMerger::emitAndLinkProtocolList( infoCategoryWriter.catPtrListInfo.align); listSec->parent = infoCategoryWriter.catPtrListInfo.outputSection; listSec->live = true; - addInputSection(listSec); + allInputSections.push_back(listSec); listSec->parent = infoCategoryWriter.catPtrListInfo.outputSection; @@ -848,7 +848,7 @@ void ObjcCategoryMerger::emitAndLinkPointerList( infoCategoryWriter.catPtrListInfo.align); listSec->parent = infoCategoryWriter.catPtrListInfo.outputSection; listSec->live = true; - addInputSection(listSec); + allInputSections.push_back(listSec); listSec->parent = infoCategoryWriter.catPtrListInfo.outputSection; @@ -889,7 +889,7 @@ ObjcCategoryMerger::emitCatListEntrySec(const std::string &forCateogryName, bodyData, infoCategoryWriter.catListInfo.align); newCatList->parent = infoCategoryWriter.catListInfo.outputSection; newCatList->live = true; - addInputSection(newCatList); + allInputSections.push_back(newCatList); newCatList->parent = infoCategoryWriter.catListInfo.outputSection; @@ -927,7 +927,7 @@ Defined *ObjcCategoryMerger::emitCategoryBody(const std::string &name, bodyData, infoCategoryWriter.catBodyInfo.align); newBodySec->parent = infoCategoryWriter.catBodyInfo.outputSection; newBodySec->live = true; - addInputSection(newBodySec); + allInputSections.push_back(newBodySec); std::string symName = objc::symbol_names::category + baseClassName + "_$_(" + name + ")"; @@ -1132,7 +1132,7 @@ void ObjcCategoryMerger::generateCatListForNonErasedCategories( infoCategoryWriter.catListInfo.align); listSec->parent = infoCategoryWriter.catListInfo.outputSection; listSec->live = true; - addInputSection(listSec); + allInputSections.push_back(listSec); std::string slotSymName = "<__objc_catlist slot for category "; slotSymName += nonErasedCatBody->getName(); @@ -1221,11 +1221,9 @@ void ObjcCategoryMerger::doCleanup() { generatedSectionData.clear(); } StringRef ObjcCategoryMerger::newStringData(const char *str) { uint32_t len = strlen(str); - uint32_t bufSize = len + 1; - auto &data = newSectionData(bufSize); + auto &data = newSectionData(len + 1); char *strData = reinterpret_cast(data.data()); - // Copy the string chars and null-terminator - memcpy(strData, str, bufSize); + strncpy(strData, str, len); return StringRef(strData, len); } diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp index 1b3694528de1d..7ee3261ce3075 100644 --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -793,7 +793,7 @@ void StubHelperSection::setUp() { in.imageLoaderCache->parent = ConcatOutputSection::getOrCreateForInput(in.imageLoaderCache); - addInputSection(in.imageLoaderCache); + inputSections.push_back(in.imageLoaderCache); // Since this isn't in the symbol table or in any input file, the noDeadStrip // argument doesn't matter. dyldPrivate = @@ -855,7 +855,7 @@ ConcatInputSection *ObjCSelRefsSection::makeSelRef(StringRef methname) { /*addend=*/static_cast(methnameOffset), /*referent=*/in.objcMethnameSection->isec}); objcSelref->parent = ConcatOutputSection::getOrCreateForInput(objcSelref); - addInputSection(objcSelref); + inputSections.push_back(objcSelref); objcSelref->isFinal = true; methnameToSelref[CachedHashStringRef(methname)] = objcSelref; return objcSelref; diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h index ba882c4a6f328..532f9481766a9 100644 --- a/llvm/include/llvm/BinaryFormat/DXContainer.h +++ b/llvm/include/llvm/BinaryFormat/DXContainer.h @@ -424,19 +424,6 @@ struct ResourceBindInfo : public v0::ResourceBindInfo { }; } // namespace v2 - -namespace v3 { -struct RuntimeInfo : public v2::RuntimeInfo { - uint32_t EntryNameOffset; - - void swapBytes() { sys::swapByteOrder(EntryNameOffset); } - - void swapBytes(Triple::EnvironmentType Stage) { - v2::RuntimeInfo::swapBytes(Stage); - } -}; - -} // namespace v3 } // namespace PSV #define COMPONENT_PRECISION(Val, Enum) Enum = Val, diff --git a/llvm/include/llvm/MC/DXContainerPSVInfo.h b/llvm/include/llvm/MC/DXContainerPSVInfo.h index bad2fe78eb8fb..7d21c18d252f1 100644 --- a/llvm/include/llvm/MC/DXContainerPSVInfo.h +++ b/llvm/include/llvm/MC/DXContainerPSVInfo.h @@ -9,11 +9,9 @@ #ifndef LLVM_MC_DXCONTAINERPSVINFO_H #define LLVM_MC_DXCONTAINERPSVINFO_H -#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/DXContainer.h" -#include "llvm/MC/StringTableBuilder.h" #include "llvm/TargetParser/Triple.h" #include @@ -47,9 +45,8 @@ struct PSVSignatureElement { // modifiable format, and can be used to serialize the data back into valid PSV // RuntimeInfo. struct PSVRuntimeInfo { - PSVRuntimeInfo() : DXConStrTabBuilder(StringTableBuilder::DXContainer) {} bool IsFinalized = false; - dxbc::PSV::v3::RuntimeInfo BaseData; + dxbc::PSV::v2::RuntimeInfo BaseData; SmallVector Resources; SmallVector InputElements; SmallVector OutputElements; @@ -67,7 +64,6 @@ struct PSVRuntimeInfo { std::array, 4> InputOutputMap; SmallVector InputPatchMap; SmallVector PatchOutputMap; - llvm::StringRef EntryName; // Serialize PSVInfo into the provided raw_ostream. The version field // specifies the data version to encode, the default value specifies encoding @@ -75,12 +71,19 @@ struct PSVRuntimeInfo { void write(raw_ostream &OS, uint32_t Version = std::numeric_limits::max()) const; - void finalize(Triple::EnvironmentType Stage); - -private: - SmallVector IndexBuffer; - SmallVector SignatureElements; - StringTableBuilder DXConStrTabBuilder; + void finalize(Triple::EnvironmentType Stage) { + IsFinalized = true; + BaseData.SigInputElements = static_cast(InputElements.size()); + BaseData.SigOutputElements = static_cast(OutputElements.size()); + BaseData.SigPatchOrPrimElements = + static_cast(PatchOrPrimElements.size()); + if (!sys::IsBigEndianHost) + return; + BaseData.swapBytes(); + BaseData.swapBytes(Stage); + for (auto &Res : Resources) + Res.swapBytes(); + } }; class Signature { diff --git a/llvm/include/llvm/MC/StringTableBuilder.h b/llvm/include/llvm/MC/StringTableBuilder.h index a738683548cfa..4ee421e22c171 100644 --- a/llvm/include/llvm/MC/StringTableBuilder.h +++ b/llvm/include/llvm/MC/StringTableBuilder.h @@ -74,8 +74,12 @@ class StringTableBuilder { /// Check if a string is contained in the string table. Since this class /// doesn't store the string values, this function can be used to check if /// storage needs to be done prior to adding the string. - bool contains(StringRef S) const { return contains(CachedHashStringRef(S)); } - bool contains(CachedHashStringRef S) const { return StringIndexMap.count(S); } + bool contains(StringRef S) const { + return contains(CachedHashStringRef(S)); + } + bool contains(CachedHashStringRef S) const { + return StringIndexMap.count(S); + } size_t getSize() const { return Size; } void clear(); diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h index 19c83ba6c6e85..b6e3d321da246 100644 --- a/llvm/include/llvm/Object/DXContainer.h +++ b/llvm/include/llvm/Object/DXContainer.h @@ -125,8 +125,7 @@ class PSVRuntimeInfo { uint32_t Size; using InfoStruct = std::variant; + dxbc::PSV::v1::RuntimeInfo, dxbc::PSV::v2::RuntimeInfo>; InfoStruct BasicInfo; ResourceArray Resources; StringRef StringTable; @@ -152,11 +151,9 @@ class PSVRuntimeInfo { ResourceArray getResources() const { return Resources; } uint32_t getVersion() const { - return Size >= sizeof(dxbc::PSV::v3::RuntimeInfo) - ? 3 - : (Size >= sizeof(dxbc::PSV::v2::RuntimeInfo) ? 2 - : (Size >= sizeof(dxbc::PSV::v1::RuntimeInfo)) ? 1 - : 0); + return Size >= sizeof(dxbc::PSV::v2::RuntimeInfo) + ? 2 + : (Size >= sizeof(dxbc::PSV::v1::RuntimeInfo) ? 1 : 0); } uint32_t getResourceStride() const { return Resources.Stride; } @@ -164,11 +161,6 @@ class PSVRuntimeInfo { const InfoStruct &getInfo() const { return BasicInfo; } template const T *getInfoAs() const { - if (const auto *P = std::get_if(&BasicInfo)) - return static_cast(P); - if (std::is_same::value) - return nullptr; - if (const auto *P = std::get_if(&BasicInfo)) return static_cast(P); if (std::is_same::value) diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h index 9c4d9e19f11ba..f7f8d5e6bf472 100644 --- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h +++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h @@ -107,7 +107,7 @@ struct PSVInfo { // the format. uint32_t Version; - dxbc::PSV::v3::RuntimeInfo Info; + dxbc::PSV::v2::RuntimeInfo Info; uint32_t ResourceStride; SmallVector Resources; SmallVector SigInputElements; @@ -121,15 +121,12 @@ struct PSVInfo { MaskVector InputPatchMap; MaskVector PatchOutputMap; - StringRef EntryName; - void mapInfoForVersion(yaml::IO &IO); PSVInfo(); PSVInfo(const dxbc::PSV::v0::RuntimeInfo *P, uint16_t Stage); PSVInfo(const dxbc::PSV::v1::RuntimeInfo *P); PSVInfo(const dxbc::PSV::v2::RuntimeInfo *P); - PSVInfo(const dxbc::PSV::v3::RuntimeInfo *P, StringRef StringTable); }; struct SignatureParameter { diff --git a/llvm/lib/MC/DXContainerPSVInfo.cpp b/llvm/lib/MC/DXContainerPSVInfo.cpp index aeff693801397..48182fcd31df0 100644 --- a/llvm/lib/MC/DXContainerPSVInfo.cpp +++ b/llvm/lib/MC/DXContainerPSVInfo.cpp @@ -81,18 +81,13 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { BindingSize = sizeof(dxbc::PSV::v0::ResourceBindInfo); break; case 2: - InfoSize = sizeof(dxbc::PSV::v2::RuntimeInfo); - BindingSize = sizeof(dxbc::PSV::v2::ResourceBindInfo); - break; - case 3: default: - InfoSize = sizeof(dxbc::PSV::v3::RuntimeInfo); + InfoSize = sizeof(dxbc::PSV::v2::RuntimeInfo); BindingSize = sizeof(dxbc::PSV::v2::ResourceBindInfo); } - // Write the size of the info. - support::endian::write(OS, InfoSize, llvm::endianness::little); + support::endian::write(OS, InfoSize, llvm::endianness::little); // Write the info itself. OS.write(reinterpret_cast(&BaseData), InfoSize); @@ -109,12 +104,32 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { if (Version == 0) return; - support::endian::write(OS, - static_cast(DXConStrTabBuilder.getSize()), + StringTableBuilder StrTabBuilder((StringTableBuilder::DXContainer)); + SmallVector IndexBuffer; + SmallVector SignatureElements; + SmallVector SemanticNames; + + ProcessElementList(StrTabBuilder, IndexBuffer, SignatureElements, + SemanticNames, InputElements); + ProcessElementList(StrTabBuilder, IndexBuffer, SignatureElements, + SemanticNames, OutputElements); + ProcessElementList(StrTabBuilder, IndexBuffer, SignatureElements, + SemanticNames, PatchOrPrimElements); + + StrTabBuilder.finalize(); + for (auto ElAndName : zip(SignatureElements, SemanticNames)) { + v0::SignatureElement &El = std::get<0>(ElAndName); + StringRef Name = std::get<1>(ElAndName); + El.NameOffset = static_cast(StrTabBuilder.getOffset(Name)); + if (sys::IsBigEndianHost) + El.swapBytes(); + } + + support::endian::write(OS, static_cast(StrTabBuilder.getSize()), llvm::endianness::little); // Write the string table. - DXConStrTabBuilder.write(OS); + StrTabBuilder.write(OS); // Write the index table size, then table. support::endian::write(OS, static_cast(IndexBuffer.size()), @@ -147,46 +162,6 @@ void PSVRuntimeInfo::write(raw_ostream &OS, uint32_t Version) const { llvm::endianness::little); } -void PSVRuntimeInfo::finalize(Triple::EnvironmentType Stage) { - IsFinalized = true; - BaseData.SigInputElements = static_cast(InputElements.size()); - BaseData.SigOutputElements = static_cast(OutputElements.size()); - BaseData.SigPatchOrPrimElements = - static_cast(PatchOrPrimElements.size()); - - SmallVector SemanticNames; - - // Build a string table and set associated offsets to be written when - // write() is called - ProcessElementList(DXConStrTabBuilder, IndexBuffer, SignatureElements, - SemanticNames, InputElements); - ProcessElementList(DXConStrTabBuilder, IndexBuffer, SignatureElements, - SemanticNames, OutputElements); - ProcessElementList(DXConStrTabBuilder, IndexBuffer, SignatureElements, - SemanticNames, PatchOrPrimElements); - - DXConStrTabBuilder.add(EntryName); - - DXConStrTabBuilder.finalize(); - for (auto ElAndName : zip(SignatureElements, SemanticNames)) { - llvm::dxbc::PSV::v0::SignatureElement &El = std::get<0>(ElAndName); - StringRef Name = std::get<1>(ElAndName); - El.NameOffset = static_cast(DXConStrTabBuilder.getOffset(Name)); - if (sys::IsBigEndianHost) - El.swapBytes(); - } - - BaseData.EntryNameOffset = - static_cast(DXConStrTabBuilder.getOffset(EntryName)); - - if (!sys::IsBigEndianHost) - return; - BaseData.swapBytes(); - BaseData.swapBytes(Stage); - for (auto &Res : Resources) - Res.swapBytes(); -} - void Signature::write(raw_ostream &OS) { SmallVector SigParams; SigParams.reserve(Params.size()); diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp index 3b1a6203a1f8f..935749afe3385 100644 --- a/llvm/lib/Object/DXContainer.cpp +++ b/llvm/lib/Object/DXContainer.cpp @@ -247,14 +247,7 @@ Error DirectX::PSVRuntimeInfo::parse(uint16_t ShaderKind) { const uint32_t PSVVersion = getVersion(); // Detect the PSVVersion by looking at the size field. - if (PSVVersion == 3) { - v3::RuntimeInfo Info; - if (Error Err = readStruct(PSVInfoData, Current, Info)) - return Err; - if (sys::IsBigEndianHost) - Info.swapBytes(ShaderStage); - BasicInfo = Info; - } else if (PSVVersion == 2) { + if (PSVVersion == 2) { v2::RuntimeInfo Info; if (Error Err = readStruct(PSVInfoData, Current, Info)) return Err; @@ -432,8 +425,6 @@ Error DirectX::PSVRuntimeInfo::parse(uint16_t ShaderKind) { } uint8_t DirectX::PSVRuntimeInfo::getSigInputCount() const { - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigInputElements; if (const auto *P = std::get_if(&BasicInfo)) return P->SigInputElements; if (const auto *P = std::get_if(&BasicInfo)) @@ -442,8 +433,6 @@ uint8_t DirectX::PSVRuntimeInfo::getSigInputCount() const { } uint8_t DirectX::PSVRuntimeInfo::getSigOutputCount() const { - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigOutputElements; if (const auto *P = std::get_if(&BasicInfo)) return P->SigOutputElements; if (const auto *P = std::get_if(&BasicInfo)) @@ -452,8 +441,6 @@ uint8_t DirectX::PSVRuntimeInfo::getSigOutputCount() const { } uint8_t DirectX::PSVRuntimeInfo::getSigPatchOrPrimCount() const { - if (const auto *P = std::get_if(&BasicInfo)) - return P->SigPatchOrPrimElements; if (const auto *P = std::get_if(&BasicInfo)) return P->SigPatchOrPrimElements; if (const auto *P = std::get_if(&BasicInfo)) diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp index f3a518df31750..09a5e41c71234 100644 --- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp +++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp @@ -198,9 +198,8 @@ void DXContainerWriter::writeParts(raw_ostream &OS) { if (!P.Info.has_value()) continue; mcdxbc::PSVRuntimeInfo PSV; - memcpy(&PSV.BaseData, &P.Info->Info, sizeof(dxbc::PSV::v3::RuntimeInfo)); + memcpy(&PSV.BaseData, &P.Info->Info, sizeof(dxbc::PSV::v2::RuntimeInfo)); PSV.Resources = P.Info->Resources; - PSV.EntryName = P.Info->EntryName; for (auto El : P.Info->SigInputElements) PSV.InputElements.push_back(mcdxbc::PSVSignatureElement{ diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp index 38063670aee6e..a6871e7855e4e 100644 --- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp +++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp @@ -74,16 +74,6 @@ DXContainerYAML::PSVInfo::PSVInfo(const dxbc::PSV::v2::RuntimeInfo *P) memcpy(&Info, P, sizeof(dxbc::PSV::v2::RuntimeInfo)); } -DXContainerYAML::PSVInfo::PSVInfo(const dxbc::PSV::v3::RuntimeInfo *P, - StringRef StringTable) - : Version(3), - EntryName(StringTable.substr(P->EntryNameOffset, - StringTable.find('\0', P->EntryNameOffset) - - P->EntryNameOffset)) { - memset(&Info, 0, sizeof(Info)); - memcpy(&Info, P, sizeof(dxbc::PSV::v3::RuntimeInfo)); -} - namespace yaml { void MappingTraits::mapping( @@ -358,11 +348,6 @@ void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) { IO.mapRequired("NumThreadsX", Info.NumThreadsX); IO.mapRequired("NumThreadsY", Info.NumThreadsY); IO.mapRequired("NumThreadsZ", Info.NumThreadsZ); - - if (Version == 2) - return; - - IO.mapRequired("EntryName", EntryName); } } // namespace llvm diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-amplification.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-amplification.yaml deleted file mode 100644 index 09885bd529f05..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-amplification.yaml +++ /dev/null @@ -1,97 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 14 - PayloadSizeInBytes: 4092 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigInputVectors: 0 - SigOutputVectors: [ 8, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: ASEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 14 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 14 -# CHECK-NEXT: PayloadSizeInBytes: 4092 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: ASEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-compute.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-compute.yaml deleted file mode 100644 index ee6fb112c7722..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-compute.yaml +++ /dev/null @@ -1,95 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 5 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigInputVectors: 0 - SigOutputVectors: [ 8, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: CSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 5 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 5 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: CSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-domain.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-domain.yaml deleted file mode 100644 index dd367deae88e4..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-domain.yaml +++ /dev/null @@ -1,105 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 4 - InputControlPointCount: 1024 - OutputPositionPresent: 1 - TessellatorDomain: 2056 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigPatchConstOrPrimVectors: 0 - SigInputVectors: 0 - SigOutputVectors: [ 0, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: DSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - PatchOutputMap: [] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 4 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 4 -# CHECK-NEXT: InputControlPointCount: 1024 -# CHECK-NEXT: OutputPositionPresent: 1 -# CHECK-NEXT: TessellatorDomain: 2056 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigPatchConstOrPrimVectors: 0 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 0, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: DSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: PatchOutputMap: [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-geometry.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-geometry.yaml deleted file mode 100644 index 4c7680b63b02b..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-geometry.yaml +++ /dev/null @@ -1,105 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 2 - InputPrimitive: 1024 - OutputTopology: 4096 - OutputStreamMask: 2056 - OutputPositionPresent: 1 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - MaxVertexCount: 4096 - SigInputVectors: 0 - SigOutputVectors: [ 8, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: GSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 2 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 2 -# CHECK-NEXT: InputPrimitive: 1024 -# CHECK-NEXT: OutputTopology: 4096 -# CHECK-NEXT: OutputStreamMask: 2056 -# CHECK-NEXT: OutputPositionPresent: 1 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: MaxVertexCount: 4096 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: GSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-hull.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-hull.yaml deleted file mode 100644 index 3bbad8a9b0ee6..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-hull.yaml +++ /dev/null @@ -1,107 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 3 - InputControlPointCount: 1024 - OutputControlPointCount: 4096 - TessellatorDomain: 2056 - TessellatorOutputPrimitive: 8192 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigPatchConstOrPrimVectors: 0 - SigInputVectors: 0 - SigOutputVectors: [ 0, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: HSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - InputPatchMap: [] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 3 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 3 -# CHECK-NEXT: InputControlPointCount: 1024 -# CHECK-NEXT: OutputControlPointCount: 4096 -# CHECK-NEXT: TessellatorDomain: 2056 -# CHECK-NEXT: TessellatorOutputPrimitive: 8192 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigPatchConstOrPrimVectors: 0 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 0, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: HSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: InputPatchMap: [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-mesh.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-mesh.yaml deleted file mode 100644 index c5ea1fcf07808..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-mesh.yaml +++ /dev/null @@ -1,109 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 13 - GroupSharedBytesUsed: 1024 - GroupSharedBytesDependentOnViewID: 2056 - PayloadSizeInBytes: 4092 - MaxOutputVertices: 8196 - MaxOutputPrimitives: 4092 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigPrimVectors: 128 - MeshOutputTopology: 16 - SigInputVectors: 0 - SigOutputVectors: [ 8, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: MSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 13 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 13 -# CHECK-NEXT: GroupSharedBytesUsed: 1024 -# CHECK-NEXT: GroupSharedBytesDependentOnViewID: 2056 -# CHECK-NEXT: PayloadSizeInBytes: 4092 -# CHECK-NEXT: MaxOutputVertices: 8196 -# CHECK-NEXT: MaxOutputPrimitives: 4092 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigPrimVectors: 128 -# CHECK-NEXT: MeshOutputTopology: 16 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: MSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-pixel.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-pixel.yaml deleted file mode 100644 index b28d5ec8074d8..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-pixel.yaml +++ /dev/null @@ -1,99 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 0 - DepthOutput: 7 - SampleFrequency: 96 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigInputVectors: 0 - SigOutputVectors: [ 8, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: PSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 0 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 0 -# CHECK-NEXT: DepthOutput: 7 -# CHECK-NEXT: SampleFrequency: 96 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: PSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: Name diff --git a/llvm/test/ObjectYAML/DXContainer/PSVv3-vertex.yaml b/llvm/test/ObjectYAML/DXContainer/PSVv3-vertex.yaml deleted file mode 100644 index d1fb55839931c..0000000000000 --- a/llvm/test/ObjectYAML/DXContainer/PSVv3-vertex.yaml +++ /dev/null @@ -1,97 +0,0 @@ -# RUN: yaml2obj %s | obj2yaml | FileCheck %s - ---- !dxcontainer -Header: - Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] - Version: - Major: 1 - Minor: 0 - PartCount: 2 -Parts: - - Name: PSV0 - Size: 144 - PSVInfo: - Version: 3 - ShaderStage: 1 - OutputPositionPresent: 1 - MinimumWaveLaneCount: 0 - MaximumWaveLaneCount: 4294967295 - UsesViewID: 0 - SigInputVectors: 0 - SigOutputVectors: [ 8, 16, 32, 64 ] - NumThreadsX: 512 - NumThreadsY: 1024 - NumThreadsZ: 2048 - EntryName: VSEntry - ResourceStride: 24 - Resources: - - Type: 1 - Space: 2 - LowerBound: 3 - UpperBound: 4 - Kind: 5 - Flags: 6 - - Type: 128 - Space: 32768 - LowerBound: 8388608 - UpperBound: 2147483648 - Kind: 65535 - Flags: 16776960 - SigInputElements: [] - SigOutputElements: [] - SigPatchOrPrimElements: [] - InputOutputMap: - - [ ] - - [ ] - - [ ] - - [ ] - - Name: DXIL - Size: 24 - Program: - MajorVersion: 6 - MinorVersion: 0 - ShaderKind: 1 - Size: 6 - DXILMajorVersion: 0 - DXILMinorVersion: 1 - DXILSize: 0 -... - -# CHECK: Name: PSV0 -# CHECK: PSVInfo: -# CHECK-NEXT: Version: 3 -# CHECK-NEXT: ShaderStage: 1 -# CHECK-NEXT: OutputPositionPresent: 1 -# CHECK-NEXT: MinimumWaveLaneCount: 0 -# CHECK-NEXT: MaximumWaveLaneCount: 4294967295 -# CHECK-NEXT: UsesViewID: 0 -# CHECK-NEXT: SigInputVectors: 0 -# CHECK-NEXT: SigOutputVectors: [ 8, 16, 32, 64 ] -# CHECK-NEXT: NumThreadsX: 512 -# CHECK-NEXT: NumThreadsY: 1024 -# CHECK-NEXT: NumThreadsZ: 2048 -# CHECK-NEXT: EntryName: VSEntry -# CHECK-NEXT: ResourceStride: 24 -# CHECK-NEXT: Resources: -# CHECK-NEXT: - Type: 1 -# CHECK-NEXT: Space: 2 -# CHECK-NEXT: LowerBound: 3 -# CHECK-NEXT: UpperBound: 4 -# CHECK-NEXT: Kind: 5 -# CHECK-NEXT: Flags: 6 -# CHECK-NEXT: - Type: 128 -# CHECK-NEXT: Space: 32768 -# CHECK-NEXT: LowerBound: 8388608 -# CHECK-NEXT: UpperBound: 2147483648 -# CHECK-NEXT: Kind: 65535 -# CHECK-NEXT: Flags: 16776960 -# CHECK-NEXT: SigInputElements: [] -# CHECK-NEXT: SigOutputElements: [] -# CHECK-NEXT: SigPatchOrPrimElements: [] -# CHECK-NEXT: InputOutputMap: -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: - [ ] -# CHECK-NEXT: Name diff --git a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp index ec4f5c74498f8..69d9b9a2f784f 100644 --- a/llvm/tools/obj2yaml/dxcontainer2yaml.cpp +++ b/llvm/tools/obj2yaml/dxcontainer2yaml.cpp @@ -99,9 +99,6 @@ dumpDXContainer(MemoryBufferRef Source) { else if (const auto *P = std::get_if(&PSVInfo->getInfo())) NewPart.Info = DXContainerYAML::PSVInfo(P); - else if (const auto *P = - std::get_if(&PSVInfo->getInfo())) - NewPart.Info = DXContainerYAML::PSVInfo(P, PSVInfo->getStringTable()); NewPart.Info->ResourceStride = PSVInfo->getResourceStride(); for (auto Res : PSVInfo->getResources()) NewPart.Info->Resources.push_back(Res);