[PATCH] D10765: [OPENMP] Parsing and sema support for #pragma omp target data" directive.

Alexey Bataev a.bataev at hotmail.com
Thu Jul 16 21:53:30 PDT 2015


ABataev added inline comments.

================
Comment at: lib/CodeGen/CGExpr.cpp:1963
@@ -1963,1 +1962,3 @@
+      } 
+
       assert(isa<BlockDecl>(CurCodeDecl));
----------------
Restore original file

================
Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:1099
@@ -1098,4 +1098,3 @@
 /// }
-static void emitOMPIfClause(CodeGenFunction &CGF, const Expr *Cond,
-                            const RegionCodeGenTy &ThenGen,
-                            const RegionCodeGenTy &ElseGen) {
+void CodeGenFunction::EmitOMPIfClause(CodeGenFunction &CGF, const Expr *Cond,
+                                      const RegionCodeGenTy &ThenGen,
----------------
1. If EmitOMPIfClause is now a part of CodeGenFunction, it must be moved to CGStmtOpenmp.cpp.
2. The first argument CGF is not required, so remove it and use '*this' instead.
3. This changes must be committed in a separate patch (for codegen).

================
Comment at: lib/CodeGen/CGStmtOpenMP.cpp:2124-2152
@@ -2123,1 +2123,30 @@
 }
+
+// Generate the instructions for '#pragma omp target data' directive.
+void CodeGenFunction::EmitOMPTargetDataDirective(
+    const OMPTargetDataDirective &S) {
+
+  // if clause condition
+  const Expr *IfCond = nullptr;
+  if (auto C = S.getSingleClause(OMPC_if)) {
+    IfCond = cast<OMPIfClause>(C)->getCondition();
+  }
+
+  if (IfCond) {
+    auto &&ThenGen = [](CodeGenFunction &CGF) { /*code gen for data mapping*/ };
+    auto &&ElseGen = [](CodeGenFunction &CGF) {};
+    CodeGenFunction::EmitOMPIfClause(*this, IfCond, ThenGen, ElseGen);
+  }
+
+  auto CS = cast<CapturedStmt>(S.getAssociatedStmt());
+
+  CGM.getOpenMPRuntime().emitInlinedDirective(
+      *this, OMPD_target_data,
+      [&CS](CodeGenFunction &CGF) { CGF.EmitStmt(CS->getCapturedStmt()); });
+
+  if (IfCond) {
+    auto &&ThenGen = [](CodeGenFunction &CGF) { /*code gen for data mapping*/ };
+    auto &&ElseGen = [](CodeGenFunction &CGF) {};
+    CodeGenFunction::EmitOMPIfClause(*this, IfCond, ThenGen, ElseGen);
+  }
+}
----------------
As the first commit we can ignore all clauses, just call EmitStmt(cast<CapturedStmt>(S.getAssociateStmt())->getCapturedStmt());

================
Comment at: lib/Parse/ParseOpenMP.cpp:65
@@ -60,1 +64,3 @@
+
+      if (!TokenIsAnnotation && DKind == OMPD_unknown) {
         TokenMatched =
----------------
SDKind == OMPD_unknown

================
Comment at: lib/Parse/ParseOpenMP.cpp:68-69
@@ -61,2 +67,4 @@
             (i == 0) && !P.getPreprocessor().getSpelling(Tok).compare("point");
+      } else if (!TokenIsAnnotation && DKind == OMPD_target) {
+        TokenMatched = !P.getPreprocessor().getSpelling(Tok).compare("data");
       } else {
----------------
        TokenMatched =
            (i == 0) && !P.getPreprocessor().getSpelling(Tok).compare("point") ||
            (i == 1) && !P.getPreprocessor().getSpelling(Tok).compare("data");


http://reviews.llvm.org/D10765







More information about the cfe-commits mailing list