1
2//===-- Allocatable.cpp -- Allocatable statements lowering ----------------===//
3//
4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5// See https://llvm.org/LICENSE.txt for license information.
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
11//
12//===----------------------------------------------------------------------===//
13
14#include "flang/Optimizer/Builder/Runtime/CUDA/Descriptor.h"
15#include "flang/Optimizer/Builder/FIRBuilder.h"
16#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
17#include "flang/Runtime/CUDA/descriptor.h"
18
19using namespace Fortran::runtime::cuda;
20
21void fir::runtime::cuda::genSyncGlobalDescriptor(fir::FirOpBuilder &builder,
22 mlir::Location loc,
23 mlir::Value hostPtr) {
24 mlir::func::FuncOp callee =
25 fir::runtime::getRuntimeFunc<mkRTKey(CUFSyncGlobalDescriptor)>(loc,
26 builder);
27 auto fTy = callee.getFunctionType();
28 mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc);
29 mlir::Value sourceLine =
30 fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
31 llvm::SmallVector<mlir::Value> args{fir::runtime::createArguments(
32 builder, loc, fTy, hostPtr, sourceFile, sourceLine)};
33 builder.create<fir::CallOp>(loc, callee, args);
34}
35
36void fir::runtime::cuda::genDescriptorCheckSection(fir::FirOpBuilder &builder,
37 mlir::Location loc,
38 mlir::Value desc) {
39 mlir::func::FuncOp func =
40 fir::runtime::getRuntimeFunc<mkRTKey(CUFDescriptorCheckSection)>(loc,
41 builder);
42 auto fTy = func.getFunctionType();
43 mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc);
44 mlir::Value sourceLine =
45 fir::factory::locationToLineNo(builder, loc, fTy.getInput(2));
46 llvm::SmallVector<mlir::Value> args{fir::runtime::createArguments(
47 builder, loc, fTy, desc, sourceFile, sourceLine)};
48 builder.create<fir::CallOp>(loc, func, args);
49}
50
51void fir::runtime::cuda::genSetAllocatorIndex(fir::FirOpBuilder &builder,
52 mlir::Location loc,
53 mlir::Value desc,
54 mlir::Value index) {
55 mlir::func::FuncOp func =
56 fir::runtime::getRuntimeFunc<mkRTKey(CUFSetAllocatorIndex)>(loc, builder);
57 auto fTy = func.getFunctionType();
58 mlir::Value sourceFile = fir::factory::locationToFilename(builder, loc);
59 mlir::Value sourceLine =
60 fir::factory::locationToLineNo(builder, loc, fTy.getInput(3));
61 llvm::SmallVector<mlir::Value> args{fir::runtime::createArguments(
62 builder, loc, fTy, desc, index, sourceFile, sourceLine)};
63 builder.create<fir::CallOp>(loc, func, args);
64}
65

source code of flang/lib/Optimizer/Builder/Runtime/CUDA/Descriptor.cpp