20#include "llvm/Support/Regex.h"
23#define GEN_PASS_DEF_GPUNVVMATTACHTARGET
24#include "mlir/Dialect/GPU/Transforms/NVVM/Passes.h.inc"
31struct NVVMAttachTarget
35 DictionaryAttr getFlags(OpBuilder &builder)
const;
37 void runOnOperation()
override;
39 void getDependentDialects(DialectRegistry ®istry)
const override {
40 registry.
insert<NVVM::NVVMDialect>();
45DictionaryAttr NVVMAttachTarget::getFlags(
OpBuilder &builder)
const {
48 auto addFlag = [&](StringRef flag) {
56 addFlag(
"collect-compiler-diagnostics");
64 nvvmOptionAttrs.emplace_back(
65 mlir::StringAttr::get(builder.
getContext(), StringRef(opt)));
69 mlir::ArrayAttr::get(builder.
getContext(), nvvmOptionAttrs)));
78void NVVMAttachTarget::runOnOperation() {
88 for (
Block &block : region.getBlocks())
89 for (
auto module : block.getOps<gpu::GPUModuleOp>()) {
91 if (!
moduleMatcher.empty() && !matcher.match(module.getName()))
95 if (std::optional<ArrayAttr> attrs = module.getTargets())
96 targets.append(attrs->getValue().begin(), attrs->getValue().end());
99 targets.erase(llvm::unique(targets), targets.end());
101 module.setTargetsAttr(builder.getArrayAttr(targets));
static llvm::ManagedStatic< PassManagerOptions > options
Block represents an ordered list of Operations.
MLIRContext * getContext() const
DictionaryAttr getDictionaryAttr(ArrayRef< NamedAttribute > value)
NamedAttribute getNamedAttr(StringRef name, Attribute val)
ArrayAttr getStrArrayAttr(ArrayRef< StringRef > values)
Attr getAttr(Args &&...args)
Get or construct an instance of the attribute Attr with provided arguments.
This class helps build Operations.
OpT getOperation()
Return the current operation being transformed.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
std::pair< llvm::BumpPtrAllocator, SmallVector< const char * > > tokenizeCmdOptions() const
Returns a tokenization of the command line options.
::mlir::Pass::Option< std::string > moduleMatcher
::mlir::Pass::Option< std::string > features
::mlir::Pass::Option< std::string > cmdOptions
::mlir::Pass::Option< bool > ftzFlag
::mlir::Pass::Option< bool > verifyTarget
::mlir::Pass::Option< bool > fastFlag
::mlir::Pass::ListOption< std::string > linkLibs
::mlir::Pass::Option< std::string > chip
::mlir::Pass::Option< std::string > triple
::mlir::Pass::Option< unsigned > optLevel
::mlir::Pass::Option< bool > compilerDiagnosticsFlag
Include the generated interface declarations.