llvm/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp

//===- VectorToSPIRV.cpp - Vector to SPIR-V Patterns ----------------------===//
//
// 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 implements patterns to convert Vector dialect to SPIRV dialect.
//
//===----------------------------------------------------------------------===//

#include "mlir/Conversion/VectorToSPIRV/VectorToSPIRV.h"

#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/Dialect/SPIRV/Transforms/SPIRVConversion.h"
#include "mlir/Dialect/Vector/IR/VectorOps.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Location.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/SmallVectorExtras.h"
#include "llvm/Support/FormatVariadic.h"
#include <cassert>
#include <cstdint>
#include <numeric>

usingnamespacemlir;

/// Returns the integer value from the first valid input element, assuming Value
/// inputs are defined by a constant index ops and Attribute inputs are integer
/// attributes.
static uint64_t getFirstIntValue(ValueRange values) {}
static uint64_t getFirstIntValue(ArrayRef<Attribute> attr) {}
static uint64_t getFirstIntValue(ArrayAttr attr) {}
static uint64_t getFirstIntValue(ArrayRef<OpFoldResult> foldResults) {}

/// Returns the number of bits for the given scalar/vector type.
static int getNumBits(Type type) {}

namespace {

struct VectorShapeCast final : public OpConversionPattern<vector::ShapeCastOp> {};

struct VectorBitcastConvert final
    : public OpConversionPattern<vector::BitCastOp> {};

struct VectorBroadcastConvert final
    : public OpConversionPattern<vector::BroadcastOp> {};

struct VectorExtractOpConvert final
    : public OpConversionPattern<vector::ExtractOp> {};

struct VectorExtractStridedSliceOpConvert final
    : public OpConversionPattern<vector::ExtractStridedSliceOp> {};

template <class SPIRVFMAOp>
struct VectorFmaOpConvert final : public OpConversionPattern<vector::FMAOp> {};

struct VectorInsertOpConvert final
    : public OpConversionPattern<vector::InsertOp> {};

struct VectorExtractElementOpConvert final
    : public OpConversionPattern<vector::ExtractElementOp> {};

struct VectorInsertElementOpConvert final
    : public OpConversionPattern<vector::InsertElementOp> {};

struct VectorInsertStridedSliceOpConvert final
    : public OpConversionPattern<vector::InsertStridedSliceOp> {};

static SmallVector<Value> extractAllElements(
    vector::ReductionOp reduceOp, vector::ReductionOp::Adaptor adaptor,
    VectorType srcVectorType, ConversionPatternRewriter &rewriter) {}

struct ReductionRewriteInfo {};

FailureOr<ReductionRewriteInfo> static getReductionInfo(
    vector::ReductionOp op, vector::ReductionOp::Adaptor adaptor,
    ConversionPatternRewriter &rewriter, const TypeConverter &typeConverter) {}

template <typename SPIRVUMaxOp, typename SPIRVUMinOp, typename SPIRVSMaxOp,
          typename SPIRVSMinOp>
struct VectorReductionPattern final : OpConversionPattern<vector::ReductionOp> {};

template <typename SPIRVFMaxOp, typename SPIRVFMinOp>
struct VectorReductionFloatMinMax final
    : OpConversionPattern<vector::ReductionOp> {};

class VectorSplatPattern final : public OpConversionPattern<vector::SplatOp> {};

struct VectorShuffleOpConvert final
    : public OpConversionPattern<vector::ShuffleOp> {};

struct VectorInterleaveOpConvert final
    : public OpConversionPattern<vector::InterleaveOp> {};

struct VectorDeinterleaveOpConvert final
    : public OpConversionPattern<vector::DeinterleaveOp> {};

struct VectorLoadOpConverter final
    : public OpConversionPattern<vector::LoadOp> {};

struct VectorStoreOpConverter final
    : public OpConversionPattern<vector::StoreOp> {};

struct VectorReductionToIntDotProd final
    : OpRewritePattern<vector::ReductionOp> {};

struct VectorReductionToFPDotProd final
    : OpConversionPattern<vector::ReductionOp> {};

struct VectorStepOpConvert final : OpConversionPattern<vector::StepOp> {};

} // namespace
#define CL_INT_MAX_MIN_OPS

#define GL_INT_MAX_MIN_OPS

#define CL_FLOAT_MAX_MIN_OPS
#define GL_FLOAT_MAX_MIN_OPS

void mlir::populateVectorToSPIRVPatterns(SPIRVTypeConverter &typeConverter,
                                         RewritePatternSet &patterns) {}

void mlir::populateVectorReductionToSPIRVDotProductPatterns(
    RewritePatternSet &patterns) {}