33#include "mlir/Dialect/LLVMIR/NVVMOpsDialect.cpp.inc"
40struct NVVMInlinerInterface final : DialectInlinerInterface {
41 using DialectInlinerInterface::DialectInlinerInterface;
42 bool isLegalToInline(Operation *, Region *,
bool, IRMapping &)
const final {
49void NVVMDialect::initialize() {
52 allowUnknownOperations();
53 addInterfaces<NVVMInlinerInterface>();
54 declarePromisedInterface<ConvertToLLVMPatternInterface, NVVMDialect>();
55 declarePromisedInterface<gpu::TargetAttrInterface, NVVMTargetAttr>();
58LogicalResult NVVMDialect::verifyOperationAttribute(
Operation *op,
60 StringAttr attrName = attr.
getName();
62 if (attrName == NVVMDialect::getKernelFuncAttrName()) {
63 if (!isa<LLVM::LLVMFuncOp>(op)) {
64 return op->
emitError() <<
"'" << NVVMDialect::getKernelFuncAttrName()
65 <<
"' attribute attached to unexpected op";
70 if (attrName == NVVMDialect::getMaxntidAttrName() ||
71 attrName == NVVMDialect::getReqntidAttrName() ||
72 attrName == NVVMDialect::getClusterDimAttrName()) {
73 auto values = llvm::dyn_cast<DenseI32ArrayAttr>(attr.
getValue());
74 if (!values || values.empty() || values.size() > 3) {
77 <<
"' attribute must be integer array with maximum 3 index";
82 if (attrName == NVVMDialect::getMinctasmAttrName() ||
83 attrName == NVVMDialect::getMaxnregAttrName() ||
84 attrName == NVVMDialect::getClusterMaxBlocksAttrName()) {
85 if (!llvm::dyn_cast<IntegerAttr>(attr.
getValue())) {
87 <<
"'" << attrName <<
"' attribute must be integer constant";
91 if (attrName == NVVMDialect::getBlocksAreClustersAttrName()) {
95 <<
"'" << attrName <<
"' attribute must be used along with " <<
"'"
96 << NVVMDialect::getReqntidAttrName() <<
"' and " <<
"'"
97 << NVVMDialect::getClusterDimAttrName() <<
"'";
104LogicalResult NVVMDialect::verifyRegionArgAttribute(
Operation *op,
105 unsigned regionIndex,
108 auto funcOp = dyn_cast<FunctionOpInterface>(op);
113 StringAttr attrName = argAttr.
getName();
114 if (attrName == NVVM::NVVMDialect::getGridConstantAttrName()) {
118 <<
"' attribute must be present only on kernel arguments";
120 if (!isa<UnitAttr>(argAttr.
getValue()))
121 return op->
emitError() <<
"'" << attrName <<
"' must be a unit attribute";
122 if (!funcOp.getArgAttr(argIndex, LLVM::LLVMDialect::getByValAttrName())) {
125 <<
"' attribute requires the argument to also have attribute '"
126 << LLVM::LLVMDialect::getByValAttrName() <<
"'";
static bool isLegalToInline(InlinerInterface &interface, Region *src, Region *insertRegion, bool shouldCloneInlinedRegion, IRMapping &valueMapping)
Utility to check that all of the operations within 'src' can be inlined.
NamedAttribute represents a combination of a name and an Attribute value.
StringAttr getName() const
Return the name of the attribute.
Attribute getValue() const
Return the value of the attribute.
Operation is the basic unit of execution within MLIR.
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
bool hasDiscardableAttr(StringRef name)
Return true if this operation has a discardable attribute with the provided name.
Include the generated interface declarations.