1 //===-- Command.cpp -- generate command line 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 #ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COMMAND_H 10 #define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COMMAND_H 11 12 namespace mlir { 13 class Value; 14 class Location; 15 } // namespace mlir 16 17 namespace fir { 18 class FirOpBuilder; 19 } // namespace fir 20 21 namespace fir::runtime { 22 23 /// Generate call to COMMAND_ARGUMENT_COUNT intrinsic runtime routine. 24 mlir::Value genCommandArgumentCount(fir::FirOpBuilder &, mlir::Location); 25 26 /// Generate a call to the GetCommand runtime function which implements the 27 /// GET_COMMAND intrinsic. 28 /// \p command, \p length and \p errmsg must be fir.box that can be absent (but 29 /// not null mlir values). The status value is returned. 30 mlir::Value genGetCommand(fir::FirOpBuilder &, mlir::Location, 31 mlir::Value command, mlir::Value length, 32 mlir::Value errmsg); 33 34 /// Generate a call to the GetPID runtime function which implements the 35 /// GETPID intrinsic. 36 mlir::Value genGetPID(fir::FirOpBuilder &, mlir::Location); 37 38 /// Generate a call to the GetCommandArgument runtime function which implements 39 /// the GET_COMMAND_ARGUMENT intrinsic. 40 /// \p value, \p length and \p errmsg must be fir.box that can be absent (but 41 /// not null mlir values). The status value is returned. 42 mlir::Value genGetCommandArgument(fir::FirOpBuilder &, mlir::Location, 43 mlir::Value number, mlir::Value value, 44 mlir::Value length, mlir::Value errmsg); 45 46 /// Generate a call to GetEnvVariable runtime function which implements 47 /// the GET_ENVIRONMENT_VARIABLE intrinsic. 48 /// \p value, \p length and \p errmsg must be fir.box that can be absent (but 49 /// not null mlir values). The status value is returned. \p name must be a 50 /// fir.box and \p trimName a boolean value. 51 mlir::Value genGetEnvVariable(fir::FirOpBuilder &, mlir::Location, 52 mlir::Value name, mlir::Value value, 53 mlir::Value length, mlir::Value trimName, 54 mlir::Value errmsg); 55 56 /// Generate a call to the GetCwd runtime function which implements 57 /// the GETCWD intrinsic. 58 mlir::Value genGetCwd(fir::FirOpBuilder &builder, mlir::Location loc, 59 mlir::Value c); 60 61 } // namespace fir::runtime 62 #endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COMMAND_H 63