16#include "llvm/IR/ConstantRange.h"
24 llvm::Intrinsic::nvvm_barrier_cta_sync_all,
25 llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_all,
26 llvm::Intrinsic::nvvm_barrier_cta_sync_count,
27 llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_count,
44 llvm::Intrinsic::ID
id = inst->getIntrinsicID();
45 bool aligned = (
id == llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_all ||
46 id == llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_count);
47 bool hasCount = (
id == llvm::Intrinsic::nvvm_barrier_cta_sync_count ||
48 id == llvm::Intrinsic::nvvm_barrier_cta_sync_aligned_count);
53 llvmOperands, llvmOpBundles,
false, {}, {},
54 mlirOperands, mlirAttrs)))
57 auto op = NVVM::BarrierOp::create(
58 odsBuilder, moduleImport.
translateLoc(inst->getDebugLoc()),
59 mlirOperands.front(), hasCount ? mlirOperands.back() :
Value{},
68#include "mlir/Dialect/LLVMIR/NVVMConvertibleLLVMIRIntrinsics.inc"
77#include "mlir/Dialect/LLVMIR/NVVMConvertibleLLVMIRIntrinsics.inc"
83 return convertibleIntrinsics;
91 llvm::Intrinsic::ID intrinsicID = inst->getIntrinsicID();
100 llvmOpBundles.reserve(inst->getNumOperandBundles());
101 for (
unsigned i = 0; i < inst->getNumOperandBundles(); ++i)
102 llvmOpBundles.push_back(inst->getOperandBundleAt(i));
107 llvmOperands, llvmOpBundles);
109#include "mlir/Dialect/LLVMIR/NVVMFromLLVMIRConversions.inc"
119class NVVMDialectLLVMIRImportInterface :
public LLVMImportDialectInterface {
121 using LLVMImportDialectInterface::LLVMImportDialectInterface;
125 LogicalResult convertIntrinsic(OpBuilder &builder, llvm::CallInst *inst,
126 LLVM::ModuleImport &moduleImport)
const final {
132 ArrayRef<unsigned> getSupportedIntrinsics() const final {
140 registry.
insert<NVVM::NVVMDialect>();
142 dialect->addInterfaces<NVVMDialectLLVMIRImportInterface>();
static ArrayRef< unsigned > getSupportedIntrinsicsImpl()
Returns the LLVM intrinsic IDs that have a corresponding MLIR NVVM op.
static bool isBarrierSyncIntrinsic(llvm::Intrinsic::ID id)
Returns true if id is one of the bar.sync intrinsic IDs imported into nvvm.barrier.
static bool isConvertibleIntrinsic(llvm::Intrinsic::ID id)
Returns true if the LLVM intrinsic id has a corresponding MLIR NVVM op.
static LogicalResult convertIntrinsicImpl(OpBuilder &odsBuilder, llvm::CallInst *inst, LLVM::ModuleImport &moduleImport)
Converts the LLVM intrinsic to an MLIR NVVM dialect operation if a conversion exits.
static constexpr llvm::Intrinsic::ID kBarrierSyncIntrinsics[]
LLVM intrinsic IDs of the four bar.sync variants imported into nvvm.barrier.
static LogicalResult convertBarrierSyncIntrinsic(OpBuilder &odsBuilder, llvm::CallInst *inst, LLVM::ModuleImport &moduleImport, ArrayRef< llvm::Value * > llvmOperands, ArrayRef< llvm::OperandBundleUse > llvmOpBundles)
Imports one of the four bar.sync LLVM intrinsic variants into a single nvvm.barrier op,...
BoolAttr getBoolAttr(bool value)
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
bool addExtension(TypeID extensionID, std::unique_ptr< DialectExtensionBase > extension)
Add the given extension to the registry.
Module import implementation class that provides methods to import globals and functions from an LLVM...
LogicalResult convertIntrinsicArguments(ArrayRef< llvm::Value * > values, ArrayRef< llvm::OperandBundleUse > opBundles, bool requiresOpBundles, ArrayRef< unsigned > immArgPositions, ArrayRef< StringLiteral > immArgAttrNames, SmallVectorImpl< Value > &valuesOut, SmallVectorImpl< NamedAttribute > &attrsOut)
Converts the LLVM values for an intrinsic to mixed MLIR values and attributes for LLVM_IntrOpBase.
Location translateLoc(llvm::DILocation *loc)
Translates the debug location.
void mapNoResultOp(llvm::Instruction *llvm, Operation *mlir)
Stores a mapping between an LLVM instruction and the imported MLIR operation if the operation returns...
MLIRContext is the top-level object for a collection of MLIR operations.
void appendDialectRegistry(const DialectRegistry ®istry)
Append the contents of the given dialect registry to the registry associated with this context.
This class helps build Operations.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.
llvm::DenseSet< ValueT, ValueInfoT > DenseSet
void registerNVVMDialectImport(DialectRegistry ®istry)
Registers the NVVM dialect and its import from LLVM IR in the given registry.