
LLVM itself is generally moving away from using `undef` and towards using `poison`, to the point of having a lint that caches new uses of `undef` in tests. In order to not trip the lint on new patterns and to conform to the evolution of LLVM - Rename valious ::undef() methods on StructBuilder subclasses to ::poison() - Audit the uses of UndefOp in the MLIR libraries and replace almost all of them with PoisonOp The remaining uses of `undef` are initializing `uninitialized` memrefs, explicit conversions to undef from SPIR-V, and a few cases in AMDGPUToROCDL where usage like %v = insertelement <M x iN> undef, iN %v, i32 0 %arg = bitcast <M x iN> %v to i(M * N) is used to handle "i32" arguments that are are really packed vectors of smaller types that won't always be fully initialized.
41 lines
2.5 KiB
MLIR
41 lines
2.5 KiB
MLIR
// RUN: mlir-opt %s -sparse-storage-specifier-to-llvm --cse --canonicalize | FileCheck %s
|
|
|
|
#CSR = #sparse_tensor.encoding<{map = (d0, d1) -> (d0 : dense, d1 : compressed)}>
|
|
|
|
// CHECK-LABEL: func.func @sparse_metadata_init() -> !llvm.struct<(array<2 x i64>, array<3 x i64>)> {
|
|
// CHECK-DAG: %[[STRUCT:.*]] = llvm.mlir.poison : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK-DAG: %[[CST0:.*]] = arith.constant 0 : i64
|
|
// CHECK: %[[VAL_1:.*]] = llvm.insertvalue %[[CST0]], %[[STRUCT]][1, 0] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK: %[[VAL_2:.*]] = llvm.insertvalue %[[CST0]], %[[VAL_1]][1, 1] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK: %[[VAL_3:.*]] = llvm.insertvalue %[[CST0]], %[[VAL_2]][1, 2] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK: return %[[VAL_3]] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK: }
|
|
func.func @sparse_metadata_init() -> !sparse_tensor.storage_specifier<#CSR> {
|
|
%0 = sparse_tensor.storage_specifier.init : !sparse_tensor.storage_specifier<#CSR>
|
|
return %0 : !sparse_tensor.storage_specifier<#CSR>
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_get_md(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.struct<(array<2 x i64>, array<3 x i64>)>) -> index {
|
|
// CHECK: %[[VAL_1:.*]] = llvm.extractvalue %[[VAL_0]][0, 0] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK: %[[CAST:.*]] = arith.index_cast %[[VAL_1]] : i64 to index
|
|
// CHECK: return %[[CAST]] : index
|
|
func.func @sparse_get_md(%arg0: !sparse_tensor.storage_specifier<#CSR>) -> index {
|
|
%0 = sparse_tensor.storage_specifier.get %arg0 lvl_sz at 0
|
|
: !sparse_tensor.storage_specifier<#CSR>
|
|
return %0 : index
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_set_md(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: !llvm.struct<(array<2 x i64>, array<3 x i64>)>,
|
|
// CHECK-SAME: %[[VAL_1:.*]]: index) -> !llvm.struct<(array<2 x i64>, array<3 x i64>)> {
|
|
// CHECK: %[[CAST:.*]] = arith.index_cast %[[VAL_1]] : index to i64
|
|
// CHECK: %[[VAL_2:.*]] = llvm.insertvalue %[[CAST]], %[[VAL_0]][0, 0] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
// CHECK: return %[[VAL_2]] : !llvm.struct<(array<2 x i64>, array<3 x i64>)>
|
|
func.func @sparse_set_md(%arg0: !sparse_tensor.storage_specifier<#CSR>, %arg1: index)
|
|
-> !sparse_tensor.storage_specifier<#CSR> {
|
|
%0 = sparse_tensor.storage_specifier.set %arg0 lvl_sz at 0 with %arg1
|
|
: !sparse_tensor.storage_specifier<#CSR>
|
|
return %0 : !sparse_tensor.storage_specifier<#CSR>
|
|
}
|