MLIR 24.0.0git
OpenACCUtilsLoop.cpp File Reference
#include "mlir/Dialect/OpenACC/OpenACCUtilsLoop.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/OpenACC/OpenACC.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/SCF/Utils/Utils.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/ErrorHandling.h"

Go to the source code of this file.

Namespaces

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

Functions

static void mapACCLoopIVsToSCFIVs (acc::LoopOp accLoop, ValueRange newIVs, OpBuilder &b, IRMapping &mapping)
 Handle differing types between SCF (index) and ACC loops.
static Block::iterator cloneACCRegionIntoForLoop (Region *src, Block *dest, Block::iterator insertionPoint, IRMapping &mapping, RewriterBase &rewriter)
 Helper used by loop conversion: clone region and return insertion point only.
static void copyLoopAnnotationAttr (Operation *from, Operation *to)
 Copy the discardable LLVM loop annotation attribute from an acc.loop to the lowered SCF op so later SCF to CFG/LLVM lowering can emit !llvm.loop metadata.
std::pair< llvm::SmallVector< Value >, Block::iteratormlir::acc::cloneACCRegionInto (Region *src, Block *dest, Block::iterator inlinePoint, IRMapping &mapping, ValueRange resultsToReplace)
 Clone an ACC region into a destination block at the given insertion point.
scf::ExecuteRegionOp mlir::acc::wrapMultiBlockRegionWithSCFExecuteRegion (Region &region, IRMapping &mapping, Location loc, RewriterBase &rewriter)
 Wrap a multi-block region in an scf.execute_region.
scf::ForOp mlir::acc::convertACCLoopToSCFFor (LoopOp loopOp, RewriterBase &rewriter, bool enableCollapse)
 Convert a structured acc.loop to scf.for.
scf::ParallelOp mlir::acc::convertACCLoopToSCFParallel (LoopOp loopOp, RewriterBase &rewriter)
 Convert acc.loop to scf.parallel.
scf::ExecuteRegionOp mlir::acc::convertUnstructuredACCLoopToSCFExecuteRegion (LoopOp loopOp, RewriterBase &rewriter)
 Convert an unstructured acc.loop to scf.execute_region.
void mlir::acc::setCollapseCountAttr (Operation *op, uint64_t count)
 Record on a collapsed loop how many original loops were folded into it.
uint64_t mlir::acc::getCollapseCount (Operation *op)
 Number of original loops collapsed into op, or 1 when op carries no collapse_count attribute.

Function Documentation

◆ cloneACCRegionIntoForLoop()

Block::iterator cloneACCRegionIntoForLoop ( Region * src,
Block * dest,
Block::iterator insertionPoint,
IRMapping & mapping,
RewriterBase & rewriter )
static

Helper used by loop conversion: clone region and return insertion point only.

Definition at line 90 of file OpenACCUtilsLoop.cpp.

References mlir::acc::cloneACCRegionInto().

Referenced by mlir::acc::convertACCLoopToSCFFor(), and mlir::acc::convertACCLoopToSCFParallel().

◆ copyLoopAnnotationAttr()

void copyLoopAnnotationAttr ( Operation * from,
Operation * to )
static

Copy the discardable LLVM loop annotation attribute from an acc.loop to the lowered SCF op so later SCF to CFG/LLVM lowering can emit !llvm.loop metadata.

Definition at line 103 of file OpenACCUtilsLoop.cpp.

References mlir::Operation::getDiscardableAttr(), and mlir::Operation::setDiscardableAttr().

Referenced by mlir::acc::convertACCLoopToSCFFor(), and mlir::acc::convertACCLoopToSCFParallel().

◆ mapACCLoopIVsToSCFIVs()

void mapACCLoopIVsToSCFIVs ( acc::LoopOp accLoop,
ValueRange newIVs,
OpBuilder & b,
IRMapping & mapping )
static

Handle differing types between SCF (index) and ACC loops.

Creates casts from the new SCF IVs to the original ACC IV types and updates the mapping. The newIVs should correspond 1:1 with the ACC loop's IVs.

Definition at line 55 of file OpenACCUtilsLoop.cpp.

References b, mlir::getValueOrCreateCastToIndexLike(), and mlir::IRMapping::map().

Referenced by mlir::acc::convertACCLoopToSCFFor(), and mlir::acc::convertACCLoopToSCFParallel().