Skip to content

Commit

Permalink
Merge from 'master' to 'sycl-web' (#17)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/include/clang/Basic/LangOptions.h
  • Loading branch information
bader committed May 2, 2020
2 parents d521eaf + 69aacaf commit 68e9306
Show file tree
Hide file tree
Showing 135 changed files with 7,926 additions and 648 deletions.
35 changes: 35 additions & 0 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3197,6 +3197,41 @@ The pragma can also be used with ``off`` which turns FP contraction off for a
section of the code. This can be useful when fast contraction is otherwise
enabled for the translation unit with the ``-ffp-contract=fast`` flag.
The ``#pragma float_control`` pragma allows precise floating-point
semantics and floating-point exception behavior to be specified
for a section of the source code. This pragma can only appear at file scope or
at the start of a compound statement (excluding comments). When using within a
compound statement, the pragma is active within the scope of the compound
statement. This pragma is modeled after a Microsoft pragma with the
same spelling and syntax. For pragmas specified at file scope, a stack
is supported so that the ``pragma float_control`` settings can be pushed or popped.
When ``pragma float_control(precise, on)`` is enabled, the section of code
governed by the pragma uses precise floating point semantics, effectively
``-ffast-math`` is disabled and ``-ffp-contract=on``
(fused multiply add) is enabled.
When ``pragma float_control(except, on)`` is enabled, the section of code governed
by the pragma behaves as though the command-line option
``-ffp-exception-behavior=strict`` is enabled,
when ``pragma float_control(precise, off)`` is enabled, the section of code
governed by the pragma behaves as though the command-line option
``-ffp-exception-behavior=ignore`` is enabled.
The full syntax this pragma supports is
``float_control(except|precise, on|off [, push])`` and
``float_control(push|pop)``.
The ``push`` and ``pop`` forms, including using ``push`` as the optional
third argument, can only occur at file scope.
.. code-block:: c++
for(...) {
// This block will be compiled with -fno-fast-math and -ffp-contract=on
#pragma float_control(precise, on)
a = b[i] * c[i] + e;
}
Specifying an attribute for multiple declarations (#pragma clang attribute)
===========================================================================
Expand Down
78 changes: 68 additions & 10 deletions clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -2107,26 +2107,48 @@ class ParenExpr : public Expr {
/// applied to a non-complex value, the former returns its operand and the
/// later returns zero in the type of the operand.
///
class UnaryOperator : public Expr {
class UnaryOperator final
: public Expr,
private llvm::TrailingObjects<UnaryOperator, FPOptions> {
Stmt *Val;

size_t numTrailingObjects(OverloadToken<FPOptions>) const {
return UnaryOperatorBits.HasFPFeatures ? 1 : 0;
}

FPOptions &getTrailingFPFeatures() {
assert(UnaryOperatorBits.HasFPFeatures);
return *getTrailingObjects<FPOptions>();
}

const FPOptions &getTrailingFPFeatures() const {
assert(UnaryOperatorBits.HasFPFeatures);
return *getTrailingObjects<FPOptions>();
}

public:
typedef UnaryOperatorKind Opcode;

UnaryOperator(Expr *input, Opcode opc, QualType type, ExprValueKind VK,
ExprObjectKind OK, SourceLocation l, bool CanOverflow)
: Expr(UnaryOperatorClass, type, VK, OK), Val(input) {
UnaryOperatorBits.Opc = opc;
UnaryOperatorBits.CanOverflow = CanOverflow;
UnaryOperatorBits.Loc = l;
setDependence(computeDependence(this));
}
protected:
UnaryOperator(const ASTContext &Ctx, Expr *input, Opcode opc, QualType type,
ExprValueKind VK, ExprObjectKind OK, SourceLocation l,
bool CanOverflow, FPOptions FPFeatures);

/// Build an empty unary operator.
explicit UnaryOperator(EmptyShell Empty) : Expr(UnaryOperatorClass, Empty) {
explicit UnaryOperator(bool HasFPFeatures, EmptyShell Empty)
: Expr(UnaryOperatorClass, Empty) {
UnaryOperatorBits.Opc = UO_AddrOf;
UnaryOperatorBits.HasFPFeatures = HasFPFeatures;
}

public:
static UnaryOperator *CreateEmpty(const ASTContext &C, bool hasFPFeatures);

static UnaryOperator *Create(const ASTContext &C, Expr *input, Opcode opc,
QualType type, ExprValueKind VK,
ExprObjectKind OK, SourceLocation l,
bool CanOverflow, FPOptions FPFeatures);

Opcode getOpcode() const {
return static_cast<Opcode>(UnaryOperatorBits.Opc);
}
Expand All @@ -2148,6 +2170,18 @@ class UnaryOperator : public Expr {
bool canOverflow() const { return UnaryOperatorBits.CanOverflow; }
void setCanOverflow(bool C) { UnaryOperatorBits.CanOverflow = C; }

// Get the FP contractability status of this operator. Only meaningful for
// operations on floating point types.
bool isFPContractableWithinStatement(const LangOptions &LO) const {
return getFPFeatures(LO).allowFPContractWithinStatement();
}

// Get the FENV_ACCESS status of this operator. Only meaningful for
// operations on floating point types.
bool isFEnvAccessOn(const LangOptions &LO) const {
return getFPFeatures(LO).allowFEnvAccess();
}

/// isPostfix - Return true if this is a postfix operation, like x++.
static bool isPostfix(Opcode Op) {
return Op == UO_PostInc || Op == UO_PostDec;
Expand Down Expand Up @@ -2214,6 +2248,30 @@ class UnaryOperator : public Expr {
const_child_range children() const {
return const_child_range(&Val, &Val + 1);
}

/// Is FPFeatures in Trailing Storage?
bool hasStoredFPFeatures() const { return UnaryOperatorBits.HasFPFeatures; }

protected:
/// Get FPFeatures from trailing storage
FPOptions getStoredFPFeatures() const { return getTrailingFPFeatures(); }

/// Set FPFeatures in trailing storage, used only by Serialization
void setStoredFPFeatures(FPOptions F) { getTrailingFPFeatures() = F; }

public:
// Get the FP features status of this operator. Only meaningful for
// operations on floating point types.
FPOptions getFPFeatures(const LangOptions &LO) const {
if (UnaryOperatorBits.HasFPFeatures)
return getStoredFPFeatures();
return FPOptions::defaultWithoutTrailingStorage(LO);
}

friend TrailingObjects;
friend class ASTReader;
friend class ASTStmtReader;
friend class ASTStmtWriter;
};

/// Helper class for OffsetOfExpr.
Expand Down
7 changes: 6 additions & 1 deletion clang/include/clang/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,11 @@ class alignas(void *) Stmt {

unsigned Opc : 5;
unsigned CanOverflow : 1;
//
/// This is only meaningful for operations on floating point
/// types when additional values need to be in trailing storage.
/// It is 0 otherwise.
unsigned HasFPFeatures : 1;

SourceLocation Loc;
};
Expand Down Expand Up @@ -610,7 +615,7 @@ class alignas(void *) Stmt {
unsigned OperatorKind : 6;

// Only meaningful for floating point types.
unsigned FPFeatures : 8;
unsigned FPFeatures : 14;
};

class CXXRewrittenBinaryOperatorBitfields {
Expand Down
Loading

0 comments on commit 68e9306

Please sign in to comment.