diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2011-10-11 02:20:01 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2011-10-11 02:20:01 +0000 |
commit | 276b061970939293f1abaf694bd3ef05b2cbda79 (patch) | |
tree | 95ac74efe0dda24d43635e5d034868d1379b6752 /lib/AST | |
parent | f11dbe9676832e599e046b2ed0f132a6bb858e0a (diff) |
Initial implementation of __atomic_* (everything except __atomic_is_lock_free).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r-- | lib/AST/Expr.cpp | 1 | ||||
-rw-r--r-- | lib/AST/ExprClassification.cpp | 1 | ||||
-rw-r--r-- | lib/AST/ExprConstant.cpp | 1 | ||||
-rw-r--r-- | lib/AST/ItaniumMangle.cpp | 1 | ||||
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 53 | ||||
-rw-r--r-- | lib/AST/StmtProfile.cpp | 4 |
6 files changed, 61 insertions, 0 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index dc37ac9226..465b490d47 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -1538,6 +1538,7 @@ bool Expr::isUnusedResultAWarning(SourceLocation &Loc, SourceRange &R1, } case CompoundAssignOperatorClass: case VAArgExprClass: + case AtomicExprClass: return false; case ConditionalOperatorClass: { diff --git a/lib/AST/ExprClassification.cpp b/lib/AST/ExprClassification.cpp index 624e9d2944..49c68213aa 100644 --- a/lib/AST/ExprClassification.cpp +++ b/lib/AST/ExprClassification.cpp @@ -162,6 +162,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::SubstNonTypeTemplateParmPackExprClass: case Expr::AsTypeExprClass: case Expr::ObjCIndirectCopyRestoreExprClass: + case Expr::AtomicExprClass: return Cl::CL_PRValue; // Next come the complicated cases. diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index c0f913d7ed..85cb40f9e0 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -2857,6 +2857,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { case Expr::AsTypeExprClass: case Expr::ObjCIndirectCopyRestoreExprClass: case Expr::MaterializeTemporaryExprClass: + case Expr::AtomicExprClass: return ICEDiag(2, E->getLocStart()); case Expr::InitListExprClass: diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index 2b93250fad..d4ac7229b2 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/lib/AST/ItaniumMangle.cpp @@ -2255,6 +2255,7 @@ recurse: case Expr::CXXNoexceptExprClass: case Expr::CUDAKernelCallExprClass: case Expr::AsTypeExprClass: + case Expr::AtomicExprClass: { // As bad as this diagnostic is, it's better than crashing. DiagnosticsEngine &Diags = Context.getDiags(); diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index dfa2612152..78d9a596fb 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1011,6 +1011,59 @@ void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) { OS << ")"; } +void StmtPrinter::VisitAtomicExpr(AtomicExpr *Node) { + const char *Name; + switch (Node->getOp()) { + case AtomicExpr::Load: + Name = "__atomic_load("; + break; + case AtomicExpr::Store: + Name = "__atomic_store("; + break; + case AtomicExpr::CmpXchgStrong: + Name = "__atomic_compare_exchange_strong("; + break; + case AtomicExpr::CmpXchgWeak: + Name = "__atomic_compare_exchange_weak("; + break; + case AtomicExpr::Xchg: + Name = "__atomic_exchange("; + break; + case AtomicExpr::Add: + Name = "__atomic_fetch_add("; + break; + case AtomicExpr::Sub: + Name = "__atomic_fetch_sub("; + break; + case AtomicExpr::And: + Name = "__atomic_fetch_and("; + break; + case AtomicExpr::Or: + Name = "__atomic_fetch_or("; + break; + case AtomicExpr::Xor: + Name = "__atomic_fetch_xor("; + break; + } + OS << Name; + PrintExpr(Node->getPtr()); + OS << ", "; + if (Node->getOp() != AtomicExpr::Load) { + PrintExpr(Node->getVal1()); + OS << ", "; + } + if (Node->isCmpXChg()) { + PrintExpr(Node->getVal2()); + OS << ", "; + } + PrintExpr(Node->getOrder()); + if (Node->isCmpXChg()) { + OS << ", "; + PrintExpr(Node->getOrderFail()); + } + OS << ")"; +} + // C++ void StmtPrinter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *Node) { const char *OpStrings[NUM_OVERLOADED_OPERATORS] = { diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp index 12321ef0d6..df49e843f9 100644 --- a/lib/AST/StmtProfile.cpp +++ b/lib/AST/StmtProfile.cpp @@ -468,6 +468,10 @@ void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { } } +void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { + VisitExpr(S); +} + static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, UnaryOperatorKind &UnaryOp, BinaryOperatorKind &BinaryOp) { |