koops updated this revision to Diff 505869.
koops added a comment.
Herald added subscribers: jplehr, sunshaoce.

1. formatting
2. Adding lit test
3. Removing bind clause from the set of clauses passed during bind(parallel) to 
the OMPForDirective and bind(teams) to the OMPDistributeDirective.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144634/new/

https://reviews.llvm.org/D144634

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp

Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7803,6 +7803,52 @@
       CGF.EmitStmt(CS);
     }
   };
+  /* Bind */
+  SmallVector<OMPClause *, 6> newClauses;
+  for (auto clausePtr : S.clauses()) {
+    if (clausePtr->getClauseKind() != llvm::omp::Clause::OMPC_bind) {
+      newClauses.push_back(clausePtr);
+    }
+  }
+  ArrayRef<clang::OMPClause *> newAClauses(newClauses);
+
+  for (const auto *C : S.getClausesOfKind<OMPBindClause>()) {
+    OpenMPBindClauseKind bindParam = C->getBindKind();
+    switch (bindParam) {
+    case OMPC_BIND_parallel: {
+      OMPForDirective *ompForD = OMPForDirective::Create(
+          *(S.LoopDirCrParmV->C), S.LoopDirCrParmV->StartLoc,
+          S.LoopDirCrParmV->EndLoc, S.LoopDirCrParmV->CollapsedNum, newAClauses,
+          S.LoopDirCrParmV->AssociatedStmt, S.LoopDirCrParmV->Exprs, NULL, 0);
+      EmitOMPForDirective(*ompForD);
+      return;
+      break;
+    }
+    case OMPC_BIND_teams: {
+      OMPDistributeDirective *ompDistD = OMPDistributeDirective::Create(
+          *(S.LoopDirCrParmV->C), S.LoopDirCrParmV->StartLoc,
+          S.LoopDirCrParmV->EndLoc, S.LoopDirCrParmV->CollapsedNum, newAClauses,
+          S.LoopDirCrParmV->AssociatedStmt, S.LoopDirCrParmV->Exprs);
+      EmitOMPDistributeDirective(*ompDistD);
+      return;
+      break;
+    }
+    case OMPC_BIND_thread: {
+      /*
+      OMPSimdDirective *ompSimdD = OMPSimdDirective::Create(
+          *(S.LoopDirCrParmV->C), S.LoopDirCrParmV->StartLoc,
+          S.LoopDirCrParmV->EndLoc, S.LoopDirCrParmV->CollapsedNum,
+          newAClauses, S.LoopDirCrParmV->AssociatedStmt,
+          S.LoopDirCrParmV->Exprs);
+      EmitOMPSimdDirective(*ompSimdD);
+      return;
+      */
+      break;
+    }
+    case OMPC_BIND_unknown:
+      return;
+    }
+  }
   OMPLexicalScope Scope(*this, S, OMPD_unknown);
   CGM.getOpenMPRuntime().emitInlinedDirective(*this, OMPD_loop, CodeGen);
 }
Index: clang/lib/AST/StmtOpenMP.cpp
===================================================================
--- clang/lib/AST/StmtOpenMP.cpp
+++ clang/lib/AST/StmtOpenMP.cpp
@@ -2340,6 +2340,10 @@
   Dir->setDependentInits(Exprs.DependentInits);
   Dir->setFinalsConditions(Exprs.FinalsConditions);
   Dir->setPreInits(Exprs.PreInits);
+
+  Dir->LoopParamInit(C, StartLoc, EndLoc, CollapsedNum, Clauses, AssociatedStmt,
+                     Exprs);
+
   return Dir;
 }
 
@@ -2351,6 +2355,14 @@
       numLoopChildren(CollapsedNum, OMPD_loop), CollapsedNum);
 }
 
+void OMPGenericLoopDirective::LoopParamInit(
+    const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+    unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
+    const HelperExprs &Exprs) {
+  this->LoopDirCrParmV = new LoopDirCrParam(C, StartLoc, EndLoc, CollapsedNum,
+                                            Clauses, AssociatedStmt, Exprs);
+}
+
 OMPTeamsGenericLoopDirective *OMPTeamsGenericLoopDirective::Create(
     const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
     unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
Index: clang/include/clang/AST/StmtOpenMP.h
===================================================================
--- clang/include/clang/AST/StmtOpenMP.h
+++ clang/include/clang/AST/StmtOpenMP.h
@@ -5945,6 +5945,30 @@
          unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
          Stmt *AssociatedStmt, const HelperExprs &Exprs);
 
+  struct LoopDirCrParam {
+    const ASTContext *C;
+    SourceLocation StartLoc;
+    SourceLocation EndLoc;
+    unsigned CollapsedNum;
+    ArrayRef<OMPClause *> Clauses;
+    Stmt *AssociatedStmt;
+    const HelperExprs Exprs;
+
+    LoopDirCrParam(const ASTContext &C, SourceLocation StartLoc,
+                   SourceLocation EndLoc, unsigned CollapsedNum,
+                   ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
+                   const HelperExprs &Exprs)
+        : C(&C), StartLoc(StartLoc), EndLoc(EndLoc), CollapsedNum(CollapsedNum),
+          Clauses(Clauses), AssociatedStmt(AssociatedStmt), Exprs(Exprs) {}
+  };
+
+  void LoopParamInit(const ASTContext &C, SourceLocation StartLoc,
+                     SourceLocation EndLoc, unsigned CollapsedNum,
+                     ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
+                     const HelperExprs &Exprs);
+
+  struct LoopDirCrParam *LoopDirCrParmV;
+
   /// Creates an empty directive with a place for \a NumClauses clauses.
   ///
   /// \param C AST context.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D144634: [Clang][Ope... Sunil K via Phabricator via cfe-commits

Reply via email to