From 5c50cbd25a40f8b60e44a2ccc2f1ba3c9e0d0299 Mon Sep 17 00:00:00 2001
From: Dmitry Sidorov <dsidorov@amd.com>
Date: Wed, 13 May 2026 15:01:58 +0200
Subject: [PATCH 10/26] Add SPV_AMD_weak_linkage extension (#583)

Spec is available here KhronosGroup/SPIRV-Registry#401
---
 include/spirv/unified1/spirv.bf                |  2 ++
 include/spirv/unified1/spirv.core.grammar.json | 13 +++++++++++++
 include/spirv/unified1/spirv.cs                |  2 ++
 include/spirv/unified1/spirv.h                 |  4 ++++
 include/spirv/unified1/spirv.hpp               |  4 ++++
 include/spirv/unified1/spirv.hpp11             |  4 ++++
 include/spirv/unified1/spirv.json              |  4 +++-
 include/spirv/unified1/spirv.lua               |  2 ++
 include/spirv/unified1/spirv.py                |  2 ++
 include/spirv/unified1/spv.d                   |  2 ++
 10 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/include/spirv/unified1/spirv.bf b/include/spirv/unified1/spirv.bf
index efd329f..8d0bc34 100644
--- a/include/spirv/unified1/spirv.bf
+++ b/include/spirv/unified1/spirv.bf
@@ -485,6 +485,7 @@ namespace Spv
             Export = 0,
             Import = 1,
             LinkOnceODR = 2,
+            WeakAMD = 3,
             Max = 0x7fffffff,
         }
 
@@ -1238,6 +1239,7 @@ namespace Spv
             DescriptorHeapEXT = 5128,
             ConstantDataKHR = 5146,
             PoisonFreezeKHR = 5156,
+            WeakLinkageAMD = 5181,
             SampleMaskOverrideCoverageNV = 5249,
             GeometryShaderPassthroughNV = 5251,
             ShaderViewportIndexLayerEXT = 5254,
diff --git a/include/spirv/unified1/spirv.core.grammar.json b/include/spirv/unified1/spirv.core.grammar.json
index d8d36df..c84dc2d 100644
--- a/include/spirv/unified1/spirv.core.grammar.json
+++ b/include/spirv/unified1/spirv.core.grammar.json
@@ -14595,6 +14595,12 @@
           "capabilities" : [ "Linkage" ],
           "extensions" : [ "SPV_KHR_linkonce_odr" ],
           "version" : "None"
+        },
+        {
+          "enumerant" : "WeakAMD",
+          "value" : 3,
+          "capabilities" : [ "WeakLinkageAMD" ],
+          "version" : "None"
         }
       ]
     },
@@ -17744,6 +17750,13 @@
           "provisional" : true,
           "version" : "None"
         },
+        {
+          "enumerant" : "WeakLinkageAMD",
+          "value" : 5181,
+          "capabilities" : [ "Linkage" ],
+          "extensions" : [ "SPV_AMD_weak_linkage" ],
+          "version" : "None"
+        },
         {
           "enumerant" : "SampleMaskOverrideCoverageNV",
           "value" : 5249,
diff --git a/include/spirv/unified1/spirv.cs b/include/spirv/unified1/spirv.cs
index 248e593..b0a8f1e 100644
--- a/include/spirv/unified1/spirv.cs
+++ b/include/spirv/unified1/spirv.cs
@@ -484,6 +484,7 @@ namespace Spv
             Export = 0,
             Import = 1,
             LinkOnceODR = 2,
+            WeakAMD = 3,
             Max = 0x7fffffff,
         }
 
@@ -1237,6 +1238,7 @@ namespace Spv
             DescriptorHeapEXT = 5128,
             ConstantDataKHR = 5146,
             PoisonFreezeKHR = 5156,
+            WeakLinkageAMD = 5181,
             SampleMaskOverrideCoverageNV = 5249,
             GeometryShaderPassthroughNV = 5251,
             ShaderViewportIndexLayerEXT = 5254,
diff --git a/include/spirv/unified1/spirv.h b/include/spirv/unified1/spirv.h
index 1759d89..4f76b90 100644
--- a/include/spirv/unified1/spirv.h
+++ b/include/spirv/unified1/spirv.h
@@ -475,6 +475,7 @@ typedef enum SpvLinkageType_ {
     SpvLinkageTypeExport = 0,
     SpvLinkageTypeImport = 1,
     SpvLinkageTypeLinkOnceODR = 2,
+    SpvLinkageTypeWeakAMD = 3,
     SpvLinkageTypeMax = 0x7fffffff,
 } SpvLinkageType;
 
@@ -1208,6 +1209,7 @@ typedef enum SpvCapability_ {
     SpvCapabilityDescriptorHeapEXT = 5128,
     SpvCapabilityConstantDataKHR = 5146,
     SpvCapabilityPoisonFreezeKHR = 5156,
+    SpvCapabilityWeakLinkageAMD = 5181,
     SpvCapabilitySampleMaskOverrideCoverageNV = 5249,
     SpvCapabilityGeometryShaderPassthroughNV = 5251,
     SpvCapabilityShaderViewportIndexLayerEXT = 5254,
@@ -3893,6 +3895,7 @@ inline const char* SpvLinkageTypeToString(SpvLinkageType value) {
     case SpvLinkageTypeExport: return "Export";
     case SpvLinkageTypeImport: return "Import";
     case SpvLinkageTypeLinkOnceODR: return "LinkOnceODR";
+    case SpvLinkageTypeWeakAMD: return "WeakAMD";
     default: return "Unknown";
     }
 }
@@ -4385,6 +4388,7 @@ inline const char* SpvCapabilityToString(SpvCapability value) {
     case SpvCapabilityDescriptorHeapEXT: return "DescriptorHeapEXT";
     case SpvCapabilityConstantDataKHR: return "ConstantDataKHR";
     case SpvCapabilityPoisonFreezeKHR: return "PoisonFreezeKHR";
+    case SpvCapabilityWeakLinkageAMD: return "WeakLinkageAMD";
     case SpvCapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV";
     case SpvCapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
     case SpvCapabilityShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT";
diff --git a/include/spirv/unified1/spirv.hpp b/include/spirv/unified1/spirv.hpp
index e6cc26c..fd64eb7 100644
--- a/include/spirv/unified1/spirv.hpp
+++ b/include/spirv/unified1/spirv.hpp
@@ -471,6 +471,7 @@ enum LinkageType {
     LinkageTypeExport = 0,
     LinkageTypeImport = 1,
     LinkageTypeLinkOnceODR = 2,
+    LinkageTypeWeakAMD = 3,
     LinkageTypeMax = 0x7fffffff,
 };
 
@@ -1204,6 +1205,7 @@ enum Capability {
     CapabilityDescriptorHeapEXT = 5128,
     CapabilityConstantDataKHR = 5146,
     CapabilityPoisonFreezeKHR = 5156,
+    CapabilityWeakLinkageAMD = 5181,
     CapabilitySampleMaskOverrideCoverageNV = 5249,
     CapabilityGeometryShaderPassthroughNV = 5251,
     CapabilityShaderViewportIndexLayerEXT = 5254,
@@ -3889,6 +3891,7 @@ inline const char* LinkageTypeToString(LinkageType value) {
     case LinkageTypeExport: return "Export";
     case LinkageTypeImport: return "Import";
     case LinkageTypeLinkOnceODR: return "LinkOnceODR";
+    case LinkageTypeWeakAMD: return "WeakAMD";
     default: return "Unknown";
     }
 }
@@ -4381,6 +4384,7 @@ inline const char* CapabilityToString(Capability value) {
     case CapabilityDescriptorHeapEXT: return "DescriptorHeapEXT";
     case CapabilityConstantDataKHR: return "ConstantDataKHR";
     case CapabilityPoisonFreezeKHR: return "PoisonFreezeKHR";
+    case CapabilityWeakLinkageAMD: return "WeakLinkageAMD";
     case CapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV";
     case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
     case CapabilityShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT";
diff --git a/include/spirv/unified1/spirv.hpp11 b/include/spirv/unified1/spirv.hpp11
index c841190..4e626c9 100644
--- a/include/spirv/unified1/spirv.hpp11
+++ b/include/spirv/unified1/spirv.hpp11
@@ -471,6 +471,7 @@ enum class LinkageType : unsigned {
     Export = 0,
     Import = 1,
     LinkOnceODR = 2,
+    WeakAMD = 3,
     Max = 0x7fffffff,
 };
 
@@ -1204,6 +1205,7 @@ enum class Capability : unsigned {
     DescriptorHeapEXT = 5128,
     ConstantDataKHR = 5146,
     PoisonFreezeKHR = 5156,
+    WeakLinkageAMD = 5181,
     SampleMaskOverrideCoverageNV = 5249,
     GeometryShaderPassthroughNV = 5251,
     ShaderViewportIndexLayerEXT = 5254,
@@ -3889,6 +3891,7 @@ inline const char* LinkageTypeToString(LinkageType value) {
     case LinkageType::Export: return "Export";
     case LinkageType::Import: return "Import";
     case LinkageType::LinkOnceODR: return "LinkOnceODR";
+    case LinkageType::WeakAMD: return "WeakAMD";
     default: return "Unknown";
     }
 }
@@ -4381,6 +4384,7 @@ inline const char* CapabilityToString(Capability value) {
     case Capability::DescriptorHeapEXT: return "DescriptorHeapEXT";
     case Capability::ConstantDataKHR: return "ConstantDataKHR";
     case Capability::PoisonFreezeKHR: return "PoisonFreezeKHR";
+    case Capability::WeakLinkageAMD: return "WeakLinkageAMD";
     case Capability::SampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV";
     case Capability::GeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
     case Capability::ShaderViewportIndexLayerEXT: return "ShaderViewportIndexLayerEXT";
diff --git a/include/spirv/unified1/spirv.json b/include/spirv/unified1/spirv.json
index 88f2605..135663c 100644
--- a/include/spirv/unified1/spirv.json
+++ b/include/spirv/unified1/spirv.json
@@ -484,7 +484,8 @@
                 {
                     "Export": 0,
                     "Import": 1,
-                    "LinkOnceODR": 2
+                    "LinkOnceODR": 2,
+                    "WeakAMD": 3
                 }
             },
             {
@@ -1170,6 +1171,7 @@
                     "DescriptorHeapEXT": 5128,
                     "ConstantDataKHR": 5146,
                     "PoisonFreezeKHR": 5156,
+                    "WeakLinkageAMD": 5181,
                     "SampleMaskOverrideCoverageNV": 5249,
                     "GeometryShaderPassthroughNV": 5251,
                     "ShaderViewportIndexLayerEXT": 5254,
diff --git a/include/spirv/unified1/spirv.lua b/include/spirv/unified1/spirv.lua
index db1bfd5..8cbe093 100644
--- a/include/spirv/unified1/spirv.lua
+++ b/include/spirv/unified1/spirv.lua
@@ -462,6 +462,7 @@ spv = {
         Export = 0,
         Import = 1,
         LinkOnceODR = 2,
+        WeakAMD = 3,
         Max = 0x7fffffff,
     },
 
@@ -1195,6 +1196,7 @@ spv = {
         DescriptorHeapEXT = 5128,
         ConstantDataKHR = 5146,
         PoisonFreezeKHR = 5156,
+        WeakLinkageAMD = 5181,
         SampleMaskOverrideCoverageNV = 5249,
         GeometryShaderPassthroughNV = 5251,
         ShaderViewportIndexLayerEXT = 5254,
diff --git a/include/spirv/unified1/spirv.py b/include/spirv/unified1/spirv.py
index 976e23b..bb65ae9 100644
--- a/include/spirv/unified1/spirv.py
+++ b/include/spirv/unified1/spirv.py
@@ -447,6 +447,7 @@ spv = {
         'Export' : 0,
         'Import' : 1,
         'LinkOnceODR' : 2,
+        'WeakAMD' : 3,
     },
 
     'AccessQualifier' : {
@@ -1166,6 +1167,7 @@ spv = {
         'DescriptorHeapEXT' : 5128,
         'ConstantDataKHR' : 5146,
         'PoisonFreezeKHR' : 5156,
+        'WeakLinkageAMD' : 5181,
         'SampleMaskOverrideCoverageNV' : 5249,
         'GeometryShaderPassthroughNV' : 5251,
         'ShaderViewportIndexLayerEXT' : 5254,
diff --git a/include/spirv/unified1/spv.d b/include/spirv/unified1/spv.d
index a9093d6..8d31fee 100644
--- a/include/spirv/unified1/spv.d
+++ b/include/spirv/unified1/spv.d
@@ -487,6 +487,7 @@ enum LinkageType : uint
     Export = 0,
     Import = 1,
     LinkOnceODR = 2,
+    WeakAMD = 3,
     Max = 0x7fffffff,
 }
 
@@ -1240,6 +1241,7 @@ enum Capability : uint
     DescriptorHeapEXT = 5128,
     ConstantDataKHR = 5146,
     PoisonFreezeKHR = 5156,
+    WeakLinkageAMD = 5181,
     SampleMaskOverrideCoverageNV = 5249,
     GeometryShaderPassthroughNV = 5251,
     ShaderViewportIndexLayerEXT = 5254,
-- 
2.54.0

