[flang-commits] [flang] 3887ebb - [flang][lowering] Add support for lowering of the `ieor` intrinsic
Andrzej Warzynski via flang-commits
flang-commits at lists.llvm.org
Wed Mar 16 09:50:53 PDT 2022
Author: Andrzej Warzynski
Date: 2022-03-16T16:50:43Z
New Revision: 3887ebbba0eb33ade9f181e4ce9b0a3a9f764ee5
URL: https://github.com/llvm/llvm-project/commit/3887ebbba0eb33ade9f181e4ce9b0a3a9f764ee5
DIFF: https://github.com/llvm/llvm-project/commit/3887ebbba0eb33ade9f181e4ce9b0a3a9f764ee5.diff
LOG: [flang][lowering] Add support for lowering of the `ieor` intrinsic
This patch adds support for lowering of the `ieor` 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
Co-authored-by: V Donaldson <vdonaldson at nvidia.com>
Co-authored-by: Jean Perier <jperier at nvidia.com>
Co-authored-by: Valentin Clement <clementval at gmail.com>
Differential Revision: https://reviews.llvm.org/D121791
Added:
flang/test/Lower/Intrinsics/ieor.f90
Modified:
flang/lib/Lower/IntrinsicCall.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/IntrinsicCall.cpp b/flang/lib/Lower/IntrinsicCall.cpp
index 4e24eb4c17ad6..b6a8dddb08e9f 100644
--- a/flang/lib/Lower/IntrinsicCall.cpp
+++ b/flang/lib/Lower/IntrinsicCall.cpp
@@ -459,6 +459,7 @@ struct IntrinsicLibrary {
mlir::Value genIand(mlir::Type, llvm::ArrayRef<mlir::Value>);
mlir::Value genIbits(mlir::Type, llvm::ArrayRef<mlir::Value>);
mlir::Value genIbset(mlir::Type, llvm::ArrayRef<mlir::Value>);
+ mlir::Value genIeor(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>);
@@ -635,6 +636,7 @@ static constexpr IntrinsicHandler handlers[]{
{"iand", &I::genIand},
{"ibits", &I::genIbits},
{"ibset", &I::genIbset},
+ {"ieor", &I::genIeor},
{"ishft", &I::genIshft},
{"ishftc", &I::genIshftc},
{"len",
@@ -1930,6 +1932,13 @@ mlir::Value IntrinsicLibrary::genIbset(mlir::Type resultType,
return builder.create<mlir::arith::OrIOp>(loc, args[0], mask);
}
+// IEOR
+mlir::Value IntrinsicLibrary::genIeor(mlir::Type resultType,
+ llvm::ArrayRef<mlir::Value> args) {
+ assert(args.size() == 2);
+ return builder.create<mlir::arith::XOrIOp>(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/ieor.f90 b/flang/test/Lower/Intrinsics/ieor.f90
new file mode 100644
index 0000000000000..011bbb9d5cd2b
--- /dev/null
+++ b/flang/test/Lower/Intrinsics/ieor.f90
@@ -0,0 +1,9 @@
+! RUN: bbc -emit-fir %s -o - | FileCheck %s
+
+! CHECK-LABEL: ieor_test
+subroutine ieor_test(a, b)
+ integer :: a, b
+ print *, ieor(a, b)
+ ! CHECK: %{{[0-9]+}} = arith.xori %{{[0-9]+}}, %{{[0-9]+}} : i{{(8|16|32|64|128)}}
+end subroutine ieor_test
+
More information about the flang-commits
mailing list