[flang] [llvm] Reland [flang] In AllocMemOp lowering, convert types for calling malloc on 32-bit (PR #130384)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 7 19:03:05 PST 2025
https://github.com/ArcaneNibble created https://github.com/llvm/llvm-project/pull/130384
Previous PR: #129308
Changes: I added `REQUIRES: x86-registered-target` to the newly-added test so that it won't break the other buildbots.
>From 1984009c1e6ebf7f9d96a721f299022dc2877b21 Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 04:47:18 +0000
Subject: [PATCH 1/7] add wasm32 target
FIXME: check ABI
---
flang/lib/Optimizer/CodeGen/Target.cpp | 41 ++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/flang/lib/Optimizer/CodeGen/Target.cpp b/flang/lib/Optimizer/CodeGen/Target.cpp
index e2f8fb9d239a1..932c5fbcb9b9d 100644
--- a/flang/lib/Optimizer/CodeGen/Target.cpp
+++ b/flang/lib/Optimizer/CodeGen/Target.cpp
@@ -1816,6 +1816,44 @@ struct TargetLoongArch64 : public GenericTarget<TargetLoongArch64> {
};
} // namespace
+//===----------------------------------------------------------------------===//
+// WebAssembly (wasm32) target specifics.
+//===----------------------------------------------------------------------===//
+
+namespace {
+struct TargetWasm32 : public GenericTarget<TargetWasm32> {
+ using GenericTarget::GenericTarget;
+
+ static constexpr int defaultWidth = 32;
+
+ CodeGenSpecifics::Marshalling
+ complexArgumentType(mlir::Location, mlir::Type eleTy) const override {
+ assert(fir::isa_real(eleTy));
+ CodeGenSpecifics::Marshalling marshal;
+ // Use a type that will be translated into LLVM as:
+ // { t, t } struct of 2 eleTy, byval, align 4
+ auto structTy =
+ mlir::TupleType::get(eleTy.getContext(), mlir::TypeRange{eleTy, eleTy});
+ marshal.emplace_back(fir::ReferenceType::get(structTy),
+ AT{/*alignment=*/4, /*byval=*/true});
+ return marshal;
+ }
+
+ CodeGenSpecifics::Marshalling
+ complexReturnType(mlir::Location loc, mlir::Type eleTy) const override {
+ assert(fir::isa_real(eleTy));
+ CodeGenSpecifics::Marshalling marshal;
+ // Use a type that will be translated into LLVM as:
+ // { t, t } struct of 2 eleTy, sret, align 4
+ auto structTy = mlir::TupleType::get(eleTy.getContext(),
+ mlir::TypeRange{eleTy, eleTy});
+ marshal.emplace_back(fir::ReferenceType::get(structTy),
+ AT{/*alignment=*/4, /*byval=*/false, /*sret=*/true});
+ return marshal;
+ }
+};
+} // namespace
+
// Instantiate the overloaded target instance based on the triple value.
// TODO: Add other targets to this file as needed.
std::unique_ptr<fir::CodeGenSpecifics>
@@ -1871,6 +1909,9 @@ fir::CodeGenSpecifics::get(mlir::MLIRContext *ctx, llvm::Triple &&trp,
case llvm::Triple::ArchType::loongarch64:
return std::make_unique<TargetLoongArch64>(
ctx, std::move(trp), std::move(kindMap), targetCPU, targetFeatures, dl);
+ case llvm::Triple::ArchType::wasm32:
+ return std::make_unique<TargetWasm32>(
+ ctx, std::move(trp), std::move(kindMap), targetCPU, targetFeatures, dl);
}
TODO(mlir::UnknownLoc::get(ctx), "target not implemented");
}
>From ad740dc470fd9c7c22c08fafd5c06472f9db862d Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 05:12:20 +0000
Subject: [PATCH 2/7] shut up runtime build errors
---
flang-rt/lib/runtime/execute.cpp | 8 ++++++++
flang-rt/lib/runtime/extensions.cpp | 4 ++--
flang-rt/lib/runtime/file.cpp | 5 +++++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/flang-rt/lib/runtime/execute.cpp b/flang-rt/lib/runtime/execute.cpp
index f180da846a32c..da13f74d17884 100644
--- a/flang-rt/lib/runtime/execute.cpp
+++ b/flang-rt/lib/runtime/execute.cpp
@@ -21,7 +21,9 @@
#include "flang/Common/windows-include.h"
#else
#include <signal.h>
+#ifndef __wasi__
#include <sys/wait.h>
+#endif
#include <unistd.h>
#endif
@@ -65,6 +67,7 @@ void CheckAndStoreIntToDescriptor(
}
}
+#ifndef __wasi__
// If a condition occurs that would assign a nonzero value to CMDSTAT but
// the CMDSTAT variable is not present, error termination is initiated.
std::int64_t TerminationCheck(std::int64_t status, const Descriptor *cmdstat,
@@ -180,6 +183,7 @@ std::int64_t TerminationCheck(std::int64_t status, const Descriptor *cmdstat,
#endif
return exitStatusVal;
}
+#endif
void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
const Descriptor *exitstat, const Descriptor *cmdstat,
@@ -202,6 +206,7 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
RUNTIME_CHECK(terminator, IsValidCharDescriptor(cmdmsg));
}
+#ifndef __wasi__
if (wait) {
// either wait is not specified or wait is true: synchronous mode
std::int64_t status{std::system(newCmd)};
@@ -278,6 +283,9 @@ void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
}
#endif
}
+#else
+ terminator.Crash("not supported on WASI");
+#endif
// Deallocate memory if EnsureNullTerminated dynamically allocated memory
if (newCmd != command.OffsetElement()) {
FreeMemory(newCmd);
diff --git a/flang-rt/lib/runtime/extensions.cpp b/flang-rt/lib/runtime/extensions.cpp
index 75195c33a6c21..eb016bd733e0e 100644
--- a/flang-rt/lib/runtime/extensions.cpp
+++ b/flang-rt/lib/runtime/extensions.cpp
@@ -61,7 +61,7 @@ extern "C" {
namespace Fortran::runtime {
gid_t RTNAME(GetGID)() {
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__wasi__)
// Group IDs don't exist on Windows, return 1 to avoid errors
return 1;
#else
@@ -70,7 +70,7 @@ gid_t RTNAME(GetGID)() {
}
uid_t RTNAME(GetUID)() {
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__wasi__)
// User IDs don't exist on Windows, return 1 to avoid errors
return 1;
#else
diff --git a/flang-rt/lib/runtime/file.cpp b/flang-rt/lib/runtime/file.cpp
index 16e73db488727..8e2bc97ef7dac 100644
--- a/flang-rt/lib/runtime/file.cpp
+++ b/flang-rt/lib/runtime/file.cpp
@@ -31,6 +31,10 @@ void OpenFile::set_path(OwningPtr<char> &&path, std::size_t bytes) {
}
static int openfile_mkstemp(IoErrorHandler &handler) {
+#ifdef __wasi__
+ handler.SignalError("not supported on WASI");
+ return -1;
+#else
#ifdef _WIN32
const unsigned int uUnique{0};
// GetTempFileNameA needs a directory name < MAX_PATH-14 characters in length.
@@ -58,6 +62,7 @@ static int openfile_mkstemp(IoErrorHandler &handler) {
::unlink(path);
#endif
return fd;
+#endif
}
void OpenFile::Open(OpenStatus status, Fortran::common::optional<Action> action,
>From b4e28fd5c4f664bc03e02197e13f7b2ab832bf32 Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 05:42:53 +0000
Subject: [PATCH 3/7] horrible unusable long hack
---
flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index 5158abaa31ed1..e43c3de3db615 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -260,7 +260,7 @@ constexpr TypeBuilderFunc getModel<void **>() {
template <>
constexpr TypeBuilderFunc getModel<long>() {
return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(long));
+ return mlir::IntegerType::get(context, 8 * 4);
};
}
template <>
@@ -309,7 +309,7 @@ constexpr TypeBuilderFunc getModel<const long long *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned long>() {
return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(unsigned long));
+ return mlir::IntegerType::get(context, 8 * 4);
};
}
template <>
>From 4acce2adc28da0843c609412a8da817cd13f7845 Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 19:17:43 +0000
Subject: [PATCH 4/7] wip storing c type sizes for fir builder
---
.../flang/Optimizer/Builder/FIRBuilder.h | 79 +++++++++++++++++--
flang/lib/Optimizer/Builder/FIRBuilder.cpp | 19 +++++
2 files changed, 91 insertions(+), 7 deletions(-)
diff --git a/flang/include/flang/Optimizer/Builder/FIRBuilder.h b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
index 1675c15363868..fe496d34813eb 100644
--- a/flang/include/flang/Optimizer/Builder/FIRBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/FIRBuilder.h
@@ -43,9 +43,28 @@ class BoxValue;
inline mlir::Type getIntPtrType(mlir::OpBuilder &builder) {
// TODO: Delay the need of such type until codegen or find a way to use
// llvm::DataLayout::getPointerSizeInBits here.
+ // (Note: this is *only* used by MemoryUtils.cpp)
return builder.getI64Type();
}
+//===----------------------------------------------------------------------===//
+// MinimalCTargetInfo
+//===----------------------------------------------------------------------===//
+
+/// Minimal information needed to interface with C code on the target,
+/// for generating runtime calls.
+struct MinimalCTargetInfo {
+ unsigned char CharWidth;
+ unsigned char ShortWidth;
+ unsigned char IntWidth;
+ unsigned char LongWidth;
+ unsigned char LongLongWidth;
+ unsigned char DataPointerWidth;
+ unsigned char EnumWidth;
+
+ MinimalCTargetInfo(const llvm::Triple &T);
+};
+
//===----------------------------------------------------------------------===//
// FirOpBuilder
//===----------------------------------------------------------------------===//
@@ -57,7 +76,8 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
explicit FirOpBuilder(mlir::Operation *op, fir::KindMapping kindMap,
mlir::SymbolTable *symbolTable = nullptr)
: OpBuilder{op, /*listener=*/this}, kindMap{std::move(kindMap)},
- symbolTable{symbolTable} {
+ symbolTable{symbolTable},
+ cTargetInfo{fir::getTargetTriple(getModule())} {
auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
if (fmi) {
// Set the builder with FastMathFlags attached to the operation.
@@ -67,17 +87,20 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
mlir::SymbolTable *symbolTable = nullptr)
: OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
- symbolTable{symbolTable} {
+ symbolTable{symbolTable},
+ cTargetInfo{fir::getTargetTriple(getModule())} {
setListener(this);
}
explicit FirOpBuilder(mlir::OpBuilder &builder, mlir::ModuleOp mod)
: OpBuilder(builder), OpBuilder::Listener(),
- kindMap{getKindMapping(mod)} {
+ kindMap{getKindMapping(mod)},
+ cTargetInfo{fir::getTargetTriple(getModule())} {
setListener(this);
}
explicit FirOpBuilder(mlir::OpBuilder &builder, fir::KindMapping kindMap,
mlir::Operation *op)
- : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)} {
+ : OpBuilder(builder), OpBuilder::Listener(), kindMap{std::move(kindMap)},
+ cTargetInfo{fir::getTargetTriple(getModule())} {
setListener(this);
auto fmi = mlir::dyn_cast<mlir::arith::ArithFastMathInterface>(*op);
if (fmi) {
@@ -93,7 +116,8 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
: OpBuilder(other), OpBuilder::Listener(), kindMap{other.kindMap},
fastMathFlags{other.fastMathFlags},
integerOverflowFlags{other.integerOverflowFlags},
- symbolTable{other.symbolTable} {
+ symbolTable{other.symbolTable},
+ cTargetInfo{other.cTargetInfo} {
setListener(this);
}
@@ -101,7 +125,8 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
: OpBuilder(other), OpBuilder::Listener(),
kindMap{std::move(other.kindMap)}, fastMathFlags{other.fastMathFlags},
integerOverflowFlags{other.integerOverflowFlags},
- symbolTable{other.symbolTable} {
+ symbolTable{other.symbolTable},
+ cTargetInfo{other.cTargetInfo} {
setListener(this);
}
@@ -160,7 +185,45 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
/// Get the integer type whose bit width corresponds to the width of pointer
/// types, or is bigger.
- mlir::Type getIntPtrType() { return fir::getIntPtrType(*this); }
+ mlir::Type getIntPtrType() {
+ return getIntegerType(cTargetInfo.DataPointerWidth);
+ }
+
+ /// Get the integer type whose bit width corresponds to the width of
+ /// the `char` type in C
+ mlir::Type getCCharType() {
+ return getIntegerType(cTargetInfo.CharWidth);
+ }
+
+ /// Get the integer type whose bit width corresponds to the width of
+ /// the `short` type in C
+ mlir::Type getCShortType() {
+ return getIntegerType(cTargetInfo.ShortWidth);
+ }
+
+ /// Get the integer type whose bit width corresponds to the width of
+ /// the `int` type in C
+ mlir::Type getCIntType() {
+ return getIntegerType(cTargetInfo.IntWidth);
+ }
+
+ /// Get the integer type whose bit width corresponds to the width of
+ /// the `long` type in C
+ mlir::Type getCLongType() {
+ return getIntegerType(cTargetInfo.LongWidth);
+ }
+
+ /// Get the integer type whose bit width corresponds to the width of
+ /// the `long long` type in C
+ mlir::Type getCLongLongType() {
+ return getIntegerType(cTargetInfo.LongLongWidth);
+ }
+
+ /// Get the integer type whose bit width corresponds to the width of
+ /// enums in C
+ mlir::Type getCEnumType() {
+ return getIntegerType(cTargetInfo.EnumWidth);
+ }
/// Wrap `str` to a SymbolRefAttr.
mlir::SymbolRefAttr getSymbolRefAttr(llvm::StringRef str) {
@@ -619,6 +682,8 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
/// Stored via a unique_ptr rather than an optional so as not to bloat this
/// class when most instances won't ever need a data layout.
std::unique_ptr<mlir::DataLayout> dataLayout = nullptr;
+
+ MinimalCTargetInfo cTargetInfo;
};
} // namespace fir
diff --git a/flang/lib/Optimizer/Builder/FIRBuilder.cpp b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
index b3d440cedee07..963d816a4d31e 100644
--- a/flang/lib/Optimizer/Builder/FIRBuilder.cpp
+++ b/flang/lib/Optimizer/Builder/FIRBuilder.cpp
@@ -33,6 +33,25 @@
#include "llvm/Support/MD5.h"
#include <optional>
+fir::MinimalCTargetInfo::MinimalCTargetInfo(const llvm::Triple &T) {
+ CharWidth = 8;
+ ShortWidth = 16;
+ DataPointerWidth = T.getArchPointerBitWidth();
+ // TODO: This will need to be changed for targets such as AVR and MSP430
+ IntWidth = 32;
+ // TODO: flags such as -fshort-enums can change ABI
+ EnumWidth = IntWidth;
+ LongLongWidth = 64;
+ if (T.isArch64Bit() && T.isOSWindows()) {
+ // Windows uses sizeof(long) = 32 bits
+ LongWidth = 32;
+ } else {
+ // Assumes sizeof(long) == sizeof(ptr)
+ // (typical for Unix-likes: ILP32 and LP64)
+ LongWidth = DataPointerWidth;
+ }
+}
+
static llvm::cl::opt<std::size_t>
nameLengthHashSize("length-to-hash-string-literal",
llvm::cl::desc("string literals that exceed this length"
>From c16914cc7ea2392444d993ecae029201c9da9087 Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 20:04:46 +0000
Subject: [PATCH 5/7] plumb through new logic
---
.../Optimizer/Builder/Runtime/RTBuilder.h | 328 +++++++++--------
flang/lib/Lower/Allocatable.cpp | 4 +-
flang/lib/Lower/IO.cpp | 8 +-
.../Optimizer/Builder/Runtime/Intrinsics.cpp | 12 +-
.../lib/Optimizer/Builder/Runtime/Numeric.cpp | 66 ++--
.../Optimizer/Builder/Runtime/Reduction.cpp | 336 ++++++++++++------
.../lib/Optimizer/Builder/Runtime/Support.cpp | 4 +-
.../Builder/Runtime/Transformational.cpp | 52 +--
8 files changed, 484 insertions(+), 326 deletions(-)
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index e43c3de3db615..f7753b745f1db 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -51,17 +51,18 @@ class DerivedType;
namespace fir::runtime {
-using TypeBuilderFunc = mlir::Type (*)(mlir::MLIRContext *);
-using FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *);
+using TypeBuilderFunc = mlir::Type (*)(const fir::FirOpBuilder &);
+using FuncTypeBuilderFunc = mlir::FunctionType (*)(const fir::FirOpBuilder &);
#define REDUCTION_REF_OPERATION_MODEL(T) \
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ReferenceReductionOperation<T>>() { \
- return [](mlir::MLIRContext *context) -> mlir::Type { \
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
- auto refTy = fir::ReferenceType::get(f(context)); \
- return mlir::FunctionType::get(context, {refTy, refTy}, refTy); \
+ auto refTy = fir::ReferenceType::get(f(builder)); \
+ return mlir::FunctionType::get(builder.getContext(), {refTy, refTy}, \
+ refTy); \
}; \
}
@@ -69,11 +70,11 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *);
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ValueReductionOperation<T>>() { \
- return [](mlir::MLIRContext *context) -> mlir::Type { \
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
- auto refTy = fir::ReferenceType::get(f(context)); \
- return mlir::FunctionType::get(context, {f(context), f(context)}, \
- refTy); \
+ auto refTy = fir::ReferenceType::get(f(builder)); \
+ return mlir::FunctionType::get(builder.getContext(), \
+ {f(builder), f(builder)}, refTy); \
}; \
}
@@ -81,16 +82,17 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *);
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ReductionCharOperation<T>>() { \
- return [](mlir::MLIRContext *context) -> mlir::Type { \
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto voidTy = fir::LLVMPointerType::get( \
- context, mlir::IntegerType::get(context, 8)); \
- auto size_tTy = \
- mlir::IntegerType::get(context, 8 * sizeof(std::size_t)); \
- auto refTy = fir::ReferenceType::get(f(context)); \
+ builder.getContext(), \
+ mlir::IntegerType::get(builder.getContext(), 8)); \
+ auto size_tTy = mlir::IntegerType::get(builder.getContext(), \
+ 8 * sizeof(std::size_t)); \
+ auto refTy = fir::ReferenceType::get(f(builder)); \
return mlir::FunctionType::get( \
- context, {refTy, size_tTy, refTy, refTy, size_tTy, size_tTy}, \
- voidTy); \
+ builder.getContext(), \
+ {refTy, size_tTy, refTy, refTy, size_tTy, size_tTy}, voidTy); \
}; \
}
@@ -98,8 +100,8 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(mlir::MLIRContext *);
// Type builder models
//===----------------------------------------------------------------------===//
-// TODO: all usages of sizeof in this file assume build == host == target.
-// This will need to be re-visited for cross compilation.
+// TODO: not all usages of sizeof have been necessarily correctly audited
+// for cross compilation.
/// Return a function that returns the type signature model for the type `T`
/// when provided an MLIRContext*. This allows one to translate C(++) function
@@ -113,21 +115,22 @@ static constexpr TypeBuilderFunc getModel();
template <>
constexpr TypeBuilderFunc getModel<unsigned int>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(unsigned int));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
+ 8 * sizeof(unsigned int));
};
}
template <>
constexpr TypeBuilderFunc getModel<short int>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(short int));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(short int));
};
}
template <>
constexpr TypeBuilderFunc getModel<short int *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<short int>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -136,15 +139,15 @@ constexpr TypeBuilderFunc getModel<const short int *>() {
}
template <>
constexpr TypeBuilderFunc getModel<int>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(int));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(int));
};
}
template <>
constexpr TypeBuilderFunc getModel<int &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<int>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -153,15 +156,16 @@ constexpr TypeBuilderFunc getModel<int *>() {
}
template <>
constexpr TypeBuilderFunc getModel<const int *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<int>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<char *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(context, 8));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(
+ mlir::IntegerType::get(builder.getContext(), 8));
};
}
template <>
@@ -170,33 +174,36 @@ constexpr TypeBuilderFunc getModel<const char *>() {
}
template <>
constexpr TypeBuilderFunc getModel<const char16_t *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(context, 16));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(
+ mlir::IntegerType::get(builder.getContext(), 16));
};
}
template <>
constexpr TypeBuilderFunc getModel<const char32_t *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(context, 32));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(
+ mlir::IntegerType::get(builder.getContext(), 32));
};
}
template <>
constexpr TypeBuilderFunc getModel<char>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(char));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char));
};
}
template <>
constexpr TypeBuilderFunc getModel<signed char>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(signed char));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
+ 8 * sizeof(signed char));
};
}
template <>
constexpr TypeBuilderFunc getModel<signed char *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<signed char>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -205,69 +212,71 @@ constexpr TypeBuilderFunc getModel<const signed char *>() {
}
template <>
constexpr TypeBuilderFunc getModel<char16_t>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(char16_t));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char16_t));
};
}
template <>
constexpr TypeBuilderFunc getModel<char16_t *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<char16_t>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<char32_t>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(char32_t));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char32_t));
};
}
template <>
constexpr TypeBuilderFunc getModel<char32_t *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<char32_t>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned char>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(unsigned char));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
+ 8 * sizeof(unsigned char));
};
}
template <>
constexpr TypeBuilderFunc getModel<void *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::LLVMPointerType::get(context,
- mlir::IntegerType::get(context, 8));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::LLVMPointerType::get(
+ builder.getContext(), mlir::IntegerType::get(builder.getContext(), 8));
};
}
template <>
constexpr TypeBuilderFunc getModel<void (*)(int)>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
return fir::LLVMPointerType::get(
- context,
- mlir::FunctionType::get(context, /*inputs=*/{}, /*results*/ {}));
+ builder.getContext(),
+ mlir::FunctionType::get(builder.getContext(), /*inputs=*/{},
+ /*results*/ {}));
};
}
template <>
constexpr TypeBuilderFunc getModel<void **>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(
- fir::LLVMPointerType::get(context, mlir::IntegerType::get(context, 8)));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(fir::LLVMPointerType::get(
+ builder.getContext(), mlir::IntegerType::get(builder.getContext(), 8)));
};
}
template <>
constexpr TypeBuilderFunc getModel<long>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * 4);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * 4);
};
}
template <>
constexpr TypeBuilderFunc getModel<long &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<long>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -280,22 +289,22 @@ constexpr TypeBuilderFunc getModel<const long *>() {
}
template <>
constexpr TypeBuilderFunc getModel<long long>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(long long));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(long long));
};
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::int128_t>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context,
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(Fortran::common::int128_t));
};
}
template <>
constexpr TypeBuilderFunc getModel<long long &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<long long>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -308,27 +317,28 @@ constexpr TypeBuilderFunc getModel<const long long *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * 4);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 8 * 4);
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long long>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 8 * sizeof(unsigned long long));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
+ 8 * sizeof(unsigned long long));
};
}
template <>
constexpr TypeBuilderFunc getModel<double>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::Float64Type::get(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::Float64Type::get(builder.getContext());
};
}
template <>
constexpr TypeBuilderFunc getModel<double &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<double>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -341,26 +351,26 @@ constexpr TypeBuilderFunc getModel<const double *>() {
}
template <>
constexpr TypeBuilderFunc getModel<long double>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
// See TODO at the top of the file. This is configuring for the host system
// - it might be incorrect when cross-compiling!
constexpr size_t size = sizeof(long double);
static_assert(size == 16 || size == 10 || size == 8,
"unsupported long double size");
if constexpr (size == 16)
- return mlir::Float128Type::get(context);
+ return mlir::Float128Type::get(builder.getContext());
if constexpr (size == 10)
- return mlir::Float80Type::get(context);
+ return mlir::Float80Type::get(builder.getContext());
if constexpr (size == 8)
- return mlir::Float64Type::get(context);
+ return mlir::Float64Type::get(builder.getContext());
llvm_unreachable("failed static assert");
};
}
template <>
constexpr TypeBuilderFunc getModel<long double *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<long double>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -369,15 +379,15 @@ constexpr TypeBuilderFunc getModel<const long double *>() {
}
template <>
constexpr TypeBuilderFunc getModel<float>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::Float32Type::get(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::Float32Type::get(builder.getContext());
};
}
template <>
constexpr TypeBuilderFunc getModel<float &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<float>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -390,36 +400,37 @@ constexpr TypeBuilderFunc getModel<const float *>() {
}
template <>
constexpr TypeBuilderFunc getModel<bool>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context, 1);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(), 1);
};
}
template <>
constexpr TypeBuilderFunc getModel<bool &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<bool>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<bool *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<bool>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned short>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(
- context, 8 * sizeof(unsigned short),
+ builder.getContext(), 8 * sizeof(unsigned short),
mlir::IntegerType::SignednessSemantics::Unsigned);
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned char *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(context, 8));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(
+ mlir::IntegerType::get(builder.getContext(), 8));
};
}
template <>
@@ -428,9 +439,9 @@ constexpr TypeBuilderFunc getModel<const unsigned char *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned short *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(
- mlir::IntegerType::get(context, 8 * sizeof(unsigned short)));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::IntegerType::get(
+ builder.getContext(), 8 * sizeof(unsigned short)));
};
}
template <>
@@ -447,9 +458,9 @@ constexpr TypeBuilderFunc getModel<const unsigned *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(
- mlir::IntegerType::get(context, 8 * sizeof(unsigned long)));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::IntegerType::get(
+ builder.getContext(), 8 * sizeof(unsigned long)));
};
}
template <>
@@ -458,9 +469,9 @@ constexpr TypeBuilderFunc getModel<const unsigned long *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long long *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(
- mlir::IntegerType::get(context, 8 * sizeof(unsigned long long)));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::IntegerType::get(
+ builder.getContext(), 8 * sizeof(unsigned long long)));
};
}
template <>
@@ -473,9 +484,9 @@ constexpr TypeBuilderFunc getModel<Fortran::common::uint128_t>() {
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::int128_t *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<Fortran::common::int128_t>()};
- return fir::ReferenceType::get(f(context));
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -496,8 +507,8 @@ constexpr TypeBuilderFunc getModel<const Fortran::common::uint128_t *>() {
template <>
constexpr TypeBuilderFunc getModel<std::complex<float> &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type floatTy = getModel<float>()(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type floatTy = getModel<float>()(builder);
return fir::ReferenceType::get(mlir::ComplexType::get(floatTy));
};
}
@@ -511,8 +522,8 @@ constexpr TypeBuilderFunc getModel<const std::complex<float> *>() {
}
template <>
constexpr TypeBuilderFunc getModel<std::complex<double> &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type floatTy = getModel<double>()(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type floatTy = getModel<double>()(builder);
return fir::ReferenceType::get(mlir::ComplexType::get(floatTy));
};
}
@@ -526,29 +537,29 @@ constexpr TypeBuilderFunc getModel<const std::complex<double> *>() {
}
template <>
constexpr TypeBuilderFunc getModel<c_float_complex_t>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type floatTy = getModel<float>()(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type floatTy = getModel<float>()(builder);
return mlir::ComplexType::get(floatTy);
};
}
template <>
constexpr TypeBuilderFunc getModel<c_double_complex_t>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type floatTy = getModel<double>()(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type floatTy = getModel<double>()(builder);
return mlir::ComplexType::get(floatTy);
};
}
template <>
constexpr TypeBuilderFunc getModel<const Fortran::runtime::Descriptor &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::BoxType::get(mlir::NoneType::get(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::BoxType::get(mlir::NoneType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(
- fir::BoxType::get(mlir::NoneType::get(context)));
+ fir::BoxType::get(mlir::NoneType::get(builder.getContext())));
};
}
template <>
@@ -561,29 +572,29 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor *>() {
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::TypeCategory>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context,
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
sizeof(Fortran::common::TypeCategory) * 8);
};
}
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::typeInfo::DerivedType &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::NoneType::get(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::NoneType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::typeInfo::DerivedType *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::NoneType::get(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::NoneType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc getModel<void>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::NoneType::get(context);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::NoneType::get(builder.getContext());
};
}
@@ -594,23 +605,23 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return mlir::IntegerType::get(context,
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(Fortran::runtime::io::Iostat));
};
}
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::io::NamelistGroup &>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::TupleType::get(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::TupleType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::io::NonTbpDefinedIoTable *>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- return fir::ReferenceType::get(mlir::TupleType::get(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return fir::ReferenceType::get(mlir::TupleType::get(builder.getContext()));
};
}
@@ -649,37 +660,37 @@ REDUCTION_VALUE_OPERATION_MODEL(long double)
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ValueReductionOperation<std::complex<float>>>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type cplx = mlir::ComplexType::get(getModel<float>()(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type cplx = mlir::ComplexType::get(getModel<float>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
- return mlir::FunctionType::get(context, {cplx, cplx}, refTy);
+ return mlir::FunctionType::get(builder.getContext(), {cplx, cplx}, refTy);
};
}
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ValueReductionOperation<std::complex<double>>>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type cplx = mlir::ComplexType::get(getModel<double>()(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type cplx = mlir::ComplexType::get(getModel<double>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
- return mlir::FunctionType::get(context, {cplx, cplx}, refTy);
+ return mlir::FunctionType::get(builder.getContext(), {cplx, cplx}, refTy);
};
}
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ReferenceReductionOperation<std::complex<float>>>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type cplx = mlir::ComplexType::get(getModel<float>()(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type cplx = mlir::ComplexType::get(getModel<float>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
- return mlir::FunctionType::get(context, {refTy, refTy}, refTy);
+ return mlir::FunctionType::get(builder.getContext(), {refTy, refTy}, refTy);
};
}
template <>
constexpr TypeBuilderFunc getModel<
Fortran::runtime::ReferenceReductionOperation<std::complex<double>>>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- mlir::Type cplx = mlir::ComplexType::get(getModel<double>()(context));
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ mlir::Type cplx = mlir::ComplexType::get(getModel<double>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
- return mlir::FunctionType::get(context, {refTy, refTy}, refTy);
+ return mlir::FunctionType::get(builder.getContext(), {refTy, refTy}, refTy);
};
}
@@ -690,10 +701,11 @@ REDUCTION_CHAR_OPERATION_MODEL(char32_t)
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ReductionDerivedTypeOperation>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
- auto voidTy =
- fir::LLVMPointerType::get(context, mlir::IntegerType::get(context, 8));
- return mlir::FunctionType::get(context, {voidTy, voidTy, voidTy}, voidTy);
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ auto voidTy = fir::LLVMPointerType::get(
+ builder.getContext(), mlir::IntegerType::get(builder.getContext(), 8));
+ return mlir::FunctionType::get(builder.getContext(),
+ {voidTy, voidTy, voidTy}, voidTy);
};
}
@@ -702,16 +714,16 @@ struct RuntimeTableKey;
template <typename RT, typename... ATs>
struct RuntimeTableKey<RT(ATs...)> {
static constexpr FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctxt) {
+ return [](const fir::FirOpBuilder &builder) {
TypeBuilderFunc ret = getModel<RT>();
std::array<TypeBuilderFunc, sizeof...(ATs)> args = {getModel<ATs>()...};
- mlir::Type retTy = ret(ctxt);
+ mlir::Type retTy = ret(builder);
llvm::SmallVector<mlir::Type, sizeof...(ATs)> argTys;
for (auto f : args)
- argTys.push_back(f(ctxt));
+ argTys.push_back(f(builder));
if (mlir::isa<mlir::NoneType>(retTy))
- return mlir::FunctionType::get(ctxt, argTys, {});
- return mlir::FunctionType::get(ctxt, argTys, {retTy});
+ return mlir::FunctionType::get(builder.getContext(), argTys, {});
+ return mlir::FunctionType::get(builder.getContext(), argTys, {retTy});
};
}
};
@@ -813,7 +825,7 @@ static mlir::func::FuncOp getRuntimeFunc(mlir::Location loc,
auto func = builder.getNamedFunction(name);
if (func)
return func;
- auto funTy = RuntimeEntry::getTypeModel()(builder.getContext());
+ auto funTy = RuntimeEntry::getTypeModel()(builder);
return builder.createRuntimeFunction(loc, name, funTy, isIO);
}
diff --git a/flang/lib/Lower/Allocatable.cpp b/flang/lib/Lower/Allocatable.cpp
index 9938bd573d1fa..603505ba129a2 100644
--- a/flang/lib/Lower/Allocatable.cpp
+++ b/flang/lib/Lower/Allocatable.cpp
@@ -777,7 +777,7 @@ class AllocateStmtHelper {
mlir::Value source = sourceExpr ? fir::getBase(sourceExv) : nullptr;
// Keep return type the same as a standard AllocatableAllocate call.
- mlir::Type retTy = fir::runtime::getModel<int>()(builder.getContext());
+ mlir::Type retTy = fir::runtime::getModel<int>()(builder);
return builder
.create<cuf::AllocateOp>(
loc, retTy, box.getAddr(), errmsg, stream, pinned, source, cudaAttr,
@@ -846,7 +846,7 @@ static mlir::Value genCudaDeallocate(fir::FirOpBuilder &builder,
: errorManager.errMsgAddr;
// Keep return type the same as a standard AllocatableAllocate call.
- mlir::Type retTy = fir::runtime::getModel<int>()(builder.getContext());
+ mlir::Type retTy = fir::runtime::getModel<int>()(builder);
return builder
.create<cuf::DeallocateOp>(
loc, retTy, box.getAddr(), errmsg, cudaAttr,
diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp
index 16e6d05bd3b10..280c911b14e2f 100644
--- a/flang/lib/Lower/IO.cpp
+++ b/flang/lib/Lower/IO.cpp
@@ -267,9 +267,9 @@ getNonTbpDefinedIoTableAddr(Fortran::lower::AbstractConverter &converter,
mlir::StringAttr linkOnce = builder.createLinkOnceLinkage();
mlir::Type idxTy = builder.getIndexType();
mlir::Type sizeTy =
- fir::runtime::getModel<std::size_t>()(builder.getContext());
- mlir::Type intTy = fir::runtime::getModel<int>()(builder.getContext());
- mlir::Type boolTy = fir::runtime::getModel<bool>()(builder.getContext());
+ fir::runtime::getModel<std::size_t>()(builder);
+ mlir::Type intTy = fir::runtime::getModel<int>()(builder);
+ mlir::Type boolTy = fir::runtime::getModel<bool>()(builder);
mlir::Type listTy = fir::SequenceType::get(
definedIoProcMap.size(),
mlir::TupleType::get(context, {refTy, refTy, intTy, boolTy}));
@@ -427,7 +427,7 @@ getNamelistGroup(Fortran::lower::AbstractConverter &converter,
mlir::StringAttr linkOnce = builder.createLinkOnceLinkage();
mlir::Type idxTy = builder.getIndexType();
mlir::Type sizeTy =
- fir::runtime::getModel<std::size_t>()(builder.getContext());
+ fir::runtime::getModel<std::size_t>()(builder);
mlir::Type charRefTy = fir::ReferenceType::get(builder.getIntegerType(8));
mlir::Type descRefTy =
fir::ReferenceType::get(fir::BoxType::get(mlir::NoneType::get(context)));
diff --git a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
index 2f46e7605fe91..dce29c030f584 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
@@ -32,13 +32,15 @@ namespace {
struct ForcedRandomNumberReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(RandomNumber16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
- auto strTy = fir::runtime::getModel<const char *>()(ctx);
- auto intTy = fir::runtime::getModel<int>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
+ auto strTy = fir::runtime::getModel<const char *>()(builder);
+ auto intTy = fir::runtime::getModel<int>()(builder);
;
- return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy}, {});
+ return mlir::FunctionType::get(builder.getContext(),
+ {boxTy, strTy, intTy}, {});
};
}
};
diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
index 4ff7c86bb0a24..5fa5eda3789a8 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
@@ -26,7 +26,8 @@ using namespace Fortran::runtime;
struct ForcedErfcScaled10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ErfcScaled10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -37,7 +38,8 @@ struct ForcedErfcScaled10 {
struct ForcedErfcScaled16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ErfcScaled16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -48,7 +50,8 @@ struct ForcedErfcScaled16 {
struct ForcedExponent10_4 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent10_4));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(ctx, fltTy, intTy);
@@ -59,7 +62,8 @@ struct ForcedExponent10_4 {
struct ForcedExponent10_8 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent10_8));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
return mlir::FunctionType::get(ctx, fltTy, intTy);
@@ -71,7 +75,8 @@ struct ForcedExponent10_8 {
struct ForcedExponent16_4 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent16_4));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(ctx, fltTy, intTy);
@@ -82,7 +87,8 @@ struct ForcedExponent16_4 {
struct ForcedExponent16_8 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent16_8));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
return mlir::FunctionType::get(ctx, fltTy, intTy);
@@ -94,7 +100,8 @@ struct ForcedExponent16_8 {
struct ForcedFraction10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Fraction10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -105,7 +112,8 @@ struct ForcedFraction10 {
struct ForcedFraction16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Fraction16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -116,7 +124,8 @@ struct ForcedFraction16 {
struct ForcedMod10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
@@ -130,7 +139,8 @@ struct ForcedMod10 {
struct ForcedMod16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
@@ -144,7 +154,8 @@ struct ForcedMod16 {
struct ForcedModulo10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModuloReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
@@ -158,7 +169,8 @@ struct ForcedModulo10 {
struct ForcedModulo16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModuloReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
@@ -172,7 +184,8 @@ struct ForcedModulo16 {
struct ForcedNearest10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Nearest10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto boolTy = mlir::IntegerType::get(ctx, 1);
return mlir::FunctionType::get(ctx, {fltTy, boolTy}, {fltTy});
@@ -184,7 +197,8 @@ struct ForcedNearest10 {
struct ForcedNearest16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Nearest16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto boolTy = mlir::IntegerType::get(ctx, 1);
return mlir::FunctionType::get(ctx, {fltTy, boolTy}, {fltTy});
@@ -196,7 +210,8 @@ struct ForcedNearest16 {
struct ForcedRRSpacing10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(RRSpacing10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -207,7 +222,8 @@ struct ForcedRRSpacing10 {
struct ForcedRRSpacing16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(RRSpacing16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -218,7 +234,8 @@ struct ForcedRRSpacing16 {
struct ForcedScale10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Scale10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
return mlir::FunctionType::get(ctx, {fltTy, intTy}, {fltTy});
@@ -230,7 +247,8 @@ struct ForcedScale10 {
struct ForcedScale16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Scale16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
return mlir::FunctionType::get(ctx, {fltTy, intTy}, {fltTy});
@@ -242,7 +260,8 @@ struct ForcedScale16 {
struct ForcedSetExponent10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SetExponent10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
return mlir::FunctionType::get(ctx, {fltTy, intTy}, {fltTy});
@@ -254,7 +273,8 @@ struct ForcedSetExponent10 {
struct ForcedSetExponent16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SetExponent16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
return mlir::FunctionType::get(ctx, {fltTy, intTy}, {fltTy});
@@ -266,7 +286,8 @@ struct ForcedSetExponent16 {
struct ForcedSpacing10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Spacing10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
@@ -277,7 +298,8 @@ struct ForcedSpacing10 {
struct ForcedSpacing16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Spacing16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
};
diff --git a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
index f778b963c59ca..0712e6c35d707 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
@@ -26,10 +26,12 @@ using namespace Fortran::runtime;
struct ForcedMaxvalReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MaxvalReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -42,10 +44,12 @@ struct ForcedMaxvalReal10 {
struct ForcedMaxvalReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MaxvalReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -59,10 +63,12 @@ struct ForcedMaxvalInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MaxvalInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -76,11 +82,13 @@ struct ForcedMaxvalUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MaxvalUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -93,10 +101,12 @@ struct ForcedMaxvalUnsigned16 {
struct ForcedMinvalReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MinvalReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -109,10 +119,12 @@ struct ForcedMinvalReal10 {
struct ForcedMinvalReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MinvalReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -126,10 +138,12 @@ struct ForcedMinvalInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MinvalInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -143,11 +157,13 @@ struct ForcedMinvalUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MinvalUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -172,10 +188,12 @@ using ForcedMinlocUnsigned16 = mkRTKey(MinlocUnsigned16);
struct ForcedNorm2Real10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy}, {ty});
@@ -187,10 +205,12 @@ struct ForcedNorm2Real10 {
struct ForcedNorm2Real16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy}, {ty});
@@ -202,9 +222,11 @@ struct ForcedNorm2Real16 {
struct ForcedNorm2DimReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2DimReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(
@@ -218,10 +240,12 @@ struct ForcedNorm2DimReal16 {
struct ForcedProductReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ProductReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -234,10 +258,12 @@ struct ForcedProductReal10 {
struct ForcedProductReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ProductReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -251,10 +277,12 @@ struct ForcedProductInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ProductInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -268,11 +296,13 @@ struct ForcedProductUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ProductUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -286,10 +316,12 @@ struct ForcedProductComplex10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppProductComplex10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
auto resTy = fir::ReferenceType::get(ty);
@@ -304,10 +336,12 @@ struct ForcedProductComplex16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppProductComplex16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
auto resTy = fir::ReferenceType::get(ty);
@@ -322,10 +356,12 @@ struct ForcedDotProductReal10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty});
@@ -338,10 +374,12 @@ struct ForcedDotProductReal16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty});
@@ -354,10 +392,12 @@ struct ForcedDotProductComplex10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppDotProductComplex10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
auto resTy = fir::ReferenceType::get(ty);
@@ -372,10 +412,12 @@ struct ForcedDotProductComplex16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppDotProductComplex16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
auto resTy = fir::ReferenceType::get(ty);
@@ -390,10 +432,12 @@ struct ForcedDotProductInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty});
@@ -406,11 +450,13 @@ struct ForcedDotProductUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty});
@@ -422,10 +468,12 @@ struct ForcedDotProductUnsigned16 {
struct ForcedSumReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -438,10 +486,12 @@ struct ForcedSumReal10 {
struct ForcedSumReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -454,10 +504,12 @@ struct ForcedSumReal16 {
struct ForcedSumInteger16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -470,11 +522,13 @@ struct ForcedSumInteger16 {
struct ForcedSumUnsigned16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -488,10 +542,12 @@ struct ForcedSumComplex10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppSumComplex10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
auto resTy = fir::ReferenceType::get(ty);
@@ -506,10 +562,12 @@ struct ForcedSumComplex16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppSumComplex16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
auto resTy = fir::ReferenceType::get(ty);
@@ -523,10 +581,12 @@ struct ForcedSumComplex16 {
struct ForcedIAll16 {
static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IAll16);
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -539,10 +599,12 @@ struct ForcedIAll16 {
struct ForcedIAny16 {
static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IAny16);
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -555,10 +617,12 @@ struct ForcedIAny16 {
struct ForcedIParity16 {
static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IParity16);
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int));
return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy},
@@ -572,10 +636,12 @@ struct ForcedReduceReal10Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -592,10 +658,12 @@ struct ForcedReduceReal10Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -612,10 +680,12 @@ struct ForcedReduceReal16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -632,10 +702,12 @@ struct ForcedReduceReal16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -652,10 +724,12 @@ struct ForcedReduceReal10DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -674,10 +748,12 @@ struct ForcedReduceReal10DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -696,10 +772,12 @@ struct ForcedReduceReal16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -718,10 +796,12 @@ struct ForcedReduceReal16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -740,10 +820,12 @@ struct ForcedReduceInteger16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -760,10 +842,12 @@ struct ForcedReduceUnsigned16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -780,10 +864,12 @@ struct ForcedReduceInteger16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -800,10 +886,12 @@ struct ForcedReduceUnsigned16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -820,10 +908,12 @@ struct ForcedReduceInteger16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -842,11 +932,13 @@ struct ForcedReduceUnsigned16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -865,10 +957,12 @@ struct ForcedReduceInteger16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -887,11 +981,13 @@ struct ForcedReduceUnsigned16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -910,10 +1006,12 @@ struct ForcedReduceComplex10Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -931,10 +1029,12 @@ struct ForcedReduceComplex10Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -952,10 +1052,12 @@ struct ForcedReduceComplex10DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -974,10 +1076,12 @@ struct ForcedReduceComplex10DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -996,10 +1100,12 @@ struct ForcedReduceComplex16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -1017,10 +1123,12 @@ struct ForcedReduceComplex16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -1038,10 +1146,12 @@ struct ForcedReduceComplex16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -1060,10 +1170,12 @@ struct ForcedReduceComplex16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
auto refTy = fir::ReferenceType::get(ty);
auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
diff --git a/flang/lib/Optimizer/Builder/Runtime/Support.cpp b/flang/lib/Optimizer/Builder/Runtime/Support.cpp
index b5e9ddb87c7c4..85e8d1add9256 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Support.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Support.cpp
@@ -17,9 +17,9 @@ using namespace Fortran::runtime;
template <>
constexpr fir::runtime::TypeBuilderFunc
fir::runtime::getModel<Fortran::runtime::LowerBoundModifier>() {
- return [](mlir::MLIRContext *context) -> mlir::Type {
+ return [](const fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(
- context, sizeof(Fortran::runtime::LowerBoundModifier) * 8);
+ builder.getContext(), sizeof(Fortran::runtime::LowerBoundModifier) * 8);
};
}
diff --git a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
index 978524494af9b..1ecaba47e2b9f 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
@@ -24,10 +24,11 @@ using namespace Fortran::runtime;
struct ForcedBesselJn_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJn_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(
@@ -40,10 +41,11 @@ struct ForcedBesselJn_10 {
struct ForcedBesselJn_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJn_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(
@@ -56,9 +58,10 @@ struct ForcedBesselJn_16 {
struct ForcedBesselJnX0_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJnX0_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(ctx, {boxTy, intTy, intTy, strTy, intTy},
@@ -71,9 +74,10 @@ struct ForcedBesselJnX0_10 {
struct ForcedBesselJnX0_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJnX0_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(ctx, {boxTy, intTy, intTy, strTy, intTy},
@@ -86,10 +90,11 @@ struct ForcedBesselJnX0_16 {
struct ForcedBesselYn_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYn_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(
@@ -102,10 +107,11 @@ struct ForcedBesselYn_10 {
struct ForcedBesselYn_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYn_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(
@@ -118,9 +124,10 @@ struct ForcedBesselYn_16 {
struct ForcedBesselYnX0_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYnX0_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(ctx, {boxTy, intTy, intTy, strTy, intTy},
@@ -133,9 +140,10 @@ struct ForcedBesselYnX0_10 {
struct ForcedBesselYnX0_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYnX0_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto boxTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
auto intTy = mlir::IntegerType::get(ctx, 32);
return mlir::FunctionType::get(ctx, {boxTy, intTy, intTy, strTy, intTy},
@@ -324,13 +332,15 @@ void fir::runtime::genEoshiftVector(fir::FirOpBuilder &builder,
/// Define ForcedMatmul<ACAT><AKIND><BCAT><BKIND> models.
struct ForcedMatmulTypeModel {
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](mlir::MLIRContext *ctx) {
+ return [](const fir::FirOpBuilder &builder) {
+ auto ctx = builder.getContext();
auto boxRefTy =
- fir::runtime::getModel<Fortran::runtime::Descriptor &>()(ctx);
+ fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
auto boxTy =
- fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx);
- auto strTy = fir::runtime::getModel<const char *>()(ctx);
- auto intTy = fir::runtime::getModel<int>()(ctx);
+ fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
+ builder);
+ auto strTy = fir::runtime::getModel<const char *>()(builder);
+ auto intTy = fir::runtime::getModel<int>()(builder);
return mlir::FunctionType::get(
ctx, {boxRefTy, boxTy, boxTy, strTy, intTy}, {});
};
>From 59eeb7fcab529b180bb6c71dce16645025cd1e76 Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 20:15:08 +0000
Subject: [PATCH 6/7] remove const; begin work
---
.../Optimizer/Builder/Runtime/RTBuilder.h | 139 +++++++++---------
.../Optimizer/Builder/Runtime/Intrinsics.cpp | 2 +-
.../lib/Optimizer/Builder/Runtime/Numeric.cpp | 44 +++---
.../Optimizer/Builder/Runtime/Reduction.cpp | 112 +++++++-------
.../lib/Optimizer/Builder/Runtime/Support.cpp | 2 +-
.../Builder/Runtime/Transformational.cpp | 18 +--
6 files changed, 158 insertions(+), 159 deletions(-)
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index f7753b745f1db..ba5982404f70e 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -51,14 +51,14 @@ class DerivedType;
namespace fir::runtime {
-using TypeBuilderFunc = mlir::Type (*)(const fir::FirOpBuilder &);
-using FuncTypeBuilderFunc = mlir::FunctionType (*)(const fir::FirOpBuilder &);
+using TypeBuilderFunc = mlir::Type (*)(fir::FirOpBuilder &);
+using FuncTypeBuilderFunc = mlir::FunctionType (*)(fir::FirOpBuilder &);
#define REDUCTION_REF_OPERATION_MODEL(T) \
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ReferenceReductionOperation<T>>() { \
- return [](const fir::FirOpBuilder &builder) -> mlir::Type { \
+ return [](fir::FirOpBuilder &builder) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto refTy = fir::ReferenceType::get(f(builder)); \
return mlir::FunctionType::get(builder.getContext(), {refTy, refTy}, \
@@ -70,7 +70,7 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(const fir::FirOpBuilder &);
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ValueReductionOperation<T>>() { \
- return [](const fir::FirOpBuilder &builder) -> mlir::Type { \
+ return [](fir::FirOpBuilder &builder) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto refTy = fir::ReferenceType::get(f(builder)); \
return mlir::FunctionType::get(builder.getContext(), \
@@ -82,7 +82,7 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(const fir::FirOpBuilder &);
template <> \
constexpr TypeBuilderFunc \
getModel<Fortran::runtime::ReductionCharOperation<T>>() { \
- return [](const fir::FirOpBuilder &builder) -> mlir::Type { \
+ return [](fir::FirOpBuilder &builder) -> mlir::Type { \
TypeBuilderFunc f{getModel<T>()}; \
auto voidTy = fir::LLVMPointerType::get( \
builder.getContext(), \
@@ -115,20 +115,19 @@ static constexpr TypeBuilderFunc getModel();
template <>
constexpr TypeBuilderFunc getModel<unsigned int>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(),
- 8 * sizeof(unsigned int));
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
+ return builder.getCIntType();
};
}
template <>
constexpr TypeBuilderFunc getModel<short int>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(short int));
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
+ return builder.getCShortType();
};
}
template <>
constexpr TypeBuilderFunc getModel<short int *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<short int>()};
return fir::ReferenceType::get(f(builder));
};
@@ -139,13 +138,13 @@ constexpr TypeBuilderFunc getModel<const short int *>() {
}
template <>
constexpr TypeBuilderFunc getModel<int>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(int));
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
+ return builder.getCIntType();
};
}
template <>
constexpr TypeBuilderFunc getModel<int &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<int>()};
return fir::ReferenceType::get(f(builder));
};
@@ -156,14 +155,14 @@ constexpr TypeBuilderFunc getModel<int *>() {
}
template <>
constexpr TypeBuilderFunc getModel<const int *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<int>()};
return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<char *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(
mlir::IntegerType::get(builder.getContext(), 8));
};
@@ -174,34 +173,34 @@ constexpr TypeBuilderFunc getModel<const char *>() {
}
template <>
constexpr TypeBuilderFunc getModel<const char16_t *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(
mlir::IntegerType::get(builder.getContext(), 16));
};
}
template <>
constexpr TypeBuilderFunc getModel<const char32_t *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(
mlir::IntegerType::get(builder.getContext(), 32));
};
}
template <>
constexpr TypeBuilderFunc getModel<char>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char));
};
}
template <>
constexpr TypeBuilderFunc getModel<signed char>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(signed char));
};
}
template <>
constexpr TypeBuilderFunc getModel<signed char *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<signed char>()};
return fir::ReferenceType::get(f(builder));
};
@@ -212,47 +211,47 @@ constexpr TypeBuilderFunc getModel<const signed char *>() {
}
template <>
constexpr TypeBuilderFunc getModel<char16_t>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char16_t));
};
}
template <>
constexpr TypeBuilderFunc getModel<char16_t *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<char16_t>()};
return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<char32_t>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char32_t));
};
}
template <>
constexpr TypeBuilderFunc getModel<char32_t *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<char32_t>()};
return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned char>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(unsigned char));
};
}
template <>
constexpr TypeBuilderFunc getModel<void *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::LLVMPointerType::get(
builder.getContext(), mlir::IntegerType::get(builder.getContext(), 8));
};
}
template <>
constexpr TypeBuilderFunc getModel<void (*)(int)>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::LLVMPointerType::get(
builder.getContext(),
mlir::FunctionType::get(builder.getContext(), /*inputs=*/{},
@@ -261,20 +260,20 @@ constexpr TypeBuilderFunc getModel<void (*)(int)>() {
}
template <>
constexpr TypeBuilderFunc getModel<void **>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(fir::LLVMPointerType::get(
builder.getContext(), mlir::IntegerType::get(builder.getContext(), 8)));
};
}
template <>
constexpr TypeBuilderFunc getModel<long>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 8 * 4);
};
}
template <>
constexpr TypeBuilderFunc getModel<long &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<long>()};
return fir::ReferenceType::get(f(builder));
};
@@ -289,20 +288,20 @@ constexpr TypeBuilderFunc getModel<const long *>() {
}
template <>
constexpr TypeBuilderFunc getModel<long long>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(long long));
};
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::int128_t>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(Fortran::common::int128_t));
};
}
template <>
constexpr TypeBuilderFunc getModel<long long &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<long long>()};
return fir::ReferenceType::get(f(builder));
};
@@ -317,26 +316,26 @@ constexpr TypeBuilderFunc getModel<const long long *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 8 * 4);
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long long>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(unsigned long long));
};
}
template <>
constexpr TypeBuilderFunc getModel<double>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::Float64Type::get(builder.getContext());
};
}
template <>
constexpr TypeBuilderFunc getModel<double &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<double>()};
return fir::ReferenceType::get(f(builder));
};
@@ -351,7 +350,7 @@ constexpr TypeBuilderFunc getModel<const double *>() {
}
template <>
constexpr TypeBuilderFunc getModel<long double>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
// See TODO at the top of the file. This is configuring for the host system
// - it might be incorrect when cross-compiling!
constexpr size_t size = sizeof(long double);
@@ -368,7 +367,7 @@ constexpr TypeBuilderFunc getModel<long double>() {
}
template <>
constexpr TypeBuilderFunc getModel<long double *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<long double>()};
return fir::ReferenceType::get(f(builder));
};
@@ -379,13 +378,13 @@ constexpr TypeBuilderFunc getModel<const long double *>() {
}
template <>
constexpr TypeBuilderFunc getModel<float>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::Float32Type::get(builder.getContext());
};
}
template <>
constexpr TypeBuilderFunc getModel<float &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<float>()};
return fir::ReferenceType::get(f(builder));
};
@@ -400,27 +399,27 @@ constexpr TypeBuilderFunc getModel<const float *>() {
}
template <>
constexpr TypeBuilderFunc getModel<bool>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(), 1);
};
}
template <>
constexpr TypeBuilderFunc getModel<bool &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<bool>()};
return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<bool *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<bool>()};
return fir::ReferenceType::get(f(builder));
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned short>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(
builder.getContext(), 8 * sizeof(unsigned short),
mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -428,7 +427,7 @@ constexpr TypeBuilderFunc getModel<unsigned short>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned char *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(
mlir::IntegerType::get(builder.getContext(), 8));
};
@@ -439,7 +438,7 @@ constexpr TypeBuilderFunc getModel<const unsigned char *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned short *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::IntegerType::get(
builder.getContext(), 8 * sizeof(unsigned short)));
};
@@ -458,7 +457,7 @@ constexpr TypeBuilderFunc getModel<const unsigned *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::IntegerType::get(
builder.getContext(), 8 * sizeof(unsigned long)));
};
@@ -469,7 +468,7 @@ constexpr TypeBuilderFunc getModel<const unsigned long *>() {
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long long *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::IntegerType::get(
builder.getContext(), 8 * sizeof(unsigned long long)));
};
@@ -484,7 +483,7 @@ constexpr TypeBuilderFunc getModel<Fortran::common::uint128_t>() {
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::int128_t *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
TypeBuilderFunc f{getModel<Fortran::common::int128_t>()};
return fir::ReferenceType::get(f(builder));
};
@@ -507,7 +506,7 @@ constexpr TypeBuilderFunc getModel<const Fortran::common::uint128_t *>() {
template <>
constexpr TypeBuilderFunc getModel<std::complex<float> &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type floatTy = getModel<float>()(builder);
return fir::ReferenceType::get(mlir::ComplexType::get(floatTy));
};
@@ -522,7 +521,7 @@ constexpr TypeBuilderFunc getModel<const std::complex<float> *>() {
}
template <>
constexpr TypeBuilderFunc getModel<std::complex<double> &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type floatTy = getModel<double>()(builder);
return fir::ReferenceType::get(mlir::ComplexType::get(floatTy));
};
@@ -537,27 +536,27 @@ constexpr TypeBuilderFunc getModel<const std::complex<double> *>() {
}
template <>
constexpr TypeBuilderFunc getModel<c_float_complex_t>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type floatTy = getModel<float>()(builder);
return mlir::ComplexType::get(floatTy);
};
}
template <>
constexpr TypeBuilderFunc getModel<c_double_complex_t>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type floatTy = getModel<double>()(builder);
return mlir::ComplexType::get(floatTy);
};
}
template <>
constexpr TypeBuilderFunc getModel<const Fortran::runtime::Descriptor &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::BoxType::get(mlir::NoneType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(
fir::BoxType::get(mlir::NoneType::get(builder.getContext())));
};
@@ -572,7 +571,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor *>() {
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::TypeCategory>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(),
sizeof(Fortran::common::TypeCategory) * 8);
};
@@ -580,20 +579,20 @@ constexpr TypeBuilderFunc getModel<Fortran::common::TypeCategory>() {
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::typeInfo::DerivedType &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::NoneType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::typeInfo::DerivedType *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::NoneType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc getModel<void>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::NoneType::get(builder.getContext());
};
}
@@ -605,7 +604,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
}
template <>
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(builder.getContext(),
8 * sizeof(Fortran::runtime::io::Iostat));
};
@@ -613,14 +612,14 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::io::NamelistGroup &>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::TupleType::get(builder.getContext()));
};
}
template <>
constexpr TypeBuilderFunc
getModel<const Fortran::runtime::io::NonTbpDefinedIoTable *>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return fir::ReferenceType::get(mlir::TupleType::get(builder.getContext()));
};
}
@@ -660,7 +659,7 @@ REDUCTION_VALUE_OPERATION_MODEL(long double)
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ValueReductionOperation<std::complex<float>>>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type cplx = mlir::ComplexType::get(getModel<float>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
return mlir::FunctionType::get(builder.getContext(), {cplx, cplx}, refTy);
@@ -669,7 +668,7 @@ getModel<Fortran::runtime::ValueReductionOperation<std::complex<float>>>() {
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ValueReductionOperation<std::complex<double>>>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type cplx = mlir::ComplexType::get(getModel<double>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
return mlir::FunctionType::get(builder.getContext(), {cplx, cplx}, refTy);
@@ -678,7 +677,7 @@ getModel<Fortran::runtime::ValueReductionOperation<std::complex<double>>>() {
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ReferenceReductionOperation<std::complex<float>>>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type cplx = mlir::ComplexType::get(getModel<float>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
return mlir::FunctionType::get(builder.getContext(), {refTy, refTy}, refTy);
@@ -687,7 +686,7 @@ getModel<Fortran::runtime::ReferenceReductionOperation<std::complex<float>>>() {
template <>
constexpr TypeBuilderFunc getModel<
Fortran::runtime::ReferenceReductionOperation<std::complex<double>>>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
mlir::Type cplx = mlir::ComplexType::get(getModel<double>()(builder));
auto refTy = fir::ReferenceType::get(cplx);
return mlir::FunctionType::get(builder.getContext(), {refTy, refTy}, refTy);
@@ -701,7 +700,7 @@ REDUCTION_CHAR_OPERATION_MODEL(char32_t)
template <>
constexpr TypeBuilderFunc
getModel<Fortran::runtime::ReductionDerivedTypeOperation>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
auto voidTy = fir::LLVMPointerType::get(
builder.getContext(), mlir::IntegerType::get(builder.getContext(), 8));
return mlir::FunctionType::get(builder.getContext(),
@@ -714,7 +713,7 @@ struct RuntimeTableKey;
template <typename RT, typename... ATs>
struct RuntimeTableKey<RT(ATs...)> {
static constexpr FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
TypeBuilderFunc ret = getModel<RT>();
std::array<TypeBuilderFunc, sizeof...(ATs)> args = {getModel<ATs>()...};
mlir::Type retTy = ret(builder);
diff --git a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
index dce29c030f584..0949474124f9a 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp
@@ -32,7 +32,7 @@ namespace {
struct ForcedRandomNumberReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(RandomNumber16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto boxTy =
fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
builder);
diff --git a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
index 5fa5eda3789a8..7360077d3fd7f 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
@@ -26,7 +26,7 @@ using namespace Fortran::runtime;
struct ForcedErfcScaled10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ErfcScaled10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -38,7 +38,7 @@ struct ForcedErfcScaled10 {
struct ForcedErfcScaled16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ErfcScaled16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -50,7 +50,7 @@ struct ForcedErfcScaled16 {
struct ForcedExponent10_4 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent10_4));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 32);
@@ -62,7 +62,7 @@ struct ForcedExponent10_4 {
struct ForcedExponent10_8 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent10_8));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
@@ -75,7 +75,7 @@ struct ForcedExponent10_8 {
struct ForcedExponent16_4 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent16_4));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 32);
@@ -87,7 +87,7 @@ struct ForcedExponent16_4 {
struct ForcedExponent16_8 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Exponent16_8));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
@@ -100,7 +100,7 @@ struct ForcedExponent16_8 {
struct ForcedFraction10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Fraction10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -112,7 +112,7 @@ struct ForcedFraction10 {
struct ForcedFraction16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Fraction16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -124,7 +124,7 @@ struct ForcedFraction16 {
struct ForcedMod10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -139,7 +139,7 @@ struct ForcedMod10 {
struct ForcedMod16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -154,7 +154,7 @@ struct ForcedMod16 {
struct ForcedModulo10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModuloReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -169,7 +169,7 @@ struct ForcedModulo10 {
struct ForcedModulo16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ModuloReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8));
@@ -184,7 +184,7 @@ struct ForcedModulo16 {
struct ForcedNearest10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Nearest10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto boolTy = mlir::IntegerType::get(ctx, 1);
@@ -197,7 +197,7 @@ struct ForcedNearest10 {
struct ForcedNearest16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Nearest16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto boolTy = mlir::IntegerType::get(ctx, 1);
@@ -210,7 +210,7 @@ struct ForcedNearest16 {
struct ForcedRRSpacing10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(RRSpacing10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -222,7 +222,7 @@ struct ForcedRRSpacing10 {
struct ForcedRRSpacing16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(RRSpacing16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -234,7 +234,7 @@ struct ForcedRRSpacing16 {
struct ForcedScale10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Scale10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
@@ -247,7 +247,7 @@ struct ForcedScale10 {
struct ForcedScale16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Scale16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
@@ -260,7 +260,7 @@ struct ForcedScale16 {
struct ForcedSetExponent10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SetExponent10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float80Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
@@ -273,7 +273,7 @@ struct ForcedSetExponent10 {
struct ForcedSetExponent16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SetExponent16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto fltTy = mlir::Float128Type::get(ctx);
auto intTy = mlir::IntegerType::get(ctx, 64);
@@ -286,7 +286,7 @@ struct ForcedSetExponent16 {
struct ForcedSpacing10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Spacing10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
@@ -298,7 +298,7 @@ struct ForcedSpacing10 {
struct ForcedSpacing16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Spacing16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
return mlir::FunctionType::get(ctx, {ty}, {ty});
diff --git a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
index 0712e6c35d707..47b56de12f807 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
@@ -26,7 +26,7 @@ using namespace Fortran::runtime;
struct ForcedMaxvalReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MaxvalReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -44,7 +44,7 @@ struct ForcedMaxvalReal10 {
struct ForcedMaxvalReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MaxvalReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -63,7 +63,7 @@ struct ForcedMaxvalInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MaxvalInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -82,7 +82,7 @@ struct ForcedMaxvalUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MaxvalUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -101,7 +101,7 @@ struct ForcedMaxvalUnsigned16 {
struct ForcedMinvalReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MinvalReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -119,7 +119,7 @@ struct ForcedMinvalReal10 {
struct ForcedMinvalReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MinvalReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -138,7 +138,7 @@ struct ForcedMinvalInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MinvalInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -157,7 +157,7 @@ struct ForcedMinvalUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(MinvalUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -188,7 +188,7 @@ using ForcedMinlocUnsigned16 = mkRTKey(MinlocUnsigned16);
struct ForcedNorm2Real10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -205,7 +205,7 @@ struct ForcedNorm2Real10 {
struct ForcedNorm2Real16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -222,7 +222,7 @@ struct ForcedNorm2Real16 {
struct ForcedNorm2DimReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2DimReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto boxTy =
fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(
@@ -240,7 +240,7 @@ struct ForcedNorm2DimReal16 {
struct ForcedProductReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ProductReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -258,7 +258,7 @@ struct ForcedProductReal10 {
struct ForcedProductReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ProductReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -277,7 +277,7 @@ struct ForcedProductInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ProductInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -296,7 +296,7 @@ struct ForcedProductUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ProductUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -316,7 +316,7 @@ struct ForcedProductComplex10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppProductComplex10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -336,7 +336,7 @@ struct ForcedProductComplex16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppProductComplex16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
@@ -356,7 +356,7 @@ struct ForcedDotProductReal10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -374,7 +374,7 @@ struct ForcedDotProductReal16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -392,7 +392,7 @@ struct ForcedDotProductComplex10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppDotProductComplex10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -412,7 +412,7 @@ struct ForcedDotProductComplex16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppDotProductComplex16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
@@ -432,7 +432,7 @@ struct ForcedDotProductInteger16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -450,7 +450,7 @@ struct ForcedDotProductUnsigned16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(DotProductUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -468,7 +468,7 @@ struct ForcedDotProductUnsigned16 {
struct ForcedSumReal10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumReal10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -486,7 +486,7 @@ struct ForcedSumReal10 {
struct ForcedSumReal16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumReal16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -504,7 +504,7 @@ struct ForcedSumReal16 {
struct ForcedSumInteger16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumInteger16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -522,7 +522,7 @@ struct ForcedSumInteger16 {
struct ForcedSumUnsigned16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumUnsigned16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -542,7 +542,7 @@ struct ForcedSumComplex10 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppSumComplex10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -562,7 +562,7 @@ struct ForcedSumComplex16 {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppSumComplex16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
@@ -581,7 +581,7 @@ struct ForcedSumComplex16 {
struct ForcedIAll16 {
static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IAll16);
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -599,7 +599,7 @@ struct ForcedIAll16 {
struct ForcedIAny16 {
static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IAny16);
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -617,7 +617,7 @@ struct ForcedIAny16 {
struct ForcedIParity16 {
static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IParity16);
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -636,7 +636,7 @@ struct ForcedReduceReal10Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -658,7 +658,7 @@ struct ForcedReduceReal10Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -680,7 +680,7 @@ struct ForcedReduceReal16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -702,7 +702,7 @@ struct ForcedReduceReal16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -724,7 +724,7 @@ struct ForcedReduceReal10DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -748,7 +748,7 @@ struct ForcedReduceReal10DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal10DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -772,7 +772,7 @@ struct ForcedReduceReal16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -796,7 +796,7 @@ struct ForcedReduceReal16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceReal16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -820,7 +820,7 @@ struct ForcedReduceInteger16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -842,7 +842,7 @@ struct ForcedReduceUnsigned16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -864,7 +864,7 @@ struct ForcedReduceInteger16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -886,7 +886,7 @@ struct ForcedReduceUnsigned16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -908,7 +908,7 @@ struct ForcedReduceInteger16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -932,7 +932,7 @@ struct ForcedReduceUnsigned16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -957,7 +957,7 @@ struct ForcedReduceInteger16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceInteger16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(ctx, 128);
auto boxTy =
@@ -981,7 +981,7 @@ struct ForcedReduceUnsigned16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(ReduceUnsigned16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::IntegerType::get(
ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -1006,7 +1006,7 @@ struct ForcedReduceComplex10Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -1029,7 +1029,7 @@ struct ForcedReduceComplex10Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -1052,7 +1052,7 @@ struct ForcedReduceComplex10DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -1076,7 +1076,7 @@ struct ForcedReduceComplex10DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex10DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx));
auto boxTy =
@@ -1100,7 +1100,7 @@ struct ForcedReduceComplex16Ref {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16Ref));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
@@ -1123,7 +1123,7 @@ struct ForcedReduceComplex16Value {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16Value));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
@@ -1146,7 +1146,7 @@ struct ForcedReduceComplex16DimRef {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16DimRef));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
@@ -1170,7 +1170,7 @@ struct ForcedReduceComplex16DimValue {
static constexpr const char *name =
ExpandAndQuoteKey(RTNAME(CppReduceComplex16DimValue));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx));
auto boxTy =
diff --git a/flang/lib/Optimizer/Builder/Runtime/Support.cpp b/flang/lib/Optimizer/Builder/Runtime/Support.cpp
index 85e8d1add9256..c43df2105b5c4 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Support.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Support.cpp
@@ -17,7 +17,7 @@ using namespace Fortran::runtime;
template <>
constexpr fir::runtime::TypeBuilderFunc
fir::runtime::getModel<Fortran::runtime::LowerBoundModifier>() {
- return [](const fir::FirOpBuilder &builder) -> mlir::Type {
+ return [](fir::FirOpBuilder &builder) -> mlir::Type {
return mlir::IntegerType::get(
builder.getContext(), sizeof(Fortran::runtime::LowerBoundModifier) * 8);
};
diff --git a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
index 1ecaba47e2b9f..6d8a8c428b736 100644
--- a/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
+++ b/flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
@@ -24,7 +24,7 @@ using namespace Fortran::runtime;
struct ForcedBesselJn_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJn_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -41,7 +41,7 @@ struct ForcedBesselJn_10 {
struct ForcedBesselJn_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJn_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -58,7 +58,7 @@ struct ForcedBesselJn_16 {
struct ForcedBesselJnX0_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJnX0_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto boxTy =
fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
@@ -74,7 +74,7 @@ struct ForcedBesselJnX0_10 {
struct ForcedBesselJnX0_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselJnX0_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto boxTy =
fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
@@ -90,7 +90,7 @@ struct ForcedBesselJnX0_16 {
struct ForcedBesselYn_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYn_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float80Type::get(ctx);
auto boxTy =
@@ -107,7 +107,7 @@ struct ForcedBesselYn_10 {
struct ForcedBesselYn_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYn_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto ty = mlir::Float128Type::get(ctx);
auto boxTy =
@@ -124,7 +124,7 @@ struct ForcedBesselYn_16 {
struct ForcedBesselYnX0_10 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYnX0_10));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto boxTy =
fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
@@ -140,7 +140,7 @@ struct ForcedBesselYnX0_10 {
struct ForcedBesselYnX0_16 {
static constexpr const char *name = ExpandAndQuoteKey(RTNAME(BesselYnX0_16));
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto boxTy =
fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
@@ -332,7 +332,7 @@ void fir::runtime::genEoshiftVector(fir::FirOpBuilder &builder,
/// Define ForcedMatmul<ACAT><AKIND><BCAT><BKIND> models.
struct ForcedMatmulTypeModel {
static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() {
- return [](const fir::FirOpBuilder &builder) {
+ return [](fir::FirOpBuilder &builder) {
auto ctx = builder.getContext();
auto boxRefTy =
fir::runtime::getModel<Fortran::runtime::Descriptor &>()(builder);
>From 3a89328312912996fa9009249f5ea89f64e3f20d Mon Sep 17 00:00:00 2001
From: R <rqou at berkeley.edu>
Date: Fri, 28 Feb 2025 20:31:11 +0000
Subject: [PATCH 7/7] fixes for most things
---
.../Optimizer/Builder/Runtime/RTBuilder.h | 47 +++++++++----------
1 file changed, 21 insertions(+), 26 deletions(-)
diff --git a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
index ba5982404f70e..4021e8149fadf 100644
--- a/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
+++ b/flang/include/flang/Optimizer/Builder/Runtime/RTBuilder.h
@@ -87,8 +87,7 @@ using FuncTypeBuilderFunc = mlir::FunctionType (*)(fir::FirOpBuilder &);
auto voidTy = fir::LLVMPointerType::get( \
builder.getContext(), \
mlir::IntegerType::get(builder.getContext(), 8)); \
- auto size_tTy = mlir::IntegerType::get(builder.getContext(), \
- 8 * sizeof(std::size_t)); \
+ auto size_tTy = builder.getIntPtrType(); \
auto refTy = fir::ReferenceType::get(f(builder)); \
return mlir::FunctionType::get( \
builder.getContext(), \
@@ -188,14 +187,13 @@ constexpr TypeBuilderFunc getModel<const char32_t *>() {
template <>
constexpr TypeBuilderFunc getModel<char>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char));
+ return builder.getCCharType();
};
}
template <>
constexpr TypeBuilderFunc getModel<signed char>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(),
- 8 * sizeof(signed char));
+ return builder.getCCharType();
};
}
template <>
@@ -212,7 +210,7 @@ constexpr TypeBuilderFunc getModel<const signed char *>() {
template <>
constexpr TypeBuilderFunc getModel<char16_t>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char16_t));
+ return mlir::IntegerType::get(builder.getContext(), 16);
};
}
template <>
@@ -225,7 +223,7 @@ constexpr TypeBuilderFunc getModel<char16_t *>() {
template <>
constexpr TypeBuilderFunc getModel<char32_t>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(char32_t));
+ return mlir::IntegerType::get(builder.getContext(), 32);
};
}
template <>
@@ -238,8 +236,7 @@ constexpr TypeBuilderFunc getModel<char32_t *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned char>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(),
- 8 * sizeof(unsigned char));
+ return builder.getCCharType();
};
}
template <>
@@ -268,7 +265,7 @@ constexpr TypeBuilderFunc getModel<void **>() {
template <>
constexpr TypeBuilderFunc getModel<long>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * 4);
+ return builder.getCLongType();
};
}
template <>
@@ -289,7 +286,7 @@ constexpr TypeBuilderFunc getModel<const long *>() {
template <>
constexpr TypeBuilderFunc getModel<long long>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * sizeof(long long));
+ return builder.getCLongLongType();
};
}
template <>
@@ -317,14 +314,13 @@ constexpr TypeBuilderFunc getModel<const long long *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned long>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(), 8 * 4);
+ return builder.getCLongType();
};
}
template <>
constexpr TypeBuilderFunc getModel<unsigned long long>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(),
- 8 * sizeof(unsigned long long));
+ return builder.getCLongLongType();
};
}
template <>
@@ -420,6 +416,7 @@ constexpr TypeBuilderFunc getModel<bool *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned short>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
+ // TODO: This has special signedness semantics?
return mlir::IntegerType::get(
builder.getContext(), 8 * sizeof(unsigned short),
mlir::IntegerType::SignednessSemantics::Unsigned);
@@ -428,8 +425,8 @@ constexpr TypeBuilderFunc getModel<unsigned short>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned char *>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return fir::ReferenceType::get(
- mlir::IntegerType::get(builder.getContext(), 8));
+ TypeBuilderFunc f{getModel<unsigned char>()};
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -439,8 +436,8 @@ constexpr TypeBuilderFunc getModel<const unsigned char *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned short *>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(
- builder.getContext(), 8 * sizeof(unsigned short)));
+ TypeBuilderFunc f{getModel<unsigned short>()};
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -458,8 +455,8 @@ constexpr TypeBuilderFunc getModel<const unsigned *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned long *>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(
- builder.getContext(), 8 * sizeof(unsigned long)));
+ TypeBuilderFunc f{getModel<unsigned long>()};
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -469,8 +466,8 @@ constexpr TypeBuilderFunc getModel<const unsigned long *>() {
template <>
constexpr TypeBuilderFunc getModel<unsigned long long *>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return fir::ReferenceType::get(mlir::IntegerType::get(
- builder.getContext(), 8 * sizeof(unsigned long long)));
+ TypeBuilderFunc f{getModel<unsigned long long>()};
+ return fir::ReferenceType::get(f(builder));
};
}
template <>
@@ -572,8 +569,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::Descriptor *>() {
template <>
constexpr TypeBuilderFunc getModel<Fortran::common::TypeCategory>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(),
- sizeof(Fortran::common::TypeCategory) * 8);
+ return builder.getCEnumType();
};
}
template <>
@@ -605,8 +601,7 @@ constexpr TypeBuilderFunc getModel<Fortran::runtime::io::IoStatementState *>() {
template <>
constexpr TypeBuilderFunc getModel<Fortran::runtime::io::Iostat>() {
return [](fir::FirOpBuilder &builder) -> mlir::Type {
- return mlir::IntegerType::get(builder.getContext(),
- 8 * sizeof(Fortran::runtime::io::Iostat));
+ return builder.getCEnumType();
};
}
template <>
More information about the llvm-commits
mailing list