/// Get a reference to the kind map.
const fir::KindMapping &getKindMap() { return kindMap; }
+ /// Get the default integer type
+ [[maybe_unused]] mlir::IntegerType getDefaultIntegerType() {
+ return getIntegerType(
+ getKindMap().getIntegerBitsize(getKindMap().defaultIntegerKind()));
+ }
+
/// The LHS and RHS are not always in agreement in terms of
/// type. In some cases, the disagreement is between COMPLEX and other scalar
/// types. In that case, the conversion must insert/extract out of a COMPLEX
--- /dev/null
+//===-- Command.cpp -- generate command line runtime API calls ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COMMAND_H
+#define FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COMMAND_H
+
+namespace mlir {
+class Value;
+class Location;
+} // namespace mlir
+
+namespace fir {
+class FirOpBuilder;
+}
+
+namespace fir::runtime {
+
+/// Generate call to COMMAND_ARGUMENT_COUNT intrinsic runtime routine.
+mlir::Value genCommandArgumentCount(fir::FirOpBuilder &, mlir::Location);
+
+} // namespace fir::runtime
+#endif // FORTRAN_OPTIMIZER_BUILDER_RUNTIME_COMMAND_H
MutableBox.cpp
Runtime/Assign.cpp
Runtime/Character.cpp
+ Runtime/Command.cpp
Runtime/Derived.cpp
Runtime/Numeric.cpp
Runtime/Ragged.cpp
--- /dev/null
+//===-- Command.cpp -- generate command line runtime API calls ------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/Builder/Runtime/Command.h"
+#include "flang/Optimizer/Builder/FIRBuilder.h"
+#include "flang/Optimizer/Builder/Runtime/RTBuilder.h"
+#include "flang/Runtime/command.h"
+
+using namespace Fortran::runtime;
+
+mlir::Value fir::runtime::genCommandArgumentCount(fir::FirOpBuilder &builder,
+ mlir::Location loc) {
+ auto argumentCountFunc =
+ fir::runtime::getRuntimeFunc<mkRTKey(ArgumentCount)>(loc, builder);
+ return builder.create<fir::CallOp>(loc, argumentCountFunc).getResult(0);
+}
--- /dev/null
+//===- CommandTest.cpp -- command line runtime builder unit tests ---------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/Builder/Runtime/Command.h"
+#include "RuntimeCallTestBase.h"
+#include "gtest/gtest.h"
+
+TEST_F(RuntimeCallTest, genCommandArgumentCountTest) {
+ mlir::Location loc = firBuilder->getUnknownLoc();
+ mlir::Value result = fir::runtime::genCommandArgumentCount(*firBuilder, loc);
+ checkCallOp(result.getDefiningOp(), "_FortranAArgumentCount", /*nbArgs=*/0,
+ /*addLocArgs=*/false);
+}
Builder/DoLoopHelperTest.cpp
Builder/FIRBuilderTest.cpp
Builder/Runtime/AssignTest.cpp
+ Builder/Runtime/CommandTest.cpp
Builder/Runtime/CharacterTest.cpp
Builder/Runtime/DerivedTest.cpp
Builder/Runtime/NumericTest.cpp