[OpenCL] Support variable memory scope in atomic builtins

Differential Revision: https://reviews.llvm.org/D36580

llvm-svn: 310924
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 8cb9f76..7dc1418 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -3939,16 +3939,13 @@
   switch (Op) {
   case AO__c11_atomic_init:
   case AO__opencl_atomic_init:
-    return 2;
   case AO__c11_atomic_load:
-  case AO__opencl_atomic_load:
   case AO__atomic_load_n:
-    return 3;
+    return 2;
 
+  case AO__opencl_atomic_load:
   case AO__c11_atomic_store:
   case AO__c11_atomic_exchange:
-  case AO__opencl_atomic_store:
-  case AO__opencl_atomic_exchange:
   case AO__atomic_load:
   case AO__atomic_store:
   case AO__atomic_store_n:
@@ -3958,13 +3955,6 @@
   case AO__c11_atomic_fetch_and:
   case AO__c11_atomic_fetch_or:
   case AO__c11_atomic_fetch_xor:
-  case AO__opencl_atomic_fetch_add:
-  case AO__opencl_atomic_fetch_sub:
-  case AO__opencl_atomic_fetch_and:
-  case AO__opencl_atomic_fetch_or:
-  case AO__opencl_atomic_fetch_xor:
-  case AO__opencl_atomic_fetch_min:
-  case AO__opencl_atomic_fetch_max:
   case AO__atomic_fetch_add:
   case AO__atomic_fetch_sub:
   case AO__atomic_fetch_and:
@@ -3977,20 +3967,29 @@
   case AO__atomic_or_fetch:
   case AO__atomic_xor_fetch:
   case AO__atomic_nand_fetch:
-    return 4;
+    return 3;
 
+  case AO__opencl_atomic_store:
+  case AO__opencl_atomic_exchange:
+  case AO__opencl_atomic_fetch_add:
+  case AO__opencl_atomic_fetch_sub:
+  case AO__opencl_atomic_fetch_and:
+  case AO__opencl_atomic_fetch_or:
+  case AO__opencl_atomic_fetch_xor:
+  case AO__opencl_atomic_fetch_min:
+  case AO__opencl_atomic_fetch_max:
   case AO__atomic_exchange:
-    return 5;
+    return 4;
 
   case AO__c11_atomic_compare_exchange_strong:
   case AO__c11_atomic_compare_exchange_weak:
+    return 5;
+
   case AO__opencl_atomic_compare_exchange_strong:
   case AO__opencl_atomic_compare_exchange_weak:
-    return 6;
-
   case AO__atomic_compare_exchange:
   case AO__atomic_compare_exchange_n:
-    return 7;
+    return 6;
   }
   llvm_unreachable("unknown atomic op");
 }