mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-29 21:24:04 +00:00
[flang] Lower present intrinsic
This patch adds lowering for the `present` intrinsic. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D121884 Co-authored-by: Jean Perier <jperier@nvidia.com>
This commit is contained in:
parent
4d323f4837
commit
96fd54c964
@ -485,6 +485,7 @@ struct IntrinsicLibrary {
|
||||
mlir::Value genNot(mlir::Type, llvm::ArrayRef<mlir::Value>);
|
||||
fir::ExtendedValue genNull(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
|
||||
fir::ExtendedValue genPack(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
|
||||
fir::ExtendedValue genPresent(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
|
||||
fir::ExtendedValue genProduct(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
|
||||
void genRandomInit(llvm::ArrayRef<fir::ExtendedValue>);
|
||||
void genRandomNumber(llvm::ArrayRef<fir::ExtendedValue>);
|
||||
@ -726,6 +727,10 @@ static constexpr IntrinsicHandler handlers[]{
|
||||
{"mask", asBox},
|
||||
{"vector", asBox, handleDynamicOptional}}},
|
||||
/*isElemental=*/false},
|
||||
{"present",
|
||||
&I::genPresent,
|
||||
{{{"a", asInquired}}},
|
||||
/*isElemental=*/false},
|
||||
{"product",
|
||||
&I::genProduct,
|
||||
{{{"array", asBox},
|
||||
@ -2563,6 +2568,15 @@ IntrinsicLibrary::genPack(mlir::Type resultType,
|
||||
"unexpected result for PACK");
|
||||
}
|
||||
|
||||
// PRESENT
|
||||
fir::ExtendedValue
|
||||
IntrinsicLibrary::genPresent(mlir::Type,
|
||||
llvm::ArrayRef<fir::ExtendedValue> args) {
|
||||
assert(args.size() == 1);
|
||||
return builder.create<fir::IsPresentOp>(loc, builder.getI1Type(),
|
||||
fir::getBase(args[0]));
|
||||
}
|
||||
|
||||
// PRODUCT
|
||||
fir::ExtendedValue
|
||||
IntrinsicLibrary::genProduct(mlir::Type resultType,
|
||||
|
10
flang/test/Lower/Intrinsics/present.f90
Normal file
10
flang/test/Lower/Intrinsics/present.f90
Normal file
@ -0,0 +1,10 @@
|
||||
! RUN: bbc -emit-fir %s -o - | FileCheck %s
|
||||
|
||||
! CHECK-LABEL: present_test
|
||||
! CHECK-SAME: %[[arg0:[^:]+]]: !fir.box<!fir.array<?xi32>>
|
||||
subroutine present_test(a)
|
||||
integer, optional :: a(:)
|
||||
|
||||
if (present(a)) print *,a
|
||||
! CHECK: %{{.*}} = fir.is_present %[[arg0]] : (!fir.box<!fir.array<?xi32>>) -> i1
|
||||
end subroutine
|
Loading…
x
Reference in New Issue
Block a user