summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
authorAlexey Bataev <a.bataev@hotmail.com>2016-03-03 05:21:39 +0000
committerAlexey Bataev <a.bataev@hotmail.com>2016-03-03 05:21:39 +0000
commit94a4f0cb5f8a44e1228f1fd06c8d970125084c71 (patch)
tree5e5bfcc492ec4e95123b4a51523a59da17ebebf5 /clang/lib/Serialization/ASTReaderDecl.cpp
parent2a4985c929e93e623a2899f485f6f5f014bf4c83 (diff)
downloadbcm5719-llvm-94a4f0cb5f8a44e1228f1fd06c8d970125084c71.tar.gz
bcm5719-llvm-94a4f0cb5f8a44e1228f1fd06c8d970125084c71.zip
[OPENMP 4.0] Initial support for 'omp declare reduction' construct.
Add parsing, sema analysis and serialization/deserialization for 'declare reduction' construct. User-defined reductions are defined as #pragma omp declare reduction( reduction-identifier : typename-list : combiner ) [initializer ( initializer-expr )] These custom reductions may be used in 'reduction' clauses of OpenMP constructs. The combiner specifies how partial results can be combined into a single value. The combiner can use the special variable identifiers omp_in and omp_out that are of the type of the variables being reduced with this reduction-identifier. Each of them will denote one of the values to be combined before executing the combiner. It is assumed that the special omp_out identifier will refer to the storage that holds the resulting combined value after executing the combiner. As the initializer-expr value of a user-defined reduction is not known a priori the initializer-clause can be used to specify one. Then the contents of the initializer-clause will be used as the initializer for private copies of reduction list items where the omp_priv identifier will refer to the storage to be initialized. The special identifier omp_orig can also appear in the initializer-clause and it will refer to the storage of the original variable to be reduced. Differential Revision: http://reviews.llvm.org/D11182 llvm-svn: 262582
Diffstat (limited to 'clang/lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index 213f2aa0ecf..2389d671d42 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -356,6 +356,7 @@ namespace clang {
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
+ void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
/// We've merged the definition \p MergedDef into the existing definition
@@ -2394,6 +2395,15 @@ void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
D->setVars(Vars);
}
+void ASTDeclReader::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
+ VisitNamedDecl(D);
+ D->setLocation(Reader.ReadSourceLocation(F, Record, Idx));
+ D->setCombiner(Reader.ReadExpr(F));
+ D->setInitializer(Reader.ReadExpr(F));
+ D->PrevDeclInScope = Reader.ReadDeclID(F, Record, Idx);
+ D->setType(Reader.readType(F, Record, Idx));
+}
+
void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
VisitVarDecl(D);
}
@@ -2449,7 +2459,8 @@ static bool isConsumerInterestedIn(Decl *D, bool HasBody) {
isa<ImportDecl>(D) ||
isa<PragmaCommentDecl>(D) ||
isa<PragmaDetectMismatchDecl>(D) ||
- isa<OMPThreadPrivateDecl>(D))
+ isa<OMPThreadPrivateDecl>(D) ||
+ isa<OMPDeclareReductionDecl>(D))
return true;
if (VarDecl *Var = dyn_cast<VarDecl>(D))
return Var->isFileVarDecl() &&
@@ -3363,6 +3374,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
case DECL_OMP_THREADPRIVATE:
D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record[Idx++]);
break;
+ case DECL_OMP_DECLARE_REDUCTION:
+ D = OMPDeclareReductionDecl::CreateDeserialized(Context, ID);
+ break;
case DECL_OMP_CAPTUREDEXPR:
D = OMPCapturedExprDecl::CreateDeserialized(Context, ID);
break;
OpenPOWER on IntegriCloud