llvm/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp

//===- SPIRVTypes.cpp - MLIR SPIR-V Types ---------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the types in the SPIR-V dialect.
//
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/TypeSwitch.h"

#include <cstdint>
#include <iterator>

usingnamespacemlir;
usingnamespacemlir::spirv;

//===----------------------------------------------------------------------===//
// ArrayType
//===----------------------------------------------------------------------===//

struct spirv::detail::ArrayTypeStorage : public TypeStorage {};

ArrayType ArrayType::get(Type elementType, unsigned elementCount) {}

ArrayType ArrayType::get(Type elementType, unsigned elementCount,
                         unsigned stride) {}

unsigned ArrayType::getNumElements() const {}

Type ArrayType::getElementType() const {}

unsigned ArrayType::getArrayStride() const {}

void ArrayType::getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
                              std::optional<StorageClass> storage) {}

void ArrayType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

std::optional<int64_t> ArrayType::getSizeInBytes() {}

//===----------------------------------------------------------------------===//
// CompositeType
//===----------------------------------------------------------------------===//

bool CompositeType::classof(Type type) {}

bool CompositeType::isValid(VectorType type) {}

Type CompositeType::getElementType(unsigned index) const {}

unsigned CompositeType::getNumElements() const {}

bool CompositeType::hasCompileTimeKnownNumElements() const {}

void CompositeType::getExtensions(
    SPIRVType::ExtensionArrayRefVector &extensions,
    std::optional<StorageClass> storage) {}

void CompositeType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

std::optional<int64_t> CompositeType::getSizeInBytes() {}

//===----------------------------------------------------------------------===//
// CooperativeMatrixType
//===----------------------------------------------------------------------===//

struct spirv::detail::CooperativeMatrixTypeStorage final : TypeStorage {};

CooperativeMatrixType CooperativeMatrixType::get(Type elementType,
                                                 uint32_t rows,
                                                 uint32_t columns, Scope scope,
                                                 CooperativeMatrixUseKHR use) {}

Type CooperativeMatrixType::getElementType() const {}

uint32_t CooperativeMatrixType::getRows() const {}

uint32_t CooperativeMatrixType::getColumns() const {}

Scope CooperativeMatrixType::getScope() const {}

CooperativeMatrixUseKHR CooperativeMatrixType::getUse() const {}

void CooperativeMatrixType::getExtensions(
    SPIRVType::ExtensionArrayRefVector &extensions,
    std::optional<StorageClass> storage) {}

void CooperativeMatrixType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

//===----------------------------------------------------------------------===//
// ImageType
//===----------------------------------------------------------------------===//

template <typename T>
static constexpr unsigned getNumBits() {}
template <>
constexpr unsigned getNumBits<Dim>() {}
template <>
constexpr unsigned getNumBits<ImageDepthInfo>() {}
template <>
constexpr unsigned getNumBits<ImageArrayedInfo>() {}
template <>
constexpr unsigned getNumBits<ImageSamplingInfo>() {}
template <>
constexpr unsigned getNumBits<ImageSamplerUseInfo>() {}
template <>
constexpr unsigned getNumBits<ImageFormat>() {}

struct spirv::detail::ImageTypeStorage : public TypeStorage {};

ImageType
ImageType::get(std::tuple<Type, Dim, ImageDepthInfo, ImageArrayedInfo,
                          ImageSamplingInfo, ImageSamplerUseInfo, ImageFormat>
                   value) {}

Type ImageType::getElementType() const {}

Dim ImageType::getDim() const {}

ImageDepthInfo ImageType::getDepthInfo() const {}

ImageArrayedInfo ImageType::getArrayedInfo() const {}

ImageSamplingInfo ImageType::getSamplingInfo() const {}

ImageSamplerUseInfo ImageType::getSamplerUseInfo() const {}

ImageFormat ImageType::getImageFormat() const {}

void ImageType::getExtensions(SPIRVType::ExtensionArrayRefVector &,
                              std::optional<StorageClass>) {}

void ImageType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass>) {}

//===----------------------------------------------------------------------===//
// PointerType
//===----------------------------------------------------------------------===//

struct spirv::detail::PointerTypeStorage : public TypeStorage {};

PointerType PointerType::get(Type pointeeType, StorageClass storageClass) {}

Type PointerType::getPointeeType() const {}

StorageClass PointerType::getStorageClass() const {}

void PointerType::getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
                                std::optional<StorageClass> storage) {}

void PointerType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

//===----------------------------------------------------------------------===//
// RuntimeArrayType
//===----------------------------------------------------------------------===//

struct spirv::detail::RuntimeArrayTypeStorage : public TypeStorage {};

RuntimeArrayType RuntimeArrayType::get(Type elementType) {}

RuntimeArrayType RuntimeArrayType::get(Type elementType, unsigned stride) {}

Type RuntimeArrayType::getElementType() const {}

unsigned RuntimeArrayType::getArrayStride() const {}

void RuntimeArrayType::getExtensions(
    SPIRVType::ExtensionArrayRefVector &extensions,
    std::optional<StorageClass> storage) {}

void RuntimeArrayType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

//===----------------------------------------------------------------------===//
// ScalarType
//===----------------------------------------------------------------------===//

bool ScalarType::classof(Type type) {}

bool ScalarType::isValid(FloatType type) {}

bool ScalarType::isValid(IntegerType type) {}

void ScalarType::getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
                               std::optional<StorageClass> storage) {}

void ScalarType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

std::optional<int64_t> ScalarType::getSizeInBytes() {}

//===----------------------------------------------------------------------===//
// SPIRVType
//===----------------------------------------------------------------------===//

bool SPIRVType::classof(Type type) {}

bool SPIRVType::isScalarOrVector() {}

void SPIRVType::getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
                              std::optional<StorageClass> storage) {}

void SPIRVType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

std::optional<int64_t> SPIRVType::getSizeInBytes() {}

//===----------------------------------------------------------------------===//
// SampledImageType
//===----------------------------------------------------------------------===//
struct spirv::detail::SampledImageTypeStorage : public TypeStorage {};

SampledImageType SampledImageType::get(Type imageType) {}

SampledImageType
SampledImageType::getChecked(function_ref<InFlightDiagnostic()> emitError,
                             Type imageType) {}

Type SampledImageType::getImageType() const {}

LogicalResult
SampledImageType::verifyInvariants(function_ref<InFlightDiagnostic()> emitError,
                                   Type imageType) {}

void SampledImageType::getExtensions(
    SPIRVType::ExtensionArrayRefVector &extensions,
    std::optional<StorageClass> storage) {}

void SampledImageType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

//===----------------------------------------------------------------------===//
// StructType
//===----------------------------------------------------------------------===//

/// Type storage for SPIR-V structure types:
///
/// Structures are uniqued using:
/// - for identified structs:
///   - a string identifier;
/// - for literal structs:
///   - a list of member types;
///   - a list of member offset info;
///   - a list of member decoration info.
///
/// Identified structures only have a mutable component consisting of:
/// - a list of member types;
/// - a list of member offset info;
/// - a list of member decoration info.
struct spirv::detail::StructTypeStorage : public TypeStorage {};

StructType
StructType::get(ArrayRef<Type> memberTypes,
                ArrayRef<StructType::OffsetInfo> offsetInfo,
                ArrayRef<StructType::MemberDecorationInfo> memberDecorations) {}

StructType StructType::getIdentified(MLIRContext *context,
                                     StringRef identifier) {}

StructType StructType::getEmpty(MLIRContext *context, StringRef identifier) {}

StringRef StructType::getIdentifier() const {}

bool StructType::isIdentified() const {}

unsigned StructType::getNumElements() const {}

Type StructType::getElementType(unsigned index) const {}

TypeRange StructType::getElementTypes() const {}

bool StructType::hasOffset() const {}

uint64_t StructType::getMemberOffset(unsigned index) const {}

void StructType::getMemberDecorations(
    SmallVectorImpl<StructType::MemberDecorationInfo> &memberDecorations)
    const {}

void StructType::getMemberDecorations(
    unsigned index,
    SmallVectorImpl<StructType::MemberDecorationInfo> &decorationsInfo) const {}

LogicalResult
StructType::trySetBody(ArrayRef<Type> memberTypes,
                       ArrayRef<OffsetInfo> offsetInfo,
                       ArrayRef<MemberDecorationInfo> memberDecorations) {}

void StructType::getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
                               std::optional<StorageClass> storage) {}

void StructType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

llvm::hash_code spirv::hash_value(
    const StructType::MemberDecorationInfo &memberDecorationInfo) {}

//===----------------------------------------------------------------------===//
// MatrixType
//===----------------------------------------------------------------------===//

struct spirv::detail::MatrixTypeStorage : public TypeStorage {};

MatrixType MatrixType::get(Type columnType, uint32_t columnCount) {}

MatrixType MatrixType::getChecked(function_ref<InFlightDiagnostic()> emitError,
                                  Type columnType, uint32_t columnCount) {}

LogicalResult
MatrixType::verifyInvariants(function_ref<InFlightDiagnostic()> emitError,
                             Type columnType, uint32_t columnCount) {}

/// Returns true if the matrix elements are vectors of float elements
bool MatrixType::isValidColumnType(Type columnType) {}

Type MatrixType::getColumnType() const {}

Type MatrixType::getElementType() const {}

unsigned MatrixType::getNumColumns() const {}

unsigned MatrixType::getNumRows() const {}

unsigned MatrixType::getNumElements() const {}

void MatrixType::getExtensions(SPIRVType::ExtensionArrayRefVector &extensions,
                               std::optional<StorageClass> storage) {}

void MatrixType::getCapabilities(
    SPIRVType::CapabilityArrayRefVector &capabilities,
    std::optional<StorageClass> storage) {}

//===----------------------------------------------------------------------===//
// SPIR-V Dialect
//===----------------------------------------------------------------------===//

void SPIRVDialect::registerTypes() {}