aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/BinaryFormat
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/BinaryFormat')
-rw-r--r--llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp8
-rw-r--r--llvm/lib/BinaryFormat/DXContainer.cpp30
-rw-r--r--llvm/lib/BinaryFormat/Dwarf.cpp19
-rw-r--r--llvm/lib/BinaryFormat/ELF.cpp3
-rw-r--r--llvm/lib/BinaryFormat/Magic.cpp11
-rw-r--r--llvm/lib/BinaryFormat/MsgPackWriter.cpp2
6 files changed, 60 insertions, 13 deletions
diff --git a/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp b/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
index c5ab35d94860..35a79ec04b6e 100644
--- a/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
+++ b/llvm/lib/BinaryFormat/AMDGPUMetadataVerifier.cpp
@@ -14,7 +14,6 @@
#include "llvm/BinaryFormat/AMDGPUMetadataVerifier.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/MsgPackDocument.h"
@@ -57,7 +56,7 @@ bool MetadataVerifier::verifyInteger(msgpack::DocNode &Node) {
bool MetadataVerifier::verifyArray(
msgpack::DocNode &Node, function_ref<bool(msgpack::DocNode &)> verifyNode,
- Optional<size_t> Size) {
+ std::optional<size_t> Size) {
if (!Node.isArray())
return false;
auto &Array = Node.getArray();
@@ -263,6 +262,8 @@ bool MetadataVerifier::verifyKernel(msgpack::DocNode &Node) {
if (!verifyScalarEntry(KernelMap, ".uses_dynamic_stack", false,
msgpack::Type::Boolean))
return false;
+ if (!verifyIntegerEntry(KernelMap, ".workgroup_processor_mode", false))
+ return false;
if (!verifyIntegerEntry(KernelMap, ".kernarg_segment_align", true))
return false;
if (!verifyIntegerEntry(KernelMap, ".wavefront_size", true))
@@ -277,6 +278,9 @@ bool MetadataVerifier::verifyKernel(msgpack::DocNode &Node) {
return false;
if (!verifyIntegerEntry(KernelMap, ".vgpr_spill_count", false))
return false;
+ if (!verifyIntegerEntry(KernelMap, ".uniform_work_group_size", false))
+ return false;
+
return true;
}
diff --git a/llvm/lib/BinaryFormat/DXContainer.cpp b/llvm/lib/BinaryFormat/DXContainer.cpp
new file mode 100644
index 000000000000..60a89c66d28c
--- /dev/null
+++ b/llvm/lib/BinaryFormat/DXContainer.cpp
@@ -0,0 +1,30 @@
+
+//===-- llvm/BinaryFormat/DXContainer.cpp - DXContainer Utils ----*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains utility functions for working with DXContainers.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/BinaryFormat/DXContainer.h"
+#include "llvm/ADT/StringSwitch.h"
+
+using namespace llvm;
+using namespace llvm::dxbc;
+
+dxbc::PartType dxbc::parsePartType(StringRef S) {
+#define CONTAINER_PART(PartName) .Case(#PartName, PartType::PartName)
+ return StringSwitch<dxbc::PartType>(S)
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+ .Default(dxbc::PartType::Unknown);
+}
+
+bool ShaderHash::isPopulated() {
+ static uint8_t Zeros[16] = {0};
+ return Flags > 0 || 0 != memcmp(&Digest, &Zeros, 16);
+}
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index c88425711656..a9bbe41125b1 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -365,10 +365,11 @@ unsigned llvm::dwarf::LanguageVendor(dwarf::SourceLanguage Lang) {
}
}
-Optional<unsigned> llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) {
+std::optional<unsigned>
+llvm::dwarf::LanguageLowerBound(dwarf::SourceLanguage Lang) {
switch (Lang) {
default:
- return None;
+ return std::nullopt;
#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR) \
case DW_LANG_##NAME: \
return LOWER_BOUND;
@@ -691,13 +692,13 @@ StringRef llvm::dwarf::IndexString(unsigned Idx) {
}
}
-Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
- FormParams Params) {
+std::optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
+ FormParams Params) {
switch (Form) {
case DW_FORM_addr:
if (Params)
return Params.AddrSize;
- return None;
+ return std::nullopt;
case DW_FORM_block: // ULEB128 length L followed by L bytes.
case DW_FORM_block1: // 1 byte length L followed by L bytes.
@@ -715,12 +716,12 @@ Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
case DW_FORM_rnglistx: // ULEB128.
case DW_FORM_GNU_addr_index: // ULEB128.
case DW_FORM_GNU_str_index: // ULEB128.
- return None;
+ return std::nullopt;
case DW_FORM_ref_addr:
if (Params)
return Params.getRefAddrByteSize();
- return None;
+ return std::nullopt;
case DW_FORM_flag:
case DW_FORM_data1:
@@ -753,7 +754,7 @@ Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
case DW_FORM_strp_sup:
if (Params)
return Params.getDwarfOffsetByteSize();
- return None;
+ return std::nullopt;
case DW_FORM_data8:
case DW_FORM_ref8:
@@ -775,7 +776,7 @@ Optional<uint8_t> llvm::dwarf::getFixedFormByteSize(dwarf::Form Form,
default:
break;
}
- return None;
+ return std::nullopt;
}
bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version,
diff --git a/llvm/lib/BinaryFormat/ELF.cpp b/llvm/lib/BinaryFormat/ELF.cpp
index e2e601b6d90f..dc8f3051a149 100644
--- a/llvm/lib/BinaryFormat/ELF.cpp
+++ b/llvm/lib/BinaryFormat/ELF.cpp
@@ -197,6 +197,7 @@ uint16_t ELF::convertArchNameToEMachine(StringRef Arch) {
.Case("bpf", EM_BPF)
.Case("ve", EM_VE)
.Case("csky", EM_CSKY)
+ .Case("loongarch", EM_LOONGARCH)
.Default(EM_NONE);
}
@@ -561,6 +562,8 @@ StringRef ELF::convertEMachineToArchName(uint16_t EMachine) {
return "ve";
case EM_CSKY:
return "csky";
+ case EM_LOONGARCH:
+ return "loongarch";
default:
return "None";
}
diff --git a/llvm/lib/BinaryFormat/Magic.cpp b/llvm/lib/BinaryFormat/Magic.cpp
index d45195fb95c5..0e5a5ea279b5 100644
--- a/llvm/lib/BinaryFormat/Magic.cpp
+++ b/llvm/lib/BinaryFormat/Magic.cpp
@@ -182,6 +182,8 @@ file_magic llvm::identify_magic(StringRef Magic) {
return file_magic::macho_dsym_companion;
case 11:
return file_magic::macho_kext_bundle;
+ case 12:
+ return file_magic::macho_file_set;
}
break;
}
@@ -192,13 +194,13 @@ file_magic llvm::identify_magic(StringRef Magic) {
case 0x50: // mc68K
if (startswith(Magic, "\x50\xed\x55\xba"))
return file_magic::cuda_fatbinary;
- LLVM_FALLTHROUGH;
+ [[fallthrough]];
case 0x4c: // 80386 Windows
case 0xc4: // ARMNT Windows
if (Magic[1] == 0x01)
return file_magic::coff_object;
- LLVM_FALLTHROUGH;
+ [[fallthrough]];
case 0x90: // PA-RISC Windows
case 0x68: // mc68K Windows
@@ -236,6 +238,11 @@ file_magic llvm::identify_magic(StringRef Magic) {
return file_magic::dxcontainer_object;
break;
+ case 0x41: // ARM64EC windows
+ if (Magic[1] == char(0xA6))
+ return file_magic::coff_object;
+ break;
+
default:
break;
}
diff --git a/llvm/lib/BinaryFormat/MsgPackWriter.cpp b/llvm/lib/BinaryFormat/MsgPackWriter.cpp
index b4d70e8f78c1..d3b557d00577 100644
--- a/llvm/lib/BinaryFormat/MsgPackWriter.cpp
+++ b/llvm/lib/BinaryFormat/MsgPackWriter.cpp
@@ -14,6 +14,8 @@
#include "llvm/BinaryFormat/MsgPackWriter.h"
#include "llvm/BinaryFormat/MsgPack.h"
+#include <cmath>
+
using namespace llvm;
using namespace msgpack;