[flang-commits] [flang] 617be27 - [flang] Support DFLOAT legacy extension intrinsic function

peter klausler via flang-commits flang-commits at lists.llvm.org
Wed Aug 4 12:18:56 PDT 2021


Author: peter klausler
Date: 2021-08-04T12:18:41-07:00
New Revision: 617be2756fd0e0d943d082e8f86309c4133ce64b

URL: https://github.com/llvm/llvm-project/commit/617be2756fd0e0d943d082e8f86309c4133ce64b
DIFF: https://github.com/llvm/llvm-project/commit/617be2756fd0e0d943d082e8f86309c4133ce64b.diff

LOG: [flang] Support DFLOAT legacy extension intrinsic function

Like the similar legacy extension FLOAT(), DFLOAT() represents a
conversion from default integer to DOUBLE PRECISION.  Rewrite
into a conversion operation.

Differential Revision: https://reviews.llvm.org/D107489

Added: 
    flang/test/Semantics/dfloat.f90

Modified: 
    flang/docs/Extensions.md
    flang/lib/Evaluate/intrinsics.cpp

Removed: 
    


################################################################################
diff  --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md
index 49295ae430bd9..34767f05a30ff 100644
--- a/flang/docs/Extensions.md
+++ b/flang/docs/Extensions.md
@@ -133,6 +133,7 @@ end
   the arguments as if they were operands to an intrinsic `+` operator,
   and defining the result type accordingly.
 * DOUBLE COMPLEX intrinsics DREAL, DCMPLX, DCONJG, and DIMAG.
+* The DFLOAT intrinsic function.
 * INT_PTR_KIND intrinsic returns the kind of c_intptr_t.
 * Restricted specific conversion intrinsics FLOAT, SNGL, IDINT, IFIX, DREAL,
   and DCMPLX accept arguments of any kind instead of only the default kind or

diff  --git a/flang/lib/Evaluate/intrinsics.cpp b/flang/lib/Evaluate/intrinsics.cpp
index 8340e809f85ef..ae9e7c4599869 100644
--- a/flang/lib/Evaluate/intrinsics.cpp
+++ b/flang/lib/Evaluate/intrinsics.cpp
@@ -817,7 +817,7 @@ static const IntrinsicInterface genericIntrinsicFunction[]{
 // TODO: Non-standard intrinsic functions
 //  AND, OR, XOR, LSHIFT, RSHIFT, SHIFT, ZEXT, IZEXT,
 //  COMPL, EQV, NEQV, INT8, JINT, JNINT, KNINT,
-//  QCMPLX, DFLOAT, QEXT, QFLOAT, QREAL, DNUM,
+//  QCMPLX, QEXT, QFLOAT, QREAL, DNUM,
 //  INUM, JNUM, KNUM, QNUM, RNUM, RAN, RANF, ILEN,
 //  MCLOCK, SECNDS, COTAN, IBCHNG, ISHA, ISHC, ISHL, IXOR
 //  IARG, IARGC, NARGS, NUMARG, BADDRESS, IADDR, CACHESIZE,
@@ -924,6 +924,7 @@ static const SpecificIntrinsicInterface specificIntrinsicFunction[]{
              {"y", AnyIntOrReal, Rank::elementalOrBOZ, Optionality::optional}},
          DoublePrecisionComplex},
         "cmplx", true},
+    {{"dfloat", {{"i", AnyInt}}, DoublePrecision}, "real", true},
     {{"dreal", {{"a", AnyComplex}}, DoublePrecision}, "real", true},
     {{"dconjg", {{"a", DoublePrecisionComplex}}, DoublePrecisionComplex},
         "conjg"},

diff  --git a/flang/test/Semantics/dfloat.f90 b/flang/test/Semantics/dfloat.f90
new file mode 100644
index 0000000000000..c04360d722906
--- /dev/null
+++ b/flang/test/Semantics/dfloat.f90
@@ -0,0 +1,15 @@
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
+! Checks that a call to the legacy extension intrinsic function
+! DFLOAT is transmogrified into a type conversion operation.
+module m
+  !CHECK: d = 1._8
+  double precision :: d = dfloat(1)
+ contains
+  subroutine sub(n)
+    integer, intent(in) :: n
+    !CHECK: 2._8
+    print *, dfloat(2)
+    !CHECK: real(n,kind=8)
+    print *, dfloat(n)
+  end subroutine
+end module


        


More information about the flang-commits mailing list