32 if (
auto hostData = dyn_cast<HostDataOp>(user))
43 UseDeviceOpLowering(
const LLVMTypeConverter &converter,
44 Region &globalSymbolRegion, SymbolTable &symbolTable,
45 const ACCRuntimeCallConfig &config,
46 PatternBenefit benefit = 1)
47 : ConvertOpToLLVMPattern<UseDeviceOp>(converter, benefit),
48 globalSymbolRegion(globalSymbolRegion), symbolTable(symbolTable),
52 matchAndRewrite(UseDeviceOp op, OpAdaptor adaptor,
53 ConversionPatternRewriter &rewriter)
const override {
56 return rewriter.notifyMatchFailure(
57 op,
"use_device clause of no host_data construct");
59 Location loc = op.getLoc();
60 Value hostPtr = adaptor.getVar();
61 auto emitCall = [&]() -> FailureOr<Value> {
63 rewriter, globalSymbolRegion,
67 auto keepHostPtr = [&]() -> FailureOr<Value> {
return hostPtr; };
69 Value ifCond = hostData.getIfCond()
70 ? rewriter.getRemappedValue(hostData.getIfCond())
73 rewriter.setInsertionPoint(hostData);
75 loc, ifCond, rewriter, emitCall, keepHostPtr);
79 rewriter.replaceOp(op, *devicePtr);
83 Region &globalSymbolRegion;
84 SymbolTable &symbolTable;
85 ACCRuntimeCallConfig config;
91 using ConvertOpToLLVMPattern<HostDataOp>::ConvertOpToLLVMPattern;
94 matchAndRewrite(HostDataOp op, OpAdaptor,
95 ConversionPatternRewriter &rewriter)
const override {
105 target.addIllegalOp<acc::HostDataOp, acc::UseDeviceOp>();
112 patterns.
add<UseDeviceOpLowering>(converter, globalSymbolRegion, symbolTable,
114 patterns.
add<HostDataOpLowering>(converter);
static HostDataOp getHostDataConstruct(UseDeviceOp op)
Returns the host_data construct op gives a device address to, or null when the clause belongs to no s...
Utility class for operation conversions targeting the LLVM dialect that match exactly one source oper...
Conversion from types to the LLVM IR dialect.
Operation is the basic unit of execution within MLIR.
user_range getUsers()
Returns a range of all users.
This class contains a list of basic blocks and a link to the parent operation it is attached to.
RewritePatternSet & add(ConstructorArg &&arg, ConstructorArgs &&...args)
Add an instance of each of the pattern types 'Ts' to the pattern list with the given arguments.
This class allows for representing and managing the symbol table used by operations with the 'SymbolT...
Configuration for OpenACC to LLVM runtime lowering.
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 ...
void spliceConstructRegion(Operation *op, Region ®ion, RewriterBase &rewriter)
Splices region, the body of a structured construct, into the block holding op, so that the construct ...
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.
void configureACCHostDataConversionLegality(ConversionTarget &target)
Configure conversion legality for the OpenACC host_data construct.
void populateACCHostDataPatterns(LLVMTypeConverter &converter, RewritePatternSet &patterns, Region &globalSymbolRegion, SymbolTable &symbolTable, const acc::ACCRuntimeCallConfig &config={})
Populate patterns that lower the OpenACC host_data construct to runtime calls, one per use_device cla...