forked from OSchip/llvm-project
[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@nvidia.com> Co-authored-by: V Donaldson <vdonaldson@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
This commit is contained in:
parent
7afa44f5f5
commit
4571f8aa05
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
Loading…
Reference in New Issue