MLIR  19.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
UnifyAliasedResourcePass.cpp File Reference
#include "mlir/Dialect/SPIRV/Transforms/Passes.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/IR/TargetAndABI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/SymbolTable.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
#include <algorithm>
#include <iterator>
#include "mlir/Dialect/SPIRV/Transforms/Passes.h.inc"

Go to the source code of this file.

Classes

class  ConvertAliasResource< OpTy >
 
struct  ConvertVariable
 
struct  ConvertAddressOf
 
struct  ConvertAccessChain
 
struct  ConvertLoad
 
struct  ConvertStore
 

Namespaces

 mlir
 Include the generated interface declarations.
 
 mlir::spirv
 

Macros

#define GEN_PASS_DEF_SPIRVUNIFYALIASEDRESOURCEPASS
 
#define DEBUG_TYPE   "spirv-unify-aliased-resource"
 

Typedefs

using Descriptor = std::pair< uint32_t, uint32_t >
 
using AliasedResourceMap = DenseMap< Descriptor, SmallVector< spirv::GlobalVariableOp > >
 

Functions

static AliasedResourceMap collectAliasedResources (spirv::ModuleOp moduleOp)
 Collects all aliased resources in the given SPIR-V moduleOp. More...
 
static Type getRuntimeArrayElementType (Type type)
 Returns the element type if the given type is a runtime array resource: !spirv.ptr<!spirv.struct<!spirv.rtarray<...>>>. More...
 
static std::optional< int > deduceCanonicalResource (ArrayRef< spirv::SPIRVType > types)
 Given a list of resource element types, returns the index of the canonical resource that all resources should be unified into. More...
 
static bool areSameBitwidthScalarType (Type a, Type b)
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "spirv-unify-aliased-resource"

Definition at line 38 of file UnifyAliasedResourcePass.cpp.

◆ GEN_PASS_DEF_SPIRVUNIFYALIASEDRESOURCEPASS

#define GEN_PASS_DEF_SPIRVUNIFYALIASEDRESOURCEPASS

Definition at line 33 of file UnifyAliasedResourcePass.cpp.

Typedef Documentation

◆ AliasedResourceMap

using AliasedResourceMap = DenseMap<Descriptor, SmallVector<spirv::GlobalVariableOp> >

Definition at line 47 of file UnifyAliasedResourcePass.cpp.

◆ Descriptor

using Descriptor = std::pair<uint32_t, uint32_t>

Definition at line 46 of file UnifyAliasedResourcePass.cpp.

Function Documentation

◆ areSameBitwidthScalarType()

static bool areSameBitwidthScalarType ( Type  a,
Type  b 
)
static

◆ collectAliasedResources()

static AliasedResourceMap collectAliasedResources ( spirv::ModuleOp  moduleOp)
static

Collects all aliased resources in the given SPIR-V moduleOp.

Definition at line 51 of file UnifyAliasedResourcePass.cpp.

◆ deduceCanonicalResource()

static std::optional<int> deduceCanonicalResource ( ArrayRef< spirv::SPIRVType types)
static

Given a list of resource element types, returns the index of the canonical resource that all resources should be unified into.

Returns std::nullopt if unable to unify.

Definition at line 88 of file UnifyAliasedResourcePass.cpp.

References mlir::detail::enumerate(), mlir::Type::getIntOrFloatBitWidth(), mlir::spirv::SPIRVType::getSizeInBytes(), and mlir::spirv::SPIRVType::isScalarOrVector().

◆ getRuntimeArrayElementType()

static Type getRuntimeArrayElementType ( Type  type)
static

Returns the element type if the given type is a runtime array resource: !spirv.ptr<!spirv.struct<!spirv.rtarray<...>>>.

Returns null type otherwise.

Definition at line 67 of file UnifyAliasedResourcePass.cpp.