20#include "llvm/Support/Regex.h"
23#define GEN_PASS_DEF_GPUXEVMATTACHTARGET
24#include "mlir/Dialect/GPU/Transforms/XeVM/Passes.h.inc"
31struct XeVMAttachTarget
35 DictionaryAttr getFlags(OpBuilder &builder)
const;
37 void runOnOperation()
override;
40 registry.
insert<xevm::XeVMDialect>();
45DictionaryAttr XeVMAttachTarget::getFlags(
OpBuilder &builder)
const {
49 std::pair<llvm::BumpPtrAllocator, SmallVector<const char *>>
options =
54 xevmOptionAttrs.emplace_back(
55 mlir::StringAttr::get(builder.
getContext(), StringRef(opt)));
59 mlir::ArrayAttr::get(builder.
getContext(), xevmOptionAttrs)));
68void XeVMAttachTarget::runOnOperation() {
77 for (
Block &block : region.getBlocks())
78 for (
auto module : block.getOps<gpu::GPUModuleOp>()) {
80 if (!
moduleMatcher.empty() && !matcher.match(module.getName()))
84 if (std::optional<ArrayAttr> attrs = module.getTargets())
85 targets.append(attrs->getValue().begin(), attrs->getValue().end());
88 targets.erase(llvm::unique(targets), targets.end());
90 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.
The DialectRegistry maps a dialect namespace to a constructor for the matching dialect.
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::ListOption< std::string > linkLibs
::mlir::Pass::Option< unsigned > optLevel
::mlir::Pass::Option< std::string > cmdOptions
::mlir::Pass::Option< std::string > moduleMatcher
::mlir::Pass::Option< std::string > chip
void getDependentDialects(::mlir::DialectRegistry ®istry) const override
Return the dialect that must be loaded in the context before this pass.
::mlir::Pass::Option< std::string > triple
Include the generated interface declarations.