[flang-commits] [flang] [flang] Extension intrinsics INT8 and INT2 (PR #109433)
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Fri Sep 20 07:46:10 PDT 2024
https://github.com/klausler created https://github.com/llvm/llvm-project/pull/109433
These are legacy conversion intrinsic functions supported by nearly all Fortran compilers (esp. INT8).
They are equivalent to INT(..., KIND=8 or 2), respectively.
>From c284c5f199ca2c94579657d505ac8080b93a4d0b Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Fri, 20 Sep 2024 07:43:24 -0700
Subject: [PATCH] [flang] Extension intrinsics INT8 and INT2
These are legacy conversion intrinsic functions supported
by nearly all Fortran compilers (esp. INT8).
They are equivalent to INT(..., KIND=8 or 2), respectively.
---
flang/lib/Evaluate/intrinsics.cpp | 6 ++++++
flang/test/Evaluate/int8.f90 | 5 +++++
2 files changed, 11 insertions(+)
create mode 100644 flang/test/Evaluate/int8.f90
diff --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 166dae93178c51..26661d9d534b3d 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -1169,6 +1169,12 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
// procedure pointer target.
{{"index", {{"string", DefaultChar}, {"substring", DefaultChar}},
DefaultInt}},
+ {{"int2", {{"a", AnyNumeric, Rank::elementalOrBOZ}},
+ TypePattern{IntType, KindCode::exactKind, 2}},
+ "int"},
+ {{"int8", {{"a", AnyNumeric, Rank::elementalOrBOZ}},
+ TypePattern{IntType, KindCode::exactKind, 8}},
+ "int"},
{{"isign", {{"a", DefaultInt}, {"b", DefaultInt}}, DefaultInt}, "sign"},
{{"jiabs", {{"a", TypePattern{IntType, KindCode::exactKind, 4}}},
TypePattern{IntType, KindCode::exactKind, 4}},
diff --git a/flang/test/Evaluate/int8.f90 b/flang/test/Evaluate/int8.f90
new file mode 100644
index 00000000000000..ef8321f4c710b3
--- /dev/null
+++ b/flang/test/Evaluate/int8.f90
@@ -0,0 +1,5 @@
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
+!CHECK: warning: REAL(4) to INTEGER(2) conversion overflowed
+!CHECK: PRINT *, 32767_2, 4000000000_8
+print *, int2(4.e9), int8(4.e9)
+end
More information about the flang-commits
mailing list