50 lines · cpp
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-exception7//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 fir::CallOp::create(builder, 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 fir::CallOp::create(builder, loc, func, args);49}50