62#define GEN_PASS_DEF_ACCDECLAREGPUMODULEINSERTION
63#include "mlir/Dialect/OpenACC/Transforms/Passes.h.inc"
67#define DEBUG_TYPE "acc-declare-gpu-module-insertion"
73static bool hasAccDeclareGlobals(ModuleOp mod) {
74 for (
Operation &op : mod.getBody()->getOperations())
80class ACCDeclareGPUModuleInsertion
82 ACCDeclareGPUModuleInsertion> {
87 LogicalResult copyGlobalsToGPUModule(gpu::GPUModuleOp gpuMod, ModuleOp mod,
91 for (
Operation &globalOp : mod.getBody()->getOperations()) {
95 auto symOp = dyn_cast<SymbolOpInterface>(&globalOp);
99 StringAttr name = symOp.getNameAttr();
105 if (existing->getName() != globalOp.getName() ||
111 accSupport.
emitNYI(globalOp.getLoc(),
112 llvm::Twine(
"duplicate global symbol '") +
113 name.getValue() +
"' in gpu module");
119 gpuSymTable.
insert(globalOp.clone());
124 void runOnOperation()
override {
125 ModuleOp mod = getOperation();
129 if (!hasAccDeclareGlobals(mod))
133 std::optional<gpu::GPUModuleOp> gpuMod =
136 accSupport.
emitNYI(mod.getLoc(),
"Failed to create GPU module");
140 if (
failed(copyGlobalsToGPUModule(*gpuMod, mod, accSupport)))
Operation is the basic unit of execution within MLIR.
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Operation * lookup(StringRef name) const
Look up a symbol with the specified name, returning null if no such name exists.
StringAttr insert(Operation *symbol, Block::iterator insertPt={})
Insert a new symbol into the table, and rename it as necessary to avoid collisions.
InFlightDiagnostic emitNYI(Location loc, const Twine &message)
Report a case that is not yet supported by the implementation.
std::optional< gpu::GPUModuleOp > getOrCreateGPUModule(ModuleOp mod, bool create=true, llvm::StringRef name="")
Get or optionally create a GPU module in the given module.
ACCDeclareGPUModuleInsertionBase()
static constexpr StringLiteral getDeclareAttrName()
Used to obtain the attribute name for declare.
Include the generated interface declarations.
static bool isEquivalentTo(Operation *lhs, Operation *rhs, function_ref< LogicalResult(Value, Value)> checkEquivalent, function_ref< void(Value, Value)> markEquivalent=nullptr, Flags flags=Flags::None, function_ref< LogicalResult(ValueRange, ValueRange)> checkCommutativeEquivalent=nullptr)
Compare two operations (including their regions) and return if they are equivalent.
static LogicalResult ignoreValueEquivalence(Value lhs, Value rhs)
Helper that can be used with isEquivalentTo above to consider ops equivalent even if their operands a...