MLIR 24.0.0git
ACCToLLVMUtils.cpp
Go to the documentation of this file.
1//===- ACCToLLVMUtils.cpp - OpenACC to LLVM helpers -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
19#include "llvm/ADT/Hashing.h"
20#include "llvm/ADT/STLExtras.h"
21#include "llvm/ADT/SmallString.h"
22#include "llvm/ADT/StringExtras.h"
23#include "llvm/ADT/Twine.h"
24
25#include <iterator>
26
27using namespace mlir;
28using namespace mlir::acc;
29
31 while (auto fusedLoc = dyn_cast<FusedLoc>(loc))
32 loc = fusedLoc.getLocations().back();
33 return loc;
34}
35
36std::optional<FileLineColLoc>
37acc::getFileLineColLoc(Location loc, bool errorOnInvalidLocation) {
38 Location unfusedLoc = unfuseLoc(loc);
39
40 if (auto fileLoc = dyn_cast<FileLineColLoc>(unfusedLoc))
41 return fileLoc;
42
43 if (auto callSiteLoc = dyn_cast<CallSiteLoc>(unfusedLoc)) {
44 if (auto calleeFileLoc = getFileLineColLoc(callSiteLoc.getCallee(), false))
45 return calleeFileLoc;
46 if (auto callerFileLoc =
47 getFileLineColLoc(callSiteLoc.getCaller(), errorOnInvalidLocation))
48 return callerFileLoc;
49 }
50
51 if (errorOnInvalidLocation)
52 llvm_unreachable(
53 "cannot get file:line information: invalid Location information");
54 return std::nullopt;
55}
56
58 if (!op)
59 return "";
60 auto funcOp = dyn_cast<FunctionOpInterface>(op);
61 if (!funcOp)
62 funcOp = op->getParentOfType<FunctionOpInterface>();
63 return funcOp ? funcOp.getName() : StringRef();
64}
65
67 if (auto *op = value.getDefiningOp())
68 return getParentFunctionName(op);
69 return "";
70}
71
73 for (Value value : values) {
74 if (StringRef name = getParentFunctionName(value); !name.empty())
75 return name;
76 }
77 return "";
78}
79
80std::string acc::getInternalGlobalName(StringRef kind, StringRef detail) {
81 SmallString<64> name("acc.");
82 name += kind;
83 if (detail.empty())
84 return name.str().str();
85
86 name += '.';
87 for (unsigned char c : detail)
88 name += (llvm::isAlnum(c) || c == '_' || c == '$' || c == '.') ? c : '_';
89 return name.str().str();
90}
91
92/// Creates or reuses a module-internal null-terminated string global and
93/// returns the GlobalOp.
94static LLVM::GlobalOp getOrCreateGlobalStringOp(Location loc,
95 OpBuilder &builder,
96 StringRef name, StringRef value,
97 Region &globalSymbolRegion,
98 SymbolTable *symbolTable) {
99 SmallString<32> nullTermStr(value);
100 nullTermStr.push_back('\0');
101 StringAttr valueAttr = builder.getStringAttr(nullTermStr);
102
103 // A name says what the global holds, so a global of that name is the one to
104 // reuse as long as it holds this very value. Names come out of detail the
105 // source spells and are not one to one with it, so a name can also lead to a
106 // global holding something else, which a suffix then keeps apart.
107 SmallString<64> uniqueName(name);
108 if (symbolTable) {
109 unsigned suffix = 0;
110 while (Operation *taken = symbolTable->lookup(uniqueName)) {
111 auto global = dyn_cast<LLVM::GlobalOp>(taken);
112 if (global && global.getValueOrNull() == valueAttr)
113 return global;
114 uniqueName.clear();
115 (name + "." + Twine(suffix++)).toVector(uniqueName);
116 }
117 }
118
119 // Materialize the global through the incoming builder so that it stays
120 // tracked when the caller is a dialect conversion rewriter.
121 OpBuilder::InsertionGuard guard(builder);
122 builder.setInsertionPointToStart(&globalSymbolRegion.front());
123 auto arrayTy = LLVM::LLVMArrayType::get(builder.getI8Type(),
124 nullTermStr.size_in_bytes());
125 auto global =
126 LLVM::GlobalOp::create(builder, loc, arrayTy, /*isConstant=*/true,
127 LLVM::Linkage::Internal, uniqueName, valueAttr,
128 /*alignment=*/0);
129 if (symbolTable)
130 symbolTable->insert(global);
131 return global;
132}
133
135 StringRef name, StringRef value,
136 Region &globalSymbolRegion,
137 SymbolTable *symbolTable) {
138 Type i64Ty = builder.getI64Type();
139 Type ptrTy = LLVM::LLVMPointerType::get(builder.getContext());
140 LLVM::GlobalOp global = getOrCreateGlobalStringOp(
141 loc, builder, name, value, globalSymbolRegion, symbolTable);
142
143 Value globalPtr = LLVM::AddressOfOp::create(builder, loc, global);
144 Value cst0 = LLVM::ConstantOp::create(builder, loc, i64Ty,
145 builder.getI64IntegerAttr(0));
146 return LLVM::GEPOp::create(builder, loc, ptrTy, global.getType(), globalPtr,
147 ArrayRef<Value>({cst0, cst0}));
148}
149
150Value acc::createIdent(Location loc, StringRef functionName, OpBuilder &builder,
151 Region &globalSymbolRegion,
152 const ACCRuntimeCallConfig &config,
153 SymbolTable *symbolTable) {
154 MLIRContext *ctx = builder.getContext();
155 Type i32Ty = builder.getI32Type();
156 Type i64Ty = builder.getI64Type();
157 Type ptrTy = LLVM::LLVMPointerType::get(ctx);
158 Type structTy = LLVM::LLVMStructType::getLiteral(
159 ctx, {i32Ty, i32Ty, i32Ty, i32Ty, ptrTy});
160
161 std::string source;
162 // The position the globals describe is what names them, so a global found
163 // under such a name holds this very source string or ident.
164 std::string position;
165 if (auto fileLineColLoc =
166 getFileLineColLoc(loc, /*errorOnInvalidLocation=*/false)) {
167 std::string filename = fileLineColLoc->getFilename().str();
168 std::string line = std::to_string(fileLineColLoc->getLine());
169 std::string column = std::to_string(fileLineColLoc->getColumn());
170 std::string functionDisplayName =
171 functionName.empty() ? std::string()
172 : config.getFunctionDisplayName(functionName);
173 source = ";";
174 source += filename + ";";
175 source += functionDisplayName + ";";
176 source += line + ";";
177 source += column + ";";
178 source += ";";
179 position = line + "." + column + ".";
180 position += std::to_string(static_cast<uint64_t>(llvm::hash_value(source)));
181 } else {
182 source = ";unknown;unknown;0;0;;";
183 position = "unknown";
184 }
185
186 std::string identGlobalName = getInternalGlobalName("ident", position);
187 LLVM::GlobalOp identGlobal =
188 symbolTable ? symbolTable->lookup<LLVM::GlobalOp>(identGlobalName)
189 : LLVM::GlobalOp();
190 if (!identGlobal) {
191 LLVM::GlobalOp sourceGlobal = getOrCreateGlobalStringOp(
192 loc, builder, getInternalGlobalName("loc", position), source,
193 globalSymbolRegion, symbolTable);
194
195 OpBuilder::InsertionGuard guard(builder);
196 builder.setInsertionPointAfter(sourceGlobal);
197 identGlobal = LLVM::GlobalOp::create(
198 builder, loc, structTy, /*isConstant=*/true, LLVM::Linkage::Internal,
199 identGlobalName, /*value=*/Attribute(), /*alignment=*/0);
200 if (symbolTable)
201 symbolTable->insert(identGlobal);
202
203 Block *block = builder.createBlock(&identGlobal.getInitializerRegion());
204 builder.setInsertionPointToStart(block);
205 Value ident = LLVM::ZeroOp::create(builder, loc, structTy);
206 Value sourceBase = LLVM::AddressOfOp::create(builder, loc, sourceGlobal);
207 Value cst0 = LLVM::ConstantOp::create(builder, loc, i64Ty,
208 builder.getI64IntegerAttr(0));
209 Value sourcePtr =
210 LLVM::GEPOp::create(builder, loc, ptrTy, sourceGlobal.getType(),
211 sourceBase, ArrayRef<Value>({cst0, cst0}));
212 ident = LLVM::InsertValueOp::create(builder, loc, structTy, ident,
213 sourcePtr, ArrayRef<int64_t>{4});
214 LLVM::ReturnOp::create(builder, loc, ident);
215 }
216
217 return LLVM::AddressOfOp::create(builder, loc, identGlobal);
218}
219
221 Type i64Ty = builder.getI64Type();
222 if (value.getType() == i64Ty)
223 return value;
224 if (isa<IndexType>(value.getType()))
225 return arith::IndexCastOp::create(builder, loc, i64Ty, value);
226 unsigned bitwidth = value.getType().getIntOrFloatBitWidth();
227 if (bitwidth > 64)
228 return arith::TruncIOp::create(builder, loc, i64Ty, value);
229 return arith::ExtSIOp::create(builder, loc, i64Ty, value);
230}
231
233 return LLVM::ConstantOp::create(builder, loc, builder.getI64Type(), value);
234}
235
236Value acc::remapOrSelf(Value value, ConversionPatternRewriter &rewriter) {
237 if (!value)
238 return {};
239 if (Value converted = rewriter.getRemappedValue(value))
240 return converted;
241 return value;
242}
243
244Value acc::getAsyncQueue(Location loc, Value asyncOperand, bool asyncOnly,
245 OpBuilder &builder,
246 const ACCRuntimeCallConfig &config) {
247 Type i64Ty = builder.getI64Type();
248 if (asyncOnly)
249 return LLVM::ConstantOp::create(builder, loc, i64Ty,
251 if (asyncOperand)
252 return castToI64(loc, asyncOperand, builder);
253 return LLVM::ConstantOp::create(builder, loc, i64Ty,
254 config.getAsyncSyncRuntimeValue());
255}
256
257LogicalResult acc::emitWaitCall(Location loc, ValueRange waitOperands,
258 Value asyncQueue, OpBuilder &builder,
259 Region &globalSymbolRegion,
260 SymbolTable &symbolTable,
261 const ACCRuntimeCallConfig &config,
262 Value deviceNum) {
263 Type i32Ty = builder.getI32Type();
264 Type i64Ty = builder.getI64Type();
265 Type ptrTy = LLVM::LLVMPointerType::get(builder.getContext());
266
267 SmallVector<Value> queues;
268 queues.reserve(waitOperands.size());
269 for (Value waitOperand : waitOperands)
270 queues.push_back(castToI64(loc, waitOperand, builder));
271
272 unsigned size = queues.size();
273 Value waitNum = LLVM::ConstantOp::create(builder, loc, i32Ty, size);
274 Value waitList;
275 if (size == 0) {
276 waitList = LLVM::ZeroOp::create(builder, loc, ptrTy);
277 } else {
278 waitList = LLVM::AllocaOp::create(builder, loc, ptrTy, i64Ty, waitNum);
279 for (auto [index, queue] : llvm::enumerate(queues)) {
280 Value idx = LLVM::ConstantOp::create(builder, loc, i32Ty,
281 static_cast<int64_t>(index));
282 Value elementPtr = LLVM::GEPOp::create(builder, loc, ptrTy, i64Ty,
283 waitList, ArrayRef<Value>{idx});
284 LLVM::StoreOp::create(builder, loc, queue, elementPtr);
285 }
286 }
287
288 StringRef functionName = getParentFunctionName(waitOperands);
289 if (functionName.empty())
290 if (Block *block = builder.getInsertionBlock())
291 functionName = getParentFunctionName(block->getParentOp());
292 Value ident = createIdent(loc, functionName, builder, globalSymbolRegion,
293 config, &symbolTable);
294 Value flags = LLVM::ConstantOp::create(builder, loc, i64Ty, 0);
295 Value deviceType = LLVM::ConstantOp::create(
296 builder, loc, i64Ty, config.getDeviceTypeRuntimeValue(DeviceType::None));
297 if (!deviceNum)
298 deviceNum = LLVM::ConstantOp::create(builder, loc, i32Ty, 0);
299
300 return createRuntimeCall(
301 loc, builder, globalSymbolRegion, symbolTable,
302 RuntimeFunction::ACCRTL_tgt_acc_wait, config,
303 {ident, flags, deviceType, deviceNum, waitNum, waitList, asyncQueue});
304}
305
306FailureOr<Value> acc::emitGetDevicePtrCall(Operation *clauseOp, Value hostPtr,
307 bool ifPresent, OpBuilder &builder,
308 Region &globalSymbolRegion,
309 SymbolTable &symbolTable,
310 const ACCRuntimeCallConfig &config) {
311 Location loc = clauseOp->getLoc();
312 Value ident = createIdent(loc, getParentFunctionName(clauseOp), builder,
313 globalSymbolRegion, config, &symbolTable);
314 Value flags = LLVM::ConstantOp::create(
315 builder, loc, builder.getI64Type(),
316 config.getMapFlagsRuntimeValue(ifPresent ? MapFlags::if_present
317 : MapFlags::none));
318 // Both slots hold the address of the object, a clause naming a section of
319 // one included: the entry point looks up the mapping that address belongs
320 // to rather than being told which one to ask about.
321 FailureOr<LLVM::CallOp> call = createRuntimeCall(
322 loc, builder, globalSymbolRegion, symbolTable,
323 RuntimeFunction::ACCRTL_tgt_acc_get_deviceptr, config,
324 {ident, /*basePtr=*/hostPtr, flags, /*hostPtr=*/hostPtr});
325 if (failed(call))
326 return failure();
327 return call->getResult();
328}
329
330LogicalResult acc::emitGuardedByIfCond(Location loc, Value ifCond,
331 RewriterBase &rewriter,
332 function_ref<LogicalResult()> emitFn) {
333 if (!ifCond)
334 return emitFn();
335
336 Block *parentBlock = rewriter.getInsertionBlock();
337 Block *continueBlock =
338 rewriter.splitBlock(parentBlock, rewriter.getInsertionPoint());
339 Block *thenBlock = rewriter.createBlock(
340 parentBlock->getParent(), std::next(Region::iterator(parentBlock)));
341
342 rewriter.setInsertionPointToEnd(parentBlock);
343 LLVM::CondBrOp::create(rewriter, loc, ifCond, thenBlock, ValueRange{},
344 continueBlock, ValueRange{});
345
346 rewriter.setInsertionPointToStart(thenBlock);
347 LogicalResult result = emitFn();
348 rewriter.setInsertionPointToEnd(thenBlock);
349 LLVM::BrOp::create(rewriter, loc, ValueRange{}, continueBlock);
350 rewriter.setInsertionPointToStart(continueBlock);
351 return result;
352}
353
354FailureOr<Value>
356 RewriterBase &rewriter,
357 function_ref<FailureOr<Value>()> thenFn,
358 function_ref<FailureOr<Value>()> elseFn) {
359 if (!ifCond)
360 return thenFn();
361
362 Block *parentBlock = rewriter.getInsertionBlock();
363 Block *continueBlock =
364 rewriter.splitBlock(parentBlock, rewriter.getInsertionPoint());
365 Block *thenBlock = rewriter.createBlock(
366 parentBlock->getParent(), std::next(Region::iterator(parentBlock)));
367 Block *elseBlock = rewriter.createBlock(
368 parentBlock->getParent(), std::next(Region::iterator(thenBlock)));
369
370 rewriter.setInsertionPointToEnd(parentBlock);
371 LLVM::CondBrOp::create(rewriter, loc, ifCond, thenBlock, ValueRange{},
372 elseBlock, ValueRange{});
373
374 rewriter.setInsertionPointToStart(thenBlock);
375 FailureOr<Value> thenValue = thenFn();
376 if (failed(thenValue))
377 return failure();
378 rewriter.setInsertionPointToEnd(thenBlock);
379 LLVM::BrOp::create(rewriter, loc, ValueRange{*thenValue}, continueBlock);
380
381 rewriter.setInsertionPointToStart(elseBlock);
382 FailureOr<Value> elseValue = elseFn();
383 if (failed(elseValue))
384 return failure();
385 rewriter.setInsertionPointToEnd(elseBlock);
386 LLVM::BrOp::create(rewriter, loc, ValueRange{*elseValue}, continueBlock);
387
388 assert(thenValue->getType() == elseValue->getType() &&
389 "both paths of an if clause have to produce the same type");
390 BlockArgument selected =
391 continueBlock->addArgument(thenValue->getType(), loc);
392 rewriter.setInsertionPointToStart(continueBlock);
393 return Value(selected);
394}
395
397 RewriterBase &rewriter) {
398 Block *prev = op->getBlock();
399 Block *succ = rewriter.splitBlock(prev, Block::iterator(op));
400 rewriter.setInsertionPointToEnd(prev);
401 LLVM::BrOp::create(rewriter, op->getLoc(), &region.getBlocks().front());
402 for (Block &block : region.getBlocks()) {
403 // A region that ends without a terminator, as an `acc.kernel_environment`
404 // body does, continues after the construct from the end of its block.
405 if (block.empty() || !block.back().hasTrait<OpTrait::IsTerminator>()) {
406 rewriter.setInsertionPointToEnd(&block);
407 LLVM::BrOp::create(rewriter, op->getLoc(), succ);
408 continue;
409 }
410 Operation *terminator = block.getTerminator();
411 if (isa<acc::TerminatorOp>(terminator)) {
412 rewriter.setInsertionPoint(terminator);
413 LLVM::BrOp::create(rewriter, op->getLoc(), succ);
414 rewriter.eraseOp(terminator);
415 }
416 }
417 rewriter.inlineRegionBefore(region, succ);
418}
static LLVM::GlobalOp getOrCreateGlobalStringOp(Location loc, OpBuilder &builder, StringRef name, StringRef value, Region &globalSymbolRegion, SymbolTable *symbolTable)
Creates or reuses a module-internal null-terminated string global and returns the GlobalOp.
Attributes are known-constant values of operations.
Definition Attributes.h:25
This class represents an argument of a Block.
Definition Value.h:308
Block represents an ordered list of Operations.
Definition Block.h:34
OpListType::iterator iterator
Definition Block.h:165
Region * getParent() const
Provide a 'getParent' method for ilist_node_with_parent methods.
Definition Block.cpp:27
BlockArgument addArgument(Type type, Location loc)
Add one value to the argument list.
Definition Block.cpp:158
IntegerType getI64Type()
Definition Builders.cpp:73
IntegerType getI32Type()
Definition Builders.cpp:71
IntegerAttr getI64IntegerAttr(int64_t value)
Definition Builders.cpp:120
StringAttr getStringAttr(const Twine &bytes)
Definition Builders.cpp:271
MLIRContext * getContext() const
Definition Builders.h:56
IntegerType getI8Type()
Definition Builders.cpp:67
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
MLIRContext is the top-level object for a collection of MLIR operations.
Definition MLIRContext.h:71
RAII guard to reset the insertion point of the builder when destroyed.
Definition Builders.h:351
This class helps build Operations.
Definition Builders.h:210
Block::iterator getInsertionPoint() const
Returns the current insertion point of the builder.
Definition Builders.h:448
Block * createBlock(Region *parent, Region::iterator insertPt={}, TypeRange argTypes={}, ArrayRef< Location > locs={})
Add new block with 'argTypes' arguments and set the insertion point to the end of it.
Definition Builders.cpp:439
void setInsertionPointToStart(Block *block)
Sets the insertion point to the start of the specified block.
Definition Builders.h:434
void setInsertionPoint(Block *block, Block::iterator insertPoint)
Set the insertion point to the specified location.
Definition Builders.h:401
void setInsertionPointToEnd(Block *block)
Sets the insertion point to the end of the specified block.
Definition Builders.h:439
Block * getInsertionBlock() const
Return the block the current insertion point belongs to.
Definition Builders.h:445
void setInsertionPointAfter(Operation *op)
Sets the insertion point to the node after the specified operation, which will cause subsequent inser...
Definition Builders.h:415
This class provides the API for ops that are known to be terminators.
Operation is the basic unit of execution within MLIR.
Definition Operation.h:87
Block * getBlock()
Returns the operation block that contains this operation.
Definition Operation.h:230
Location getLoc()
The source location the operation was defined or derived from.
Definition Operation.h:240
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
Definition Operation.h:255
This class contains a list of basic blocks and a link to the parent operation it is attached to.
Definition Region.h:26
Block & front()
Definition Region.h:65
BlockListType & getBlocks()
Definition Region.h:45
BlockListType::iterator iterator
Definition Region.h:52
This class coordinates the application of a rewrite on a set of IR, providing a way for clients to tr...
Block * splitBlock(Block *block, Block::iterator before)
Split the operations starting at "before" (inclusive) out of the given block into a new block,...
virtual void eraseOp(Operation *op)
This method erases an operation that is known to have no uses.
void inlineRegionBefore(Region &region, Region &parent, Region::iterator before)
Move the blocks that belong to "region" before the given position in another region "parent".
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Definition SymbolTable.h:25
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.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
Definition Types.h:74
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
Definition Types.cpp:124
This class provides an abstraction over the different types of ranges over Values.
Definition ValueRange.h:392
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Definition Value.h:96
Type getType() const
Return the type of this value.
Definition Value.h:105
Operation * getDefiningOp() const
If this value is the result of an operation, return the operation that defines it.
Definition Value.cpp:18
Configuration for OpenACC to LLVM runtime lowering.
std::string getFunctionDisplayName(StringRef mangledOrSymbol) const
int64_t getDeviceTypeRuntimeValue(DeviceType type) const
int64_t getMapFlagsRuntimeValue(MapFlags flags) const
std::optional< FileLineColLoc > getFileLineColLoc(Location loc, bool errorOnInvalidLocation)
Returns file:line:column location information when available.
LogicalResult emitWaitCall(Location loc, ValueRange waitOperands, Value asyncQueue, OpBuilder &builder, Region &globalSymbolRegion, SymbolTable &symbolTable, const ACCRuntimeCallConfig &config, Value deviceNum={})
Emits the runtime call that waits for waitOperands on asyncQueue, which is what a wait clause or an a...
Value getAsyncQueue(Location loc, Value asyncOperand, bool asyncOnly, OpBuilder &builder, const ACCRuntimeCallConfig &config)
Returns the queue an async clause selects: the value of the clause when it has one,...
Value createIdent(Location loc, StringRef functionName, OpBuilder &builder, Region &globalSymbolRegion, const ACCRuntimeCallConfig &config, SymbolTable *symbolTable=nullptr)
Returns a pointer to a constant global holding an ident_t for OpenACC runtime calls.
Value remapOrSelf(Value value, ConversionPatternRewriter &rewriter)
Returns the value value was converted to, or value itself when the conversion left it as it was.
FailureOr< Value > emitValueSelectedByIfCond(Location loc, Value ifCond, RewriterBase &rewriter, function_ref< FailureOr< Value >()> thenFn, function_ref< FailureOr< Value >()> elseFn)
Emits thenFn on the path a branch on ifCond takes and elseFn on the other one, and returns the value ...
Value constantI64(Location loc, int64_t value, OpBuilder &builder)
Creates an i64 constant.
std::string getInternalGlobalName(StringRef kind, StringRef detail)
Returns the name to give a global that the conversion creates to hold detail of kind,...
StringRef getParentFunctionName(Operation *op)
Returns the symbol name of the function op belongs to, or of op itself when it is a function.
LogicalResult emitGuardedByIfCond(Location loc, Value ifCond, RewriterBase &rewriter, function_ref< LogicalResult()> emitFn)
Runs emitFn guarded by a branch on ifCond, or unguarded when there is no condition.
Value castToI64(Location loc, Value value, OpBuilder &builder)
Sign-extends or truncates value to the i64 the runtime entry points take for values like queue number...
Value getOrCreateGlobalString(Location loc, OpBuilder &builder, StringRef name, StringRef value, Region &globalSymbolRegion, SymbolTable *symbolTable=nullptr)
Creates or reuses a null-terminated string global in globalSymbolRegion.
void spliceConstructRegion(Operation *op, Region &region, RewriterBase &rewriter)
Splices region, the body of a structured construct, into the block holding op, so that the construct ...
FailureOr< LLVM::CallOp > createRuntimeCall(Location loc, OpBuilder &builder, Region &globalSymbolRegion, SymbolTable &symbolTable, RuntimeFunction fn, const ACCRuntimeCallConfig &config, ArrayRef< Value > arguments)
Declares (if needed) and returns a call to the runtime function identified by fn using the name from ...
Location unfuseLoc(Location loc)
Unfuses fused locations, returning the last sub-location.
FailureOr< Value > emitGetDevicePtrCall(Operation *clauseOp, Value hostPtr, bool ifPresent, OpBuilder &builder, Region &globalSymbolRegion, SymbolTable &symbolTable, const ACCRuntimeCallConfig &config)
Emits the runtime call that asks for the device address the object of the data clause clauseOp is map...
Include the generated interface declarations.
llvm::function_ref< Fn > function_ref
Definition LLVM.h:155