#include "Utils/CodegenUtils.h"
#include "mlir/Conversion/LLVMCommon/StructBuilder.h"
#include "mlir/Dialect/SparseTensor/IR/SparseTensorStorageLayout.h"
#include "mlir/Dialect/SparseTensor/Transforms/Passes.h"
#include <optional>
usingnamespacemlir;
usingnamespacesparse_tensor;
namespace {
static SmallVector<Type, 4> getSpecifierFields(StorageSpecifierType tp) { … }
static Type convertSpecifier(StorageSpecifierType tp) { … }
constexpr uint64_t kLvlSizePosInSpecifier = …;
constexpr uint64_t kMemSizePosInSpecifier = …;
constexpr uint64_t kDimOffsetPosInSpecifier = …;
constexpr uint64_t kDimStridePosInSpecifier = …;
class SpecifierStructBuilder : public StructBuilder { … };
Value SpecifierStructBuilder::getInitValue(OpBuilder &builder, Location loc,
Type structType, Value source) { … }
Value SpecifierStructBuilder::dimOffset(OpBuilder &builder, Location loc,
Dimension dim) const { … }
void SpecifierStructBuilder::setDimOffset(OpBuilder &builder, Location loc,
Dimension dim, Value size) { … }
Value SpecifierStructBuilder::lvlSize(OpBuilder &builder, Location loc,
Level lvl) const { … }
void SpecifierStructBuilder::setLvlSize(OpBuilder &builder, Location loc,
Level lvl, Value size) { … }
Value SpecifierStructBuilder::dimStride(OpBuilder &builder, Location loc,
Dimension dim) const { … }
void SpecifierStructBuilder::setDimStride(OpBuilder &builder, Location loc,
Dimension dim, Value size) { … }
Value SpecifierStructBuilder::memSize(OpBuilder &builder, Location loc,
FieldIndex fidx) const { … }
void SpecifierStructBuilder::setMemSize(OpBuilder &builder, Location loc,
FieldIndex fidx, Value size) { … }
Value SpecifierStructBuilder::memSizeArray(OpBuilder &builder,
Location loc) const { … }
void SpecifierStructBuilder::setMemSizeArray(OpBuilder &builder, Location loc,
Value array) { … }
}
StorageSpecifierToLLVMTypeConverter::StorageSpecifierToLLVMTypeConverter() { … }
template <typename Base, typename SourceOp>
class SpecifierGetterSetterOpConverter : public OpConversionPattern<SourceOp> { … };
struct StorageSpecifierSetOpConverter
: public SpecifierGetterSetterOpConverter<StorageSpecifierSetOpConverter,
SetStorageSpecifierOp> { … };
struct StorageSpecifierGetOpConverter
: public SpecifierGetterSetterOpConverter<StorageSpecifierGetOpConverter,
GetStorageSpecifierOp> { … };
struct StorageSpecifierInitOpConverter
: public OpConversionPattern<StorageSpecifierInitOp> { … };
void mlir::populateStorageSpecifierToLLVMPatterns(
const TypeConverter &converter, RewritePatternSet &patterns) { … }