bool isBool = srcBits == 1;
if (isBool)
srcBits = typeConverter.getOptions().boolNumBits;
- auto dstType = typeConverter.convertType(memrefType)
- .cast<spirv::PointerType>()
- .getPointeeType()
- .cast<spirv::StructType>()
- .getElementType(0)
- .cast<spirv::ArrayType>()
- .getElementType();
+ Type pointeeType = typeConverter.convertType(memrefType)
+ .cast<spirv::PointerType>()
+ .getPointeeType();
+ Type structElemType = pointeeType.cast<spirv::StructType>().getElementType(0);
+ Type dstType;
+ if (auto arrayType = structElemType.dyn_cast<spirv::ArrayType>())
+ dstType = arrayType.getElementType();
+ else
+ dstType = structElemType.cast<spirv::RuntimeArrayType>().getElementType();
+
int dstBits = dstType.getIntOrFloatBitWidth();
assert(dstBits % srcBits == 0);
bool isBool = srcBits == 1;
if (isBool)
srcBits = typeConverter.getOptions().boolNumBits;
- auto dstType = typeConverter.convertType(memrefType)
- .cast<spirv::PointerType>()
- .getPointeeType()
- .cast<spirv::StructType>()
- .getElementType(0)
- .cast<spirv::ArrayType>()
- .getElementType();
+ Type pointeeType = typeConverter.convertType(memrefType)
+ .cast<spirv::PointerType>()
+ .getPointeeType();
+ Type structElemType = pointeeType.cast<spirv::StructType>().getElementType(0);
+ Type dstType;
+ if (auto arrayType = structElemType.dyn_cast<spirv::ArrayType>())
+ dstType = arrayType.getElementType();
+ else
+ dstType = structElemType.cast<spirv::RuntimeArrayType>().getElementType();
+
int dstBits = dstType.getIntOrFloatBitWidth();
assert(dstBits % srcBits == 0);
return
}
+// CHECK-LABEL: func @load_store_unknown_dim
+// CHECK-SAME: %[[SRC:[a-z0-9]+]]: !spv.ptr<!spv.struct<(!spv.rtarray<i32, stride=4> [0])>, StorageBuffer>,
+// CHECK-SAME: %[[DST:[a-z0-9]+]]: !spv.ptr<!spv.struct<(!spv.rtarray<i32, stride=4> [0])>, StorageBuffer>)
+func @load_store_unknown_dim(%i: index, %source: memref<?xi32>, %dest: memref<?xi32>) {
+ // CHECK: %[[AC0:.+]] = spv.AccessChain %[[SRC]]
+ // CHECK: spv.Load "StorageBuffer" %[[AC0]]
+ %0 = memref.load %source[%i] : memref<?xi32>
+ // CHECK: %[[AC1:.+]] = spv.AccessChain %[[DST]]
+ // CHECK: spv.Store "StorageBuffer" %[[AC1]]
+ memref.store %0, %dest[%i]: memref<?xi32>
+ return
+}
+
} // end module
// -----