Skip to content

Commit 68e9306

Browse files
committed
Merge from 'master' to 'sycl-web' (#17)
CONFLICT (content): Merge conflict in clang/include/clang/Basic/LangOptions.h
2 parents d521eaf + 69aacaf commit 68e9306

File tree

135 files changed

+7926
-648
lines changed

Some content is hidden

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

135 files changed

+7926
-648
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3197,6 +3197,41 @@ The pragma can also be used with ``off`` which turns FP contraction off for a
31973197
section of the code. This can be useful when fast contraction is otherwise
31983198
enabled for the translation unit with the ``-ffp-contract=fast`` flag.
31993199
3200+
The ``#pragma float_control`` pragma allows precise floating-point
3201+
semantics and floating-point exception behavior to be specified
3202+
for a section of the source code. This pragma can only appear at file scope or
3203+
at the start of a compound statement (excluding comments). When using within a
3204+
compound statement, the pragma is active within the scope of the compound
3205+
statement. This pragma is modeled after a Microsoft pragma with the
3206+
same spelling and syntax. For pragmas specified at file scope, a stack
3207+
is supported so that the ``pragma float_control`` settings can be pushed or popped.
3208+
3209+
When ``pragma float_control(precise, on)`` is enabled, the section of code
3210+
governed by the pragma uses precise floating point semantics, effectively
3211+
``-ffast-math`` is disabled and ``-ffp-contract=on``
3212+
(fused multiply add) is enabled.
3213+
3214+
When ``pragma float_control(except, on)`` is enabled, the section of code governed
3215+
by the pragma behaves as though the command-line option
3216+
``-ffp-exception-behavior=strict`` is enabled,
3217+
when ``pragma float_control(precise, off)`` is enabled, the section of code
3218+
governed by the pragma behaves as though the command-line option
3219+
``-ffp-exception-behavior=ignore`` is enabled.
3220+
3221+
The full syntax this pragma supports is
3222+
``float_control(except|precise, on|off [, push])`` and
3223+
``float_control(push|pop)``.
3224+
The ``push`` and ``pop`` forms, including using ``push`` as the optional
3225+
third argument, can only occur at file scope.
3226+
3227+
.. code-block:: c++
3228+
3229+
for(...) {
3230+
// This block will be compiled with -fno-fast-math and -ffp-contract=on
3231+
#pragma float_control(precise, on)
3232+
a = b[i] * c[i] + e;
3233+
}
3234+
32003235
Specifying an attribute for multiple declarations (#pragma clang attribute)
32013236
===========================================================================
32023237

clang/include/clang/AST/Expr.h

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,26 +2107,48 @@ class ParenExpr : public Expr {
21072107
/// applied to a non-complex value, the former returns its operand and the
21082108
/// later returns zero in the type of the operand.
21092109
///
2110-
class UnaryOperator : public Expr {
2110+
class UnaryOperator final
2111+
: public Expr,
2112+
private llvm::TrailingObjects<UnaryOperator, FPOptions> {
21112113
Stmt *Val;
21122114

2115+
size_t numTrailingObjects(OverloadToken<FPOptions>) const {
2116+
return UnaryOperatorBits.HasFPFeatures ? 1 : 0;
2117+
}
2118+
2119+
FPOptions &getTrailingFPFeatures() {
2120+
assert(UnaryOperatorBits.HasFPFeatures);
2121+
return *getTrailingObjects<FPOptions>();
2122+
}
2123+
2124+
const FPOptions &getTrailingFPFeatures() const {
2125+
assert(UnaryOperatorBits.HasFPFeatures);
2126+
return *getTrailingObjects<FPOptions>();
2127+
}
2128+
21132129
public:
21142130
typedef UnaryOperatorKind Opcode;
21152131

2116-
UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK,
2117-
ExprObjectKind OK, SourceLocation l, bool CanOverflow)
2118-
: Expr(UnaryOperatorClass, type, VK, OK), Val(input) {
2119-
UnaryOperatorBits.Opc = opc;
2120-
UnaryOperatorBits.CanOverflow = CanOverflow;
2121-
UnaryOperatorBits.Loc = l;
2122-
setDependence(computeDependence(this));
2123-
}
2132+
protected:
2133+
UnaryOperator(const ASTContext &Ctx, Expr *input, Opcode opc, QualType type,
2134+
ExprValueKind VK, ExprObjectKind OK, SourceLocation l,
2135+
bool CanOverflow, FPOptions FPFeatures);
21242136

21252137
/// Build an empty unary operator.
2126-
explicit UnaryOperator(EmptyShell Empty) : Expr(UnaryOperatorClass, Empty) {
2138+
explicit UnaryOperator(bool HasFPFeatures, EmptyShell Empty)
2139+
: Expr(UnaryOperatorClass, Empty) {
21272140
UnaryOperatorBits.Opc = UO_AddrOf;
2141+
UnaryOperatorBits.HasFPFeatures = HasFPFeatures;
21282142
}
21292143

2144+
public:
2145+
static UnaryOperator *CreateEmpty(const ASTContext &C, bool hasFPFeatures);
2146+
2147+
static UnaryOperator *Create(const ASTContext &C, Expr *input, Opcode opc,
2148+
QualType type, ExprValueKind VK,
2149+
ExprObjectKind OK, SourceLocation l,
2150+
bool CanOverflow, FPOptions FPFeatures);
2151+
21302152
Opcode getOpcode() const {
21312153
return static_cast<Opcode>(UnaryOperatorBits.Opc);
21322154
}
@@ -2148,6 +2170,18 @@ class UnaryOperator : public Expr {
21482170
bool canOverflow() const { return UnaryOperatorBits.CanOverflow; }
21492171
void setCanOverflow(bool C) { UnaryOperatorBits.CanOverflow = C; }
21502172

2173+
// Get the FP contractability status of this operator. Only meaningful for
2174+
// operations on floating point types.
2175+
bool isFPContractableWithinStatement(const LangOptions &LO) const {
2176+
return getFPFeatures(LO).allowFPContractWithinStatement();
2177+
}
2178+
2179+
// Get the FENV_ACCESS status of this operator. Only meaningful for
2180+
// operations on floating point types.
2181+
bool isFEnvAccessOn(const LangOptions &LO) const {
2182+
return getFPFeatures(LO).allowFEnvAccess();
2183+
}
2184+
21512185
/// isPostfix - Return true if this is a postfix operation, like x++.
21522186
static bool isPostfix(Opcode Op) {
21532187
return Op == UO_PostInc || Op == UO_PostDec;
@@ -2214,6 +2248,30 @@ class UnaryOperator : public Expr {
22142248
const_child_range children() const {
22152249
return const_child_range(&Val, &Val + 1);
22162250
}
2251+
2252+
/// Is FPFeatures in Trailing Storage?
2253+
bool hasStoredFPFeatures() const { return UnaryOperatorBits.HasFPFeatures; }
2254+
2255+
protected:
2256+
/// Get FPFeatures from trailing storage
2257+
FPOptions getStoredFPFeatures() const { return getTrailingFPFeatures(); }
2258+
2259+
/// Set FPFeatures in trailing storage, used only by Serialization
2260+
void setStoredFPFeatures(FPOptions F) { getTrailingFPFeatures() = F; }
2261+
2262+
public:
2263+
// Get the FP features status of this operator. Only meaningful for
2264+
// operations on floating point types.
2265+
FPOptions getFPFeatures(const LangOptions &LO) const {
2266+
if (UnaryOperatorBits.HasFPFeatures)
2267+
return getStoredFPFeatures();
2268+
return FPOptions::defaultWithoutTrailingStorage(LO);
2269+
}
2270+
2271+
friend TrailingObjects;
2272+
friend class ASTReader;
2273+
friend class ASTStmtReader;
2274+
friend class ASTStmtWriter;
22172275
};
22182276

22192277
/// Helper class for OffsetOfExpr.

clang/include/clang/AST/Stmt.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ class alignas(void *) Stmt {
427427

428428
unsigned Opc : 5;
429429
unsigned CanOverflow : 1;
430+
//
431+
/// This is only meaningful for operations on floating point
432+
/// types when additional values need to be in trailing storage.
433+
/// It is 0 otherwise.
434+
unsigned HasFPFeatures : 1;
430435

431436
SourceLocation Loc;
432437
};
@@ -610,7 +615,7 @@ class alignas(void *) Stmt {
610615
unsigned OperatorKind : 6;
611616

612617
// Only meaningful for floating point types.
613-
unsigned FPFeatures : 8;
618+
unsigned FPFeatures : 14;
614619
};
615620

616621
class CXXRewrittenBinaryOperatorBitfields {

0 commit comments

Comments
 (0)