[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@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>

Differential Revision: https://reviews.llvm.org/D121791
This commit is contained in:
Andrzej Warzynski 2022-03-16 11:40:05 +00:00
parent 30718f3aa6
commit 3887ebbba0
2 changed files with 18 additions and 0 deletions

View File

@ -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) {

View File

@ -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