1f6ae8e8cSValentin Clement //===-- Reduction.cpp -- generate reduction intrinsics runtime calls- -----===// 2f6ae8e8cSValentin Clement // 3f6ae8e8cSValentin Clement // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4f6ae8e8cSValentin Clement // See https://llvm.org/LICENSE.txt for license information. 5f6ae8e8cSValentin Clement // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6f6ae8e8cSValentin Clement // 7f6ae8e8cSValentin Clement //===----------------------------------------------------------------------===// 8f6ae8e8cSValentin Clement 9f6ae8e8cSValentin Clement #include "flang/Optimizer/Builder/Runtime/Reduction.h" 10f6ae8e8cSValentin Clement #include "flang/Optimizer/Builder/BoxValue.h" 11f6ae8e8cSValentin Clement #include "flang/Optimizer/Builder/Character.h" 12f6ae8e8cSValentin Clement #include "flang/Optimizer/Builder/FIRBuilder.h" 13f6ae8e8cSValentin Clement #include "flang/Optimizer/Builder/Runtime/RTBuilder.h" 1404b18530SPete Steinfeld #include "flang/Optimizer/Support/Utils.h" 150babff96SValentin Clement (バレンタイン クレメン) #include "flang/Runtime/reduce.h" 16f6ae8e8cSValentin Clement #include "flang/Runtime/reduction.h" 1723aa5a74SRiver Riddle #include "mlir/Dialect/Func/IR/FuncOps.h" 18f6ae8e8cSValentin Clement 19f6ae8e8cSValentin Clement using namespace Fortran::runtime; 20f6ae8e8cSValentin Clement 21ebfe8a74STarun Prabhu #define STRINGIFY(S) #S 22ebfe8a74STarun Prabhu #define JOIN2(A, B) A##B 23ebfe8a74STarun Prabhu #define JOIN3(A, B, C) A##B##C 24ebfe8a74STarun Prabhu 25f6ae8e8cSValentin Clement /// Placeholder for real*10 version of Maxval Intrinsic 26f6ae8e8cSValentin Clement struct ForcedMaxvalReal10 { 27f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MaxvalReal10)); 28f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 29f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 30f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 31f6ae8e8cSValentin Clement auto boxTy = 32f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 33f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 34f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 35f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 36f6ae8e8cSValentin Clement {ty}); 37f6ae8e8cSValentin Clement }; 38f6ae8e8cSValentin Clement } 39f6ae8e8cSValentin Clement }; 40f6ae8e8cSValentin Clement 41f6ae8e8cSValentin Clement /// Placeholder for real*16 version of Maxval Intrinsic 42f6ae8e8cSValentin Clement struct ForcedMaxvalReal16 { 43f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MaxvalReal16)); 44f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 45f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 46f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 47f6ae8e8cSValentin Clement auto boxTy = 48f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 49f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 50f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 51f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 52f6ae8e8cSValentin Clement {ty}); 53f6ae8e8cSValentin Clement }; 54f6ae8e8cSValentin Clement } 55f6ae8e8cSValentin Clement }; 56f6ae8e8cSValentin Clement 57f6ae8e8cSValentin Clement /// Placeholder for integer*16 version of Maxval Intrinsic 58f6ae8e8cSValentin Clement struct ForcedMaxvalInteger16 { 59f6ae8e8cSValentin Clement static constexpr const char *name = 60f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(MaxvalInteger16)); 61f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 62f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 63f6ae8e8cSValentin Clement auto ty = mlir::IntegerType::get(ctx, 128); 64f6ae8e8cSValentin Clement auto boxTy = 65f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 66f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 67f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 68f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 69f6ae8e8cSValentin Clement {ty}); 70f6ae8e8cSValentin Clement }; 71f6ae8e8cSValentin Clement } 72f6ae8e8cSValentin Clement }; 73f6ae8e8cSValentin Clement 74fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 version of Maxval Intrinsic 75fc97d2e6SPeter Klausler struct ForcedMaxvalUnsigned16 { 76fc97d2e6SPeter Klausler static constexpr const char *name = 77fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(MaxvalUnsigned16)); 78fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 79fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 80fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 81fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 82fc97d2e6SPeter Klausler auto boxTy = 83fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 84fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 85fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 86fc97d2e6SPeter Klausler return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 87fc97d2e6SPeter Klausler {ty}); 88fc97d2e6SPeter Klausler }; 89fc97d2e6SPeter Klausler } 90fc97d2e6SPeter Klausler }; 91fc97d2e6SPeter Klausler 92f6ae8e8cSValentin Clement /// Placeholder for real*10 version of Minval Intrinsic 93f6ae8e8cSValentin Clement struct ForcedMinvalReal10 { 94f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MinvalReal10)); 95f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 96f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 97f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 98f6ae8e8cSValentin Clement auto boxTy = 99f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 100f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 101f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 102f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 103f6ae8e8cSValentin Clement {ty}); 104f6ae8e8cSValentin Clement }; 105f6ae8e8cSValentin Clement } 106f6ae8e8cSValentin Clement }; 107f6ae8e8cSValentin Clement 108f6ae8e8cSValentin Clement /// Placeholder for real*16 version of Minval Intrinsic 109f6ae8e8cSValentin Clement struct ForcedMinvalReal16 { 110f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(MinvalReal16)); 111f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 112f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 113f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 114f6ae8e8cSValentin Clement auto boxTy = 115f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 116f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 117f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 118f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 119f6ae8e8cSValentin Clement {ty}); 120f6ae8e8cSValentin Clement }; 121f6ae8e8cSValentin Clement } 122f6ae8e8cSValentin Clement }; 123f6ae8e8cSValentin Clement 124f6ae8e8cSValentin Clement /// Placeholder for integer*16 version of Minval Intrinsic 125f6ae8e8cSValentin Clement struct ForcedMinvalInteger16 { 126f6ae8e8cSValentin Clement static constexpr const char *name = 127f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(MinvalInteger16)); 128f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 129f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 130f6ae8e8cSValentin Clement auto ty = mlir::IntegerType::get(ctx, 128); 131f6ae8e8cSValentin Clement auto boxTy = 132f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 133f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 134f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 135f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 136f6ae8e8cSValentin Clement {ty}); 137f6ae8e8cSValentin Clement }; 138f6ae8e8cSValentin Clement } 139f6ae8e8cSValentin Clement }; 140f6ae8e8cSValentin Clement 141fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 version of Minval Intrinsic 142fc97d2e6SPeter Klausler struct ForcedMinvalUnsigned16 { 143fc97d2e6SPeter Klausler static constexpr const char *name = 144fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(MinvalUnsigned16)); 145fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 146fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 147fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 148fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 149fc97d2e6SPeter Klausler auto boxTy = 150fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 151fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 152fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 153fc97d2e6SPeter Klausler return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 154fc97d2e6SPeter Klausler {ty}); 155fc97d2e6SPeter Klausler }; 156fc97d2e6SPeter Klausler } 157fc97d2e6SPeter Klausler }; 158fc97d2e6SPeter Klausler 159cc3cc5edSjeanPerier // Maxloc/Minloc take descriptor, so these runtime signature are not ifdef 160cc3cc5edSjeanPerier // and the mkRTKey can safely be used here. Define alias so that the 161cc3cc5edSjeanPerier // REAL_INTRINSIC_INSTANCES macro works with them too 162cc3cc5edSjeanPerier using ForcedMaxlocReal10 = mkRTKey(MaxlocReal10); 163cc3cc5edSjeanPerier using ForcedMaxlocReal16 = mkRTKey(MaxlocReal16); 164cc3cc5edSjeanPerier using ForcedMaxlocInteger16 = mkRTKey(MaxlocInteger16); 165fc97d2e6SPeter Klausler using ForcedMaxlocUnsigned16 = mkRTKey(MaxlocUnsigned16); 166cc3cc5edSjeanPerier using ForcedMinlocReal10 = mkRTKey(MinlocReal10); 167cc3cc5edSjeanPerier using ForcedMinlocReal16 = mkRTKey(MinlocReal16); 168cc3cc5edSjeanPerier using ForcedMinlocInteger16 = mkRTKey(MinlocInteger16); 169fc97d2e6SPeter Klausler using ForcedMinlocUnsigned16 = mkRTKey(MinlocUnsigned16); 170cc3cc5edSjeanPerier 1717fe4abbbSTarun Prabhu /// Placeholder for real*10 version of Norm2 Intrinsic 1727fe4abbbSTarun Prabhu struct ForcedNorm2Real10 { 1737fe4abbbSTarun Prabhu static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2_10)); 1747fe4abbbSTarun Prabhu static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 1757fe4abbbSTarun Prabhu return [](mlir::MLIRContext *ctx) { 176f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 1777fe4abbbSTarun Prabhu auto boxTy = 1787fe4abbbSTarun Prabhu fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 1797fe4abbbSTarun Prabhu auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 1807fe4abbbSTarun Prabhu auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 1817fe4abbbSTarun Prabhu return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy}, {ty}); 1827fe4abbbSTarun Prabhu }; 1837fe4abbbSTarun Prabhu } 1847fe4abbbSTarun Prabhu }; 1857fe4abbbSTarun Prabhu 1867fe4abbbSTarun Prabhu /// Placeholder for real*16 version of Norm2 Intrinsic 1877fe4abbbSTarun Prabhu struct ForcedNorm2Real16 { 1887fe4abbbSTarun Prabhu static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2_16)); 1897fe4abbbSTarun Prabhu static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 1907fe4abbbSTarun Prabhu return [](mlir::MLIRContext *ctx) { 191f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 1927fe4abbbSTarun Prabhu auto boxTy = 1937fe4abbbSTarun Prabhu fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 1947fe4abbbSTarun Prabhu auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 1957fe4abbbSTarun Prabhu auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 1967fe4abbbSTarun Prabhu return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy}, {ty}); 1977fe4abbbSTarun Prabhu }; 1987fe4abbbSTarun Prabhu } 1997fe4abbbSTarun Prabhu }; 2007fe4abbbSTarun Prabhu 201baf6725bSSlava Zakharin /// Placeholder for real*16 version of Norm2Dim Intrinsic 202baf6725bSSlava Zakharin struct ForcedNorm2DimReal16 { 203baf6725bSSlava Zakharin static constexpr const char *name = ExpandAndQuoteKey(RTNAME(Norm2DimReal16)); 204baf6725bSSlava Zakharin static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 205baf6725bSSlava Zakharin return [](mlir::MLIRContext *ctx) { 206baf6725bSSlava Zakharin auto boxTy = 207baf6725bSSlava Zakharin fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 208baf6725bSSlava Zakharin auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 209baf6725bSSlava Zakharin auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 210baf6725bSSlava Zakharin return mlir::FunctionType::get( 211baf6725bSSlava Zakharin ctx, {fir::ReferenceType::get(boxTy), boxTy, intTy, strTy, intTy}, 212*12ba74e1SValentin Clement (バレンタイン クレメン) {}); 213baf6725bSSlava Zakharin }; 214baf6725bSSlava Zakharin } 215baf6725bSSlava Zakharin }; 216baf6725bSSlava Zakharin 217f6ae8e8cSValentin Clement /// Placeholder for real*10 version of Product Intrinsic 218f6ae8e8cSValentin Clement struct ForcedProductReal10 { 219f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ProductReal10)); 220f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 221f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 222f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 223f6ae8e8cSValentin Clement auto boxTy = 224f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 225f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 226f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 227f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 228f6ae8e8cSValentin Clement {ty}); 229f6ae8e8cSValentin Clement }; 230f6ae8e8cSValentin Clement } 231f6ae8e8cSValentin Clement }; 232f6ae8e8cSValentin Clement 233f6ae8e8cSValentin Clement /// Placeholder for real*16 version of Product Intrinsic 234f6ae8e8cSValentin Clement struct ForcedProductReal16 { 235f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(ProductReal16)); 236f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 237f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 238f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 239f6ae8e8cSValentin Clement auto boxTy = 240f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 241f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 242f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 243f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 244f6ae8e8cSValentin Clement {ty}); 245f6ae8e8cSValentin Clement }; 246f6ae8e8cSValentin Clement } 247f6ae8e8cSValentin Clement }; 248f6ae8e8cSValentin Clement 249f6ae8e8cSValentin Clement /// Placeholder for integer*16 version of Product Intrinsic 250f6ae8e8cSValentin Clement struct ForcedProductInteger16 { 251f6ae8e8cSValentin Clement static constexpr const char *name = 252f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(ProductInteger16)); 253f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 254f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 255f6ae8e8cSValentin Clement auto ty = mlir::IntegerType::get(ctx, 128); 256f6ae8e8cSValentin Clement auto boxTy = 257f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 258f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 259f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 260f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 261f6ae8e8cSValentin Clement {ty}); 262f6ae8e8cSValentin Clement }; 263f6ae8e8cSValentin Clement } 264f6ae8e8cSValentin Clement }; 265f6ae8e8cSValentin Clement 266fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 version of Product Intrinsic 267fc97d2e6SPeter Klausler struct ForcedProductUnsigned16 { 268fc97d2e6SPeter Klausler static constexpr const char *name = 269fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(ProductUnsigned16)); 270fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 271fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 272fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 273fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 274fc97d2e6SPeter Klausler auto boxTy = 275fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 276fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 277fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 278fc97d2e6SPeter Klausler return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 279fc97d2e6SPeter Klausler {ty}); 280fc97d2e6SPeter Klausler }; 281fc97d2e6SPeter Klausler } 282fc97d2e6SPeter Klausler }; 283fc97d2e6SPeter Klausler 284f6ae8e8cSValentin Clement /// Placeholder for complex(10) version of Product Intrinsic 285f6ae8e8cSValentin Clement struct ForcedProductComplex10 { 286f6ae8e8cSValentin Clement static constexpr const char *name = 287f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(CppProductComplex10)); 288f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 289f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 290f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 291f6ae8e8cSValentin Clement auto boxTy = 292f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 293f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 294f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 295f6ae8e8cSValentin Clement auto resTy = fir::ReferenceType::get(ty); 296f6ae8e8cSValentin Clement return mlir::FunctionType::get( 297f6ae8e8cSValentin Clement ctx, {resTy, boxTy, strTy, intTy, intTy, boxTy}, {}); 298f6ae8e8cSValentin Clement }; 299f6ae8e8cSValentin Clement } 300f6ae8e8cSValentin Clement }; 301f6ae8e8cSValentin Clement 302f6ae8e8cSValentin Clement /// Placeholder for complex(16) version of Product Intrinsic 303f6ae8e8cSValentin Clement struct ForcedProductComplex16 { 304f6ae8e8cSValentin Clement static constexpr const char *name = 305f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(CppProductComplex16)); 306f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 307f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 308f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 309f6ae8e8cSValentin Clement auto boxTy = 310f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 311f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 312f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 313f6ae8e8cSValentin Clement auto resTy = fir::ReferenceType::get(ty); 314f6ae8e8cSValentin Clement return mlir::FunctionType::get( 315f6ae8e8cSValentin Clement ctx, {resTy, boxTy, strTy, intTy, intTy, boxTy}, {}); 316f6ae8e8cSValentin Clement }; 317f6ae8e8cSValentin Clement } 318f6ae8e8cSValentin Clement }; 319f6ae8e8cSValentin Clement 320f6ae8e8cSValentin Clement /// Placeholder for real*10 version of DotProduct Intrinsic 321f6ae8e8cSValentin Clement struct ForcedDotProductReal10 { 322f6ae8e8cSValentin Clement static constexpr const char *name = 323f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(DotProductReal10)); 324f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 325f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 326f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 327f6ae8e8cSValentin Clement auto boxTy = 328f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 329f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 330f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 331f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty}); 332f6ae8e8cSValentin Clement }; 333f6ae8e8cSValentin Clement } 334f6ae8e8cSValentin Clement }; 335f6ae8e8cSValentin Clement 336f6ae8e8cSValentin Clement /// Placeholder for real*16 version of DotProduct Intrinsic 337f6ae8e8cSValentin Clement struct ForcedDotProductReal16 { 338f6ae8e8cSValentin Clement static constexpr const char *name = 339f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(DotProductReal16)); 340f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 341f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 342f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 343f6ae8e8cSValentin Clement auto boxTy = 344f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 345f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 346f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 347f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty}); 348f6ae8e8cSValentin Clement }; 349f6ae8e8cSValentin Clement } 350f6ae8e8cSValentin Clement }; 351f6ae8e8cSValentin Clement 352f6ae8e8cSValentin Clement /// Placeholder for complex(10) version of DotProduct Intrinsic 353f6ae8e8cSValentin Clement struct ForcedDotProductComplex10 { 354f6ae8e8cSValentin Clement static constexpr const char *name = 355f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(CppDotProductComplex10)); 356f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 357f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 358f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 359f6ae8e8cSValentin Clement auto boxTy = 360f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 361f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 362f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 363f6ae8e8cSValentin Clement auto resTy = fir::ReferenceType::get(ty); 364f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {resTy, boxTy, boxTy, strTy, intTy}, 365f6ae8e8cSValentin Clement {}); 366f6ae8e8cSValentin Clement }; 367f6ae8e8cSValentin Clement } 368f6ae8e8cSValentin Clement }; 369f6ae8e8cSValentin Clement 370f6ae8e8cSValentin Clement /// Placeholder for complex(16) version of DotProduct Intrinsic 371f6ae8e8cSValentin Clement struct ForcedDotProductComplex16 { 372f6ae8e8cSValentin Clement static constexpr const char *name = 373f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(CppDotProductComplex16)); 374f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 375f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 376f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 377f6ae8e8cSValentin Clement auto boxTy = 378f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 379f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 380f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 381f6ae8e8cSValentin Clement auto resTy = fir::ReferenceType::get(ty); 382f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {resTy, boxTy, boxTy, strTy, intTy}, 383f6ae8e8cSValentin Clement {}); 384f6ae8e8cSValentin Clement }; 385f6ae8e8cSValentin Clement } 386f6ae8e8cSValentin Clement }; 387f6ae8e8cSValentin Clement 388f6ae8e8cSValentin Clement /// Placeholder for integer*16 version of DotProduct Intrinsic 389f6ae8e8cSValentin Clement struct ForcedDotProductInteger16 { 390f6ae8e8cSValentin Clement static constexpr const char *name = 391f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(DotProductInteger16)); 392f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 393f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 394f6ae8e8cSValentin Clement auto ty = mlir::IntegerType::get(ctx, 128); 395f6ae8e8cSValentin Clement auto boxTy = 396f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 397f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 398f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 399f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty}); 400f6ae8e8cSValentin Clement }; 401f6ae8e8cSValentin Clement } 402f6ae8e8cSValentin Clement }; 403f6ae8e8cSValentin Clement 404fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 version of DotProduct Intrinsic 405fc97d2e6SPeter Klausler struct ForcedDotProductUnsigned16 { 406fc97d2e6SPeter Klausler static constexpr const char *name = 407fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(DotProductUnsigned16)); 408fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 409fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 410fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 411fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 412fc97d2e6SPeter Klausler auto boxTy = 413fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 414fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 415fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 416fc97d2e6SPeter Klausler return mlir::FunctionType::get(ctx, {boxTy, boxTy, strTy, intTy}, {ty}); 417fc97d2e6SPeter Klausler }; 418fc97d2e6SPeter Klausler } 419fc97d2e6SPeter Klausler }; 420fc97d2e6SPeter Klausler 421f6ae8e8cSValentin Clement /// Placeholder for real*10 version of Sum Intrinsic 422f6ae8e8cSValentin Clement struct ForcedSumReal10 { 423f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumReal10)); 424f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 425f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 426f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 427f6ae8e8cSValentin Clement auto boxTy = 428f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 429f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 430f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 431f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 432f6ae8e8cSValentin Clement {ty}); 433f6ae8e8cSValentin Clement }; 434f6ae8e8cSValentin Clement } 435f6ae8e8cSValentin Clement }; 436f6ae8e8cSValentin Clement 437f6ae8e8cSValentin Clement /// Placeholder for real*16 version of Sum Intrinsic 438f6ae8e8cSValentin Clement struct ForcedSumReal16 { 439f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumReal16)); 440f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 441f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 442f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 443f6ae8e8cSValentin Clement auto boxTy = 444f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 445f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 446f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 447f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 448f6ae8e8cSValentin Clement {ty}); 449f6ae8e8cSValentin Clement }; 450f6ae8e8cSValentin Clement } 451f6ae8e8cSValentin Clement }; 452f6ae8e8cSValentin Clement 453f6ae8e8cSValentin Clement /// Placeholder for integer*16 version of Sum Intrinsic 454f6ae8e8cSValentin Clement struct ForcedSumInteger16 { 455f6ae8e8cSValentin Clement static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumInteger16)); 456f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 457f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 458f6ae8e8cSValentin Clement auto ty = mlir::IntegerType::get(ctx, 128); 459f6ae8e8cSValentin Clement auto boxTy = 460f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 461f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 462f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 463f6ae8e8cSValentin Clement return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 464f6ae8e8cSValentin Clement {ty}); 465f6ae8e8cSValentin Clement }; 466f6ae8e8cSValentin Clement } 467f6ae8e8cSValentin Clement }; 468f6ae8e8cSValentin Clement 469fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 version of Sum Intrinsic 470fc97d2e6SPeter Klausler struct ForcedSumUnsigned16 { 471fc97d2e6SPeter Klausler static constexpr const char *name = ExpandAndQuoteKey(RTNAME(SumUnsigned16)); 472fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 473fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 474fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 475fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 476fc97d2e6SPeter Klausler auto boxTy = 477fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 478fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 479fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 480fc97d2e6SPeter Klausler return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 481fc97d2e6SPeter Klausler {ty}); 482fc97d2e6SPeter Klausler }; 483fc97d2e6SPeter Klausler } 484fc97d2e6SPeter Klausler }; 485fc97d2e6SPeter Klausler 486f6ae8e8cSValentin Clement /// Placeholder for complex(10) version of Sum Intrinsic 487f6ae8e8cSValentin Clement struct ForcedSumComplex10 { 488f6ae8e8cSValentin Clement static constexpr const char *name = 489f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(CppSumComplex10)); 490f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 491f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 492f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 493f6ae8e8cSValentin Clement auto boxTy = 494f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 495f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 496f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 497f6ae8e8cSValentin Clement auto resTy = fir::ReferenceType::get(ty); 498f6ae8e8cSValentin Clement return mlir::FunctionType::get( 499f6ae8e8cSValentin Clement ctx, {resTy, boxTy, strTy, intTy, intTy, boxTy}, {}); 500f6ae8e8cSValentin Clement }; 501f6ae8e8cSValentin Clement } 502f6ae8e8cSValentin Clement }; 503f6ae8e8cSValentin Clement 504f6ae8e8cSValentin Clement /// Placeholder for complex(16) version of Sum Intrinsic 505f6ae8e8cSValentin Clement struct ForcedSumComplex16 { 506f6ae8e8cSValentin Clement static constexpr const char *name = 507f6ae8e8cSValentin Clement ExpandAndQuoteKey(RTNAME(CppSumComplex16)); 508f6ae8e8cSValentin Clement static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 509f6ae8e8cSValentin Clement return [](mlir::MLIRContext *ctx) { 510f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 511f6ae8e8cSValentin Clement auto boxTy = 512f6ae8e8cSValentin Clement fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 513f6ae8e8cSValentin Clement auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 514f6ae8e8cSValentin Clement auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 515f6ae8e8cSValentin Clement auto resTy = fir::ReferenceType::get(ty); 516f6ae8e8cSValentin Clement return mlir::FunctionType::get( 517f6ae8e8cSValentin Clement ctx, {resTy, boxTy, strTy, intTy, intTy, boxTy}, {}); 518f6ae8e8cSValentin Clement }; 519f6ae8e8cSValentin Clement } 520f6ae8e8cSValentin Clement }; 521f6ae8e8cSValentin Clement 522ebfe8a74STarun Prabhu /// Placeholder for integer(16) version of IAll Intrinsic 523ebfe8a74STarun Prabhu struct ForcedIAll16 { 524ebfe8a74STarun Prabhu static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IAll16); 525ebfe8a74STarun Prabhu static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 526ebfe8a74STarun Prabhu return [](mlir::MLIRContext *ctx) { 527ebfe8a74STarun Prabhu auto ty = mlir::IntegerType::get(ctx, 128); 528ebfe8a74STarun Prabhu auto boxTy = 529ebfe8a74STarun Prabhu fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 530ebfe8a74STarun Prabhu auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 531ebfe8a74STarun Prabhu auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 532ebfe8a74STarun Prabhu return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 533ebfe8a74STarun Prabhu {ty}); 534ebfe8a74STarun Prabhu }; 535ebfe8a74STarun Prabhu } 536ebfe8a74STarun Prabhu }; 537ebfe8a74STarun Prabhu 538ebfe8a74STarun Prabhu /// Placeholder for integer(16) version of IAny Intrinsic 539ebfe8a74STarun Prabhu struct ForcedIAny16 { 540ebfe8a74STarun Prabhu static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IAny16); 541ebfe8a74STarun Prabhu static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 542ebfe8a74STarun Prabhu return [](mlir::MLIRContext *ctx) { 543ebfe8a74STarun Prabhu auto ty = mlir::IntegerType::get(ctx, 128); 544ebfe8a74STarun Prabhu auto boxTy = 545ebfe8a74STarun Prabhu fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 546ebfe8a74STarun Prabhu auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 547ebfe8a74STarun Prabhu auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 548ebfe8a74STarun Prabhu return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 549ebfe8a74STarun Prabhu {ty}); 550ebfe8a74STarun Prabhu }; 551ebfe8a74STarun Prabhu } 552ebfe8a74STarun Prabhu }; 553ebfe8a74STarun Prabhu 554ebfe8a74STarun Prabhu /// Placeholder for integer(16) version of IParity Intrinsic 555ebfe8a74STarun Prabhu struct ForcedIParity16 { 556ebfe8a74STarun Prabhu static constexpr const char *name = EXPAND_AND_QUOTE_KEY(IParity16); 557ebfe8a74STarun Prabhu static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 558ebfe8a74STarun Prabhu return [](mlir::MLIRContext *ctx) { 559ebfe8a74STarun Prabhu auto ty = mlir::IntegerType::get(ctx, 128); 560ebfe8a74STarun Prabhu auto boxTy = 561ebfe8a74STarun Prabhu fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 562ebfe8a74STarun Prabhu auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 563ebfe8a74STarun Prabhu auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 564ebfe8a74STarun Prabhu return mlir::FunctionType::get(ctx, {boxTy, strTy, intTy, intTy, boxTy}, 565ebfe8a74STarun Prabhu {ty}); 566ebfe8a74STarun Prabhu }; 567ebfe8a74STarun Prabhu } 568ebfe8a74STarun Prabhu }; 569ebfe8a74STarun Prabhu 5700babff96SValentin Clement (バレンタイン クレメン) /// Placeholder for real*10 version of Reduce Intrinsic 571cc3cc5edSjeanPerier struct ForcedReduceReal10Ref { 572f8fc883dSPeter Klausler static constexpr const char *name = 573f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceReal10Ref)); 5740babff96SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 5750babff96SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 576f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 5770babff96SValentin Clement (バレンタイン クレメン) auto boxTy = 5780babff96SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 57938fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 58038fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 5810babff96SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 5820babff96SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 58338fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 58438fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 58538fd0181SValentin Clement (バレンタイン クレメン) ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 58638fd0181SValentin Clement (バレンタイン クレメン) }; 58738fd0181SValentin Clement (バレンタイン クレメン) } 58838fd0181SValentin Clement (バレンタイン クレメン) }; 58938fd0181SValentin Clement (バレンタイン クレメン) 59038fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for real*10 version of Reduce Intrinsic 59138fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceReal10Value { 59238fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 59338fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(ReduceReal10Value)); 59438fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 59538fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 596f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 59738fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 59838fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 5990babff96SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 60038fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 60138fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 60238fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 6030babff96SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 6040babff96SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 6050babff96SValentin Clement (バレンタイン クレメン) ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 6060babff96SValentin Clement (バレンタイン クレメン) }; 6070babff96SValentin Clement (バレンタイン クレメン) } 6080babff96SValentin Clement (バレンタイン クレメン) }; 6090babff96SValentin Clement (バレンタイン クレメン) 6100babff96SValentin Clement (バレンタイン クレメン) /// Placeholder for real*16 version of Reduce Intrinsic 611cc3cc5edSjeanPerier struct ForcedReduceReal16Ref { 612f8fc883dSPeter Klausler static constexpr const char *name = 613f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceReal16Ref)); 6140babff96SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 6150babff96SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 616f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 6170babff96SValentin Clement (バレンタイン クレメン) auto boxTy = 6180babff96SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 61938fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 62038fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 6210babff96SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 6220babff96SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 62338fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 62438fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 62538fd0181SValentin Clement (バレンタイン クレメン) ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 62638fd0181SValentin Clement (バレンタイン クレメン) }; 62738fd0181SValentin Clement (バレンタイン クレメン) } 62838fd0181SValentin Clement (バレンタイン クレメン) }; 62938fd0181SValentin Clement (バレンタイン クレメン) 63038fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for real*16 version of Reduce Intrinsic 63138fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceReal16Value { 63238fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 63338fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(ReduceReal16Value)); 63438fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 63538fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 636f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 63738fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 63838fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 6390babff96SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 64038fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 64138fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 64238fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 6430babff96SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 6440babff96SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 6450babff96SValentin Clement (バレンタイン クレメン) ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 6460babff96SValentin Clement (バレンタイン クレメン) }; 6470babff96SValentin Clement (バレンタイン クレメン) } 6480babff96SValentin Clement (バレンタイン クレメン) }; 6490babff96SValentin Clement (バレンタイン クレメン) 6506ffdcfa7SValentin Clement (バレンタイン クレメン) /// Placeholder for DIM real*10 version of Reduce Intrinsic 651cc3cc5edSjeanPerier struct ForcedReduceReal10DimRef { 6526ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 653f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceReal10DimRef)); 6546ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 6556ffdcfa7SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 656f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 6576ffdcfa7SValentin Clement (バレンタイン クレメン) auto boxTy = 6586ffdcfa7SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 65938fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 66038fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 6616ffdcfa7SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 6626ffdcfa7SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 66338fd0181SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 66438fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 66538fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 66638fd0181SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 66738fd0181SValentin Clement (バレンタイン クレメン) {}); 66838fd0181SValentin Clement (バレンタイン クレメン) }; 66938fd0181SValentin Clement (バレンタイン クレメン) } 67038fd0181SValentin Clement (バレンタイン クレメン) }; 67138fd0181SValentin Clement (バレンタイン クレメン) 67238fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for DIM real*10 with value version of Reduce Intrinsic 67338fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceReal10DimValue { 67438fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 67538fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(ReduceReal10DimValue)); 67638fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 67738fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 678f023da12SMatthias Springer auto ty = mlir::Float80Type::get(ctx); 67938fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 68038fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 6816ffdcfa7SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 68238fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 68338fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 68438fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 6856ffdcfa7SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 6866ffdcfa7SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 6876ffdcfa7SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 6886ffdcfa7SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 6896ffdcfa7SValentin Clement (バレンタイン クレメン) {}); 6906ffdcfa7SValentin Clement (バレンタイン クレメン) }; 6916ffdcfa7SValentin Clement (バレンタイン クレメン) } 6926ffdcfa7SValentin Clement (バレンタイン クレメン) }; 6936ffdcfa7SValentin Clement (バレンタイン クレメン) 6946ffdcfa7SValentin Clement (バレンタイン クレメン) /// Placeholder for DIM real*16 version of Reduce Intrinsic 695cc3cc5edSjeanPerier struct ForcedReduceReal16DimRef { 6966ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 697f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceReal16DimRef)); 6986ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 6996ffdcfa7SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 700f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 7016ffdcfa7SValentin Clement (バレンタイン クレメン) auto boxTy = 7026ffdcfa7SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 70338fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 70438fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 7056ffdcfa7SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 7066ffdcfa7SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 70738fd0181SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 70838fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 70938fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 71038fd0181SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 71138fd0181SValentin Clement (バレンタイン クレメン) {}); 71238fd0181SValentin Clement (バレンタイン クレメン) }; 71338fd0181SValentin Clement (バレンタイン クレメン) } 71438fd0181SValentin Clement (バレンタイン クレメン) }; 71538fd0181SValentin Clement (バレンタイン クレメン) 71638fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for DIM real*16 with value version of Reduce Intrinsic 71738fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceReal16DimValue { 71838fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 71938fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(ReduceReal16DimValue)); 72038fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 72138fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 722f023da12SMatthias Springer auto ty = mlir::Float128Type::get(ctx); 72338fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 72438fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 7256ffdcfa7SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 72638fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 72738fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 72838fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 7296ffdcfa7SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 7306ffdcfa7SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 7316ffdcfa7SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 7326ffdcfa7SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 7336ffdcfa7SValentin Clement (バレンタイン クレメン) {}); 7346ffdcfa7SValentin Clement (バレンタイン クレメン) }; 7356ffdcfa7SValentin Clement (バレンタイン クレメン) } 7366ffdcfa7SValentin Clement (バレンタイン クレメン) }; 7376ffdcfa7SValentin Clement (バレンタイン クレメン) 7380babff96SValentin Clement (バレンタイン クレメン) /// Placeholder for integer*16 version of Reduce Intrinsic 739cc3cc5edSjeanPerier struct ForcedReduceInteger16Ref { 7400babff96SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 741f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceInteger16Ref)); 7420babff96SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 7430babff96SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 7440babff96SValentin Clement (バレンタイン クレメン) auto ty = mlir::IntegerType::get(ctx, 128); 7450babff96SValentin Clement (バレンタイン クレメン) auto boxTy = 7460babff96SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 74738fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 74838fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 7490babff96SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 7500babff96SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 75138fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 75238fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 75338fd0181SValentin Clement (バレンタイン クレメン) ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 75438fd0181SValentin Clement (バレンタイン クレメン) }; 75538fd0181SValentin Clement (バレンタイン クレメン) } 75638fd0181SValentin Clement (バレンタイン クレメン) }; 75738fd0181SValentin Clement (バレンタイン クレメン) 758fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 version of Reduce Intrinsic 759fc97d2e6SPeter Klausler struct ForcedReduceUnsigned16Ref { 760fc97d2e6SPeter Klausler static constexpr const char *name = 761fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceUnsigned16Ref)); 762fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 763fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 764fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get(ctx, 128); 765fc97d2e6SPeter Klausler auto boxTy = 766fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 767fc97d2e6SPeter Klausler auto refTy = fir::ReferenceType::get(ty); 768fc97d2e6SPeter Klausler auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 769fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 770fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 771fc97d2e6SPeter Klausler auto i1Ty = mlir::IntegerType::get(ctx, 1); 772fc97d2e6SPeter Klausler return mlir::FunctionType::get( 773fc97d2e6SPeter Klausler ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 774fc97d2e6SPeter Klausler }; 775fc97d2e6SPeter Klausler } 776fc97d2e6SPeter Klausler }; 777fc97d2e6SPeter Klausler 77838fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for integer*16 with value version of Reduce Intrinsic 77938fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceInteger16Value { 78038fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 78138fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(ReduceInteger16Value)); 78238fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 78338fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 78438fd0181SValentin Clement (バレンタイン クレメン) auto ty = mlir::IntegerType::get(ctx, 128); 78538fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 78638fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 7870babff96SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 78838fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 78938fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 79038fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 7910babff96SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 7920babff96SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 7930babff96SValentin Clement (バレンタイン クレメン) ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 7940babff96SValentin Clement (バレンタイン クレメン) }; 7950babff96SValentin Clement (バレンタイン クレメン) } 7960babff96SValentin Clement (バレンタイン クレメン) }; 7970babff96SValentin Clement (バレンタイン クレメン) 798fc97d2e6SPeter Klausler /// Placeholder for unsigned*16 with value version of Reduce Intrinsic 799fc97d2e6SPeter Klausler struct ForcedReduceUnsigned16Value { 800fc97d2e6SPeter Klausler static constexpr const char *name = 801fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceUnsigned16Value)); 802fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 803fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 804fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get(ctx, 128); 805fc97d2e6SPeter Klausler auto boxTy = 806fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 807fc97d2e6SPeter Klausler auto refTy = fir::ReferenceType::get(ty); 808fc97d2e6SPeter Klausler auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 809fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 810fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 811fc97d2e6SPeter Klausler auto i1Ty = mlir::IntegerType::get(ctx, 1); 812fc97d2e6SPeter Klausler return mlir::FunctionType::get( 813fc97d2e6SPeter Klausler ctx, {boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, {ty}); 814fc97d2e6SPeter Klausler }; 815fc97d2e6SPeter Klausler } 816fc97d2e6SPeter Klausler }; 817fc97d2e6SPeter Klausler 8186ffdcfa7SValentin Clement (バレンタイン クレメン) /// Placeholder for DIM integer*16 version of Reduce Intrinsic 819cc3cc5edSjeanPerier struct ForcedReduceInteger16DimRef { 8206ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 821f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceInteger16DimRef)); 8226ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 8236ffdcfa7SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 8246ffdcfa7SValentin Clement (バレンタイン クレメン) auto ty = mlir::IntegerType::get(ctx, 128); 8256ffdcfa7SValentin Clement (バレンタイン クレメン) auto boxTy = 8266ffdcfa7SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 82738fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 82838fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 8296ffdcfa7SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 8306ffdcfa7SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 83138fd0181SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 83238fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 83338fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 83438fd0181SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 83538fd0181SValentin Clement (バレンタイン クレメン) {}); 83638fd0181SValentin Clement (バレンタイン クレメン) }; 83738fd0181SValentin Clement (バレンタイン クレメン) } 83838fd0181SValentin Clement (バレンタイン クレメン) }; 83938fd0181SValentin Clement (バレンタイン クレメン) 840fc97d2e6SPeter Klausler /// Placeholder for DIM unsigned*16 version of Reduce Intrinsic 841fc97d2e6SPeter Klausler struct ForcedReduceUnsigned16DimRef { 842fc97d2e6SPeter Klausler static constexpr const char *name = 843fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceUnsigned16DimRef)); 844fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 845fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 846fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 847fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 848fc97d2e6SPeter Klausler auto boxTy = 849fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 850fc97d2e6SPeter Klausler auto refTy = fir::ReferenceType::get(ty); 851fc97d2e6SPeter Klausler auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 852fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 853fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 854fc97d2e6SPeter Klausler auto refBoxTy = fir::ReferenceType::get(boxTy); 855fc97d2e6SPeter Klausler auto i1Ty = mlir::IntegerType::get(ctx, 1); 856fc97d2e6SPeter Klausler return mlir::FunctionType::get( 857fc97d2e6SPeter Klausler ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 858fc97d2e6SPeter Klausler {}); 859fc97d2e6SPeter Klausler }; 860fc97d2e6SPeter Klausler } 861fc97d2e6SPeter Klausler }; 862fc97d2e6SPeter Klausler 86338fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for DIM integer*16 with value version of Reduce Intrinsic 86438fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceInteger16DimValue { 86538fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 86638fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(ReduceInteger16DimValue)); 86738fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 86838fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 86938fd0181SValentin Clement (バレンタイン クレメン) auto ty = mlir::IntegerType::get(ctx, 128); 87038fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 87138fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 8726ffdcfa7SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 87338fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 87438fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 87538fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 8766ffdcfa7SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 8776ffdcfa7SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 8786ffdcfa7SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 8796ffdcfa7SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 8806ffdcfa7SValentin Clement (バレンタイン クレメン) {}); 8816ffdcfa7SValentin Clement (バレンタイン クレメン) }; 8826ffdcfa7SValentin Clement (バレンタイン クレメン) } 8836ffdcfa7SValentin Clement (バレンタイン クレメン) }; 8846ffdcfa7SValentin Clement (バレンタイン クレメン) 885fc97d2e6SPeter Klausler /// Placeholder for DIM unsigned*16 with value version of Reduce Intrinsic 886fc97d2e6SPeter Klausler struct ForcedReduceUnsigned16DimValue { 887fc97d2e6SPeter Klausler static constexpr const char *name = 888fc97d2e6SPeter Klausler ExpandAndQuoteKey(RTNAME(ReduceUnsigned16DimValue)); 889fc97d2e6SPeter Klausler static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 890fc97d2e6SPeter Klausler return [](mlir::MLIRContext *ctx) { 891fc97d2e6SPeter Klausler auto ty = mlir::IntegerType::get( 892fc97d2e6SPeter Klausler ctx, 128, mlir::IntegerType::SignednessSemantics::Unsigned); 893fc97d2e6SPeter Klausler auto boxTy = 894fc97d2e6SPeter Klausler fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 895fc97d2e6SPeter Klausler auto refTy = fir::ReferenceType::get(ty); 896fc97d2e6SPeter Klausler auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 897fc97d2e6SPeter Klausler auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 898fc97d2e6SPeter Klausler auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 899fc97d2e6SPeter Klausler auto refBoxTy = fir::ReferenceType::get(boxTy); 900fc97d2e6SPeter Klausler auto i1Ty = mlir::IntegerType::get(ctx, 1); 901fc97d2e6SPeter Klausler return mlir::FunctionType::get( 902fc97d2e6SPeter Klausler ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 903fc97d2e6SPeter Klausler {}); 904fc97d2e6SPeter Klausler }; 905fc97d2e6SPeter Klausler } 906fc97d2e6SPeter Klausler }; 907fc97d2e6SPeter Klausler 9080babff96SValentin Clement (バレンタイン クレメン) /// Placeholder for complex(10) version of Reduce Intrinsic 909cc3cc5edSjeanPerier struct ForcedReduceComplex10Ref { 9100babff96SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 911f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(CppReduceComplex10Ref)); 9120babff96SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 9130babff96SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 914f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 9150babff96SValentin Clement (バレンタイン クレメン) auto boxTy = 9160babff96SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 91738fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 91838fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 9190babff96SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 9200babff96SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 92138fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 92238fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 92338fd0181SValentin Clement (バレンタイン クレメン) ctx, {refTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 92438fd0181SValentin Clement (バレンタイン クレメン) {}); 92538fd0181SValentin Clement (バレンタイン クレメン) }; 92638fd0181SValentin Clement (バレンタイン クレメン) } 92738fd0181SValentin Clement (バレンタイン クレメン) }; 92838fd0181SValentin Clement (バレンタイン クレメン) 92938fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for complex(10) with value version of Reduce Intrinsic 93038fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceComplex10Value { 93138fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 93238fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(CppReduceComplex10Value)); 93338fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 93438fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 935f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 93638fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 93738fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 9380babff96SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 93938fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 94038fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 94138fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 9420babff96SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 9430babff96SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 9440babff96SValentin Clement (バレンタイン クレメン) ctx, {refTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 9450babff96SValentin Clement (バレンタイン クレメン) {}); 9460babff96SValentin Clement (バレンタイン クレメン) }; 9470babff96SValentin Clement (バレンタイン クレメン) } 9480babff96SValentin Clement (バレンタイン クレメン) }; 9490babff96SValentin Clement (バレンタイン クレメン) 9506ffdcfa7SValentin Clement (バレンタイン クレメン) /// Placeholder for Dim complex(10) version of Reduce Intrinsic 951cc3cc5edSjeanPerier struct ForcedReduceComplex10DimRef { 9526ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 953f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(CppReduceComplex10DimRef)); 9546ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 9556ffdcfa7SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 956f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 9576ffdcfa7SValentin Clement (バレンタイン クレメン) auto boxTy = 9586ffdcfa7SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 95938fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 96038fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 9616ffdcfa7SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 9626ffdcfa7SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 96338fd0181SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 96438fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 96538fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 96638fd0181SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 96738fd0181SValentin Clement (バレンタイン クレメン) {}); 96838fd0181SValentin Clement (バレンタイン クレメン) }; 96938fd0181SValentin Clement (バレンタイン クレメン) } 97038fd0181SValentin Clement (バレンタイン クレメン) }; 97138fd0181SValentin Clement (バレンタイン クレメン) 97238fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for Dim complex(10) with value version of Reduce Intrinsic 97338fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceComplex10DimValue { 97438fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 97538fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(CppReduceComplex10DimValue)); 97638fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 97738fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 978f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float80Type::get(ctx)); 97938fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 98038fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 9816ffdcfa7SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 98238fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 98338fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 98438fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 9856ffdcfa7SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 9866ffdcfa7SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 9876ffdcfa7SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 9886ffdcfa7SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 9896ffdcfa7SValentin Clement (バレンタイン クレメン) {}); 9906ffdcfa7SValentin Clement (バレンタイン クレメン) }; 9916ffdcfa7SValentin Clement (バレンタイン クレメン) } 9926ffdcfa7SValentin Clement (バレンタイン クレメン) }; 9936ffdcfa7SValentin Clement (バレンタイン クレメン) 9940babff96SValentin Clement (バレンタイン クレメン) /// Placeholder for complex(16) version of Reduce Intrinsic 995cc3cc5edSjeanPerier struct ForcedReduceComplex16Ref { 9960babff96SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 997f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(CppReduceComplex16Ref)); 9980babff96SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 9990babff96SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 1000f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 10010babff96SValentin Clement (バレンタイン クレメン) auto boxTy = 10020babff96SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 100338fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 100438fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 10050babff96SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 10060babff96SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 100738fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 100838fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 100938fd0181SValentin Clement (バレンタイン クレメン) ctx, {refTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 101038fd0181SValentin Clement (バレンタイン クレメン) {}); 101138fd0181SValentin Clement (バレンタイン クレメン) }; 101238fd0181SValentin Clement (バレンタイン クレメン) } 101338fd0181SValentin Clement (バレンタイン クレメン) }; 101438fd0181SValentin Clement (バレンタイン クレメン) 101538fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for complex(16) with value version of Reduce Intrinsic 101638fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceComplex16Value { 101738fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 101838fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(CppReduceComplex16Value)); 101938fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 102038fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 1021f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 102238fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 102338fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 10240babff96SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 102538fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 102638fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 102738fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 10280babff96SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 10290babff96SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 10300babff96SValentin Clement (バレンタイン クレメン) ctx, {refTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 10310babff96SValentin Clement (バレンタイン クレメン) {}); 10320babff96SValentin Clement (バレンタイン クレメン) }; 10330babff96SValentin Clement (バレンタイン クレメン) } 10340babff96SValentin Clement (バレンタイン クレメン) }; 10350babff96SValentin Clement (バレンタイン クレメン) 10366ffdcfa7SValentin Clement (バレンタイン クレメン) /// Placeholder for Dim complex(16) version of Reduce Intrinsic 1037cc3cc5edSjeanPerier struct ForcedReduceComplex16DimRef { 10386ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 1039f8fc883dSPeter Klausler ExpandAndQuoteKey(RTNAME(CppReduceComplex16DimRef)); 10406ffdcfa7SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 10416ffdcfa7SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 1042f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 10436ffdcfa7SValentin Clement (バレンタイン クレメン) auto boxTy = 10446ffdcfa7SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 104538fd0181SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 104638fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {refTy, refTy}, refTy); 10476ffdcfa7SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 10486ffdcfa7SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 104938fd0181SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 105038fd0181SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 105138fd0181SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 105238fd0181SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 105338fd0181SValentin Clement (バレンタイン クレメン) {}); 105438fd0181SValentin Clement (バレンタイン クレメン) }; 105538fd0181SValentin Clement (バレンタイン クレメン) } 105638fd0181SValentin Clement (バレンタイン クレメン) }; 105738fd0181SValentin Clement (バレンタイン クレメン) 105838fd0181SValentin Clement (バレンタイン クレメン) /// Placeholder for Dim complex(16) with value version of Reduce Intrinsic 105938fd0181SValentin Clement (バレンタイン クレメン) struct ForcedReduceComplex16DimValue { 106038fd0181SValentin Clement (バレンタイン クレメン) static constexpr const char *name = 106138fd0181SValentin Clement (バレンタイン クレメン) ExpandAndQuoteKey(RTNAME(CppReduceComplex16DimValue)); 106238fd0181SValentin Clement (バレンタイン クレメン) static constexpr fir::runtime::FuncTypeBuilderFunc getTypeModel() { 106338fd0181SValentin Clement (バレンタイン クレメン) return [](mlir::MLIRContext *ctx) { 1064f023da12SMatthias Springer auto ty = mlir::ComplexType::get(mlir::Float128Type::get(ctx)); 106538fd0181SValentin Clement (バレンタイン クレメン) auto boxTy = 106638fd0181SValentin Clement (バレンタイン クレメン) fir::runtime::getModel<const Fortran::runtime::Descriptor &>()(ctx); 10676ffdcfa7SValentin Clement (バレンタイン クレメン) auto refTy = fir::ReferenceType::get(ty); 106838fd0181SValentin Clement (バレンタイン クレメン) auto opTy = mlir::FunctionType::get(ctx, {ty, ty}, refTy); 106938fd0181SValentin Clement (バレンタイン クレメン) auto strTy = fir::ReferenceType::get(mlir::IntegerType::get(ctx, 8)); 107038fd0181SValentin Clement (バレンタイン クレメン) auto intTy = mlir::IntegerType::get(ctx, 8 * sizeof(int)); 10716ffdcfa7SValentin Clement (バレンタイン クレメン) auto refBoxTy = fir::ReferenceType::get(boxTy); 10726ffdcfa7SValentin Clement (バレンタイン クレメン) auto i1Ty = mlir::IntegerType::get(ctx, 1); 10736ffdcfa7SValentin Clement (バレンタイン クレメン) return mlir::FunctionType::get( 10746ffdcfa7SValentin Clement (バレンタイン クレメン) ctx, {refBoxTy, boxTy, opTy, strTy, intTy, intTy, boxTy, refTy, i1Ty}, 10756ffdcfa7SValentin Clement (バレンタイン クレメン) {}); 10766ffdcfa7SValentin Clement (バレンタイン クレメン) }; 10776ffdcfa7SValentin Clement (バレンタイン クレメン) } 10786ffdcfa7SValentin Clement (バレンタイン クレメン) }; 10796ffdcfa7SValentin Clement (バレンタイン クレメン) 1080cc3cc5edSjeanPerier #define INTRINSIC_INSTANCE(NAME, CAT, KIND, SUFFIX) \ 1081cc3cc5edSjeanPerier if (!func && cat == TypeCategory::CAT && kind == KIND) { \ 1082cc3cc5edSjeanPerier func = fir::runtime::getRuntimeFunc<mkRTKey(NAME##CAT##KIND##SUFFIX)>( \ 1083cc3cc5edSjeanPerier loc, builder); \ 1084cc3cc5edSjeanPerier } 1085cc3cc5edSjeanPerier #define FORCED_INTRINSIC_INSTANCE(NAME, CAT, KIND, SUFFIX) \ 1086cc3cc5edSjeanPerier if (!func && cat == TypeCategory::CAT && kind == KIND) { \ 1087cc3cc5edSjeanPerier func = fir::runtime::getRuntimeFunc<Forced##NAME##CAT##KIND##SUFFIX>( \ 1088cc3cc5edSjeanPerier loc, builder); \ 1089cc3cc5edSjeanPerier } 1090cc3cc5edSjeanPerier 1091cc3cc5edSjeanPerier #define INTEGER_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1092cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Integer, 1, SUFFIX) \ 1093cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Integer, 2, SUFFIX) \ 1094cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Integer, 4, SUFFIX) \ 1095cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Integer, 8, SUFFIX) \ 1096cc3cc5edSjeanPerier FORCED_INTRINSIC_INSTANCE(NAME, Integer, 16, SUFFIX) 1097cc3cc5edSjeanPerier 1098fc97d2e6SPeter Klausler #define UNSIGNED_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1099fc97d2e6SPeter Klausler INTRINSIC_INSTANCE(NAME, Unsigned, 1, SUFFIX) \ 1100fc97d2e6SPeter Klausler INTRINSIC_INSTANCE(NAME, Unsigned, 2, SUFFIX) \ 1101fc97d2e6SPeter Klausler INTRINSIC_INSTANCE(NAME, Unsigned, 4, SUFFIX) \ 1102fc97d2e6SPeter Klausler INTRINSIC_INSTANCE(NAME, Unsigned, 8, SUFFIX) \ 1103fc97d2e6SPeter Klausler FORCED_INTRINSIC_INSTANCE(NAME, Unsigned, 16, SUFFIX) 1104fc97d2e6SPeter Klausler 1105cc3cc5edSjeanPerier #define REAL_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1106cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Real, 4, SUFFIX) \ 1107cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Real, 8, SUFFIX) \ 1108cc3cc5edSjeanPerier FORCED_INTRINSIC_INSTANCE(NAME, Real, 10, SUFFIX) \ 1109cc3cc5edSjeanPerier FORCED_INTRINSIC_INSTANCE(NAME, Real, 16, SUFFIX) 1110cc3cc5edSjeanPerier 1111cc3cc5edSjeanPerier #define COMPLEX_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1112cc3cc5edSjeanPerier INTRINSIC_INSTANCE(Cpp##NAME, Complex, 4, SUFFIX) \ 1113cc3cc5edSjeanPerier INTRINSIC_INSTANCE(Cpp##NAME, Complex, 8, SUFFIX) \ 1114cc3cc5edSjeanPerier FORCED_INTRINSIC_INSTANCE(NAME, Complex, 10, SUFFIX) \ 1115cc3cc5edSjeanPerier FORCED_INTRINSIC_INSTANCE(NAME, Complex, 16, SUFFIX) 1116cc3cc5edSjeanPerier 1117cc3cc5edSjeanPerier #define NUMERICAL_INTRINSIC_INSTANCES(NAME) \ 1118cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(NAME, ) \ 1119fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(NAME, ) \ 1120cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(NAME, ) \ 1121cc3cc5edSjeanPerier COMPLEX_INTRINSIC_INSTANCES(NAME, ) 1122cc3cc5edSjeanPerier 1123cc3cc5edSjeanPerier #define LOGICAL_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1124cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Logical, 1, SUFFIX) \ 1125cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Logical, 2, SUFFIX) \ 1126cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Logical, 4, SUFFIX) \ 1127cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Logical, 8, SUFFIX) 1128cc3cc5edSjeanPerier 1129cc3cc5edSjeanPerier #define NUMERICAL_AND_LOGICAL_INSTANCES(NAME, SUFFIX) \ 1130cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1131fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1132cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1133cc3cc5edSjeanPerier COMPLEX_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1134cc3cc5edSjeanPerier LOGICAL_INTRINSIC_INSTANCES(NAME, SUFFIX) 1135cc3cc5edSjeanPerier 1136cc3cc5edSjeanPerier // REAL/COMPLEX 2 and 3 usually have no runtime implementation, so they have 1137cc3cc5edSjeanPerier // special macros. 1138cc3cc5edSjeanPerier #define REAL_2_3_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1139cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Real, 2, SUFFIX) \ 1140cc3cc5edSjeanPerier INTRINSIC_INSTANCE(NAME, Real, 3, SUFFIX) 1141cc3cc5edSjeanPerier 1142cc3cc5edSjeanPerier #define COMPLEX_2_3_INTRINSIC_INSTANCES(NAME, SUFFIX) \ 1143cc3cc5edSjeanPerier INTRINSIC_INSTANCE(Cpp##NAME, Complex, 2, SUFFIX) \ 1144cc3cc5edSjeanPerier INTRINSIC_INSTANCE(Cpp##NAME, Complex, 3, SUFFIX) 1145cc3cc5edSjeanPerier 1146f6ae8e8cSValentin Clement /// Generate call to specialized runtime function that takes a mask and 1147f6ae8e8cSValentin Clement /// dim argument. The All, Any, and Count intrinsics use this pattern. 1148f6ae8e8cSValentin Clement template <typename FN> 1149f6ae8e8cSValentin Clement mlir::Value genSpecial2Args(FN func, fir::FirOpBuilder &builder, 1150f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value maskBox, 1151f6ae8e8cSValentin Clement mlir::Value dim) { 11524a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1153f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1154f6ae8e8cSValentin Clement auto sourceLine = 1155f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); 1156f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments(builder, loc, fTy, maskBox, 1157f6ae8e8cSValentin Clement sourceFile, sourceLine, dim); 1158f6ae8e8cSValentin Clement return builder.create<fir::CallOp>(loc, func, args).getResult(0); 1159f6ae8e8cSValentin Clement } 1160f6ae8e8cSValentin Clement 1161f6ae8e8cSValentin Clement /// Generate calls to reduction intrinsics such as All and Any. 1162f6ae8e8cSValentin Clement /// These are the descriptor based implementations that take two 1163f6ae8e8cSValentin Clement /// arguments (mask, dim). 1164f6ae8e8cSValentin Clement template <typename FN> 1165f6ae8e8cSValentin Clement static void genReduction2Args(FN func, fir::FirOpBuilder &builder, 1166f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value resultBox, 1167f6ae8e8cSValentin Clement mlir::Value maskBox, mlir::Value dim) { 11684a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1169f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1170f6ae8e8cSValentin Clement auto sourceLine = 1171f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 1172f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1173f6ae8e8cSValentin Clement builder, loc, fTy, resultBox, maskBox, dim, sourceFile, sourceLine); 1174f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1175f6ae8e8cSValentin Clement } 1176f6ae8e8cSValentin Clement 1177f6ae8e8cSValentin Clement /// Generate calls to reduction intrinsics such as Maxval and Minval. 1178f6ae8e8cSValentin Clement /// These take arguments such as (array, dim, mask). 1179f6ae8e8cSValentin Clement template <typename FN> 1180f6ae8e8cSValentin Clement static void genReduction3Args(FN func, fir::FirOpBuilder &builder, 1181f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value resultBox, 1182f6ae8e8cSValentin Clement mlir::Value arrayBox, mlir::Value dim, 1183f6ae8e8cSValentin Clement mlir::Value maskBox) { 1184f6ae8e8cSValentin Clement 11854a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1186f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1187f6ae8e8cSValentin Clement auto sourceLine = 1188f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 1189f6ae8e8cSValentin Clement auto args = 1190f6ae8e8cSValentin Clement fir::runtime::createArguments(builder, loc, fTy, resultBox, arrayBox, dim, 1191f6ae8e8cSValentin Clement sourceFile, sourceLine, maskBox); 1192f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1193f6ae8e8cSValentin Clement } 1194f6ae8e8cSValentin Clement 1195f6ae8e8cSValentin Clement /// Generate calls to reduction intrinsics such as Maxloc and Minloc. 1196f6ae8e8cSValentin Clement /// These take arguments such as (array, mask, kind, back). 1197f6ae8e8cSValentin Clement template <typename FN> 1198f6ae8e8cSValentin Clement static void genReduction4Args(FN func, fir::FirOpBuilder &builder, 1199f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value resultBox, 1200f6ae8e8cSValentin Clement mlir::Value arrayBox, mlir::Value maskBox, 1201f6ae8e8cSValentin Clement mlir::Value kind, mlir::Value back) { 12024a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1203f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1204f6ae8e8cSValentin Clement auto sourceLine = 1205f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 1206f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments(builder, loc, fTy, resultBox, 1207f6ae8e8cSValentin Clement arrayBox, kind, sourceFile, 1208f6ae8e8cSValentin Clement sourceLine, maskBox, back); 1209f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1210f6ae8e8cSValentin Clement } 1211f6ae8e8cSValentin Clement 1212f6ae8e8cSValentin Clement /// Generate calls to reduction intrinsics such as Maxloc and Minloc. 1213f6ae8e8cSValentin Clement /// These take arguments such as (array, dim, mask, kind, back). 1214f6ae8e8cSValentin Clement template <typename FN> 1215f6ae8e8cSValentin Clement static void 1216f6ae8e8cSValentin Clement genReduction5Args(FN func, fir::FirOpBuilder &builder, mlir::Location loc, 1217f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, mlir::Value dim, 1218f6ae8e8cSValentin Clement mlir::Value maskBox, mlir::Value kind, mlir::Value back) { 12194a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1220f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1221f6ae8e8cSValentin Clement auto sourceLine = 1222f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); 1223f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments(builder, loc, fTy, resultBox, 1224f6ae8e8cSValentin Clement arrayBox, kind, dim, sourceFile, 1225f6ae8e8cSValentin Clement sourceLine, maskBox, back); 1226f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1227f6ae8e8cSValentin Clement } 1228f6ae8e8cSValentin Clement 122970638d99SValentin Clement /// Generate call to `AllDim` runtime routine. 1230f6ae8e8cSValentin Clement /// This calls the descriptor based runtime call implementation of the `all` 1231f6ae8e8cSValentin Clement /// intrinsic. 1232f6ae8e8cSValentin Clement void fir::runtime::genAllDescriptor(fir::FirOpBuilder &builder, 1233f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value resultBox, 1234f6ae8e8cSValentin Clement mlir::Value maskBox, mlir::Value dim) { 1235f6ae8e8cSValentin Clement auto allFunc = fir::runtime::getRuntimeFunc<mkRTKey(AllDim)>(loc, builder); 1236f6ae8e8cSValentin Clement genReduction2Args(allFunc, builder, loc, resultBox, maskBox, dim); 1237f6ae8e8cSValentin Clement } 1238f6ae8e8cSValentin Clement 123970638d99SValentin Clement /// Generate call to `AnyDim` runtime routine. 1240f6ae8e8cSValentin Clement /// This calls the descriptor based runtime call implementation of the `any` 1241f6ae8e8cSValentin Clement /// intrinsic. 1242f6ae8e8cSValentin Clement void fir::runtime::genAnyDescriptor(fir::FirOpBuilder &builder, 1243f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value resultBox, 1244f6ae8e8cSValentin Clement mlir::Value maskBox, mlir::Value dim) { 1245f6ae8e8cSValentin Clement auto anyFunc = fir::runtime::getRuntimeFunc<mkRTKey(AnyDim)>(loc, builder); 1246f6ae8e8cSValentin Clement genReduction2Args(anyFunc, builder, loc, resultBox, maskBox, dim); 1247f6ae8e8cSValentin Clement } 1248f6ae8e8cSValentin Clement 12495259528fSTarun Prabhu /// Generate call to `ParityDim` runtime routine. 12505259528fSTarun Prabhu /// This calls the descriptor based runtime call implementation of the `parity` 12515259528fSTarun Prabhu /// intrinsic. 12525259528fSTarun Prabhu void fir::runtime::genParityDescriptor(fir::FirOpBuilder &builder, 12535259528fSTarun Prabhu mlir::Location loc, 12545259528fSTarun Prabhu mlir::Value resultBox, 12555259528fSTarun Prabhu mlir::Value maskBox, mlir::Value dim) { 12565259528fSTarun Prabhu auto parityFunc = 12575259528fSTarun Prabhu fir::runtime::getRuntimeFunc<mkRTKey(ParityDim)>(loc, builder); 12585259528fSTarun Prabhu genReduction2Args(parityFunc, builder, loc, resultBox, maskBox, dim); 12595259528fSTarun Prabhu } 12605259528fSTarun Prabhu 126170638d99SValentin Clement /// Generate call to `All` intrinsic runtime routine. This routine is 1262f6ae8e8cSValentin Clement /// specialized for mask arguments with rank == 1. 1263f6ae8e8cSValentin Clement mlir::Value fir::runtime::genAll(fir::FirOpBuilder &builder, mlir::Location loc, 1264f6ae8e8cSValentin Clement mlir::Value maskBox, mlir::Value dim) { 1265f6ae8e8cSValentin Clement auto allFunc = fir::runtime::getRuntimeFunc<mkRTKey(All)>(loc, builder); 1266f6ae8e8cSValentin Clement return genSpecial2Args(allFunc, builder, loc, maskBox, dim); 1267f6ae8e8cSValentin Clement } 1268f6ae8e8cSValentin Clement 126970638d99SValentin Clement /// Generate call to `Any` intrinsic runtime routine. This routine is 1270f6ae8e8cSValentin Clement /// specialized for mask arguments with rank == 1. 1271f6ae8e8cSValentin Clement mlir::Value fir::runtime::genAny(fir::FirOpBuilder &builder, mlir::Location loc, 1272f6ae8e8cSValentin Clement mlir::Value maskBox, mlir::Value dim) { 1273f6ae8e8cSValentin Clement auto anyFunc = fir::runtime::getRuntimeFunc<mkRTKey(Any)>(loc, builder); 1274f6ae8e8cSValentin Clement return genSpecial2Args(anyFunc, builder, loc, maskBox, dim); 1275f6ae8e8cSValentin Clement } 1276f6ae8e8cSValentin Clement 127770638d99SValentin Clement /// Generate call to `Count` runtime routine. This routine is a specialized 1278f6ae8e8cSValentin Clement /// version when mask is a rank one array or the dim argument is not 1279f6ae8e8cSValentin Clement /// specified by the user. 1280f6ae8e8cSValentin Clement mlir::Value fir::runtime::genCount(fir::FirOpBuilder &builder, 1281f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value maskBox, 1282f6ae8e8cSValentin Clement mlir::Value dim) { 1283f6ae8e8cSValentin Clement auto countFunc = fir::runtime::getRuntimeFunc<mkRTKey(Count)>(loc, builder); 1284f6ae8e8cSValentin Clement return genSpecial2Args(countFunc, builder, loc, maskBox, dim); 1285f6ae8e8cSValentin Clement } 1286f6ae8e8cSValentin Clement 128770638d99SValentin Clement /// Generate call to general `CountDim` runtime routine. This routine has a 1288f6ae8e8cSValentin Clement /// descriptor result. 1289f6ae8e8cSValentin Clement void fir::runtime::genCountDim(fir::FirOpBuilder &builder, mlir::Location loc, 1290f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value maskBox, 1291f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value kind) { 1292f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(CountDim)>(loc, builder); 12934a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1294f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1295f6ae8e8cSValentin Clement auto sourceLine = 1296f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); 1297f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1298f6ae8e8cSValentin Clement builder, loc, fTy, resultBox, maskBox, dim, kind, sourceFile, sourceLine); 1299f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1300f6ae8e8cSValentin Clement } 1301f6ae8e8cSValentin Clement 1302d43a2f09STarun Prabhu /// Generate call to `Findloc` intrinsic runtime routine. This is the version 1303d43a2f09STarun Prabhu /// that does not take a dim argument. 1304d43a2f09STarun Prabhu void fir::runtime::genFindloc(fir::FirOpBuilder &builder, mlir::Location loc, 1305d43a2f09STarun Prabhu mlir::Value resultBox, mlir::Value arrayBox, 1306d43a2f09STarun Prabhu mlir::Value valBox, mlir::Value maskBox, 1307d43a2f09STarun Prabhu mlir::Value kind, mlir::Value back) { 1308d43a2f09STarun Prabhu auto func = fir::runtime::getRuntimeFunc<mkRTKey(Findloc)>(loc, builder); 1309d43a2f09STarun Prabhu auto fTy = func.getFunctionType(); 1310d43a2f09STarun Prabhu auto sourceFile = fir::factory::locationToFilename(builder, loc); 1311d43a2f09STarun Prabhu auto sourceLine = 1312d43a2f09STarun Prabhu fir::factory::locationToLineNo(builder, loc, fTy.getInput(5)); 1313d43a2f09STarun Prabhu auto args = fir::runtime::createArguments(builder, loc, fTy, resultBox, 1314d43a2f09STarun Prabhu arrayBox, valBox, kind, sourceFile, 1315d43a2f09STarun Prabhu sourceLine, maskBox, back); 1316d43a2f09STarun Prabhu builder.create<fir::CallOp>(loc, func, args); 1317d43a2f09STarun Prabhu } 1318d43a2f09STarun Prabhu 1319d43a2f09STarun Prabhu /// Generate call to `FindlocDim` intrinsic runtime routine. This is the version 1320d43a2f09STarun Prabhu /// that takes a dim argument. 1321d43a2f09STarun Prabhu void fir::runtime::genFindlocDim(fir::FirOpBuilder &builder, mlir::Location loc, 1322d43a2f09STarun Prabhu mlir::Value resultBox, mlir::Value arrayBox, 1323d43a2f09STarun Prabhu mlir::Value valBox, mlir::Value dim, 1324d43a2f09STarun Prabhu mlir::Value maskBox, mlir::Value kind, 1325d43a2f09STarun Prabhu mlir::Value back) { 1326d43a2f09STarun Prabhu auto func = fir::runtime::getRuntimeFunc<mkRTKey(FindlocDim)>(loc, builder); 1327d43a2f09STarun Prabhu auto fTy = func.getFunctionType(); 1328d43a2f09STarun Prabhu auto sourceFile = fir::factory::locationToFilename(builder, loc); 1329d43a2f09STarun Prabhu auto sourceLine = 1330d43a2f09STarun Prabhu fir::factory::locationToLineNo(builder, loc, fTy.getInput(6)); 1331d43a2f09STarun Prabhu auto args = fir::runtime::createArguments( 1332d43a2f09STarun Prabhu builder, loc, fTy, resultBox, arrayBox, valBox, kind, dim, sourceFile, 1333d43a2f09STarun Prabhu sourceLine, maskBox, back); 1334d43a2f09STarun Prabhu builder.create<fir::CallOp>(loc, func, args); 1335d43a2f09STarun Prabhu } 1336d43a2f09STarun Prabhu 133770638d99SValentin Clement /// Generate call to `Maxloc` intrinsic runtime routine. This is the version 1338f6ae8e8cSValentin Clement /// that does not take a dim argument. 1339f6ae8e8cSValentin Clement void fir::runtime::genMaxloc(fir::FirOpBuilder &builder, mlir::Location loc, 1340f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1341cc3cc5edSjeanPerier mlir::Value maskBox, mlir::Value kindVal, 1342f6ae8e8cSValentin Clement mlir::Value back) { 13439f6aae46SSlava Zakharin auto ty = arrayBox.getType(); 13449f6aae46SSlava Zakharin auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1345e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 13469f6aae46SSlava Zakharin fir::factory::CharacterExprHelper charHelper{builder, loc}; 1347cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1348cc3cc5edSjeanPerier mlir::func::FuncOp func; 1349cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(Maxloc, ) 1350cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(Maxloc, ) 1351fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(Maxloc, ) 1352cc3cc5edSjeanPerier if (charHelper.isCharacterScalar(eleTy)) 13539f6aae46SSlava Zakharin func = fir::runtime::getRuntimeFunc<mkRTKey(MaxlocCharacter)>(loc, builder); 1354cc3cc5edSjeanPerier if (!func) 135504b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "MAXLOC"); 1356cc3cc5edSjeanPerier genReduction4Args(func, builder, loc, resultBox, arrayBox, maskBox, kindVal, 1357f6ae8e8cSValentin Clement back); 1358f6ae8e8cSValentin Clement } 1359f6ae8e8cSValentin Clement 136070638d99SValentin Clement /// Generate call to `MaxlocDim` intrinsic runtime routine. This is the version 1361f6ae8e8cSValentin Clement /// that takes a dim argument. 1362f6ae8e8cSValentin Clement void fir::runtime::genMaxlocDim(fir::FirOpBuilder &builder, mlir::Location loc, 1363f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1364f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value maskBox, 1365f6ae8e8cSValentin Clement mlir::Value kind, mlir::Value back) { 1366f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(MaxlocDim)>(loc, builder); 1367f6ae8e8cSValentin Clement genReduction5Args(func, builder, loc, resultBox, arrayBox, dim, maskBox, kind, 1368f6ae8e8cSValentin Clement back); 1369f6ae8e8cSValentin Clement } 1370f6ae8e8cSValentin Clement 137170638d99SValentin Clement /// Generate call to `Maxval` intrinsic runtime routine. This is the version 1372f6ae8e8cSValentin Clement /// that does not take a dim argument. 1373f6ae8e8cSValentin Clement mlir::Value fir::runtime::genMaxval(fir::FirOpBuilder &builder, 1374f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value arrayBox, 1375f6ae8e8cSValentin Clement mlir::Value maskBox) { 1376f6ae8e8cSValentin Clement auto ty = arrayBox.getType(); 1377f6ae8e8cSValentin Clement auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1378e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1379f6ae8e8cSValentin Clement auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); 1380cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1381cc3cc5edSjeanPerier mlir::func::FuncOp func; 1382cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(Maxval, ) 1383cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(Maxval, ) 1384fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(Maxval, ) 1385cc3cc5edSjeanPerier if (!func) 138604b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "MAXVAL"); 1387f6ae8e8cSValentin Clement 13884a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1389f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1390f6ae8e8cSValentin Clement auto sourceLine = 1391f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); 1392f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1393f6ae8e8cSValentin Clement builder, loc, fTy, arrayBox, sourceFile, sourceLine, dim, maskBox); 1394f6ae8e8cSValentin Clement 1395f6ae8e8cSValentin Clement return builder.create<fir::CallOp>(loc, func, args).getResult(0); 1396f6ae8e8cSValentin Clement } 1397f6ae8e8cSValentin Clement 139870638d99SValentin Clement /// Generate call to `MaxvalDim` intrinsic runtime routine. This is the version 1399f6ae8e8cSValentin Clement /// that handles any rank array with the dim argument specified. 1400f6ae8e8cSValentin Clement void fir::runtime::genMaxvalDim(fir::FirOpBuilder &builder, mlir::Location loc, 1401f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1402f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value maskBox) { 1403f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(MaxvalDim)>(loc, builder); 1404f6ae8e8cSValentin Clement genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1405f6ae8e8cSValentin Clement } 1406f6ae8e8cSValentin Clement 140770638d99SValentin Clement /// Generate call to `MaxvalCharacter` intrinsic runtime routine. This is the 140870638d99SValentin Clement /// version that handles character arrays of rank 1 and without a DIM argument. 1409f6ae8e8cSValentin Clement void fir::runtime::genMaxvalChar(fir::FirOpBuilder &builder, mlir::Location loc, 1410f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1411f6ae8e8cSValentin Clement mlir::Value maskBox) { 1412f6ae8e8cSValentin Clement auto func = 1413f6ae8e8cSValentin Clement fir::runtime::getRuntimeFunc<mkRTKey(MaxvalCharacter)>(loc, builder); 14144a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1415f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1416f6ae8e8cSValentin Clement auto sourceLine = 1417f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); 1418f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1419f6ae8e8cSValentin Clement builder, loc, fTy, resultBox, arrayBox, sourceFile, sourceLine, maskBox); 1420f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1421f6ae8e8cSValentin Clement } 1422f6ae8e8cSValentin Clement 142370638d99SValentin Clement /// Generate call to `Minloc` intrinsic runtime routine. This is the version 1424f6ae8e8cSValentin Clement /// that does not take a dim argument. 1425f6ae8e8cSValentin Clement void fir::runtime::genMinloc(fir::FirOpBuilder &builder, mlir::Location loc, 1426f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1427cc3cc5edSjeanPerier mlir::Value maskBox, mlir::Value kindVal, 1428f6ae8e8cSValentin Clement mlir::Value back) { 14299f6aae46SSlava Zakharin auto ty = arrayBox.getType(); 14309f6aae46SSlava Zakharin auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1431e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1432cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1433cc3cc5edSjeanPerier mlir::func::FuncOp func; 1434cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(Minloc, ) 1435cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(Minloc, ) 1436fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(Minloc, ) 14379f6aae46SSlava Zakharin fir::factory::CharacterExprHelper charHelper{builder, loc}; 1438cc3cc5edSjeanPerier if (charHelper.isCharacterScalar(eleTy)) 14399f6aae46SSlava Zakharin func = fir::runtime::getRuntimeFunc<mkRTKey(MinlocCharacter)>(loc, builder); 1440cc3cc5edSjeanPerier if (!func) 144104b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "MINLOC"); 1442cc3cc5edSjeanPerier genReduction4Args(func, builder, loc, resultBox, arrayBox, maskBox, kindVal, 1443f6ae8e8cSValentin Clement back); 1444f6ae8e8cSValentin Clement } 1445f6ae8e8cSValentin Clement 144670638d99SValentin Clement /// Generate call to `MinlocDim` intrinsic runtime routine. This is the version 1447f6ae8e8cSValentin Clement /// that takes a dim argument. 1448f6ae8e8cSValentin Clement void fir::runtime::genMinlocDim(fir::FirOpBuilder &builder, mlir::Location loc, 1449f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1450f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value maskBox, 1451f6ae8e8cSValentin Clement mlir::Value kind, mlir::Value back) { 1452f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(MinlocDim)>(loc, builder); 1453f6ae8e8cSValentin Clement genReduction5Args(func, builder, loc, resultBox, arrayBox, dim, maskBox, kind, 1454f6ae8e8cSValentin Clement back); 1455f6ae8e8cSValentin Clement } 1456f6ae8e8cSValentin Clement 145770638d99SValentin Clement /// Generate call to `MinvalDim` intrinsic runtime routine. This is the version 1458f6ae8e8cSValentin Clement /// that handles any rank array with the dim argument specified. 1459f6ae8e8cSValentin Clement void fir::runtime::genMinvalDim(fir::FirOpBuilder &builder, mlir::Location loc, 1460f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1461f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value maskBox) { 1462f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(MinvalDim)>(loc, builder); 1463f6ae8e8cSValentin Clement genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1464f6ae8e8cSValentin Clement } 1465f6ae8e8cSValentin Clement 146670638d99SValentin Clement /// Generate call to `MinvalCharacter` intrinsic runtime routine. This is the 146770638d99SValentin Clement /// version that handles character arrays of rank 1 and without a DIM argument. 1468f6ae8e8cSValentin Clement void fir::runtime::genMinvalChar(fir::FirOpBuilder &builder, mlir::Location loc, 1469f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1470f6ae8e8cSValentin Clement mlir::Value maskBox) { 1471f6ae8e8cSValentin Clement auto func = 1472f6ae8e8cSValentin Clement fir::runtime::getRuntimeFunc<mkRTKey(MinvalCharacter)>(loc, builder); 14734a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1474f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1475f6ae8e8cSValentin Clement auto sourceLine = 1476f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); 1477f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1478f6ae8e8cSValentin Clement builder, loc, fTy, resultBox, arrayBox, sourceFile, sourceLine, maskBox); 1479f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1480f6ae8e8cSValentin Clement } 1481f6ae8e8cSValentin Clement 148270638d99SValentin Clement /// Generate call to `Minval` intrinsic runtime routine. This is the version 1483f6ae8e8cSValentin Clement /// that does not take a dim argument. 1484f6ae8e8cSValentin Clement mlir::Value fir::runtime::genMinval(fir::FirOpBuilder &builder, 1485f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value arrayBox, 1486f6ae8e8cSValentin Clement mlir::Value maskBox) { 1487f6ae8e8cSValentin Clement auto ty = arrayBox.getType(); 1488f6ae8e8cSValentin Clement auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1489e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1490f6ae8e8cSValentin Clement auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); 1491cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1492f6ae8e8cSValentin Clement 1493cc3cc5edSjeanPerier mlir::func::FuncOp func; 1494cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(Minval, ) 1495cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(Minval, ) 1496fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(Minval, ) 1497cc3cc5edSjeanPerier if (!func) 149804b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "MINVAL"); 1499f6ae8e8cSValentin Clement 15004a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1501f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1502f6ae8e8cSValentin Clement auto sourceLine = 1503f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); 1504f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1505f6ae8e8cSValentin Clement builder, loc, fTy, arrayBox, sourceFile, sourceLine, dim, maskBox); 1506f6ae8e8cSValentin Clement 1507f6ae8e8cSValentin Clement return builder.create<fir::CallOp>(loc, func, args).getResult(0); 1508f6ae8e8cSValentin Clement } 1509f6ae8e8cSValentin Clement 15107fe4abbbSTarun Prabhu /// Generate call to `Norm2Dim` intrinsic runtime routine. This is the version 15117fe4abbbSTarun Prabhu /// that takes a dim argument. 15127fe4abbbSTarun Prabhu void fir::runtime::genNorm2Dim(fir::FirOpBuilder &builder, mlir::Location loc, 15137fe4abbbSTarun Prabhu mlir::Value resultBox, mlir::Value arrayBox, 15147fe4abbbSTarun Prabhu mlir::Value dim) { 1515baf6725bSSlava Zakharin mlir::func::FuncOp func; 1516baf6725bSSlava Zakharin auto ty = arrayBox.getType(); 1517baf6725bSSlava Zakharin auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1518e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1519baf6725bSSlava Zakharin if (eleTy.isF128()) 1520baf6725bSSlava Zakharin func = fir::runtime::getRuntimeFunc<ForcedNorm2DimReal16>(loc, builder); 1521baf6725bSSlava Zakharin else 1522baf6725bSSlava Zakharin func = fir::runtime::getRuntimeFunc<mkRTKey(Norm2Dim)>(loc, builder); 15237fe4abbbSTarun Prabhu auto fTy = func.getFunctionType(); 15247fe4abbbSTarun Prabhu auto sourceFile = fir::factory::locationToFilename(builder, loc); 15257fe4abbbSTarun Prabhu auto sourceLine = 15267fe4abbbSTarun Prabhu fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 15277fe4abbbSTarun Prabhu auto args = fir::runtime::createArguments( 15287fe4abbbSTarun Prabhu builder, loc, fTy, resultBox, arrayBox, dim, sourceFile, sourceLine); 15297fe4abbbSTarun Prabhu 15307fe4abbbSTarun Prabhu builder.create<fir::CallOp>(loc, func, args); 15317fe4abbbSTarun Prabhu } 15327fe4abbbSTarun Prabhu 15337fe4abbbSTarun Prabhu /// Generate call to `Norm2` intrinsic runtime routine. This is the version 15347fe4abbbSTarun Prabhu /// that does not take a dim argument. 15357fe4abbbSTarun Prabhu mlir::Value fir::runtime::genNorm2(fir::FirOpBuilder &builder, 15367fe4abbbSTarun Prabhu mlir::Location loc, mlir::Value arrayBox) { 15377fe4abbbSTarun Prabhu mlir::func::FuncOp func; 15387fe4abbbSTarun Prabhu auto ty = arrayBox.getType(); 15397fe4abbbSTarun Prabhu auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1540e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 15417fe4abbbSTarun Prabhu auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); 15427fe4abbbSTarun Prabhu 154304b18530SPete Steinfeld if (eleTy.isF32()) 15447fe4abbbSTarun Prabhu func = fir::runtime::getRuntimeFunc<mkRTKey(Norm2_4)>(loc, builder); 15457fe4abbbSTarun Prabhu else if (eleTy.isF64()) 15467fe4abbbSTarun Prabhu func = fir::runtime::getRuntimeFunc<mkRTKey(Norm2_8)>(loc, builder); 15477fe4abbbSTarun Prabhu else if (eleTy.isF80()) 15487fe4abbbSTarun Prabhu func = fir::runtime::getRuntimeFunc<ForcedNorm2Real10>(loc, builder); 15497fe4abbbSTarun Prabhu else if (eleTy.isF128()) 15507fe4abbbSTarun Prabhu func = fir::runtime::getRuntimeFunc<ForcedNorm2Real16>(loc, builder); 15517fe4abbbSTarun Prabhu else 155204b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "NORM2"); 15537fe4abbbSTarun Prabhu 15547fe4abbbSTarun Prabhu auto fTy = func.getFunctionType(); 15557fe4abbbSTarun Prabhu auto sourceFile = fir::factory::locationToFilename(builder, loc); 15567fe4abbbSTarun Prabhu auto sourceLine = 15577fe4abbbSTarun Prabhu fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); 15587fe4abbbSTarun Prabhu auto args = fir::runtime::createArguments(builder, loc, fTy, arrayBox, 15597fe4abbbSTarun Prabhu sourceFile, sourceLine, dim); 15607fe4abbbSTarun Prabhu 15617fe4abbbSTarun Prabhu return builder.create<fir::CallOp>(loc, func, args).getResult(0); 15627fe4abbbSTarun Prabhu } 15637fe4abbbSTarun Prabhu 15645259528fSTarun Prabhu /// Generate call to `Parity` intrinsic runtime routine. This routine is 15655259528fSTarun Prabhu /// specialized for mask arguments with rank == 1. 15665259528fSTarun Prabhu mlir::Value fir::runtime::genParity(fir::FirOpBuilder &builder, 15675259528fSTarun Prabhu mlir::Location loc, mlir::Value maskBox, 15685259528fSTarun Prabhu mlir::Value dim) { 15695259528fSTarun Prabhu auto parityFunc = fir::runtime::getRuntimeFunc<mkRTKey(Parity)>(loc, builder); 15705259528fSTarun Prabhu return genSpecial2Args(parityFunc, builder, loc, maskBox, dim); 15715259528fSTarun Prabhu } 15725259528fSTarun Prabhu 157370638d99SValentin Clement /// Generate call to `ProductDim` intrinsic runtime routine. This is the version 1574f6ae8e8cSValentin Clement /// that handles any rank array with the dim argument specified. 1575f6ae8e8cSValentin Clement void fir::runtime::genProductDim(fir::FirOpBuilder &builder, mlir::Location loc, 1576f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1577f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value maskBox) { 1578f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(ProductDim)>(loc, builder); 1579f6ae8e8cSValentin Clement genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1580f6ae8e8cSValentin Clement } 1581f6ae8e8cSValentin Clement 158270638d99SValentin Clement /// Generate call to `Product` intrinsic runtime routine. This is the version 1583f6ae8e8cSValentin Clement /// that does not take a dim argument. 1584f6ae8e8cSValentin Clement mlir::Value fir::runtime::genProduct(fir::FirOpBuilder &builder, 1585f6ae8e8cSValentin Clement mlir::Location loc, mlir::Value arrayBox, 1586f6ae8e8cSValentin Clement mlir::Value maskBox, 1587f6ae8e8cSValentin Clement mlir::Value resultBox) { 1588f6ae8e8cSValentin Clement auto ty = arrayBox.getType(); 1589f6ae8e8cSValentin Clement auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1590e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1591f6ae8e8cSValentin Clement auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); 1592f6ae8e8cSValentin Clement 1593cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1594cc3cc5edSjeanPerier mlir::func::FuncOp func; 1595cc3cc5edSjeanPerier NUMERICAL_INTRINSIC_INSTANCES(Product) 1596cc3cc5edSjeanPerier if (!func) 159704b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "PRODUCT"); 1598f6ae8e8cSValentin Clement 15994a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1600f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1601f6ae8e8cSValentin Clement if (fir::isa_complex(eleTy)) { 1602f6ae8e8cSValentin Clement auto sourceLine = 1603f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); 1604f6ae8e8cSValentin Clement auto args = 1605f6ae8e8cSValentin Clement fir::runtime::createArguments(builder, loc, fTy, resultBox, arrayBox, 1606f6ae8e8cSValentin Clement sourceFile, sourceLine, dim, maskBox); 1607f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1608f6ae8e8cSValentin Clement return resultBox; 1609f6ae8e8cSValentin Clement } 1610f6ae8e8cSValentin Clement 1611f6ae8e8cSValentin Clement auto sourceLine = 1612f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); 1613f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1614f6ae8e8cSValentin Clement builder, loc, fTy, arrayBox, sourceFile, sourceLine, dim, maskBox); 1615f6ae8e8cSValentin Clement 1616f6ae8e8cSValentin Clement return builder.create<fir::CallOp>(loc, func, args).getResult(0); 1617f6ae8e8cSValentin Clement } 1618f6ae8e8cSValentin Clement 161970638d99SValentin Clement /// Generate call to `DotProduct` intrinsic runtime routine. 1620f6ae8e8cSValentin Clement mlir::Value fir::runtime::genDotProduct(fir::FirOpBuilder &builder, 1621f6ae8e8cSValentin Clement mlir::Location loc, 1622f6ae8e8cSValentin Clement mlir::Value vectorABox, 1623f6ae8e8cSValentin Clement mlir::Value vectorBBox, 1624f6ae8e8cSValentin Clement mlir::Value resultBox) { 162569193c6cSSlava Zakharin // For complex data types, resultBox is !fir.ref<!fir.complex<N>>, 162669193c6cSSlava Zakharin // otherwise it is !fir.box<T>. 162769193c6cSSlava Zakharin auto ty = resultBox.getType(); 162869193c6cSSlava Zakharin auto eleTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1629f6ae8e8cSValentin Clement 1630cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1631cc3cc5edSjeanPerier mlir::func::FuncOp func; 1632cc3cc5edSjeanPerier NUMERICAL_INTRINSIC_INSTANCES(DotProduct) 1633cc3cc5edSjeanPerier if (cat == Fortran::common::TypeCategory::Logical) 1634f6ae8e8cSValentin Clement func = 1635f6ae8e8cSValentin Clement fir::runtime::getRuntimeFunc<mkRTKey(DotProductLogical)>(loc, builder); 1636cc3cc5edSjeanPerier if (!func) 163704b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "DOTPRODUCT"); 1638f6ae8e8cSValentin Clement 16394a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1640f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1641f6ae8e8cSValentin Clement 1642f6ae8e8cSValentin Clement if (fir::isa_complex(eleTy)) { 1643f6ae8e8cSValentin Clement auto sourceLine = 1644f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 1645f6ae8e8cSValentin Clement auto args = 1646f6ae8e8cSValentin Clement fir::runtime::createArguments(builder, loc, fTy, resultBox, vectorABox, 1647f6ae8e8cSValentin Clement vectorBBox, sourceFile, sourceLine); 1648f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1649f6ae8e8cSValentin Clement return resultBox; 1650f6ae8e8cSValentin Clement } 1651f6ae8e8cSValentin Clement 1652f6ae8e8cSValentin Clement auto sourceLine = 1653f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); 1654f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments(builder, loc, fTy, vectorABox, 1655f6ae8e8cSValentin Clement vectorBBox, sourceFile, sourceLine); 1656f6ae8e8cSValentin Clement return builder.create<fir::CallOp>(loc, func, args).getResult(0); 1657f6ae8e8cSValentin Clement } 165870638d99SValentin Clement /// Generate call to `SumDim` intrinsic runtime routine. This is the version 1659f6ae8e8cSValentin Clement /// that handles any rank array with the dim argument specified. 1660f6ae8e8cSValentin Clement void fir::runtime::genSumDim(fir::FirOpBuilder &builder, mlir::Location loc, 1661f6ae8e8cSValentin Clement mlir::Value resultBox, mlir::Value arrayBox, 1662f6ae8e8cSValentin Clement mlir::Value dim, mlir::Value maskBox) { 1663f6ae8e8cSValentin Clement auto func = fir::runtime::getRuntimeFunc<mkRTKey(SumDim)>(loc, builder); 1664f6ae8e8cSValentin Clement genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1665f6ae8e8cSValentin Clement } 1666f6ae8e8cSValentin Clement 166770638d99SValentin Clement /// Generate call to `Sum` intrinsic runtime routine. This is the version 1668f6ae8e8cSValentin Clement /// that does not take a dim argument. 1669f6ae8e8cSValentin Clement mlir::Value fir::runtime::genSum(fir::FirOpBuilder &builder, mlir::Location loc, 1670f6ae8e8cSValentin Clement mlir::Value arrayBox, mlir::Value maskBox, 1671f6ae8e8cSValentin Clement mlir::Value resultBox) { 1672f6ae8e8cSValentin Clement auto ty = arrayBox.getType(); 1673f6ae8e8cSValentin Clement auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1674e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1675f6ae8e8cSValentin Clement auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); 1676f6ae8e8cSValentin Clement 1677cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1678cc3cc5edSjeanPerier mlir::func::FuncOp func; 1679cc3cc5edSjeanPerier NUMERICAL_INTRINSIC_INSTANCES(Sum) 1680cc3cc5edSjeanPerier if (!func) 168104b18530SPete Steinfeld fir::intrinsicTypeTODO(builder, eleTy, loc, "SUM"); 1682f6ae8e8cSValentin Clement 16834a3460a7SRiver Riddle auto fTy = func.getFunctionType(); 1684f6ae8e8cSValentin Clement auto sourceFile = fir::factory::locationToFilename(builder, loc); 1685f6ae8e8cSValentin Clement if (fir::isa_complex(eleTy)) { 1686f6ae8e8cSValentin Clement auto sourceLine = 1687f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); 1688f6ae8e8cSValentin Clement auto args = 1689f6ae8e8cSValentin Clement fir::runtime::createArguments(builder, loc, fTy, resultBox, arrayBox, 1690f6ae8e8cSValentin Clement sourceFile, sourceLine, dim, maskBox); 1691f6ae8e8cSValentin Clement builder.create<fir::CallOp>(loc, func, args); 1692f6ae8e8cSValentin Clement return resultBox; 1693f6ae8e8cSValentin Clement } 1694f6ae8e8cSValentin Clement 1695f6ae8e8cSValentin Clement auto sourceLine = 1696f6ae8e8cSValentin Clement fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); 1697f6ae8e8cSValentin Clement auto args = fir::runtime::createArguments( 1698f6ae8e8cSValentin Clement builder, loc, fTy, arrayBox, sourceFile, sourceLine, dim, maskBox); 1699f6ae8e8cSValentin Clement 1700f6ae8e8cSValentin Clement return builder.create<fir::CallOp>(loc, func, args).getResult(0); 1701f6ae8e8cSValentin Clement } 1702ebfe8a74STarun Prabhu 1703ebfe8a74STarun Prabhu // The IAll, IAny and IParity intrinsics have essentially the same 1704ebfe8a74STarun Prabhu // implementation. This macro will generate the function body given the 1705922992a2SJay Foad // intrinsic name. 1706ebfe8a74STarun Prabhu #define GEN_IALL_IANY_IPARITY(F) \ 1707ebfe8a74STarun Prabhu mlir::Value fir::runtime::JOIN2(gen, F)( \ 1708ebfe8a74STarun Prabhu fir::FirOpBuilder & builder, mlir::Location loc, mlir::Value arrayBox, \ 1709ebfe8a74STarun Prabhu mlir::Value maskBox, mlir::Value resultBox) { \ 1710ebfe8a74STarun Prabhu mlir::func::FuncOp func; \ 1711ebfe8a74STarun Prabhu auto ty = arrayBox.getType(); \ 1712ebfe8a74STarun Prabhu auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); \ 1713e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); \ 1714ebfe8a74STarun Prabhu auto dim = builder.createIntegerConstant(loc, builder.getIndexType(), 0); \ 1715ebfe8a74STarun Prabhu \ 1716ebfe8a74STarun Prabhu if (eleTy.isInteger(builder.getKindMap().getIntegerBitsize(1))) \ 1717ebfe8a74STarun Prabhu func = fir::runtime::getRuntimeFunc<mkRTKey(JOIN2(F, 1))>(loc, builder); \ 1718ebfe8a74STarun Prabhu else if (eleTy.isInteger(builder.getKindMap().getIntegerBitsize(2))) \ 1719ebfe8a74STarun Prabhu func = fir::runtime::getRuntimeFunc<mkRTKey(JOIN2(F, 2))>(loc, builder); \ 1720ebfe8a74STarun Prabhu else if (eleTy.isInteger(builder.getKindMap().getIntegerBitsize(4))) \ 1721ebfe8a74STarun Prabhu func = fir::runtime::getRuntimeFunc<mkRTKey(JOIN2(F, 4))>(loc, builder); \ 1722ebfe8a74STarun Prabhu else if (eleTy.isInteger(builder.getKindMap().getIntegerBitsize(8))) \ 1723ebfe8a74STarun Prabhu func = fir::runtime::getRuntimeFunc<mkRTKey(JOIN2(F, 8))>(loc, builder); \ 1724ebfe8a74STarun Prabhu else if (eleTy.isInteger(builder.getKindMap().getIntegerBitsize(16))) \ 1725ebfe8a74STarun Prabhu func = fir::runtime::getRuntimeFunc<JOIN3(Forced, F, 16)>(loc, builder); \ 1726ebfe8a74STarun Prabhu else \ 1727ebfe8a74STarun Prabhu fir::emitFatalError(loc, "invalid type in " STRINGIFY(F)); \ 1728ebfe8a74STarun Prabhu \ 1729ebfe8a74STarun Prabhu auto fTy = func.getFunctionType(); \ 1730ebfe8a74STarun Prabhu auto sourceFile = fir::factory::locationToFilename(builder, loc); \ 1731ebfe8a74STarun Prabhu auto sourceLine = \ 1732ebfe8a74STarun Prabhu fir::factory::locationToLineNo(builder, loc, fTy.getInput(2)); \ 1733ebfe8a74STarun Prabhu auto args = fir::runtime::createArguments( \ 1734ebfe8a74STarun Prabhu builder, loc, fTy, arrayBox, sourceFile, sourceLine, dim, maskBox); \ 1735ebfe8a74STarun Prabhu \ 1736ebfe8a74STarun Prabhu return builder.create<fir::CallOp>(loc, func, args).getResult(0); \ 1737ebfe8a74STarun Prabhu } 1738ebfe8a74STarun Prabhu 1739ebfe8a74STarun Prabhu /// Generate call to `IAllDim` intrinsic runtime routine. This is the version 1740ebfe8a74STarun Prabhu /// that handles any rank array with the dim argument specified. 1741ebfe8a74STarun Prabhu void fir::runtime::genIAllDim(fir::FirOpBuilder &builder, mlir::Location loc, 1742ebfe8a74STarun Prabhu mlir::Value resultBox, mlir::Value arrayBox, 1743ebfe8a74STarun Prabhu mlir::Value dim, mlir::Value maskBox) { 1744ebfe8a74STarun Prabhu auto func = fir::runtime::getRuntimeFunc<mkRTKey(IAllDim)>(loc, builder); 1745ebfe8a74STarun Prabhu genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1746ebfe8a74STarun Prabhu } 1747ebfe8a74STarun Prabhu 1748ebfe8a74STarun Prabhu /// Generate call to `IAll` intrinsic runtime routine. This is the version 1749ebfe8a74STarun Prabhu /// that does not take a dim argument. 1750ebfe8a74STarun Prabhu GEN_IALL_IANY_IPARITY(IAll) 1751ebfe8a74STarun Prabhu 1752ebfe8a74STarun Prabhu /// Generate call to `IAnyDim` intrinsic runtime routine. This is the version 1753ebfe8a74STarun Prabhu /// that handles any rank array with the dim argument specified. 1754ebfe8a74STarun Prabhu void fir::runtime::genIAnyDim(fir::FirOpBuilder &builder, mlir::Location loc, 1755ebfe8a74STarun Prabhu mlir::Value resultBox, mlir::Value arrayBox, 1756ebfe8a74STarun Prabhu mlir::Value dim, mlir::Value maskBox) { 1757ebfe8a74STarun Prabhu auto func = fir::runtime::getRuntimeFunc<mkRTKey(IAnyDim)>(loc, builder); 1758ebfe8a74STarun Prabhu genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1759ebfe8a74STarun Prabhu } 1760ebfe8a74STarun Prabhu 1761ebfe8a74STarun Prabhu /// Generate call to `IAny` intrinsic runtime routine. This is the version 1762ebfe8a74STarun Prabhu /// that does not take a dim argument. 1763ebfe8a74STarun Prabhu GEN_IALL_IANY_IPARITY(IAny) 1764ebfe8a74STarun Prabhu 1765ebfe8a74STarun Prabhu /// Generate call to `IParityDim` intrinsic runtime routine. This is the version 1766ebfe8a74STarun Prabhu /// that handles any rank array with the dim argument specified. 1767ebfe8a74STarun Prabhu void fir::runtime::genIParityDim(fir::FirOpBuilder &builder, mlir::Location loc, 1768ebfe8a74STarun Prabhu mlir::Value resultBox, mlir::Value arrayBox, 1769ebfe8a74STarun Prabhu mlir::Value dim, mlir::Value maskBox) { 1770ebfe8a74STarun Prabhu auto func = fir::runtime::getRuntimeFunc<mkRTKey(IParityDim)>(loc, builder); 1771ebfe8a74STarun Prabhu genReduction3Args(func, builder, loc, resultBox, arrayBox, dim, maskBox); 1772ebfe8a74STarun Prabhu } 1773ebfe8a74STarun Prabhu 1774ebfe8a74STarun Prabhu /// Generate call to `IParity` intrinsic runtime routine. This is the version 1775ebfe8a74STarun Prabhu /// that does not take a dim argument. 1776ebfe8a74STarun Prabhu GEN_IALL_IANY_IPARITY(IParity) 17770babff96SValentin Clement (バレンタイン クレメン) 17780babff96SValentin Clement (バレンタイン クレメン) /// Generate call to `Reduce` intrinsic runtime routine. This is the version 17790babff96SValentin Clement (バレンタイン クレメン) /// that does not take a DIM argument and store result in the passed result 17800babff96SValentin Clement (バレンタイン クレメン) /// value. 17810babff96SValentin Clement (バレンタイン クレメン) void fir::runtime::genReduce(fir::FirOpBuilder &builder, mlir::Location loc, 17820babff96SValentin Clement (バレンタイン クレメン) mlir::Value arrayBox, mlir::Value operation, 17830babff96SValentin Clement (バレンタイン クレメン) mlir::Value maskBox, mlir::Value identity, 178438fd0181SValentin Clement (バレンタイン クレメン) mlir::Value ordered, mlir::Value resultBox, 178538fd0181SValentin Clement (バレンタイン クレメン) bool argByRef) { 17860babff96SValentin Clement (バレンタイン クレメン) auto ty = arrayBox.getType(); 17870babff96SValentin Clement (バレンタイン クレメン) auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1788e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 17890babff96SValentin Clement (バレンタイン クレメン) auto dim = builder.createIntegerConstant(loc, builder.getI32Type(), 1); 17900babff96SValentin Clement (バレンタイン クレメン) 17910babff96SValentin Clement (バレンタイン クレメン) assert(resultBox && "expect non null value for the result"); 17920babff96SValentin Clement (バレンタイン クレメン) assert((fir::isa_char(eleTy) || fir::isa_complex(eleTy) || 17930babff96SValentin Clement (バレンタイン クレメン) fir::isa_derived(eleTy)) && 17940babff96SValentin Clement (バレンタイン クレメン) "expect character, complex or derived-type"); 17950babff96SValentin Clement (バレンタイン クレメン) 1796cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1797cc3cc5edSjeanPerier mlir::func::FuncOp func; 1798cc3cc5edSjeanPerier if (argByRef) { 1799cc3cc5edSjeanPerier COMPLEX_2_3_INTRINSIC_INSTANCES(Reduce, Ref) 1800cc3cc5edSjeanPerier COMPLEX_INTRINSIC_INSTANCES(Reduce, Ref) 1801cc3cc5edSjeanPerier } else { 1802cc3cc5edSjeanPerier COMPLEX_2_3_INTRINSIC_INSTANCES(Reduce, Value) 1803cc3cc5edSjeanPerier COMPLEX_INTRINSIC_INSTANCES(Reduce, Value) 1804cc3cc5edSjeanPerier } 18050babff96SValentin Clement (バレンタイン クレメン) fir::factory::CharacterExprHelper charHelper{builder, loc}; 1806cc3cc5edSjeanPerier if (fir::isa_char(eleTy) && charHelper.getCharacterKind(eleTy) == 1) 18070babff96SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceChar1)>(loc, builder); 18080babff96SValentin Clement (バレンタイン クレメン) else if (fir::isa_char(eleTy) && charHelper.getCharacterKind(eleTy) == 2) 18090babff96SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceChar2)>(loc, builder); 18100babff96SValentin Clement (バレンタイン クレメン) else if (fir::isa_char(eleTy) && charHelper.getCharacterKind(eleTy) == 4) 18110babff96SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceChar4)>(loc, builder); 18120babff96SValentin Clement (バレンタイン クレメン) else if (fir::isa_derived(eleTy)) 18130babff96SValentin Clement (バレンタイン クレメン) func = 18140babff96SValentin Clement (バレンタイン クレメン) fir::runtime::getRuntimeFunc<mkRTKey(ReduceDerivedType)>(loc, builder); 1815cc3cc5edSjeanPerier if (!func) 18160babff96SValentin Clement (バレンタイン クレメン) fir::intrinsicTypeTODO(builder, eleTy, loc, "REDUCE"); 18170babff96SValentin Clement (バレンタイン クレメン) 18180babff96SValentin Clement (バレンタイン クレメン) auto fTy = func.getFunctionType(); 18190babff96SValentin Clement (バレンタイン クレメン) auto sourceFile = fir::factory::locationToFilename(builder, loc); 18200babff96SValentin Clement (バレンタイン クレメン) auto sourceLine = 18210babff96SValentin Clement (バレンタイン クレメン) fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 18220babff96SValentin Clement (バレンタイン クレメン) auto opAddr = builder.create<fir::BoxAddrOp>(loc, fTy.getInput(2), operation); 18230babff96SValentin Clement (バレンタイン クレメン) auto args = fir::runtime::createArguments( 18240babff96SValentin Clement (バレンタイン クレメン) builder, loc, fTy, resultBox, arrayBox, opAddr, sourceFile, sourceLine, 18250babff96SValentin Clement (バレンタイン クレメン) dim, maskBox, identity, ordered); 18260babff96SValentin Clement (バレンタイン クレメン) builder.create<fir::CallOp>(loc, func, args); 18270babff96SValentin Clement (バレンタイン クレメン) } 18280babff96SValentin Clement (バレンタイン クレメン) 18290babff96SValentin Clement (バレンタイン クレメン) /// Generate call to `Reduce` intrinsic runtime routine. This is the version 18300babff96SValentin Clement (バレンタイン クレメン) /// that does not take DIM argument and return a scalar result. 18310babff96SValentin Clement (バレンタイン クレメン) mlir::Value fir::runtime::genReduce(fir::FirOpBuilder &builder, 18320babff96SValentin Clement (バレンタイン クレメン) mlir::Location loc, mlir::Value arrayBox, 18330babff96SValentin Clement (バレンタイン クレメン) mlir::Value operation, mlir::Value maskBox, 183438fd0181SValentin Clement (バレンタイン クレメン) mlir::Value identity, mlir::Value ordered, 183538fd0181SValentin Clement (バレンタイン クレメン) bool argByRef) { 18360babff96SValentin Clement (バレンタイン クレメン) auto ty = arrayBox.getType(); 18370babff96SValentin Clement (バレンタイン クレメン) auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1838e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 18390babff96SValentin Clement (バレンタイン クレメン) auto dim = builder.createIntegerConstant(loc, builder.getI32Type(), 1); 18400babff96SValentin Clement (バレンタイン クレメン) 18410babff96SValentin Clement (バレンタイン クレメン) assert((fir::isa_real(eleTy) || fir::isa_integer(eleTy) || 18420babff96SValentin Clement (バレンタイン クレメン) mlir::isa<fir::LogicalType>(eleTy)) && 18430babff96SValentin Clement (バレンタイン クレメン) "expect real, interger or logical"); 18440babff96SValentin Clement (バレンタイン クレメン) 1845cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 1846cc3cc5edSjeanPerier mlir::func::FuncOp func; 1847cc3cc5edSjeanPerier if (argByRef) { 1848cc3cc5edSjeanPerier REAL_2_3_INTRINSIC_INSTANCES(Reduce, Ref) 1849cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(Reduce, Ref) 1850cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(Reduce, Ref) 1851fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(Reduce, Ref) 1852cc3cc5edSjeanPerier LOGICAL_INTRINSIC_INSTANCES(Reduce, Ref) 1853cc3cc5edSjeanPerier } else { 1854cc3cc5edSjeanPerier REAL_2_3_INTRINSIC_INSTANCES(Reduce, Value) 1855cc3cc5edSjeanPerier REAL_INTRINSIC_INSTANCES(Reduce, Value) 1856cc3cc5edSjeanPerier INTEGER_INTRINSIC_INSTANCES(Reduce, Value) 1857fc97d2e6SPeter Klausler UNSIGNED_INTRINSIC_INSTANCES(Reduce, Value) 1858cc3cc5edSjeanPerier LOGICAL_INTRINSIC_INSTANCES(Reduce, Value) 1859cc3cc5edSjeanPerier } 1860cc3cc5edSjeanPerier if (!func) 18610babff96SValentin Clement (バレンタイン クレメン) fir::intrinsicTypeTODO(builder, eleTy, loc, "REDUCE"); 18620babff96SValentin Clement (バレンタイン クレメン) 18630babff96SValentin Clement (バレンタイン クレメン) auto fTy = func.getFunctionType(); 18640babff96SValentin Clement (バレンタイン クレメン) auto sourceFile = fir::factory::locationToFilename(builder, loc); 18650babff96SValentin Clement (バレンタイン クレメン) auto sourceLine = 18660babff96SValentin Clement (バレンタイン クレメン) fir::factory::locationToLineNo(builder, loc, fTy.getInput(3)); 18670babff96SValentin Clement (バレンタイン クレメン) auto opAddr = builder.create<fir::BoxAddrOp>(loc, fTy.getInput(1), operation); 18680babff96SValentin Clement (バレンタイン クレメン) auto args = fir::runtime::createArguments(builder, loc, fTy, arrayBox, opAddr, 18690babff96SValentin Clement (バレンタイン クレメン) sourceFile, sourceLine, dim, 18700babff96SValentin Clement (バレンタイン クレメン) maskBox, identity, ordered); 18710babff96SValentin Clement (バレンタイン クレメン) return builder.create<fir::CallOp>(loc, func, args).getResult(0); 18720babff96SValentin Clement (バレンタイン クレメン) } 18736ffdcfa7SValentin Clement (バレンタイン クレメン) 18746ffdcfa7SValentin Clement (バレンタイン クレメン) void fir::runtime::genReduceDim(fir::FirOpBuilder &builder, mlir::Location loc, 18756ffdcfa7SValentin Clement (バレンタイン クレメン) mlir::Value arrayBox, mlir::Value operation, 18766ffdcfa7SValentin Clement (バレンタイン クレメン) mlir::Value dim, mlir::Value maskBox, 18776ffdcfa7SValentin Clement (バレンタイン クレメン) mlir::Value identity, mlir::Value ordered, 187838fd0181SValentin Clement (バレンタイン クレメン) mlir::Value resultBox, bool argByRef) { 18796ffdcfa7SValentin Clement (バレンタイン クレメン) auto ty = arrayBox.getType(); 18806ffdcfa7SValentin Clement (バレンタイン クレメン) auto arrTy = fir::dyn_cast_ptrOrBoxEleTy(ty); 1881e6a4346bSScott Manley auto eleTy = mlir::cast<fir::SequenceType>(arrTy).getElementType(); 1882cc3cc5edSjeanPerier auto [cat, kind] = fir::mlirTypeToCategoryKind(loc, eleTy); 18836ffdcfa7SValentin Clement (バレンタイン クレメン) 1884cc3cc5edSjeanPerier mlir::func::FuncOp func; 1885cc3cc5edSjeanPerier if (argByRef) { 1886cc3cc5edSjeanPerier REAL_2_3_INTRINSIC_INSTANCES(Reduce, DimRef) 1887cc3cc5edSjeanPerier COMPLEX_2_3_INTRINSIC_INSTANCES(Reduce, DimRef) 1888cc3cc5edSjeanPerier NUMERICAL_AND_LOGICAL_INSTANCES(Reduce, DimRef) 1889cc3cc5edSjeanPerier } else { 1890cc3cc5edSjeanPerier REAL_2_3_INTRINSIC_INSTANCES(Reduce, DimValue) 1891cc3cc5edSjeanPerier COMPLEX_2_3_INTRINSIC_INSTANCES(Reduce, DimValue) 1892cc3cc5edSjeanPerier NUMERICAL_AND_LOGICAL_INSTANCES(Reduce, DimValue) 1893cc3cc5edSjeanPerier } 18946ffdcfa7SValentin Clement (バレンタイン クレメン) fir::factory::CharacterExprHelper charHelper{builder, loc}; 1895cc3cc5edSjeanPerier if (fir::isa_char(eleTy) && charHelper.getCharacterKind(eleTy) == 1) 18966ffdcfa7SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceCharacter1Dim)>(loc, 18976ffdcfa7SValentin Clement (バレンタイン クレメン) builder); 18986ffdcfa7SValentin Clement (バレンタイン クレメン) else if (fir::isa_char(eleTy) && charHelper.getCharacterKind(eleTy) == 2) 18996ffdcfa7SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceCharacter2Dim)>(loc, 19006ffdcfa7SValentin Clement (バレンタイン クレメン) builder); 19016ffdcfa7SValentin Clement (バレンタイン クレメン) else if (fir::isa_char(eleTy) && charHelper.getCharacterKind(eleTy) == 4) 19026ffdcfa7SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceCharacter4Dim)>(loc, 19036ffdcfa7SValentin Clement (バレンタイン クレメン) builder); 19046ffdcfa7SValentin Clement (バレンタイン クレメン) else if (fir::isa_derived(eleTy)) 19056ffdcfa7SValentin Clement (バレンタイン クレメン) func = fir::runtime::getRuntimeFunc<mkRTKey(ReduceDerivedTypeDim)>(loc, 19066ffdcfa7SValentin Clement (バレンタイン クレメン) builder); 1907cc3cc5edSjeanPerier if (!func) 19086ffdcfa7SValentin Clement (バレンタイン クレメン) fir::intrinsicTypeTODO(builder, eleTy, loc, "REDUCE"); 19096ffdcfa7SValentin Clement (バレンタイン クレメン) 19106ffdcfa7SValentin Clement (バレンタイン クレメン) auto fTy = func.getFunctionType(); 19116ffdcfa7SValentin Clement (バレンタイン クレメン) auto sourceFile = fir::factory::locationToFilename(builder, loc); 19126ffdcfa7SValentin Clement (バレンタイン クレメン) 19136ffdcfa7SValentin Clement (バレンタイン クレメン) auto sourceLine = 19146ffdcfa7SValentin Clement (バレンタイン クレメン) fir::factory::locationToLineNo(builder, loc, fTy.getInput(4)); 19156ffdcfa7SValentin Clement (バレンタイン クレメン) auto opAddr = builder.create<fir::BoxAddrOp>(loc, fTy.getInput(2), operation); 19166ffdcfa7SValentin Clement (バレンタイン クレメン) auto args = fir::runtime::createArguments( 19176ffdcfa7SValentin Clement (バレンタイン クレメン) builder, loc, fTy, resultBox, arrayBox, opAddr, sourceFile, sourceLine, 19186ffdcfa7SValentin Clement (バレンタイン クレメン) dim, maskBox, identity, ordered); 19196ffdcfa7SValentin Clement (バレンタイン クレメン) builder.create<fir::CallOp>(loc, func, args); 19206ffdcfa7SValentin Clement (バレンタイン クレメン) } 1921