| 1 |
//===-- Allocatable.cpp -- generate allocatable runtime API calls----------===// |
| 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 |
|
| 9 |
#include "flang/Optimizer/Builder/Runtime/Allocatable.h" |
| 10 |
#include "flang/Optimizer/Builder/FIRBuilder.h" |
| 11 |
#include "flang/Optimizer/Builder/Runtime/RTBuilder.h" |
| 12 |
#include "flang/Runtime/allocatable.h" |
| 13 |
|
| 14 |
using namespace Fortran::runtime; |
| 15 |
|
| 16 |
mlir::Value fir::runtime::genMoveAlloc(fir::FirOpBuilder &builder, |
| 17 |
mlir::Location loc, mlir::Value to, |
| 18 |
mlir::Value from, mlir::Value hasStat, |
| 19 |
mlir::Value errMsg) { |
| 20 |
mlir::func::FuncOp func{ |
| 21 |
fir::runtime::getRuntimeFunc<mkRTKey(MoveAlloc)>(loc, builder)}; |
| 22 |
mlir::FunctionType fTy{func.getFunctionType()}; |
| 23 |
mlir::Value sourceFile{fir::factory::locationToFilename(builder, loc)}; |
| 24 |
mlir::Value sourceLine{ |
| 25 |
fir::factory::locationToLineNo(builder, loc, fTy.getInput(5))}; |
| 26 |
llvm::SmallVector<mlir::Value> args{fir::runtime::createArguments( |
| 27 |
builder, loc, fTy, to, from, hasStat, errMsg, sourceFile, sourceLine)}; |
| 28 |
|
| 29 |
return builder.create<fir::CallOp>(loc, func, args).getResult(0); |
| 30 |
} |