================
@@ -805,6 +811,64 @@ bool 
SPIRVPrepareFunctionsImpl::removeAggregateTypesFromCalls(Function *F) {
   return true;
 }
 
+static inline bool isTargetSpecificASCast(unsigned SrcAS, unsigned DstAS,
+                                          const Triple &TT) {
+  static const unsigned GenericAS =
+      storageClassToAddressSpace(SPIRV::StorageClass::Generic, TT);
+  static const unsigned BufferFatPointerAS = AMDGPUAS::BUFFER_FAT_POINTER;
+  static const unsigned BufferResourceAS = AMDGPUAS::BUFFER_RESOURCE;
+  static const unsigned UniformConstAS =
+      storageClassToAddressSpace(SPIRV::StorageClass::UniformConstant, TT);
+
+  static const std::pair<unsigned, unsigned> Casts[] = {
+    {GenericAS, BufferFatPointerAS}, {GenericAS, BufferResourceAS},
+    {BufferFatPointerAS, GenericAS}, {BufferFatPointerAS, BufferResourceAS},
+    {BufferResourceAS, GenericAS}, {BufferResourceAS, BufferFatPointerAS},
+    {GenericAS, UniformConstAS}, {UniformConstAS, GenericAS}
+  };
+
+  return find(Casts, std::make_pair(SrcAS, DstAS));
+}
+
+static bool substituteInvalidAddrSpaceCasts(Function *F) {
+  // AMDGPU supports a superset of the AS casts allowed by SPIR-V, specifically
+  //   - casts to/from UniformConstant from/to Generic
+  //   - casts to/from Input from/to Output (these are actually buffer specific
----------------
AlexVlx wrote:

This is actually wrong / vestigial.

https://github.com/llvm/llvm-project/pull/199376
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to