Skip to content

Commit 4571f8a

Browse files
banach-spacejeanPeriervdonaldsonschweitzpgi
committed
[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 <[email protected]> Co-authored-by: V Donaldson <[email protected]> Co-authored-by: Eric Schweitz <[email protected]>
1 parent 7afa44f commit 4571f8a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

flang/lib/Lower/IntrinsicCall.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ struct IntrinsicLibrary {
485485
fir::ExtendedValue genIchar(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
486486
mlir::Value genIeor(mlir::Type, llvm::ArrayRef<mlir::Value>);
487487
fir::ExtendedValue genIndex(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
488+
mlir::Value genIor(mlir::Type, llvm::ArrayRef<mlir::Value>);
488489
mlir::Value genIshft(mlir::Type, llvm::ArrayRef<mlir::Value>);
489490
mlir::Value genIshftc(mlir::Type, llvm::ArrayRef<mlir::Value>);
490491
fir::ExtendedValue genLbound(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
@@ -735,6 +736,7 @@ static constexpr IntrinsicHandler handlers[]{
735736
{"substring", asAddr},
736737
{"back", asValue, handleDynamicOptional},
737738
{"kind", asValue}}}},
739+
{"ior", &I::genIor},
738740
{"ishft", &I::genIshft},
739741
{"ishftc", &I::genIshftc},
740742
{"lbound",
@@ -2512,6 +2514,13 @@ IntrinsicLibrary::genIndex(mlir::Type resultType,
25122514
return readAndAddCleanUp(mutBox, resultType, "INDEX");
25132515
}
25142516

2517+
// IOR
2518+
mlir::Value IntrinsicLibrary::genIor(mlir::Type resultType,
2519+
llvm::ArrayRef<mlir::Value> args) {
2520+
assert(args.size() == 2);
2521+
return builder.create<mlir::arith::OrIOp>(loc, args[0], args[1]);
2522+
}
2523+
25152524
// ISHFT
25162525
mlir::Value IntrinsicLibrary::genIshft(mlir::Type resultType,
25172526
llvm::ArrayRef<mlir::Value> args) {

flang/test/Lower/Intrinsics/ior.f90

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
! RUN: bbc -emit-fir %s -o - | FileCheck %s
2+
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
3+
4+
! CHECK-LABEL: ior_test
5+
subroutine ior_test(a, b)
6+
integer :: a, b
7+
print *, ior(a, b)
8+
! CHECK: %{{[0-9]+}} = arith.ori %{{[0-9]+}}, %{{[0-9]+}} : i{{(8|16|32|64|128)}}
9+
end subroutine ior_test
10+

0 commit comments

Comments
 (0)