Re: [PATCH] D16759: [OpenMP] Parsing + sema for target parallel for directive.

2016-02-03 Thread Arpith Jacob via cfe-commits
arpith-jacob marked an inline comment as done.
arpith-jacob added a comment.

Alexey, I've made the change in the comments.  Thanks very much for your time!


http://reviews.llvm.org/D16759



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-03 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, hfinkel.
arpith-jacob added subscribers: cfe-commits, carlo.bertolli, sfantao, kkwli0, 
caomhin, fraggamuffin.
Herald added a subscriber: jholewinski.

This patch adds base support for codegen of the target directive on the NVPTX 
device.

http://reviews.llvm.org/D17877

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_target_codegen.cpp

Index: test/OpenMP/nvptx_target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_codegen.cpp
@@ -0,0 +1,587 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
+// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
+  // CHECK-NEXT: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK-NEXT: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+
+  // CHECK: define {{.*}}void [[T1]]()
+  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-NEXT: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-NEXT: [[A:%.+]] = sub i32 [[WS]], 1
+  // CHECK-NEXT: [[B:%.+]] = sub i32 [[NTID]], 1
+  // CHECK-NEXT: [[C:%.+]] = xor i32 [[A]], -1
+  // CHECK-NEXT: [[MID:%.+]] = and i32 [[B]], [[C]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+  //
+  // CHECK: [[CHECK_WORKER]]
+  // CHECK-NEXT: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  //
+  // CHECK: [[WORKER]]
+  // CHECK-NEXT: call void [[T1]]_worker()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[MASTER]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+  // CHECK-NEXT: br label {{%?}}[[TERM:.+]]
+  //
+  // CHECK: [[TERM]]
+  // CHECK-NEXT: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+  #pragma omp target
+  {
+  }
+
+  // CHECK-NOT: define {{.*}}void [[T2:@__omp_offloading_.+foo.+]]_worker()
+  #pragma omp target if(0)
+  {
+  }
+
+  // CHECK: define {{.*}}void [[T3:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]

[PATCH] D17890: [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added a reviewer: jlebar.
arpith-jacob added subscribers: carlo.bertolli, sfantao, caomhin, cfe-commits.

Support for CUDA printf is exploited to support printf for an NVPTX OpenMP 
device.

To reflect the support of both programming models, the file CGCUDABuiltin.cpp 
has been changed to CGGPUBuiltin.cpp, and the call EmitCUDADevicePrintfCallExpr 
has been changed to EmitGPUDevicePrintfCallExpr.

http://reviews.llvm.org/D17890

Files:
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGCUDABuiltin.cpp
  lib/CodeGen/CGGPUBuiltin.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.h
  test/OpenMP/nvptx_target_printf_codegen.c

Index: test/OpenMP/nvptx_target_printf_codegen.c
===
--- /dev/null
+++ test/OpenMP/nvptx_target_printf_codegen.c
@@ -0,0 +1,90 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+
+#include 
+
+// expected-no-diagnostics
+extern int printf(const char *, ...);
+extern int vprintf(const char *, va_list);
+
+// Check a simple call to printf end-to-end.
+// CHECK: [[SIMPLE_PRINTF_TY:%[a-zA-Z0-9_]+]] = type { i32, i64, double }
+int CheckSimple() {
+// CHECK: define {{.*}}void [[T1:@__omp_offloading_.+CheckSimple.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T1]]()
+// Alloca in entry block.
+// CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca [[SIMPLE_PRINTF_TY]]
+// CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID:%.+]], [[MID:%.+]]
+// CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+// CHECK: call void [[T1]]_worker()
+
+// CHECK: {{%?}}[[MASTER:.+]]:
+// CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+// printf in master-only basic block.
+// CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt
+const char* fmt = "%d %lld %f";
+// CHECK: [[PTR0:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 0
+// CHECK: store i32 1, i32* [[PTR0]], align 4
+// CHECK: [[PTR1:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 1
+// CHECK: store i64 2, i64* [[PTR1]], align 8
+// CHECK: [[PTR2:%[0-9]+]] = getelementptr inbounds [[SIMPLE_PRINTF_TY]], [[SIMPLE_PRINTF_TY]]* [[BUF]], i32 0, i32 2
+
+// CHECK: store double 3.0{{[^,]*}}, double* [[PTR2]], align 8
+// CHECK: [[BUF_CAST:%[0-9]+]] = bitcast [[SIMPLE_PRINTF_TY]]* [[BUF]] to i8*
+// CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF_CAST]])
+printf(fmt, 1, 2ll, 3.0);
+  }
+
+  return 0;
+}
+
+void CheckNoArgs() {
+// CHECK: define {{.*}}void [[T2:@__omp_offloading_.+CheckNoArgs.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T2]]()
+// CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID:%.+]], [[MID:%.+]]
+// CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+// CHECK: call void [[T2]]_worker()
+
+// printf in master-only basic block.
+// CHECK: {{%?}}[[MASTER:.+]]:
+// CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+
+// CHECK: call i32 @vprintf({{.*}}, i8* null){{$}}
+printf("hello, world!");
+  }
+}
+
+// Check that printf's alloca happens in the entry block, not inside the if
+// statement.
+int foo;
+void CheckAllocaIsInEntryBlock() {
+// CHECK: define {{.*}}void [[T3:@__omp_offloading_.+CheckAllocaIsInEntryBlock.+]]_worker()
+#pragma omp target
+  {
+// Entry point.
+// CHECK: define {{.*}}void [[T3]](
+// Alloca in entry block.
+// CHECK: alloca %printf_args
+// CHECK: [[EXCESS:%.+]] = icmp ugt i32 [[TID:%.+]], [[MID:%.+]]
+// CHECK: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+// CHECK: call void [[T3]]_worker()
+
+// CHECK: {{%?}}[[MASTER:.+]]:
+// CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+// CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, 

Re: [PATCH] D17890: [OpenMP][NVPTX][CUDA] Adding support for printf for an NVPTX OpenMP device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob added a comment.

Thanks for the quick review!  The test cases are the same as the CUDA version 
so it should be fine.


http://reviews.llvm.org/D17890



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 49851.
arpith-jacob added a comment.

Addressed feedback; see inline comments for details.


http://reviews.llvm.org/D17877

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_target_codegen.cpp

Index: test/OpenMP/nvptx_target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_codegen.cpp
@@ -0,0 +1,587 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
+// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
+  // CHECK-NEXT: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK-NEXT: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+
+  // CHECK: define {{.*}}void [[T1]]()
+  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-NEXT: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-NEXT: [[A:%.+]] = sub i32 [[WS]], 1
+  // CHECK-NEXT: [[B:%.+]] = sub i32 [[NTID]], 1
+  // CHECK-NEXT: [[C:%.+]] = xor i32 [[A]], -1
+  // CHECK-NEXT: [[MID:%.+]] = and i32 [[B]], [[C]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+  //
+  // CHECK: [[CHECK_WORKER]]
+  // CHECK-NEXT: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  //
+  // CHECK: [[WORKER]]
+  // CHECK-NEXT: call void [[T1]]_worker()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[MASTER]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+  // CHECK-NEXT: br label {{%?}}[[TERM:.+]]
+  //
+  // CHECK: [[TERM]]
+  // CHECK-NEXT: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+  #pragma omp target
+  {
+  }
+
+  // CHECK-NOT: define {{.*}}void [[T2:@__omp_offloading_.+foo.+]]_worker()
+  #pragma omp target if(0)
+  {
+  }
+
+  // CHECK: define {{.*}}void [[T3:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK

Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-04 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 15 inline comments as done.


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:348
@@ +347,2 @@
+  initializeEnvironment();
+}

This function will also handle global variables from the 'declare target' 
construct in the future.

void CGOpenMPRuntimeNVPTX::createOffloadEntry(llvm::Constant *ID,
  llvm::Constant *Addr,
  uint64_t Size) {
  auto *F = dyn_cast(Addr);
  // TODO: Add support for global variables on the device after declare target
  // support.
  if (!F)
return;


Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:348
@@ +347,2 @@
+  initializeEnvironment();
+}

arpith-jacob wrote:
> This function will also handle global variables from the 'declare target' 
> construct in the future.
> 
> void CGOpenMPRuntimeNVPTX::createOffloadEntry(llvm::Constant *ID,
>   llvm::Constant *Addr,
>   uint64_t Size) {
>   auto *F = dyn_cast(Addr);
>   // TODO: Add support for global variables on the device after declare target
>   // support.
>   if (!F)
> return;
> What about exceptions? Do you plan to support them? If yes, add tests for 
> classes with constructors/destructors and exceptions

This backend does not support exceptions.  We plan to send a separate patch 
that will selectively deactivate exceptions in target regions generated for the 
GPU. 


http://reviews.llvm.org/D17877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-09 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 50143.
arpith-jacob marked 2 inline comments as done.
arpith-jacob added a comment.

Stylistic changes to address feedback.


http://reviews.llvm.org/D17877

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.h
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.h
  test/OpenMP/nvptx_target_codegen.cpp

Index: test/OpenMP/nvptx_target_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/nvptx_target_codegen.cpp
@@ -0,0 +1,587 @@
+// Test target codegen - host bc file has to be created first.
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -omptargets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx-unknown-unknown -omptargets=nvptx-nvidia-cuda -emit-llvm %s -fopenmp-is-device -omp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[OMP_NT:@.+]] = common addrspace(3) global i32 0
+// CHECK-DAG: [[OMP_WID:@.+]] = common addrspace(3) global i64 0
+
+template
+struct TT{
+  tx X;
+  ty Y;
+};
+
+int foo(int n) {
+  int a = 0;
+  short aa = 0;
+  float b[10];
+  float bn[n];
+  double c[5][10];
+  double cn[5][n];
+  TT d;
+
+  // CHECK: define {{.*}}void [[T1:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[NT:%.+]] = load i32, i32 addrspace(3)* [[OMP_NT]]
+  // CHECK-NEXT: [[IS_ACTIVE:%.+]] = icmp slt i32 [[TID]], [[NT]]
+  // CHECK-NEXT: br i1 [[IS_ACTIVE]], label {{%?}}[[EXEC_PARALLEL:.+]], label {{%?}}[[BAR_PARALLEL:.+]]
+  //
+  // CHECK: [[EXEC_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[TERM_PARALLEL:.+]]
+  //
+  // CHECK: [[TERM_PARALLEL]]
+  // CHECK-NEXT: br label {{%?}}[[BAR_PARALLEL]]
+  //
+  // CHECK: [[BAR_PARALLEL]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[AWAIT_WORK]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+
+  // CHECK: define {{.*}}void [[T1]]()
+  // CHECK: [[NTID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
+  // CHECK-NEXT: [[WS:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.warpsize()
+  // CHECK-NEXT: [[A:%.+]] = sub i32 [[WS]], 1
+  // CHECK-NEXT: [[B:%.+]] = sub i32 [[NTID]], 1
+  // CHECK-NEXT: [[C:%.+]] = xor i32 [[A]], -1
+  // CHECK-NEXT: [[MID:%.+]] = and i32 [[B]], [[C]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: [[EXCESS:%.+]] = icmp ugt i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[EXCESS]], label {{%?}}[[EXIT:.+]], label {{%?}}[[CHECK_WORKER:.+]]
+  //
+  // CHECK: [[CHECK_WORKER]]
+  // CHECK-NEXT: [[IS_WORKER:%.+]] = icmp ult i32 [[TID]], [[MID]]
+  // CHECK-NEXT: br i1 [[IS_WORKER]], label {{%?}}[[WORKER:.+]], label {{%?}}[[MASTER:.+]]
+  //
+  // CHECK: [[WORKER]]
+  // CHECK-NEXT: call void [[T1]]_worker()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[MASTER]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
+  // CHECK-NEXT: call void @__kmpc_kernel_init(i32 0, i32 [[TID]])
+  // CHECK-NEXT: br label {{%?}}[[TERM:.+]]
+  //
+  // CHECK: [[TERM]]
+  // CHECK-NEXT: store i64 0, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: br label {{%?}}[[EXIT]]
+  //
+  // CHECK: [[EXIT]]
+  // CHECK-NEXT: ret void
+  #pragma omp target
+  {
+  }
+
+  // CHECK-NOT: define {{.*}}void [[T2:@__omp_offloading_.+foo.+]]_worker()
+  #pragma omp target if(0)
+  {
+  }
+
+  // CHECK: define {{.*}}void [[T3:@__omp_offloading_.+foo.+]]_worker()
+  // CHECK: br label {{%?}}[[AWAIT_WORK:.+]]
+  //
+  // CHECK: [[AWAIT_WORK]]
+  // CHECK-NEXT: call void @llvm.nvvm.barrier0()
+  // CHECK-NEXT: [[WORK:%.+]] = load i64, i64 addrspace(3)* [[OMP_WID]],
+  // CHECK-NEXT: [[SHOULD_EXIT:%.+]] = icmp eq i64 [[WORK]], 0
+  // CHECK-NEXT: br i1 [[SHOULD_EXIT]], label {{%?}}[[EXIT:.+]], label {{%?}}[[SEL_WORKERS:.+]]
+  //
+  // CHECK: [[SEL_WORKERS]]
+  // CHECK-NEXT: [[TID:%.+]] = call i32 @llvm.nvvm.

Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-09 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 9 inline comments as done.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:69
@@ +68,3 @@
+  /// evaluates to false.
+  virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
&D,
+StringRef ParentName,

Do we need 'virtual'?  This function needs to be called by the NVPTX 
implementation (in emitTargetOutlinedFunction) but doesn't need to be 
overridden.


http://reviews.llvm.org/D17877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17877: [OpenMP] Base support for target directive codegen on NVPTX device.

2016-03-09 Thread Arpith Jacob via cfe-commits
arpith-jacob marked an inline comment as done.


Comment at: lib/CodeGen/CGOpenMPRuntime.h:69
@@ +68,3 @@
+  /// evaluates to false.
+  virtual void emitTargetOutlinedFunctionHelper(const OMPExecutableDirective 
&D,
+StringRef ParentName,

ABataev wrote:
> arpith-jacob wrote:
> > Do we need 'virtual'?  This function needs to be called by the NVPTX 
> > implementation (in emitTargetOutlinedFunction) but doesn't need to be 
> > overridden.
> I we don't need it in 'CGOpenMPRuntime', then why it is here?
Alexey, both CGOpenMPRuntime and CGOpenMPRuntimeNVPTX call 
emitTargetOutlinedFunctionHelper().

CGOpenMPRuntime::emitTargetOutlinedFunction() sets up the 'codegen' lambda and 
then calls CGOpenMPRuntime::emitTargetOutlinedFunctionHelper() to do the work.

In the same way, CGOpenMPRuntimeNVPTX::emitTargetOutlinedFunction() sets up the 
'codegen' lambda for the GPU and then calls 
CGOpenMPRuntime::emitTargetOutlinedFunctionHelper().

Does that make sense?


http://reviews.llvm.org/D17877



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-07 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: kkwli0, sfantao, fraggamuffin, hfinkel, ABataev, 
carlo.bertolli.
arpith-jacob added a subscriber: cfe-commits.

This patch adds parsing and sema support for "#pragma omp target enter data" 
and "#pragma omp target exit data" directives.

http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/OpenMPClause.cpp
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_device_messages.cpp
  test/OpenMP/target_exit_data_if_messages.cpp
  test/OpenMP/target_exit_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,12 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
+  case Stmt::OMPTargetExitDataDirectiveClass:
+K = CXCursor_OMPTargetExitDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1949,6 +1949,8 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
+  void VisitOMPTargetExitDataDirective(const OMPTargetExitDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2624,6 +2626,16 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
+void EnqueueVisitor::VisitOMPTargetExitDataDirective(
+const OMPTargetExitDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4506,6 +4518,10 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
+  case CXCursor_OMPTargetExitDataDirective:
+return cxstring::createRef("OMPTargetExitDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_exit_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target exit data map(r) // expected-error {{map type must be specified for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(always, from: r)
+  #pragma omp target exit data map(delete: r)
+  #pragma omp target exit data map(release: r)
+  #pragma omp target exit data map(always, alloc: r) // expected-error {{map type 'alloc' is not allowed for '#pragma omp target exit data'}}
+  #pragma omp target exit data map(to: r) // expected-error {{map type 'to' is not allowed for '#pragma omp target exit data'}}
+
+  retur

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-07 Thread Arpith Jacob via cfe-commits
arpith-jacob added inline comments.


Comment at: lib/Parse/ParseOpenMP.cpp:42
@@ -37,1 +41,3 @@
+  {OMPD_unknown /*target exit*/, OMPD_unknown /*data*/,
+   OMPD_target_exit_data},
   {OMPD_for, OMPD_simd, OMPD_for_simd},

I have written this code based on the comments in the 'target data' patch and 
also the approach to parsing 'cancellation'.  This requires hard coded array 
index numbers below (see diff with cancellation and point tokens).  If anyone 
can suggest better alternatives I will be happy to rework the code.


Comment at: lib/Sema/SemaOpenMP.cpp:5918
@@ -5866,1 +5917,3 @@
+}
+
 OMPClause *Sema::ActOnOpenMPSafelenClause(Expr *Len, SourceLocation StartLoc,

This method is required to ensure that target enter/exit directives always have 
a map clause.  It can be reused by other directives such as target data.


Comment at: lib/Sema/SemaOpenMP.cpp:8507
@@ +8506,3 @@
+  Diag(StartLoc, diag::err_omp_invalid_map_type_for_directive) <<
+  static_cast(IsMapTypeImplicit) <<
+  getOpenMPSimpleClauseTypeName(OMPC_map, MapType) <<

I have to capture 'IsMapTypeImplicit' from the parser for more informative 
error messages.  This helps me support the following case:

#pragma omp target enter data map(r) // expected-error {{map type must be 
specified for '#pragma omp target enter data'}}

and distinguish it from:

#pragma omp target enter data map(tofrom: r) // expected-error {{map type 
'tofrom' is not allowed for '#pragma omp target enter data'}}


Comment at: lib/Sema/SemaOpenMP.cpp:8510
@@ +8509,3 @@
+  getOpenMPDirectiveName(DKind);
+  // Proceed to add the variable in a map clause anyway, to prevent
+  // further spurious messages

This error occurs when the user specifies an invalid map type.  After reporting 
the error I proceed to retain the clause so that it doesn't trigger the 'map 
clause not present' error.


http://reviews.llvm.org/D15989



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-16 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45074.
arpith-jacob added a comment.

Created a distinct patch for 'target enter data'.
Added nesting test cases where the unstructured statement is nested in various 
regions.


http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1953,6 +1953,7 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2628,6 +2629,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4510,6 +4516,8 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(always, to: r)
+  #pragma omp target enter data map(always, alloc: r)
+  #pragma omp target enter data map(always, from: r) // expected-error {{map type 'from' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(release: r) // expected-error {{map type 'release' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(delete: r) // expected-error {{map type 'delete' is not allowed for '#pragma omp target enter data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_enter_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target enter data map(to: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target enter data map(to: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp tar

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-16 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45075.
arpith-jacob added a comment.

Created a distinct patch for 'target enter data'.
Added nesting test cases where the unstructured statement is nested in various 
regions.
Removed extraneous comments.


http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1953,6 +1953,7 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2628,6 +2629,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4510,6 +4516,8 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(always, to: r)
+  #pragma omp target enter data map(always, alloc: r)
+  #pragma omp target enter data map(always, from: r) // expected-error {{map type 'from' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(release: r) // expected-error {{map type 'release' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(delete: r) // expected-error {{map type 'delete' is not allowed for '#pragma omp target enter data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_enter_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target enter data map(to: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target enter data map(to: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match 

[PATCH] D16279: [OpenMP] Parsing + sema for "target exit data" directive.

2016-01-17 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: kkwli0, sfantao, hfinkel, carlo.bertolli, ABataev.
arpith-jacob added subscribers: cfe-commits, caomhin, fraggamuffin.

Created a distinct patch for the 'target exit data' directive.

http://reviews.llvm.org/D16279

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_device_messages.cpp
  test/OpenMP/target_exit_data_if_messages.cpp
  test/OpenMP/target_exit_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -603,6 +603,9 @@
   case Stmt::OMPTargetEnterDataDirectiveClass:
 K = CXCursor_OMPTargetEnterDataDirective;
 break;
+  case Stmt::OMPTargetExitDataDirectiveClass:
+K = CXCursor_OMPTargetExitDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1954,6 +1954,7 @@
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
   void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
+  void VisitOMPTargetExitDataDirective(const OMPTargetExitDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2634,6 +2635,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetExitDataDirective(
+const OMPTargetExitDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4518,6 +4524,8 @@
 return cxstring::createRef("OMPTargetDataDirective");
   case CXCursor_OMPTargetEnterDataDirective:
 return cxstring::createRef("OMPTargetEnterDataDirective");
+  case CXCursor_OMPTargetExitDataDirective:
+return cxstring::createRef("OMPTargetExitDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_exit_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(always, from: r)
+  #pragma omp target exit data map(delete: r)
+  #pragma omp target exit data map(release: r)
+  #pragma omp target exit data map(always, alloc: r) // expected-error {{map type 'alloc' is not allowed for '#pragma omp target exit data'}}
+  #pragma omp target exit data map(to: r) // expected-error {{map type 'to' is not allowed for '#pragma omp target exit data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_exit_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target exit data map(from: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target exit data map(from: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target exit data map(from: i) if () // expected-error {{expected expression}}
+  #pragma omp target exit d

[PATCH] D16280: [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-17 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: kkwli0, ABataev, sfantao, hfinkel, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, caomhin, fraggamuffin.

Support for the following OpenMP 4.5 restriction on 'target enter data' and 
'target exit data':
- A map-type must be specified in all map clauses.

I have to save 'IsMapTypeImplicit' when parsing a map clause to support this 
constraint and for more informative error messages. This helps me support the 
following case:

#pragma omp target enter data map(r) // expected-error {{map type must be 
specified for '#pragma omp target enter data'}}

and distinguish it from:

#pragma omp target enter data map(tofrom: r) // expected-error {{map type 
'tofrom' is not allowed for '#pragma omp target enter data'}}


http://reviews.llvm.org/D16280

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  test/OpenMP/target_enter_data_map_messages.c
  test/OpenMP/target_exit_data_map_messages.c

Index: test/OpenMP/target_exit_data_map_messages.c
===
--- test/OpenMP/target_exit_data_map_messages.c
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -5,6 +5,7 @@
   int r;
   #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
 
+  #pragma omp target exit data map(r) // expected-error {{map type must be specified for '#pragma omp target exit data'}}
   #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
 
   #pragma omp target exit data map(always, from: r)
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- test/OpenMP/target_enter_data_map_messages.c
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -5,6 +5,7 @@
   int r;
   #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
 
+  #pragma omp target enter data map(r) // expected-error {{map type must be specified for '#pragma omp target enter data'}}
   #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
 
   #pragma omp target enter data map(always, to: r)
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -1660,10 +1660,11 @@
   /// Subclasses may override this routine to provide different behavior.
   OMPClause *RebuildOMPMapClause(
   OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType,
-  SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef VarList,
-  SourceLocation StartLoc, SourceLocation LParenLoc,
-  SourceLocation EndLoc) {
-return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType, MapLoc,
+  bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc,
+  ArrayRef VarList, SourceLocation StartLoc,
+  SourceLocation LParenLoc, SourceLocation EndLoc) {
+return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType,
+  IsMapTypeImplicit, MapLoc,
   ColonLoc, VarList,StartLoc,
   LParenLoc, EndLoc);
   }
@@ -7847,9 +7848,9 @@
 Vars.push_back(EVar.get());
   }
   return getDerived().RebuildOMPMapClause(
-  C->getMapTypeModifier(), C->getMapType(), C->getMapLoc(),
-  C->getColonLoc(), Vars, C->getLocStart(), C->getLParenLoc(),
-  C->getLocEnd());
+  C->getMapTypeModifier(), C->getMapType(), C->isImplicitMapType(),
+  C->getMapLoc(), C->getColonLoc(), Vars, C->getLocStart(),
+  C->getLParenLoc(), C->getLocEnd());
 }
 
 template 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6504,7 +6504,8 @@
 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
 const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind,
 OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier, 
-OpenMPMapClauseKind MapType, SourceLocation DepLinMapLoc) {
+OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
+SourceLocation DepLinMapLoc) {
   OMPClause *Res = nullptr;
   switch (Kind) {
   case OMPC_private:
@@ -6545,8 +6546,9 @@
   StartLoc, LParenLoc, EndLoc);
 break;
   case OMPC_map:
-Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, DepLinMapLoc, ColonLoc,
-   VarList, StartLoc, LParenLoc, EndLoc);
+Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, IsMapTypeImplicit,
+   

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45225.
arpith-jacob added a comment.

HasMapClause() is now static.
Removed comment about 'target exit data'.
Modified: just if(*I != nullptr && (*I)->getClauseKind() == OMPC_map)
Done: Remove parens around 0


http://reviews.llvm.org/D15989

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_device_messages.cpp
  test/OpenMP/target_enter_data_if_messages.cpp
  test/OpenMP/target_enter_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -600,6 +600,9 @@
   case Stmt::OMPTargetDataDirectiveClass:
 K = CXCursor_OMPTargetDataDirective;
 break;
+  case Stmt::OMPTargetEnterDataDirectiveClass:
+K = CXCursor_OMPTargetEnterDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1953,6 +1953,7 @@
   void VisitOMPAtomicDirective(const OMPAtomicDirective *D);
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
+  void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2628,6 +2629,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetEnterDataDirective(
+const OMPTargetEnterDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4510,6 +4516,8 @@
 return cxstring::createRef("OMPTargetDirective");
   case CXCursor_OMPTargetDataDirective:
 return cxstring::createRef("OMPTargetDataDirective");
+  case CXCursor_OMPTargetEnterDataDirective:
+return cxstring::createRef("OMPTargetEnterDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
+
+  #pragma omp target enter data map(always, to: r)
+  #pragma omp target enter data map(always, alloc: r)
+  #pragma omp target enter data map(always, from: r) // expected-error {{map type 'from' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(release: r) // expected-error {{map type 'release' is not allowed for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(delete: r) // expected-error {{map type 'delete' is not allowed for '#pragma omp target enter data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_enter_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target enter data map(to: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target enter data map(to: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to mat

Re: [PATCH] D15989: [OpenMP] Parsing + sema for "target enter data" and "target exit data" directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 4 inline comments as done.
arpith-jacob added a comment.

http://reviews.llvm.org/D15989



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16279: [OpenMP] Parsing + sema for "target exit data" directive.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45226.
arpith-jacob added a comment.

Addressed comments from similar patch for 'target enter data' directive.

Added comment about 'target exit data'.
Removed parens around 0.


http://reviews.llvm.org/D16279

Files:
  include/clang-c/Index.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/StmtOpenMP.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/StmtOpenMP.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmt.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_device_messages.cpp
  test/OpenMP/target_exit_data_if_messages.cpp
  test/OpenMP/target_exit_data_map_messages.c
  tools/libclang/CIndex.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -603,6 +603,9 @@
   case Stmt::OMPTargetEnterDataDirectiveClass:
 K = CXCursor_OMPTargetEnterDataDirective;
 break;
+  case Stmt::OMPTargetExitDataDirectiveClass:
+K = CXCursor_OMPTargetExitDataDirective;
+break;
   case Stmt::OMPTeamsDirectiveClass:
 K = CXCursor_OMPTeamsDirective;
 break;
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -1954,6 +1954,7 @@
   void VisitOMPTargetDirective(const OMPTargetDirective *D);
   void VisitOMPTargetDataDirective(const OMPTargetDataDirective *D);
   void VisitOMPTargetEnterDataDirective(const OMPTargetEnterDataDirective *D);
+  void VisitOMPTargetExitDataDirective(const OMPTargetExitDataDirective *D);
   void VisitOMPTeamsDirective(const OMPTeamsDirective *D);
   void VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *D);
   void VisitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective *D);
@@ -2634,6 +2635,11 @@
   VisitOMPExecutableDirective(D);
 }
 
+void EnqueueVisitor::VisitOMPTargetExitDataDirective(
+const OMPTargetExitDataDirective *D) {
+  VisitOMPExecutableDirective(D);
+}
+
 void EnqueueVisitor::VisitOMPTeamsDirective(const OMPTeamsDirective *D) {
   VisitOMPExecutableDirective(D);
 }
@@ -4518,6 +4524,8 @@
 return cxstring::createRef("OMPTargetDataDirective");
   case CXCursor_OMPTargetEnterDataDirective:
 return cxstring::createRef("OMPTargetEnterDataDirective");
+  case CXCursor_OMPTargetExitDataDirective:
+return cxstring::createRef("OMPTargetExitDataDirective");
   case CXCursor_OMPTeamsDirective:
 return cxstring::createRef("OMPTeamsDirective");
   case CXCursor_OMPCancellationPointDirective:
Index: test/OpenMP/target_exit_data_map_messages.c
===
--- /dev/null
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+
+  int r;
+  #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
+
+  #pragma omp target exit data map(always, from: r)
+  #pragma omp target exit data map(delete: r)
+  #pragma omp target exit data map(release: r)
+  #pragma omp target exit data map(always, alloc: r) // expected-error {{map type 'alloc' is not allowed for '#pragma omp target exit data'}}
+  #pragma omp target exit data map(to: r) // expected-error {{map type 'to' is not allowed for '#pragma omp target exit data'}}
+
+  return 0;
+}
Index: test/OpenMP/target_exit_data_if_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_if_messages.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+int main(int argc, char **argv) {
+  int i;
+  #pragma omp target exit data map(from: i) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target exit data map(from: i) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target exit data map(from: i) if () // expected-error {{expected expression}}
+  #pragma omp target exit data map(from: i) if (argc //

Re: [PATCH] D16280: [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45227.
arpith-jacob added a comment.

Addressed comment:
Do not cast bool to unsigned, use (IsMapTypeImplicit ? 1 : 0) instead.


http://reviews.llvm.org/D16280

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Sema/Sema.h
  lib/AST/OpenMPClause.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  test/OpenMP/target_enter_data_map_messages.c
  test/OpenMP/target_exit_data_map_messages.c

Index: test/OpenMP/target_exit_data_map_messages.c
===
--- test/OpenMP/target_exit_data_map_messages.c
+++ test/OpenMP/target_exit_data_map_messages.c
@@ -5,6 +5,7 @@
   int r;
   #pragma omp target exit data // expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
 
+  #pragma omp target exit data map(r) // expected-error {{map type must be specified for '#pragma omp target exit data'}}
   #pragma omp target exit data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target exit data'}}
 
   #pragma omp target exit data map(always, from: r)
Index: test/OpenMP/target_enter_data_map_messages.c
===
--- test/OpenMP/target_enter_data_map_messages.c
+++ test/OpenMP/target_enter_data_map_messages.c
@@ -5,6 +5,7 @@
   int r;
   #pragma omp target enter data // expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
 
+  #pragma omp target enter data map(r) // expected-error {{map type must be specified for '#pragma omp target enter data'}}
   #pragma omp target enter data map(tofrom: r) // expected-error {{map type 'tofrom' is not allowed for '#pragma omp target enter data'}}
 
   #pragma omp target enter data map(always, to: r)
Index: lib/Sema/TreeTransform.h
===
--- lib/Sema/TreeTransform.h
+++ lib/Sema/TreeTransform.h
@@ -1660,10 +1660,11 @@
   /// Subclasses may override this routine to provide different behavior.
   OMPClause *RebuildOMPMapClause(
   OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType,
-  SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef VarList,
-  SourceLocation StartLoc, SourceLocation LParenLoc,
-  SourceLocation EndLoc) {
-return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType, MapLoc,
+  bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc,
+  ArrayRef VarList, SourceLocation StartLoc,
+  SourceLocation LParenLoc, SourceLocation EndLoc) {
+return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType,
+  IsMapTypeImplicit, MapLoc,
   ColonLoc, VarList,StartLoc,
   LParenLoc, EndLoc);
   }
@@ -7847,9 +7848,9 @@
 Vars.push_back(EVar.get());
   }
   return getDerived().RebuildOMPMapClause(
-  C->getMapTypeModifier(), C->getMapType(), C->getMapLoc(),
-  C->getColonLoc(), Vars, C->getLocStart(), C->getLParenLoc(),
-  C->getLocEnd());
+  C->getMapTypeModifier(), C->getMapType(), C->isImplicitMapType(),
+  C->getMapLoc(), C->getColonLoc(), Vars, C->getLocStart(),
+  C->getLParenLoc(), C->getLocEnd());
 }
 
 template 
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -6503,7 +6503,8 @@
 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
 const DeclarationNameInfo &ReductionId, OpenMPDependClauseKind DepKind,
 OpenMPLinearClauseKind LinKind, OpenMPMapClauseKind MapTypeModifier, 
-OpenMPMapClauseKind MapType, SourceLocation DepLinMapLoc) {
+OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
+SourceLocation DepLinMapLoc) {
   OMPClause *Res = nullptr;
   switch (Kind) {
   case OMPC_private:
@@ -6544,8 +6545,9 @@
   StartLoc, LParenLoc, EndLoc);
 break;
   case OMPC_map:
-Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, DepLinMapLoc, ColonLoc,
-   VarList, StartLoc, LParenLoc, EndLoc);
+Res = ActOnOpenMPMapClause(MapTypeModifier, MapType, IsMapTypeImplicit,
+   DepLinMapLoc, ColonLoc, VarList, StartLoc,
+   LParenLoc, EndLoc);
 break;
   case OMPC_if:
   case OMPC_final:
@@ -8464,8 +8466,9 @@
 
 OMPClause *Sema::ActOnOpenMPMapClause(
 OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType,
-SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef VarList,
-SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc) {
+bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc,
+ArrayRef VarList, SourceLocation StartLoc, SourceLocation LParenLoc,
+SourceLocation EndLoc) {
   SmallVecto

Re: [PATCH] D16280: [OpenMP] Detect implicit map type to report unspecified map type for target enter/exit data directives.

2016-01-18 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 2 inline comments as done.
arpith-jacob added a comment.

http://reviews.llvm.org/D16280



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16341: [OpenMP] Check for at least one map clause on target data directive.

2016-01-19 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: kkwli0, hfinkel, ABataev, sfantao, carlo.bertolli.
arpith-jacob added subscribers: fraggamuffin, caomhin, cfe-commits.

OpenMP [2.10.1, Restrictions, p. 97]
At least one map clause must appear on the directive.

http://reviews.llvm.org/D16341

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/target_data_ast_print.cpp
  test/OpenMP/target_data_device_messages.cpp
  test/OpenMP/target_data_if_messages.cpp
  test/OpenMP/target_data_messages.c

Index: test/OpenMP/target_data_messages.c
===
--- test/OpenMP/target_data_messages.c
+++ test/OpenMP/target_data_messages.c
@@ -3,19 +3,22 @@
 void foo() { }
 
 int main(int argc, char **argv) {
+  int a;
+  #pragma omp target data // expected-error {{expected at least one map clause for '#pragma omp target data'}}
+  {}
   L1:
 foo();
-  #pragma omp target data
+  #pragma omp target data map(a)
   {
 foo();
 goto L1; // expected-error {{use of undeclared label 'L1'}}
   }
   goto L2; // expected-error {{use of undeclared label 'L2'}}
-  #pragma omp target data
+  #pragma omp target data map(a)
   L2:
   foo();
 
-  #pragma omp target data(i) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
+  #pragma omp target data map(a)(i) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
   {
 foo();
   }
Index: test/OpenMP/target_data_if_messages.cpp
===
--- test/OpenMP/target_data_if_messages.cpp
+++ test/OpenMP/target_data_if_messages.cpp
@@ -10,22 +10,23 @@
 struct S1; // expected-note {{declared here}}
 
 int main(int argc, char **argv) {
-  #pragma omp target data if // expected-error {{expected '(' after 'if'}}
-  #pragma omp target data if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if () // expected-error {{expected expression}}
-  #pragma omp target data if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
-  #pragma omp target data if (argc > 0 ? argv[1] : argv[2])
-  #pragma omp target data if (argc + argc)
-  #pragma omp target data if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause}}
-  #pragma omp target data if (S1) // expected-error {{'S1' does not refer to a value}}
-  #pragma omp target data if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if(target data : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if(target data : argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
-  #pragma omp target data if(target data : argc)
-  #pragma omp target data if(target data : argc) if (for:argc) // expected-error {{directive name modifier 'for' is not allowed for '#pragma omp target data'}}
-  #pragma omp target data if(target data : argc) if (target data:argc) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause with 'target data' name modifier}}
-  #pragma omp target data if(target data : argc) if (argc) // expected-error {{no more 'if' clause is allowed}} expected-note {{previous clause with directive name modifier specified here}}
+  int a;
+  #pragma omp target data map(to: a) if // expected-error {{expected '(' after 'if'}}
+  #pragma omp target data map(to: a) if ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if () // expected-error {{expected expression}}
+  #pragma omp target data map(to: a) if (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target data' are ignored}}
+  #pragma omp target data map(to: a) if (argc > 0 ? argv[1] : argv[2])
+  #pragma omp target data map(to: a) if (argc + argc)
+  #pragma omp target data map(to: a) if (foobool(argc)), if (true) // expected-error {{directive '#pragma omp target data' cannot contain more than one 'if' clause}}
+  #pragma omp target data map(to: a) if (S1) // expected-error {{'S1' does not refer to a value}}
+  #pragma omp target data map(to: a) if (argv[1]=2) // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if(target data : // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  #pragma omp target data map(to: a) if(target data : argc // expected-erro

[PATCH] D16358: [OpenMP] Parsing + Sema for nowait clause on target directive

2016-01-20 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, kkwli0, hfinkel, sfantao, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, caomhin, fraggamuffin.

Allow nowait clause on target directive in sema and add test cases.

http://reviews.llvm.org/D16358

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_nowait_messages.cpp

Index: test/OpenMP/target_nowait_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_nowait_messages.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp 
-ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+int main(int argc, char **argv) {
+  #pragma omp target nowait( // expected-warning {{extra tokens at the end of 
'#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target nowait (argc)) // expected-warning {{extra tokens at the 
end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target nowait device (-10u)
+  foo();
+  #pragma omp target nowait (3.14) device (-10u) // expected-warning {{extra 
tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+
+  return 0;
+}
Index: test/OpenMP/target_ast_print.cpp
===
--- test/OpenMP/target_ast_print.cpp
+++ test/OpenMP/target_ast_print.cpp
@@ -25,6 +25,8 @@
   foo();
 #pragma omp target map(always,alloc: i)
   foo();
+#pragma omp target nowait
+  foo();
   return 0;
 }
 
@@ -44,6 +46,8 @@
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
 // CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target nowait
+// CHECK-NEXT: foo()
 // CHECK: template  char tmain(char argc, char 
*argv) {
 // CHECK-NEXT: char i, j, a[20]
 // CHECK-NEXT: #pragma omp target
@@ -60,6 +64,8 @@
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
 // CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target nowait
+// CHECK-NEXT: foo()
 // CHECK: template  T tmain(T argc, T *argv) {
 // CHECK-NEXT: T i, j, a[20]
 // CHECK-NEXT: #pragma omp target
@@ -76,6 +82,8 @@
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
 // CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target nowait
+// CHECK-NEXT: foo()
 
 // CHECK-LABEL: int main(int argc, char **argv) {
 int main (int argc, char **argv) {
@@ -115,6 +123,11 @@
   foo();
 // CHECK-NEXT: foo();
 
+#pragma omp target nowait
+// CHECK-NEXT: #pragma omp target nowait
+  foo();
+// CHECK-NEXT: foo();
+
   return tmain(argc, &argc) + tmain(argv[0][0], argv[0]);
 }
 
Index: include/clang/Basic/OpenMPKinds.def
===
--- include/clang/Basic/OpenMPKinds.def
+++ include/clang/Basic/OpenMPKinds.def
@@ -355,6 +355,7 @@
 OPENMP_TARGET_CLAUSE(device)
 OPENMP_TARGET_CLAUSE(map)
 OPENMP_TARGET_CLAUSE(private)
+OPENMP_TARGET_CLAUSE(nowait)
 
 // Clauses allowed for OpenMP directive 'target data'.
 // TODO More clauses for 'target data' directive.


Index: test/OpenMP/target_nowait_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_nowait_messages.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+void foo() {
+}
+
+int main(int argc, char **argv) {
+  #pragma omp target nowait( // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target nowait device (-10u)
+  foo();
+  #pragma omp target nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+
+  return 0;
+}
Index: test/OpenMP/target_ast_print.cpp
===
--- test/OpenMP/target_ast_print.cpp
+++ test/OpenMP/target_ast_print.cpp
@@ -25,6 +25,8 @@
   foo();
 #pragma omp target map(always,alloc: i)
   foo();
+#pragma omp target nowait
+  foo();
   return 0;
 }
 
@@ -44,6 +46,8 @@
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
 // CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target nowait
+// CHECK-NEXT: foo()
 // CHECK: template  char tmain(char argc, char *argv) {
 // CHECK-NEXT: char i, j, a[20]
 // CHECK-NEXT: #pragma omp target
@@ -60,6 +64,8 @@
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
 // CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target nowait
+// CHECK-NEXT: foo()
 // CHECK: template  T tmain(T argc, T *argv) {
 // CHECK-NEXT: T i, j, a[20]
 // CHECK-NEXT: #pragma omp target
@@ -76,6 +82,8 @@
 // CHECK-NEXT: foo()
 // CHECK-NEXT: #pragma omp target map(always,alloc: i)
 // CHECK-NEXT: foo()
+// CHECK-NEXT: #pragma omp target nowait
+// CHECK-NEXT: foo()
 
 // CHECK-

[PATCH] D16361: [OpenMP] Parsing + Sema for nowait clause on target enter data directive.

2016-01-20 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, kkwli0, hfinkel, sfantao, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

Accept nowait clause on target enter data directive in sema and add test cases.

http://reviews.llvm.org/D16361

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_nowait_messages.cpp

Index: test/OpenMP/target_enter_data_nowait_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_nowait_messages.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+  int i;
+
+  #pragma omp nowait target enter data map(to: i) // expected-error {{expected an OpenMP directive}}
+  #pragma omp target nowait enter data map(to: i) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  #pragma omp target enter nowait data map(to: i) // expected-error {{expected an OpenMP directive}}
+  #pragma omp target enter data nowait() map(to: i) // expected-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}} expected-error {{expected at least one map clause for '#pragma omp target enter data'}}
+  #pragma omp target enter data map(to: i) nowait( // expected-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
+  #pragma omp target enter data map(to: i) nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
+  #pragma omp target enter data map(to: i) nowait device (-10u)
+  #pragma omp target enter data map(to: i) nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
+  #pragma omp target enter data map(to: i) nowait nowait // expected-error {{directive '#pragma omp target enter data' cannot contain more than one 'nowait' clause}}
+  #pragma omp target enter data nowait map(to: i) nowait // expected-error {{directive '#pragma omp target enter data' cannot contain more than one 'nowait' clause}}
+  return 0;
+}
Index: test/OpenMP/target_enter_data_ast_print.cpp
===
--- test/OpenMP/target_enter_data_ast_print.cpp
+++ test/OpenMP/target_enter_data_ast_print.cpp
@@ -27,6 +27,22 @@
 
 #pragma omp target enter data map(always,alloc: e)
 
+#pragma omp target enter data nowait map(to: i)
+
+#pragma omp target enter data nowait map(to: i) if (target enter data: j > 0)
+
+#pragma omp target enter data map(to: i) if (b) nowait
+
+#pragma omp target enter data map(to: c) nowait
+
+#pragma omp target enter data map(to: c) nowait if(b>e)
+
+#pragma omp target enter data nowait map(alloc: x[0:10], c)
+
+#pragma omp target enter data nowait map(to: c) map(alloc: d)
+
+#pragma omp target enter data nowait map(always,alloc: e)
+
   return 0;
 }
 
@@ -41,6 +57,14 @@
 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
+// CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
+// CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
+// CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
+// CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
+// CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
+// CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
+// CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
+// CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
 // CHECK: template  char tmain(char argc, char *argv) {
 // CHECK-NEXT: char i, j, b, c, d, e, x[20];
 // CHECK-NEXT: i = argc;
@@ -52,6 +76,14 @@
 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
+// CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
+// CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
+// CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
+// CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
+// CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
+// CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
+// CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
+// CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
 // CHECK: template  T tmain(T argc, T *argv) {
 // CHECK-NEXT: T i, j, b, c, d, e, x[20];
 // CHECK-NEXT: i = argc;
@@ -63,6 +95,14 @@
 // CHECK-NEXT: #pragma omp target enter data m

[PATCH] D16362: [OpenMP] Parsing + Sema for nowait clause on target exit data directive.

2016-01-20 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, kkwli0, hfinkel, sfantao, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

Accept nowait clause on target exit data directive in sema and add test cases.

http://reviews.llvm.org/D16362

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_nowait_messages.cpp

Index: test/OpenMP/target_exit_data_nowait_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_nowait_messages.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -verify -fopenmp -ferror-limit 100 -o - %s
+
+int main(int argc, char **argv) {
+  int i;
+
+  #pragma omp nowait target exit data map(from: i) // expected-error {{expected an OpenMP directive}}
+  #pragma omp target nowait exit data map(from: i) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  #pragma omp target exit nowait data map(from: i) // expected-error {{expected an OpenMP directive}}
+  #pragma omp target exit data nowait() map(from: i) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}} expected-error {{expected at least one map clause for '#pragma omp target exit data'}}
+  #pragma omp target exit data map(from: i) nowait( // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
+  #pragma omp target exit data map(from: i) nowait (argc)) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
+  #pragma omp target exit data map(from: i) nowait device (-10u)
+  #pragma omp target exit data map(from: i) nowait (3.14) device (-10u) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
+  #pragma omp target exit data map(from: i) nowait nowait // expected-error {{directive '#pragma omp target exit data' cannot contain more than one 'nowait' clause}}
+  #pragma omp target exit data nowait map(from: i) nowait // expected-error {{directive '#pragma omp target exit data' cannot contain more than one 'nowait' clause}}
+  return 0;
+}
Index: test/OpenMP/target_exit_data_ast_print.cpp
===
--- test/OpenMP/target_exit_data_ast_print.cpp
+++ test/OpenMP/target_exit_data_ast_print.cpp
@@ -27,6 +27,22 @@
 
 #pragma omp target exit data map(always,release: e)
 
+#pragma omp target exit data nowait map(from: i)
+
+#pragma omp target exit data nowait map(from: i) if (target exit data: j > 0)
+
+#pragma omp target exit data map(from: i) if (b) nowait
+
+#pragma omp target exit data map(from: c) nowait
+
+#pragma omp target exit data map(from: c) nowait if(b>e)
+
+#pragma omp target exit data nowait map(release: x[0:10], c)
+
+#pragma omp target exit data nowait map(from: c) map(release: d)
+
+#pragma omp target exit data nowait map(always,release: e)
+
   return 0;
 }
 
@@ -41,6 +57,14 @@
 // CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c)
 // CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d)
 // CHECK-NEXT: #pragma omp target exit data map(always,release: e)
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: i)
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: i) if(target exit data: j > 0)
+// CHECK-NEXT: #pragma omp target exit data map(from: i) if(b) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) nowait if(b > e)
+// CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c)
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: c) map(release: d)
+// CHECK-NEXT: #pragma omp target exit data nowait map(always,release: e)
 // CHECK: template  char tmain(char argc, char *argv) {
 // CHECK-NEXT: char i, j, b, c, d, e, x[20];
 // CHECK-NEXT: i = argc;
@@ -52,6 +76,14 @@
 // CHECK-NEXT: #pragma omp target exit data map(release: x[0:10],c)
 // CHECK-NEXT: #pragma omp target exit data map(from: c) map(release: d)
 // CHECK-NEXT: #pragma omp target exit data map(always,release: e)
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: i)
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: i) if(target exit data: j > 0)
+// CHECK-NEXT: #pragma omp target exit data map(from: i) if(b) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) nowait
+// CHECK-NEXT: #pragma omp target exit data map(from: c) nowait if(b > e)
+// CHECK-NEXT: #pragma omp target exit data nowait map(release: x[0:10],c)
+// CHECK-NEXT: #pragma omp target exit data nowait map(from: c) map(release: d)
+// CHECK-NEXT: #pragma omp target exit data nowait map(always,release: e)
 // CHECK: template  T tmain(T argc, T *argv) {
 // CHECK-NEXT: T i, j, b, c, d, e, x[20];
 // CHECK-NEXT: i = argc;
@@ -63,6 +95,14 @@
 // CHECK-NEXT

[PATCH] D16375: [OpenMP] Sema for depend clause on target directive.

2016-01-20 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, kkwli0, hfinkel, sfantao, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

Accept depend clause on target directive in sema and add test cases.

http://reviews.llvm.org/D16375

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_depend_messages.cpp

Index: test/OpenMP/target_depend_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_depend_messages.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+class vector {
+  public:
+int operator[](int index) { return 0; }
+};
+
+int main(int argc, char **argv, char *env[]) {
+  vector vec;
+  typedef float V __attribute__((vector_size(16)));
+  V a;
+  auto arr = x; // expected-error {{use of undeclared identifier 'x'}}
+
+  #pragma omp target depend // expected-error {{expected '(' after 'depend'}}
+  foo();
+  #pragma omp target depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  foo();
+  #pragma omp target depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target' are ignored}}
+  foo();
+  #pragma omp target depend (out: ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  foo();
+  #pragma omp target depend (out :S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target depend (in : argv[0])
+  foo();
+  #pragma omp target depend (in : ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target depend (in : main) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target depend(in : a[0]) // expected-error{{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
+  foo();
+  #pragma omp target depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target depend (in : argv[0:-1]) // expected-error {{section length is evaluated to a negative value -1}}
+  foo();
+  #pragma omp target depend (in : argv[-1:0]) // expected-error {{section lower bound is evaluated to a negative value -1}}
+  foo();
+  #pragma omp target depend (in : argv[:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an arr

[PATCH] D16400: [OpenMP] Sema for depend clause on target enter data directive.

2016-01-21 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, kkwli0, hfinkel, sfantao, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

Accept depend clause on target enter data directive in sema and add test cases.

http://reviews.llvm.org/D16400

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_depend_messages.cpp

Index: test/OpenMP/target_enter_data_depend_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_depend_messages.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+class vector {
+  public:
+int operator[](int index) { return 0; }
+};
+
+int main(int argc, char **argv, char *env[]) {
+  vector vec;
+  typedef float V __attribute__((vector_size(16)));
+  V a;
+  auto arr = x; // expected-error {{use of undeclared identifier 'x'}}
+
+  int i;
+  #pragma omp target enter data map(to: i) depend // expected-error {{expected '(' after 'depend'}}
+  foo();
+  #pragma omp target enter data map(to: i) depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target enter data map(to: i) depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target enter data map(to: i)' are ignored}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (out: ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (out :S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target enter data map(to: i) depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[0])
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : main) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend(in : a[0]) // expected-error{{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #

[PATCH] D16401: [OpenMP] Sema for depend clause on target exit data directive.

2016-01-21 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: ABataev, kkwli0, hfinkel, sfantao, carlo.bertolli.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

Accept depend clause on target exit data directive in sema and add test cases.

http://reviews.llvm.org/D16401

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_depend_messages.cpp

Index: test/OpenMP/target_exit_data_depend_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_depend_messages.cpp
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}}
+
+class vector {
+  public:
+int operator[](int index) { return 0; }
+};
+
+int main(int argc, char **argv, char *env[]) {
+  vector vec;
+  typedef float V __attribute__((vector_size(16)));
+  V a;
+  auto arr = x; // expected-error {{use of undeclared identifier 'x'}}
+
+  int i;
+  #pragma omp target exit data map(from: i) depend // expected-error {{expected '(' after 'depend'}}
+  foo();
+  #pragma omp target exit data map(from: i) depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (out: ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (out :S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target exit data map(from: i) depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[0])
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : main) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend(in : a[0]) // expected-error{{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();

Re: [PATCH] D16400: [OpenMP] Sema for depend clause on target enter data directive.

2016-01-21 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45525.
arpith-jacob added a comment.

Added template instantiation test case for all feasible tests.


http://reviews.llvm.org/D16400

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_enter_data_ast_print.cpp
  test/OpenMP/target_enter_data_depend_messages.cpp

Index: test/OpenMP/target_enter_data_depend_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_enter_data_depend_messages.cpp
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note {{declared here}}
+
+class vector {
+  public:
+int operator[](int index) { return 0; }
+};
+
+template 
+int tmain(T argc, S **argv, R *env[]) {
+  vector vec;
+  typedef float V __attribute__((vector_size(16)));
+  V a;
+  char *arr;
+
+  int i;
+  #pragma omp target enter data map(to: i) depend // expected-error {{expected '(' after 'depend'}}
+  foo();
+  #pragma omp target enter data map(to: i) depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target enter data map(to: i) depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target enter data' are ignored}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (out: ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (out :S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target enter data map(to: i) depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[0])
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : tmain) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend(in : a[0]) // expected-error{{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target enter data map(to: i) depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+ 

Re: [PATCH] D16401: [OpenMP] Sema for depend clause on target exit data directive.

2016-01-21 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45532.
arpith-jacob added a comment.

Added template instantiation test case for all feasible tests.


http://reviews.llvm.org/D16401

Files:
  include/clang/Basic/OpenMPKinds.def
  test/OpenMP/target_exit_data_ast_print.cpp
  test/OpenMP/target_exit_data_depend_messages.cpp

Index: test/OpenMP/target_exit_data_depend_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_exit_data_depend_messages.cpp
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
+
+void foo() {
+}
+
+bool foobool(int argc) {
+  return argc;
+}
+
+struct S1; // expected-note {{declared here}} expected-note {{declared here}}
+
+class vector {
+  public:
+int operator[](int index) { return 0; }
+};
+
+template 
+int tmain(T argc, S **argv, R *env[]) {
+  vector vec;
+  typedef float V __attribute__((vector_size(16)));
+  V a;
+  char *arr;
+
+  int i;
+  #pragma omp target exit data map(from: i) depend // expected-error {{expected '(' after 'depend'}}
+  foo();
+  #pragma omp target exit data map(from: i) depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend () // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (argc // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (source : argc) // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (source) // expected-error {{expected expression}} expected-warning {{missing ':' after dependency type - ignoring}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argc)) // expected-warning {{extra tokens at the end of '#pragma omp target exit data' are ignored}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (out: ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (inout : foobool(argc)), depend (in, argc) // expected-error {{expected variable name, array element or array section}} expected-warning {{missing ':' after dependency type - ignoring}} expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (out :S1) // expected-error {{'S1' does not refer to a value}}
+  foo();
+  #pragma omp target exit data map(from: i) depend(in : argv[1][1] = '2') // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : vec[1]) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[0])
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : ) // expected-error {{expected expression}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : tmain) // expected-error {{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend(in : a[0]) // expected-error{{expected variable name, array element or array section}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : vec[1:2]) // expected-error {{ value is not an array or pointer}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[ // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[:] // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[argc: // expected-error {{expected expression}} expected-error {{expected ']'}} expected-error {{expected ')'}} expected-note {{to match this '['}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target exit data map(from: i) depend (in : argv[argc:argc] // expected-error {{expected ')'}} expected-note {{to match this '

Re: [PATCH] D16341: [OpenMP] Check for at least one map clause on target data directive.

2016-01-21 Thread Arpith Jacob via cfe-commits
arpith-jacob added a comment.

Committed revision 258425.


Repository:
  rL LLVM

http://reviews.llvm.org/D16341



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16527: [OpenMP] Parsing + sema for defaultmap clause.

2016-01-24 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: hfinkel, kkwli0, sfantao, carlo.bertolli, ABataev.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

This patch adds parsing + sema for the defaultmap clause associated with the 
target directive (among others).

http://reviews.llvm.org/D16527

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_defaultmap_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2229,6 +2229,8 @@
   Visitor->AddStmt(C->getChunkSize());
   Visitor->AddStmt(C->getHelperChunkSize());
 }
+void OMPClauseEnqueue::VisitOMPDefaultmapClause(const OMPDefaultmapClause *C) {
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_defaultmap_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_defaultmap_messages.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+void foo() {
+}
+
+template 
+T tmain(T argc, S **argv) {
+  #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+  foo();
+  #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo();
+
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+  foo();
+  #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp 

Re: [PATCH] D16527: [OpenMP] Parsing + sema for defaultmap clause.

2016-01-25 Thread Arpith Jacob via cfe-commits
arpith-jacob updated this revision to Diff 45856.
arpith-jacob added a comment.

Addressed fixes by Alexey Bataev.  Thanks.


http://reviews.llvm.org/D16527

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/OpenMPKinds.def
  include/clang/Basic/OpenMPKinds.h
  include/clang/Sema/Sema.h
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/Basic/OpenMPKinds.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/Parse/ParseOpenMP.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_ast_print.cpp
  test/OpenMP/target_defaultmap_messages.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -2229,6 +2229,8 @@
   Visitor->AddStmt(C->getChunkSize());
   Visitor->AddStmt(C->getHelperChunkSize());
 }
+void OMPClauseEnqueue::VisitOMPDefaultmapClause(const OMPDefaultmapClause *C) {
+}
 }
 
 void EnqueueVisitor::EnqueueChildren(const OMPClause *S) {
Index: test/OpenMP/target_defaultmap_messages.cpp
===
--- /dev/null
+++ test/OpenMP/target_defaultmap_messages.cpp
@@ -0,0 +1,56 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+
+void foo() {
+}
+
+template 
+T tmain(T argc, S **argv) {
+  #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+  foo();
+  #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (tofrom, scalar // expected-error {{expected ')'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo();
+
+  return argc;
+}
+
+int main(int argc, char **argv) {
+  #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap ( // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap () // expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom) // expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  foo();
+  #pragma omp target defaultmap (tofrom scalar) // expected-warning {{missing ':' after defaultmap modifier - ignoring}}
+  foo();
+  #pragma omp target defaultmap (tofrom, // expected-error {{expected ')'}} expected-error {{expected 'scalar' in OpenMP clause 'defaultmap'}} expected-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}}
+  foo();
+  #pragma omp target defaultmap (scalar: // expected-error {{expected ')'}} expected-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}}
+  foo(

Re: [PATCH] D16527: [OpenMP] Parsing + sema for defaultmap clause.

2016-01-25 Thread Arpith Jacob via cfe-commits
arpith-jacob marked 5 inline comments as done.
arpith-jacob added a comment.

Patch fixed.


http://reviews.llvm.org/D16527



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16553: [OpenMP] Parsing + sema for target parallel directive.

2016-01-26 Thread Arpith Jacob via cfe-commits
arpith-jacob closed this revision.
arpith-jacob added a comment.

Committed revision 258832.

I had to modify test cases 'target_parallel_reduction_messages.cpp' and 
'target_parallel_map_messages.cpp' to use the updated error messages from 
patches recently committed to trunk.


http://reviews.llvm.org/D16553



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D16758: [OpenMP] Prevent nesting of target constructs within target code execution regions.

2016-01-31 Thread Arpith Jacob via cfe-commits
arpith-jacob created this revision.
arpith-jacob added reviewers: hfinkel, kkwli0, sfantao, carlo.bertolli, ABataev.
arpith-jacob added subscribers: cfe-commits, fraggamuffin, caomhin.

This patch enhances Sema to check for the following restriction:

OpenMP 4.5 [2.17 Nesting of Regions]
If a target, target update, target data, target enter data, or
target exit data construct is encountered during execution of a
target region, the behavior is unspecified.

http://reviews.llvm.org/D16758

Files:
  include/clang/Basic/OpenMPKinds.h
  lib/Basic/OpenMPKinds.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/distribute_private_messages.cpp
  test/OpenMP/nesting_of_regions.cpp
  test/OpenMP/target_data_device_messages.cpp
  test/OpenMP/target_device_messages.cpp
  test/OpenMP/target_if_messages.cpp
  test/OpenMP/target_messages.cpp
  test/OpenMP/target_parallel_default_messages.cpp
  test/OpenMP/target_parallel_device_messages.cpp
  test/OpenMP/target_parallel_firstprivate_messages.cpp
  test/OpenMP/target_parallel_if_messages.cpp
  test/OpenMP/target_parallel_map_messages.cpp
  test/OpenMP/target_parallel_messages.cpp
  test/OpenMP/target_parallel_num_threads_messages.cpp
  test/OpenMP/target_parallel_private_messages.cpp
  test/OpenMP/target_parallel_proc_bind_messages.cpp
  test/OpenMP/target_parallel_reduction_messages.cpp
  test/OpenMP/target_parallel_shared_messages.cpp
  test/OpenMP/target_private_messages.cpp
  test/OpenMP/teams_reduction_messages.cpp

Index: test/OpenMP/teams_reduction_messages.cpp
===
--- test/OpenMP/teams_reduction_messages.cpp
+++ test/OpenMP/teams_reduction_messages.cpp
@@ -175,13 +175,15 @@
 #pragma omp teams
 #pragma omp parallel for private(fl)
   for (int i = 0; i < 10; ++i)
+  {}
 #pragma omp target
 #pragma omp teams reduction(+ : fl)
 foo();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel for reduction(- : fl)
   for (int i = 0; i < 10; ++i)
+  {}
 #pragma omp target
 #pragma omp teams reduction(+ : fl)
 foo();
@@ -306,13 +308,15 @@
 #pragma omp teams
 #pragma omp parallel for private(fl)
   for (int i = 0; i < 10; ++i)
+  {}
 #pragma omp target
 #pragma omp teams reduction(+ : fl)
 foo();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel for reduction(- : fl)
   for (int i = 0; i < 10; ++i)
+  {}
 #pragma omp target
 #pragma omp teams reduction(+ : fl)
 foo();
Index: test/OpenMP/target_private_messages.cpp
===
--- test/OpenMP/target_private_messages.cpp
+++ test/OpenMP/target_private_messages.cpp
@@ -90,28 +90,39 @@
   int i;
   int &j = i;
 #pragma omp target private // expected-error {{expected '(' after 'private'}}
+{}
 #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
 #pragma omp target private() // expected-error {{expected expression}}
+{}
 #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
 #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
 #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+{}
 #pragma omp target private(argc)
+{}
 #pragma omp target private(S1) // expected-error {{'S1' does not refer to a value}}
+{}
 #pragma omp target private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
+{}
 #pragma omp target private(argv[1]) // expected-error {{expected variable name}}
+{}
 #pragma omp target private(e, g)
+{}
 #pragma omp target private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
+{}
 #pragma omp target shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp target'}}
 #pragma omp parallel
   {
 int v = 0;
 int i;
-#pragma omp target private(i)
-{}
   }
 #pragma omp parallel shared(i)
 #pragma omp parallel private(i)
 #pragma omp target private(j)
+{}
 #pragma omp target private(i)
   {}
   return 0;
@@ -139,28 +150,40 @@
   int i;
   int &j = i;
 #pragma omp target private // expected-error {{expected '(' after 'private'}}
+{}
 #pragma omp target private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
 #pragma omp target private() // expected-error {{expected expression}}
+{}
 #pragma omp target private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
 #pragma omp target private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
+{}
 #pragma omp target private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
+{}
 #pragma omp target private(argc)
+{}
 #pragma omp target private(S1) // expected-error {{'S1' does not ref