Age | Commit message (Collapse) | Author |
|
Make a requested change to the wording of a fatal I/O error
message.
Differential Revision: https://reviews.llvm.org/D136984
|
|
To accomplish this, this patch creates an optional list of environment
variable default values to be set by the runtime to allow directly using
the existing runtime implementation of FORT_CONVERT for I/O conversions.
|
|
Differential Revision: https://reviews.llvm.org/D135684
|
|
This patch adds a cpowi function to the flang runtime, and switches
to using that function instead of pgmath for complex number to
integer power operations.
Differential Revision: https://reviews.llvm.org/D134889
|
|
The GNU extension intrinsic IARGC is equivalent to
COMMAND_ARGUMENT_COUNT, and the GETARG is similar to
GET_COMMAND_ARGUMENT, but with less arguments. Reuse the runtime of
COMMAND_ARGUMENT_COUNT and GET_COMMAND_ARGUMENT for IARGC and GETARG.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D133558
|
|
We used to have a big switch statement over the type categories and kinds
inside Minloc/Maxloc. After D133051 the switch grew bigger, and this
changed inlining decisions made by GCC (the build compiler). Some of the
simple methods stopped being inlined, and this caused slight performance
regression in Polyhedron/gas_dyn2. This change adds separate entries
for real/integer data types to let them be optimized separately.
Differential Revision: https://reviews.llvm.org/D135610
|
|
|
|
A namelist input item that is a derived type component reference
needs additional processing when the base item or the component
is an array. When both have rank > 0, the component reference
must of course be subscripted.
(Fixes https://gitlab-master.nvidia.com/fortran/f18-stage/-/issues/999, NAG test t/tz2.)
|
|
A namelist input item that is a derived type component reference
needs additional processing when the base item or the component
is an array. When both have rank > 0, the component reference
must of course be subscripted.
Differential Revision: https://reviews.llvm.org/D135218
|
|
NAMELIST input processing in the runtime support library treats an
end-of-file found while searching for the initial '&' character
as an error condition, but it really should be distinguishable.
Call SignalEnd() rather than SignalError().
Differential Revision: https://reviews.llvm.org/D135212
|
|
std::numeric_limits<__float128>::max/lowest return 0.0, so recreate
value of FLT128_MAX ourselves to avoid using quadmath.h's FLT128_MAX
that is currently causes warnings with GCC -Wpedantic.
Differential Revision: https://reviews.llvm.org/D134496
|
|
BytesFor() used to return KIND for the size, which is not always
correct, so I changed it to return the size of the actual CppType
corresponding to the given category and kind.
MinElemLen() used to calculate size incorrectly (e.g. CFI_type_extended_double
was sized 10, whereas it may occupy more bytes on a target), so I changed it
to call BytesFor().
Additional changes were needed to resolve new failures for transformational
intrinsics. These intrinsics used to work for not fully supported
data types (e.g. REAL(3)), but now stopped working because CppType
cannot be computed for those categories/kinds. The solution is to use
known element size from the source argument(s) for establishing
the destination descriptor - the element size is all that is needed
for transformational intrinsics to keep working.
Note that this does not help cases, where runtime still has to
compute the element size, e.g. when it creates descriptors for
components of derived types. If the component has unsupported
data type, BytesFor() will still fail. So these cases require
adding support for the missing types.
New regression unit test in Runtime/Transformational.cpp
demonstrates the case that will start working properly with
this commit.
|
|
Currently, the FORT_CONVERT environment variable has the highest priority when
setting the endianness conversion for unformatted files. In discussing the
appropriate priority for the fconvert option, convert specifiers were decided
to take highest priority.
This patch also initializes the open statement convert state to unknown
to disambiguate cases where the convert specifier was not provided from
cases where convert=native was set. This makes it possible to defer to the
environment setting where appropriate.
Differential Revision: https://reviews.llvm.org/D133237
|
|
CompareToBlankPadding was doing signed compare on architecture where
`char` is signed. This caused `'abc'//char(128) > 'abc'` to evaluate
to false at runtime instead of true.
Differential Revision: https://reviews.llvm.org/D133693
|
|
HasCppTypeFor<> used to evaluate to false always, so kind 10 and 16
variants of dot_product were not instantiated even though the host
supported 80- and 128-bit real and complex data types.
In addition, HAS_FLOAT128 was not enabling complex kind=16 variant
of dot_product. This is fixed now.
Note that the change for HasCppTypeFor<> may also affect other
functions such as matmul, i.e. kind 10 and 16 variants of them
may become available now (depending on the build host).
Differential Revision: https://reviews.llvm.org/D133051
|
|
The use of std::clamp here is safe because the definition of
largestLDKind gurantees that 8 <= largestLDKind.
|
|
Unformatted I/O with byte swapping was reversing bytes in badly-sized
frames for character, complex, and some default derived type transfers.
Differential Revision: https://reviews.llvm.org/D132751
|
|
The result of MINVAL over an empty default character array should
(per the standard) have a 127 in every character position, not just
the first.
Differential Revision: https://reviews.llvm.org/D132677
|
|
Check whether `F_OK` et al are defined before redefining them; mingw
headers do define them, so check before providing the windows fallback
defines.
Also check `_WIN32` instead of `WIN32`; this is how it's consistently
done in the rest of llvm. (The former is a compiler builtin define,
while the latter isn't, but it's commonly set by e.g. build systems.)
Differential Revision: https://reviews.llvm.org/D132481
|
|
Add the remaining pieces to support IO for noncontigous formats.
This is done by passing an array descriptor to IO calls. Scalar
formats continue to pass string and length arguments. IO calls
with formats are modified to place the new format descriptor
argument directly after the original string and length arguments.
|
|
This allows building the flang runtime and libFortranDecimal standalone,
without setting up the full llvm build, by pointing cmake to these
directories.
This is the other one out of two essential steps for building the flang runtimes
for a foreign target, i.e. setting up cross compiling with flang.
Differential Revision: https://reviews.llvm.org/D130352
|
|
Formatted input allows for an empty numeric input field, which
signifies a zero value, but list-directed and NAMELIST input does
not -- apart from the special case of a NAMELIST array.
Differential Revision: https://reviews.llvm.org/D132178
|
|
The runtime I/O library correctly handles endianness conversions on payload
data I/O and on the output of sequential record headers and footers, but
does not swap endianness when required when reading sequential record headers
and footers back in for READ and BACKSPACE statements. Mea culpa. Fix.
Fixes https://github.com/llvm/llvm-project/issues/57126
Differential Revision: https://reviews.llvm.org/D132168
|
|
A character array can be used as a format in an I/O data transfer
statement, with the interpretation that its elements are concatenated
in element order to constitute the format.
Support in the runtime with an extra optional descriptor argument
to six I/O API calls; support in semantics by removing an earlier
check for a simply contiguous array presented as a format.
Some work needs to be done in lowering to pass a character array
descriptor to the I/O runtime API when present
Differential Revision: https://reviews.llvm.org/D132167
|
|
In the case of a data transfer I/O statement with an illegal unit number and
error recovery, ensure that data transfer API calls don't raise internal
errors due to the I/O statement representation unexpectedly being something
other than a data transfer statement.
Differential Revision: https://reviews.llvm.org/D132160
|
|
A literal % character in an error message needs to be doubled
so that it appears in the output of snprintf().
Differential Revision: https://reviews.llvm.org/D132158
|
|
While a NAMELIST input group item for an array can have fewer
values than expected, or none, an input group item for a scalar
must have a value.
Differential Revision: https://reviews.llvm.org/D132157
|
|
CharacterExtremumAccumulator::GetResult() needs to use byte counts, not wide
character counts, when calling memcpy() & memset().
Differential Revision: https://reviews.llvm.org/D132156
|
|
Ensure that I/O buffers are flushed at the end of the program,
and properly detect ttys for predefined units so that Fortran
output is interspersed with output from non-Fortran code.
Fixes https://github.com/llvm/llvm-project/issues/56944
Differential Revision: https://reviews.llvm.org/D132152
Update: fix typo in comment
|
|
Print the full shapes of both argument when the dimensions that must
match do not do so.
Differential Revision: https://reviews.llvm.org/D132153
|
|
Make sure that FortranDecimal, FortranRuntime and Fortran_main are
installed/packaged even when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled.
They are used by flang to link executables, so they should be provided
even with minimal installs.
Differential Revision: https://reviews.llvm.org/D131670
|
|
Remove a lambda capture of "[this]" in two cases where it
is no longer required. Will be pushed without waiting for
review if CI is successful in order to resolve a sad build bot.
Differential Revision: https://reviews.llvm.org/D131506
|
|
|
|
Allow internal I/O to support non-default kinds of CHARACTER.
The I/O runtime design anticipated this standard feature, but
this patch is somewhat larger than I thought it would be because
many code sites had to have assumptions about units (characters
vs. bytes) brought into harmony, and some encoding utilities
had to be pulled out of IoStatementState and templatized into
their own new header file so that they are available to formatted
output code without having to "thread" an IoStatementState reference
through many call chains.
Differential Revision: https://reviews.llvm.org/D131107
|
|
When an I/O statement contains a function call that attempts
to perform I/O on the same unit, detect the recursive I/O
and terminate with a useful message rather than deadlocking in
the threading library.
Differential Revision: https://reviews.llvm.org/D131097
|
|
The semantic checks and runtime have been supported. This supports the
lowering of intrinsic ABORT.
`gfortran` prints a backtrace before abort, unless `-fno-backtrace` is
given. This is good to use. The intrinsic BACKTRACE is not supported
yet, so add TODO in the runtime.
This extention is needed in SPEC2017 521.wrf_r in
https://github.com/llvm/llvm-project/issues/55955.
Reviewed By: klausler
Differential Revision: https://reviews.llvm.org/D130439
|
|
This patch refactors the runtime support for GET_COMMAND_ARGUMENT to
have a single entry point instead of 2. It also updates lowering
accordingly.
This makes it easier to handle dynamically optional arguments. See also
https://reviews.llvm.org/D118777
Differential Revision: https://reviews.llvm.org/D130475
|
|
An OPEN statement that implies closing a connection must invalidate
the unit's frame buffer so as to prevent stale data from the old
connection from being read into the newly-connected unit.
Differential Revision: https://reviews.llvm.org/D130430
|
|
As Fortran 2018 16.9.169, the argument of selected_int_kind is integer
scalar, and result is default integer scalar. The constant expression in
this intrinsic has been supported by folding the constant expression.
This supports lowering and runtime for variables in this intrinsic.
Reviewed By: Jean Perier
Differential Revision: https://reviews.llvm.org/D129959
|
|
As Fortran 2018 16.9.170, the argument of `selected_real_kind` is integer
scalar, and result is default integer scalar. The constant expression in
this intrinsic has been supported by folding the constant expression.
This supports lowering this intrinsic for variables using runtime.
Reviewed By: Jean Perier
Differential Revision: https://reviews.llvm.org/D130183
|
|
For aint/anint, LLVM conversion operations llvm.trunc and llvm.round
can support the edge case of aint(-0.) and anint(-0.). The output is -0.
and it is the same of `gfortran` and `classic flang`, while the output
of `ifort` is 0.. The `real(10)/real(16)` is not supported before.
Support it and remove the runtime functions for aint/anint.
For nint, `gfortran`, `ifort`, and LLVM Flang using llvm.lround have
different results when the magnitude of argument is more than the max of
result value range. So delay its support in lowering after more
investigations.
Reviewed By: vzakhari
Differential Revision: https://reviews.llvm.org/D130024
|
|
When MOLD= is an array and there is no SIZE= in a call to TRANSFER(),
the size of an element of the MOLD= is used as the denominator in a
division to establish the extent of the vector result. When the
total storage size of the SOURCE= is known to be zero, the result is
empty and no division is needed.
To avoid a division by zero at runtime, we need to check for a zero-sized
MOLD= element type when the storage size of SOURCE= is nonzero and there
is no SIZE=. Further, in the compilation-time rewriting of calls to
SHAPE(TRANSFER(...)) and SIZE(TRANSFER(...)) for constant folding and
simplification purposes, we can't replace the call with an arithmetic
element count expression when the storage size of SOURCE= is not known
to be zero and the element size of MOLD= is not known to be nonzero at
compilation time.
These changes mostly affect tests using a MOLD= argument that is an
assumed-length character.
Differential Revision: https://reviews.llvm.org/D129680
|
|
Most of the infrastructure for DECIMAL='COMMA' mode was in place
in the I/O runtime support library, but I dropped the ball for
list-directed character input, which has its own detection of
input separators. Finish the job.
Differential Revision: https://reviews.llvm.org/D129679
|
|
When the I/O runtime is truncating an external file due to an
implied ENDFILE or explicit ENDFILE, ensure that the unit's frame
buffer for the file discards any data that have become obsolete.
This bug caused trouble with ACCESS='STREAM' I/O using POS= on
a WRITE, but it may have not been limited to that scenario.
Differential Revision: https://reviews.llvm.org/D129673
|
|
The rule used by list-directed REAL output editing to select
between Ew.d and Fw.d output editing breaks down for 16-bit
floating-point data, since the number of significant decimal
digits is so low that Ew,d output editing is nearly always selected.
Cap the test so that five-digit values will be output with Fw.d
editing.
Differential Revision: https://reviews.llvm.org/D129672
|
|
The title says it.
Differential Revision: https://reviews.llvm.org/D129329
|
|
Section 16.9.171 says:
If X has the value zero, the result has the same value as X
So if X is -0.0, SET_EXPONENT should return -0.0.
Differential Revision: https://reviews.llvm.org/D129309
|
|
Since dynamic FORMAT strings usually come from blank-padded fixed-length
CHARACTER variables, trim leading and trailing blanks from them when they
are echoed to error messages for better readability.
Differential Revision: https://reviews.llvm.org/D129024
|
|
When Fw.d output editing takes place with directed rounding, make sure that
nonzero values that would normally be converted to zero round up (or down,
depending on the sign) to a scaled 1.
Differential Revision: https://reviews.llvm.org/D129021
|
|
In folding and in the runtime library for real MOD/MODULO(A,P),
detect overflow from the division A/P and return a properly signed
zero result. (When A/P overflows and both A and P are finite numbers
with nonzero P, the quotient would be a large integer when rounded to
the precision of the floating-point representation.)
Differential Revision: https://reviews.llvm.org/D129020
|