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

//===- MemoryOps.cpp - MLIR SPIR-V Memory Ops  ----------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// Defines the memory operations in the SPIR-V dialect.
//
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/SPIRV/IR/SPIRVEnums.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"

#include "SPIRVOpUtils.h"
#include "SPIRVParsingUtils.h"
#include "mlir/Dialect/SPIRV/IR/SPIRVTypes.h"
#include "mlir/IR/Diagnostics.h"

#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Casting.h"

usingnamespacemlir::spirv::AttrNames;

namespace mlir::spirv {

/// Parses optional memory access (a.k.a. memory operand) attributes attached to
/// a memory access operand/pointer. Specifically, parses the following syntax:
///     (`[` memory-access `]`)?
/// where:
///     memory-access ::= `"None"` | `"Volatile"` | `"Aligned", `
///         integer-literal | `"NonTemporal"`
template <typename MemoryOpTy>
ParseResult parseMemoryAccessAttributes(OpAsmParser &parser,
                                        OperationState &state) {}

// TODO Make sure to merge this and the previous function into one template
// parameterized by memory access attribute name and alignment. Doing so now
// results in VS2017 in producing an internal error (at the call site) that's
// not detailed enough to understand what is happening.
template <typename MemoryOpTy>
static ParseResult parseSourceMemoryAccessAttributes(OpAsmParser &parser,
                                                     OperationState &state) {}

// TODO Make sure to merge this and the previous function into one template
// parameterized by memory access attribute name and alignment. Doing so now
// results in VS2017 in producing an internal error (at the call site) that's
// not detailed enough to understand what is happening.
template <typename MemoryOpTy>
static void printSourceMemoryAccessAttribute(
    MemoryOpTy memoryOp, OpAsmPrinter &printer,
    SmallVectorImpl<StringRef> &elidedAttrs,
    std::optional<spirv::MemoryAccess> memoryAccessAtrrValue = std::nullopt,
    std::optional<uint32_t> alignmentAttrValue = std::nullopt) {}

template <typename MemoryOpTy>
static void printMemoryAccessAttribute(
    MemoryOpTy memoryOp, OpAsmPrinter &printer,
    SmallVectorImpl<StringRef> &elidedAttrs,
    std::optional<spirv::MemoryAccess> memoryAccessAtrrValue = std::nullopt,
    std::optional<uint32_t> alignmentAttrValue = std::nullopt) {}

template <typename LoadStoreOpTy>
static LogicalResult verifyLoadStorePtrAndValTypes(LoadStoreOpTy op, Value ptr,
                                                   Value val) {}

template <typename MemoryOpTy>
static LogicalResult verifyMemoryAccessAttribute(MemoryOpTy memoryOp) {}

// TODO Make sure to merge this and the previous function into one template
// parameterized by memory access attribute name and alignment. Doing so now
// results in VS2017 in producing an internal error (at the call site) that's
// not detailed enough to understand what is happening.
template <typename MemoryOpTy>
static LogicalResult verifySourceMemoryAccessAttribute(MemoryOpTy memoryOp) {}

//===----------------------------------------------------------------------===//
// spirv.AccessChainOp
//===----------------------------------------------------------------------===//

static Type getElementPtrType(Type type, ValueRange indices, Location baseLoc) {}

void AccessChainOp::build(OpBuilder &builder, OperationState &state,
                          Value basePtr, ValueRange indices) {}

ParseResult AccessChainOp::parse(OpAsmParser &parser, OperationState &result) {}

template <typename Op>
static void printAccessChain(Op op, ValueRange indices, OpAsmPrinter &printer) {}

void spirv::AccessChainOp::print(OpAsmPrinter &printer) {}

template <typename Op>
static LogicalResult verifyAccessChain(Op accessChainOp, ValueRange indices) {}

LogicalResult AccessChainOp::verify() {}

//===----------------------------------------------------------------------===//
// spirv.LoadOp
//===----------------------------------------------------------------------===//

void LoadOp::build(OpBuilder &builder, OperationState &state, Value basePtr,
                   MemoryAccessAttr memoryAccess, IntegerAttr alignment) {}

ParseResult LoadOp::parse(OpAsmParser &parser, OperationState &result) {}

void LoadOp::print(OpAsmPrinter &printer) {}

LogicalResult LoadOp::verify() {}

//===----------------------------------------------------------------------===//
// spirv.StoreOp
//===----------------------------------------------------------------------===//

ParseResult StoreOp::parse(OpAsmParser &parser, OperationState &result) {}

void StoreOp::print(OpAsmPrinter &printer) {}

LogicalResult StoreOp::verify() {}

//===----------------------------------------------------------------------===//
// spirv.CopyMemory
//===----------------------------------------------------------------------===//

void CopyMemoryOp::print(OpAsmPrinter &printer) {}

ParseResult CopyMemoryOp::parse(OpAsmParser &parser, OperationState &result) {}

LogicalResult CopyMemoryOp::verify() {}

static ParseResult parsePtrAccessChainOpImpl(StringRef opName,
                                             OpAsmParser &parser,
                                             OperationState &state) {}

template <typename Op>
static auto concatElemAndIndices(Op op) {}

//===----------------------------------------------------------------------===//
// spirv.InBoundsPtrAccessChainOp
//===----------------------------------------------------------------------===//

void InBoundsPtrAccessChainOp::build(OpBuilder &builder, OperationState &state,
                                     Value basePtr, Value element,
                                     ValueRange indices) {}

ParseResult InBoundsPtrAccessChainOp::parse(OpAsmParser &parser,
                                            OperationState &result) {}

void InBoundsPtrAccessChainOp::print(OpAsmPrinter &printer) {}

LogicalResult InBoundsPtrAccessChainOp::verify() {}

//===----------------------------------------------------------------------===//
// spirv.PtrAccessChainOp
//===----------------------------------------------------------------------===//

void PtrAccessChainOp::build(OpBuilder &builder, OperationState &state,
                             Value basePtr, Value element, ValueRange indices) {}

ParseResult PtrAccessChainOp::parse(OpAsmParser &parser,
                                    OperationState &result) {}

void PtrAccessChainOp::print(OpAsmPrinter &printer) {}

LogicalResult PtrAccessChainOp::verify() {}

//===----------------------------------------------------------------------===//
// spirv.Variable
//===----------------------------------------------------------------------===//

ParseResult VariableOp::parse(OpAsmParser &parser, OperationState &result) {}

void VariableOp::print(OpAsmPrinter &printer) {}

LogicalResult VariableOp::verify() {}

} // namespace mlir::spirv