22 if (
auto offloadMod = llvm::dyn_cast<OffloadModuleInterface>(*module)) {
24 offloadMod.setIsGPU(opts.
isGPU);
26 offloadMod.setRequires(offloadMod.getRequires() |
27 ClauseRequires::unified_shared_memory);
36 auto strTriples = llvm::to_vector(
37 llvm::map_range(opts.
targetTriples, [](
const llvm::Triple &triple) {
38 return triple.normalize();
40 offloadMod.setTargetTriples(strTriples);
46 StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),
47 VersionAttr::get(module.getContext(), version));
52 if (
Attribute verAttr = module->getAttr(
"omp.version"))
53 return llvm::cast<VersionAttr>(verAttr).getVersion();
58 return module->hasAttr("omp.version");
63 if (
auto parallelOp = dyn_cast<omp::ParallelOp>(owner)) {
64 if (llvm::is_contained(parallelOp.getReductionVars(), use.
get()))
66 }
else if (
auto callOp = dyn_cast<CallOpInterface>(owner)) {
67 if (llvm::is_contained(callOp.getArgOperands(), use.
get()))
74 if (
auto argIface = dyn_cast<omp::BlockArgOpenMPOpInterface>(owner)) {
76 auto it = llvm::find(privateVars, use.
get());
77 if (it != privateVars.end()) {
79 size_t idx = std::distance(privateVars.begin(), it);
82 owner, cast<SymbolRefAttr>(privateSyms[idx]));
83 return privateOp.getDataSharingType() !=
84 omp::DataSharingClauseType::Private;
95 if (isa<LLVM::AddrSpaceCastOp, LLVM::GEPOp>(owner)) {
97 return allocaUsesRequireSharedMem(result);
108 if (isa<omp::ParallelOp>(op))
112 if (!offloadIface || !offloadIface.getIsTargetDevice())
120 if (!targetOp || targetOp->isProperAncestor(parallelOp))
128 targetOp = dyn_cast<omp::TargetOp>(op);
131 if (targetOp.getKernelType() != omp::TargetExecMode::generic)
134 auto declTargetIface = op.
getParentOfType<omp::DeclareTargetInterface>();
135 if (!declTargetIface || !declTargetIface.isDeclareTarget() ||
136 declTargetIface.getDeclareTargetDeviceType() ==
137 omp::DeclareTargetDeviceType::host)
static bool allocaUseRequiresSharedMem(const OpOperand &use)
Attributes are known-constant values of operations.
IRValueT get() const
Return the current value being used by this operand.
This class represents an operand of an operation.
This class implements the operand iterators for the Operation class.
Operation is the basic unit of execution within MLIR.
AttrClass getAttrOfType(StringAttr name)
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
result_range getResults()
static Operation * lookupNearestSymbolFrom(Operation *from, StringAttr symbol)
Returns the operation registered with the given symbol name within the closest parent operation of,...
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
use_range getUses() const
Returns a range of all uses, which is useful for iterating over all uses.
Operation * getOwner() const
Return the owner of this operand.
void setOffloadModuleInterfaceAttributes(ModuleOp module, const OffloadModuleOpts &opts)
Sets OpenMP offload module interface attributes on a ModuleOp, shared between Flang and Clang (CIR) f...
bool isOpenMPModule(ModuleOp module)
Checks whether this is an OpenMP-enabled module.
int64_t getOpenMPVersionAttribute(ModuleOp module, int64_t fallback=-1)
Returns the value of the omp.version attribute, if present, or the fallback.
bool opInSharedDeviceContext(Operation &op)
Check whether the given operation is located in a context where an allocation to be used by multiple ...
void setOpenMPVersionAttribute(ModuleOp module, int64_t version)
Adds or updates the omp.version attribute.
bool allocaUsesRequireSharedMem(Value alloc)
Check whether the value representing an allocation, assumed to have been defined in a shared device c...
Include the generated interface declarations.
Offload-specific OpenMP module attributes, associated to the OffloadModuleInterface.
bool assumeNoNestedParallelism
bool assumeTeamsOversubscription
std::vector< llvm::Triple > targetTriples
bool assumeThreadsOversubscription
uint32_t openMPDeviceVersion