s-watanabe314 wrote:

Sorry again for the delay. I have resumed addressing the review feedback and 
organized the changes into two commits.
These patches were developed with assistance from Copilot.

### Commit 1: Determine REAL(16) support from the backend

- Removed dependencies on build-time macros such as 
`FLANG_RUNTIME_F128_MATH_LIB` from the frontend’s REAL(16) support check.
- The check now determines whether the LLVM backend considers `f128` legal, or 
provides libcall names for all four basic arithmetic operations: addition, 
subtraction, multiplication, and division. The presence of these names does not 
guarantee that the corresponding implementations are available in the target 
environment.
- Updated tests that check frontend REAL(16) support to use the 
`flang-frontend-supports-f128` feature.

### Commit 2: Separate Flang and Flang-RT REAL(16) configuration

- Split the shared `FlangCommon.cmake` configuration, moving the 
Flang-RT-specific settings into `FlangRTFloat128.cmake`. The `quadmath.h` 
discovery needed for Flang’s host-side constant folding remains in 
`FindFlangQuadmath.cmake`.
- When building Flang-RT libraries in non-MSVC configurations, 
`libflang_rt.quadmath` is built regardless of whether a math provider is 
available. Without a provider, the archive contains no math entry points.
- For non-MSVC targets, the Flang driver adds `libflang_rt.quadmath` when 
linking the Fortran runtime libraries, independently of the compiler’s 
build-time math-provider configuration. It no longer links `libquadmath` 
automatically; users must specify `-lquadmath` when its functions are needed.
- For MSVC configurations, the math sources remain part of `flang_rt.runtime`.

### Bootstrapping Flang-RT

Since REAL(16) support cannot be probed using the unfinished Flang compiler 
during bootstrapping, the build passes `FORTRAN_SUPPORTS_REAL16` as follows:

- An explicit setting takes precedence.
- Otherwise, it passes `ON` when a math provider is explicitly selected, or 
when the target is x86_64 or AArch64.
- For other native targets, it passes `ON` if the C `long double` type has 113 
bits of significand precision.
- If none of these conditions applies, it leaves the setting unspecified.

This is intended to minimize disruption to existing native builds. A standalone 
Flang-RT build still probes the Fortran compiler’s REAL(16) support unless the 
setting is explicitly provided.

### Validation on other platforms

The environments and targets available to me for testing are limited to x86_64 
and AArch64, so I cannot check other host/target combinations locally. Are 
these configurations covered by LLVM’s existing CI? Would it be acceptable to 
rely on LLVM CI and revert if problems arise, or would you recommend another 
way to validate these changes? I would appreciate the community’s guidance on 
how best to proceed.

https://github.com/llvm/llvm-project/pull/221907
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to