MLIR 23.0.0git
StackToShared.cpp File Reference
#include "mlir/Dialect/OpenMP/Transforms/Passes.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/OpenMP/Utils/Utils.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/STLExtras.h"
#include "mlir/Dialect/OpenMP/Transforms/Passes.h.inc"

Go to the source code of this file.

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::omp

Macros

#define GEN_PASS_DEF_STACKTOSHAREDPASS

Functions

static bool shouldReplaceAllocaWithDeviceSharedMem (Operation &op)
 Tell whether to replace an operation representing a stack allocation with a device shared memory allocation/deallocation pair based on the location of the allocation and its uses.
static void insertDeviceSharedMemDeallocation (OpBuilder &builder, TypeAttr elemType, Value arraySize, IntegerAttr alignment, Value allocVal)
 Based on the location of the definition of the given value representing the result of a device shared memory allocation, find the corresponding points where its deallocation should be placed and introduce omp.free_shared_mem ops at those points.

Macro Definition Documentation

◆ GEN_PASS_DEF_STACKTOSHAREDPASS

#define GEN_PASS_DEF_STACKTOSHAREDPASS

Definition at line 24 of file StackToShared.cpp.

Function Documentation

◆ insertDeviceSharedMemDeallocation()

void insertDeviceSharedMemDeallocation ( OpBuilder & builder,
TypeAttr elemType,
Value arraySize,
IntegerAttr alignment,
Value allocVal )
static

Based on the location of the definition of the given value representing the result of a device shared memory allocation, find the corresponding points where its deallocation should be placed and introduce omp.free_shared_mem ops at those points.

Definition at line 45 of file StackToShared.cpp.

References mlir::DominanceInfo::dominates(), mlir::Region::getBlocks(), mlir::Value::getLoc(), mlir::Value::getParentBlock(), mlir::Value::getParentRegion(), mlir::Operation::hasSuccessors(), and mlir::OpBuilder::setInsertionPoint().

◆ shouldReplaceAllocaWithDeviceSharedMem()

bool shouldReplaceAllocaWithDeviceSharedMem ( Operation & op)
static

Tell whether to replace an operation representing a stack allocation with a device shared memory allocation/deallocation pair based on the location of the allocation and its uses.

Definition at line 34 of file StackToShared.cpp.

References mlir::Operation::getResults(), mlir::omp::opInSharedDeviceContext(), and result.