Skip to content

Commit 9d1d37a

Browse files
committed
Merge from 'main' to 'sycl-web' (31 commits)
CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.cpp
2 parents 9ba4288 + b40c534 commit 9d1d37a

File tree

116 files changed

+3370
-1664
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+3370
-1664
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,16 @@ New Compiler Flags
264264

265265
* ``-fopenacc`` was added as a part of the effort to support OpenACC in clang.
266266

267+
* ``-fcx-limited-range`` enables the naive mathematical formulas for complex
268+
division and multiplication with no NaN checking of results. The default is
269+
``-fno-cx-limited-range``, but this option is enabled by ``-ffast-math``.
270+
271+
* ``-fcx-fortran-rules`` enables the naive mathematical formulas for complex
272+
multiplication and enables application of Smith's algorithm for complex
273+
division. See SMITH, R. L. Algorithm 116: Complex division. Commun. ACM 5, 8
274+
(1962). The default is ``-fno-cx-fortran-rules``.
275+
276+
267277
Deprecated Compiler Flags
268278
-------------------------
269279

@@ -513,6 +523,7 @@ Improvements to Clang's diagnostics
513523
48 | static_assert(1 << 4 == 15);
514524
| ~~~~~~~^~~~~
515525
526+
- Clang now diagnoses definitions of friend function specializations, e.g. ``friend void f<>(int) {}``.
516527

517528
Improvements to Clang's time-trace
518529
----------------------------------
@@ -1001,6 +1012,9 @@ Floating Point Support in Clang
10011012
``__builtin_exp10f128`` builtins.
10021013
- Add ``__builtin_iszero``, ``__builtin_issignaling`` and
10031014
``__builtin_issubnormal``.
1015+
- Add support for C99's ``#pragma STDC CX_LIMITED_RANGE`` feature. This
1016+
enables the naive mathematical formulas for complex multiplication and
1017+
division, which are faster but do not correctly handle overflow and infinities.
10041018

10051019
AST Matchers
10061020
------------

clang/docs/UsersManual.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,6 +1468,7 @@ floating point semantic models: precise (the default), strict, and fast.
14681468
With the exception of ``-ffp-contract=fast``, using any of the options
14691469
below to disable any of the individual optimizations in ``-ffast-math``
14701470
will cause ``__FAST_MATH__`` to no longer be set.
1471+
``-ffast-math`` enables ``-fcx-limited-range``.
14711472

14721473
This option implies:
14731474

@@ -1834,6 +1835,20 @@ floating point semantic models: precise (the default), strict, and fast.
18341835
* ``16`` - Forces ``_Float16`` operations to be emitted without using excess
18351836
precision arithmetic.
18361837

1838+
.. option:: -fcx-limited-range:
1839+
1840+
This option enables the naive mathematical formulas for complex division and
1841+
multiplication with no NaN checking of results. The default is
1842+
``-fno-cx-limited-range``, but this option is enabled by the ``-ffast-math``
1843+
option.
1844+
1845+
.. option:: -fcx-fortran-rules:
1846+
1847+
This option enables the naive mathematical formulas for complex
1848+
multiplication and enables application of Smith's algorithm for complex
1849+
division. See SMITH, R. L. Algorithm 116: Complex division. Commun.
1850+
ACM 5, 8 (1962). The default is ``-fno-cx-fortran-rules``.
1851+
18371852
.. _floating-point-environment:
18381853

18391854
Accessing the floating point environment

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,8 @@ def err_qualified_friend_def : Error<
17121712
"friend function definition cannot be qualified with '%0'">;
17131713
def err_friend_def_in_local_class : Error<
17141714
"friend function cannot be defined in a local class">;
1715+
def err_friend_specialization_def : Error<
1716+
"friend function specialization cannot be defined">;
17151717
def err_friend_not_first_in_declaration : Error<
17161718
"'friend' must appear first in a non-function declaration">;
17171719
def err_using_decl_friend : Error<

clang/include/clang/Basic/FPOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, FPEvalMethod
2929
OPTION(BFloat16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, Float16ExcessPrecision)
3030
OPTION(FPAccuracy, LangOptions::FPAccuracyKind, 3, BFloat16ExcessPrecision)
3131
OPTION(MathErrno, bool, 1, BFloat16ExcessPrecision)
32+
OPTION(ComplexRange, LangOptions::ComplexRangeKind, 2, MathErrno)
3233
#undef OPTION

clang/include/clang/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
104104
FEATURE(swiftasynccc,
105105
PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) ==
106106
clang::TargetInfo::CCCR_OK)
107+
FEATURE(pragma_stdc_cx_limited_range, true)
107108
// Objective-C features
108109
FEATURE(objc_arr, LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
109110
FEATURE(objc_arc, LangOpts.ObjCAutoRefCount)

clang/include/clang/Basic/LangOptions.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ BENIGN_LANGOPT(NoSignedZero , 1, 0, "Permit Floating Point optimization wit
220220
BENIGN_LANGOPT(AllowRecip , 1, 0, "Permit Floating Point reciprocal")
221221
BENIGN_LANGOPT(ApproxFunc , 1, 0, "Permit Floating Point approximation")
222222

223+
ENUM_LANGOPT(ComplexRange, ComplexRangeKind, 2, CX_Full, "Enable use of range reduction for complex arithmetics.")
224+
223225
BENIGN_LANGOPT(ObjCGCBitmapPrint , 1, 0, "printing of GC's bitmap layout for __weak/__strong ivars")
224226

225227
BENIGN_LANGOPT(AccessControl , 1, 1, "C++ access control")

clang/include/clang/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ class LangOptions : public LangOptionsBase {
407407
IncompleteOnly = 3,
408408
};
409409

410+
enum ComplexRangeKind { CX_Full, CX_Limited, CX_Fortran };
411+
410412
public:
411413
/// The used language standard.
412414
LangStandard::Kind LangStd;
@@ -776,6 +778,7 @@ class FPOptions {
776778
setAllowFEnvAccess(true);
777779
else
778780
setAllowFEnvAccess(LangOptions::FPM_Off);
781+
setComplexRange(LO.getComplexRange());
779782
}
780783

781784
bool allowFPContractWithinStatement() const {

clang/include/clang/Basic/TokenKinds.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,11 @@ PRAGMA_ANNOTATION(pragma_fenv_access_ms)
919919
// handles them.
920920
PRAGMA_ANNOTATION(pragma_fenv_round)
921921

922+
// Annotation for #pragma STDC CX_LIMITED_RANGE
923+
// The lexer produces these so that they only take effect when the parser
924+
// handles them.
925+
PRAGMA_ANNOTATION(pragma_cx_limited_range)
926+
922927
// Annotation for #pragma float_control
923928
// The lexer produces these so that they only take effect when the parser
924929
// handles them.

clang/include/clang/Driver/Options.td

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,30 @@ defm offload_uniform_block : BoolFOption<"offload-uniform-block",
10621062
NegFlag<SetFalse, [], [ClangOption, CC1Option], "Don't assume">,
10631063
BothFlags<[], [ClangOption], " that kernels are launched with uniform block sizes (default true for CUDA/HIP and false otherwise)">>;
10641064

1065+
def fcx_limited_range : Joined<["-"], "fcx-limited-range">,
1066+
Group<f_Group>, Visibility<[ClangOption, CC1Option]>,
1067+
HelpText<"Basic algebraic expansions of complex arithmetic operations "
1068+
"involving are enabled.">;
1069+
1070+
def fno_cx_limited_range : Joined<["-"], "fno-cx-limited-range">,
1071+
Group<f_Group>, Visibility<[ClangOption, CC1Option]>,
1072+
HelpText<"Basic algebraic expansions of complex arithmetic operations "
1073+
"involving are disabled.">;
1074+
1075+
def fcx_fortran_rules : Joined<["-"], "fcx-fortran-rules">,
1076+
Group<f_Group>, Visibility<[ClangOption, CC1Option]>,
1077+
HelpText<"Range reduction is enabled for complex arithmetic operations.">;
1078+
1079+
def fno_cx_fortran_rules : Joined<["-"], "fno-cx-fortran-rules">,
1080+
Group<f_Group>, Visibility<[ClangOption, CC1Option]>,
1081+
HelpText<"Range reduction is disabled for complex arithmetic operations.">;
1082+
1083+
def complex_range_EQ : Joined<["-"], "complex-range=">, Group<f_Group>,
1084+
Visibility<[CC1Option]>,
1085+
Values<"full,limited,fortran">, NormalizedValuesScope<"LangOptions">,
1086+
NormalizedValues<["CX_Full", "CX_Limited", "CX_Fortran"]>,
1087+
MarshallingInfoEnum<LangOpts<"ComplexRange">, "CX_Full">;
1088+
10651089
// OpenCL-only Options
10661090
def cl_opt_disable : Flag<["-"], "cl-opt-disable">, Group<opencl_Group>,
10671091
Visibility<[ClangOption, CC1Option]>,
@@ -6661,6 +6685,12 @@ def J : JoinedOrSeparate<["-"], "J">,
66616685
Group<gfortran_Group>,
66626686
Alias<module_dir>;
66636687

6688+
let Visibility = [FlangOption] in {
6689+
def no_fortran_main : Flag<["-"], "fno-fortran-main">,
6690+
Visibility<[FlangOption]>, Group<f_Group>,
6691+
HelpText<"Do not include Fortran_main.a (provided by Flang) when linking">;
6692+
} // let Visibility = [ FlangOption ]
6693+
66646694
//===----------------------------------------------------------------------===//
66656695
// FC1 Options
66666696
//===----------------------------------------------------------------------===//

clang/include/clang/Parse/Parser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,10 @@ class Parser : public CodeCompletionHandler {
769769
/// #pragma STDC FENV_ROUND...
770770
void HandlePragmaFEnvRound();
771771

772+
/// Handle the annotation token produced for
773+
/// #pragma STDC CX_LIMITED_RANGE...
774+
void HandlePragmaCXLimitedRange();
775+
772776
/// Handle the annotation token produced for
773777
/// #pragma float_control
774778
void HandlePragmaFloatControl();

0 commit comments

Comments
 (0)