[llvm] wip: [DirectX] Refactor resources into binding and type passes (PR #119738)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 10:35:20 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff a480d5172215ce8e49b492e5c0295de1f397954d eed6eefa9ac077003c61ea395b545b20edb55a11 --extensions h,cpp -- llvm/include/llvm/Analysis/DXILResource.h llvm/include/llvm/InitializePasses.h llvm/include/llvm/LinkAllPasses.h llvm/lib/Analysis/Analysis.cpp llvm/lib/Analysis/DXILResource.cpp llvm/lib/Target/DirectX/DXContainerGlobals.cpp llvm/lib/Target/DirectX/DXILDataScalarization.cpp llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp llvm/lib/Target/DirectX/DXILFinalizeLinkage.h llvm/lib/Target/DirectX/DXILFlattenArrays.cpp llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp llvm/lib/Target/DirectX/DXILOpLowering.cpp llvm/lib/Target/DirectX/DXILPrepare.cpp llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp llvm/unittests/Analysis/DXILResourceTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index 58fc0b0301..b59798a3d6 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -11,8 +11,8 @@
 
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/IR/PassManager.h"
 #include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Alignment.h"
 #include "llvm/Support/DXILABI.h"
@@ -156,7 +156,6 @@ public:
   }
 };
 
-
 /// The dx.CBuffer target extension type
 ///
 /// `target("dx.CBuffer", <Type>, ...)`
@@ -295,7 +294,8 @@ public:
   dxil::ResourceKind getResourceKind() const { return Kind; }
 
   bool operator==(const ResourceTypeInfo &RHS) const;
-  bool operator!=(const ResourceTypeInfo &RHS) const { return !(*this == RHS); }  bool operator<(const ResourceTypeInfo &RHS) const;
+  bool operator!=(const ResourceTypeInfo &RHS) const { return !(*this == RHS); }
+  bool operator<(const ResourceTypeInfo &RHS) const;
 
   void print(raw_ostream &OS, const DataLayout &DL) const;
 };
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index 5f5f70dc50..9f992ee1a8 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -420,7 +420,7 @@ static std::pair<Type *, bool> getTypedElementType(dxil::ResourceKind Kind,
     auto *RTy = cast<MSTextureExtType>(Ty);
     return {RTy->getResourceType(), RTy->isSigned()};
   }
-  case ResourceKind::TypedBuffer:{
+  case ResourceKind::TypedBuffer: {
     auto *RTy = cast<TypedBufferExtType>(Ty);
     return {RTy->getResourceType(), RTy->isSigned()};
   }
diff --git a/llvm/unittests/Analysis/DXILResourceTest.cpp b/llvm/unittests/Analysis/DXILResourceTest.cpp
index 66280fead5..4c005f817a 100644
--- a/llvm/unittests/Analysis/DXILResourceTest.cpp
+++ b/llvm/unittests/Analysis/DXILResourceTest.cpp
@@ -122,9 +122,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
   MDBuilder TestMD(Context, Int32Ty, Int1Ty);
 
   // ByteAddressBuffer Buffer;
-  ResourceTypeInfo RTI(
-      llvm::TargetExtType::get(Context, "dx.RawBuffer", Int8Ty,
-                               {/*IsWriteable=*/0, /*IsROV=*/0}));
+  ResourceTypeInfo RTI(llvm::TargetExtType::get(
+      Context, "dx.RawBuffer", Int8Ty, {/*IsWriteable=*/0, /*IsROV=*/0}));
   EXPECT_EQ(RTI.getResourceClass(), ResourceClass::SRV);
   EXPECT_EQ(RTI.getResourceKind(), ResourceKind::RawBuffer);
 
@@ -139,9 +138,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
   EXPECT_MDEQ(MD, TestMD.get(0, GV, "Buffer", 0, 0, 1, 11, 0, nullptr));
 
   // RWByteAddressBuffer BufferOut : register(u3, space2);
-  RTI = ResourceTypeInfo(
-      llvm::TargetExtType::get(Context, "dx.RawBuffer", Int8Ty,
-                               {/*IsWriteable=*/1, /*IsROV=*/0}));
+  RTI = ResourceTypeInfo(llvm::TargetExtType::get(
+      Context, "dx.RawBuffer", Int8Ty, {/*IsWriteable=*/1, /*IsROV=*/0}));
   EXPECT_EQ(RTI.getResourceClass(), ResourceClass::UAV);
   EXPECT_EQ(RTI.getUAV().GloballyCoherent, false);
   EXPECT_EQ(RTI.getUAV().HasCounter, false);
@@ -163,9 +161,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
   // StructuredBuffer<BufType0> Buffer0 : register(t0);
   StructType *BufType0 =
       StructType::create(Context, {Int32Ty, FloatTy, DoubleTy}, "BufType0");
-  RTI = ResourceTypeInfo(
-      llvm::TargetExtType::get(Context, "dx.RawBuffer", BufType0,
-                               {/*IsWriteable=*/0, /*IsROV=*/0}));
+  RTI = ResourceTypeInfo(llvm::TargetExtType::get(
+      Context, "dx.RawBuffer", BufType0, {/*IsWriteable=*/0, /*IsROV=*/0}));
   EXPECT_EQ(RTI.getResourceClass(), ResourceClass::SRV);
   ASSERT_EQ(RTI.isStruct(), true);
   EXPECT_EQ(RTI.getStruct(DL).Stride, 16u);
@@ -184,9 +181,8 @@ TEST(DXILResource, AnnotationsAndMetadata) {
               TestMD.get(0, GV, "Buffer0", 0, 0, 1, 12, 0, TestMD.get(1, 16)));
 
   // StructuredBuffer<float3> Buffer1 : register(t1);
-  RTI = ResourceTypeInfo(
-      llvm::TargetExtType::get(Context, "dx.RawBuffer", Floatx3Ty,
-                               {/*IsWriteable=*/0, /*IsROV=*/0}));
+  RTI = ResourceTypeInfo(llvm::TargetExtType::get(
+      Context, "dx.RawBuffer", Floatx3Ty, {/*IsWriteable=*/0, /*IsROV=*/0}));
   EXPECT_EQ(RTI.getResourceClass(), ResourceClass::SRV);
   ASSERT_EQ(RTI.isStruct(), true);
   EXPECT_EQ(RTI.getStruct(DL).Stride, 12u);
@@ -369,11 +365,10 @@ TEST(DXILResource, AnnotationsAndMetadata) {
                              false, TestMD.get(1, 20)));
 
   // RWTexture2DMSArray<uint, 8> g_rw_t2dmsa;
-  RTI = ResourceTypeInfo(
-      llvm::TargetExtType::get(
-          Context, "dx.MSTexture", Int32Ty,
-          {/*IsWriteable=*/1, /*SampleCount=*/8, /*IsSigned=*/0,
-           llvm::to_underlying(ResourceKind::Texture2DMSArray)}));
+  RTI = ResourceTypeInfo(llvm::TargetExtType::get(
+      Context, "dx.MSTexture", Int32Ty,
+      {/*IsWriteable=*/1, /*SampleCount=*/8, /*IsSigned=*/0,
+       llvm::to_underlying(ResourceKind::Texture2DMSArray)}));
   EXPECT_EQ(RTI.getResourceClass(), ResourceClass::UAV);
   EXPECT_EQ(RTI.getUAV().GloballyCoherent, false);
   EXPECT_EQ(RTI.getUAV().HasCounter, false);

``````````

</details>


https://github.com/llvm/llvm-project/pull/119738


More information about the llvm-commits mailing list