[flang-commits] [flang] 4571f8a - [flang][lowering] Add support for lowering of the `ior` intrinsic

Andrzej Warzynski via flang-commits flang-commits at lists.llvm.org
Fri Mar 18 03:37:16 PDT 2022


Author: Andrzej Warzynski
Date: 2022-03-18T10:36:38Z
New Revision: 4571f8aa05a1eb88532edfcf7e144633535d5e85

URL: https://github.com/llvm/llvm-project/commit/4571f8aa05a1eb88532edfcf7e144633535d5e85
DIFF: https://github.com/llvm/llvm-project/commit/4571f8aa05a1eb88532edfcf7e144633535d5e85.diff

LOG: [flang][lowering] Add support for lowering of the `ior` intrinsic

This patch adds support for lowering of the `ior` intrinsic from
Fortran to the FIR dialect of MLIR.

This is part of the upstreaming effort from the `fir-dev` branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

Differential Revision: https://reviews.llvm.org/D121928

Co-authored-by: Jean Perier <jperier at nvidia.com>
Co-authored-by: V Donaldson <vdonaldson at nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>

Added: 
    flang/test/Lower/Intrinsics/ior.f90

Modified: 
    flang/lib/Lower/IntrinsicCall.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 8fba5c180175a..5c82f594e02c8 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -485,6 +485,7 @@ struct IntrinsicLibrary {
   fir::ExtendedValue genIchar(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
   mlir::Value genIeor(mlir::Type, llvm::ArrayRef<mlir::Value>);
   fir::ExtendedValue genIndex(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
+  mlir::Value genIor(mlir::Type, llvm::ArrayRef<mlir::Value>);
   mlir::Value genIshft(mlir::Type, llvm::ArrayRef<mlir::Value>);
   mlir::Value genIshftc(mlir::Type, llvm::ArrayRef<mlir::Value>);
   fir::ExtendedValue genLbound(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
@@ -735,6 +736,7 @@ static constexpr IntrinsicHandler handlers[]{
        {"substring", asAddr},
        {"back", asValue, handleDynamicOptional},
        {"kind", asValue}}}},
+    {"ior", &I::genIor},
     {"ishft", &I::genIshft},
     {"ishftc", &I::genIshftc},
     {"lbound",
@@ -2512,6 +2514,13 @@ IntrinsicLibrary::genIndex(mlir::Type resultType,
   return readAndAddCleanUp(mutBox, resultType, "INDEX");
 }
 
+// IOR
+mlir::Value IntrinsicLibrary::genIor(mlir::Type resultType,
+                                     llvm::ArrayRef<mlir::Value> args) {
+  assert(args.size() == 2);
+  return builder.create<mlir::arith::OrIOp>(loc, args[0], args[1]);
+}
+
 // ISHFT
 mlir::Value IntrinsicLibrary::genIshft(mlir::Type resultType,
                                        llvm::ArrayRef<mlir::Value> args) {

diff  --git a/flang/test/Lower/Intrinsics/ior.f90 b/flang/test/Lower/Intrinsics/ior.f90
new file mode 100644
index 0000000000000..35f1997ba15aa
--- /dev/null
+++ b/flang/test/Lower/Intrinsics/ior.f90
@@ -0,0 +1,10 @@
+! RUN: bbc -emit-fir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
+
+! CHECK-LABEL: ior_test
+subroutine ior_test(a, b)
+  integer :: a, b
+  print *, ior(a, b)
+  ! CHECK: %{{[0-9]+}} = arith.ori %{{[0-9]+}}, %{{[0-9]+}} : i{{(8|16|32|64|128)}}
+end subroutine ior_test
+


        


More information about the flang-commits mailing list