Add frontend support for __vectorcall

Wire it through everywhere we have support for fastcall, essentially.

This allows us to parse the MSVC "14" CTP headers, but we will
miscompile them because LLVM doesn't support __vectorcall yet.

Reviewed By: Aaron Ballman

Differential Revision: http://reviews.llvm.org/D5808

llvm-svn: 220573
diff --git a/clang/test/CodeGen/microsoft-call-conv.c b/clang/test/CodeGen/microsoft-call-conv.c
index b80c58d..aabe825 100644
--- a/clang/test/CodeGen/microsoft-call-conv.c
+++ b/clang/test/CodeGen/microsoft-call-conv.c
@@ -20,6 +20,12 @@
   f3();
 // CHECK: call x86_thiscallcc void @f3()
 }
+// FIXME: Add this to LLVM.
+void __vectorcall f61(void) {
+// CHECK-LABEL: define void @f61()
+  f3();
+// CHECK: call x86_thiscallcc void @f3()
+}
 
 // PR5280
 void (__fastcall *pf1)(void) = f1;
@@ -28,19 +34,22 @@
 void (__fastcall *pf4)(void) = f4;
 void (__stdcall *pf5)(void) = f5;
 void (__thiscall *pf6)(void) = f6;
+void (__vectorcall *pf7)(void) = f61;
 
 int main(void) {
-    f4(); f5(); f6();
+    f4(); f5(); f6(); f61();
     // CHECK: call x86_fastcallcc void @f4()
     // CHECK: call x86_stdcallcc void @f5()
     // CHECK: call x86_thiscallcc void @f6()
-    pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
+    // CHECK: call void @f61()
+    pf1(); pf2(); pf3(); pf4(); pf5(); pf6(); pf7();
     // CHECK: call x86_fastcallcc void %{{.*}}()
     // CHECK: call x86_stdcallcc void %{{.*}}()
     // CHECK: call x86_thiscallcc void %{{.*}}()
     // CHECK: call x86_fastcallcc void %{{.*}}()
     // CHECK: call x86_stdcallcc void %{{.*}}()
     // CHECK: call x86_thiscallcc void %{{.*}}()
+    // CHECK: call void %{{.*}}()
     return 0;
 }
 
diff --git a/clang/test/CodeGen/mrtd.c b/clang/test/CodeGen/mrtd.c
index 1132d04..f929d4c 100644
--- a/clang/test/CodeGen/mrtd.c
+++ b/clang/test/CodeGen/mrtd.c
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck %s
 
-// CHECK: mrtd.c:10:3: warning: function with no prototype cannot use the callee-cleanup stdcall calling convention
+// CHECK: mrtd.c:10:3: warning: function with no prototype cannot use the stdcall calling convention
 
 void baz(int arg);
 
diff --git a/clang/test/CodeGenCXX/mangle-ms.cpp b/clang/test/CodeGenCXX/mangle-ms.cpp
index 3285c98..bf61d8b 100644
--- a/clang/test/CodeGenCXX/mangle-ms.cpp
+++ b/clang/test/CodeGenCXX/mangle-ms.cpp
@@ -365,3 +365,5 @@
 // CHECK-DAG: ??3TypedefNewDelete@@SAXPAX@Z
 // CHECK-DAG: ??_VTypedefNewDelete@@SAXPAX@Z
 
+void __vectorcall vector_func() { }
+// CHECK-DAG: @"\01?vector_func@@YQXXZ"
diff --git a/clang/test/Sema/callingconv.c b/clang/test/Sema/callingconv.c
index 6890815..5ac5a4a 100644
--- a/clang/test/Sema/callingconv.c
+++ b/clang/test/Sema/callingconv.c
@@ -10,7 +10,7 @@
 void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
 }
 
-void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use the callee-cleanup fastcall calling convention}}
+void __attribute__((fastcall)) test0() { // expected-error {{function with no prototype cannot use the fastcall calling convention}}
 }
 
 void __attribute__((fastcall)) test1(void) {
diff --git a/clang/test/Sema/decl-microsoft-call-conv.c b/clang/test/Sema/decl-microsoft-call-conv.c
index fefa862..c8fb6e1 100644
--- a/clang/test/Sema/decl-microsoft-call-conv.c
+++ b/clang/test/Sema/decl-microsoft-call-conv.c
@@ -11,11 +11,14 @@
 void __thiscall CrcGenerateTableThiscall() {}
 void __pascal CrcGenerateTablePascal(void);
 void __pascal CrcGenerateTablePascal() {}
+void __vectorcall CrcGenerateTableVectorcall(void);
+void __vectorcall CrcGenerateTableVectorcall() {}
 
-void __fastcall CrcGenerateTableNoProtoFastcall() {} // expected-error{{function with no prototype cannot use the callee-cleanup fastcall calling convention}}
-void __stdcall CrcGenerateTableNoProtoStdcall() {} // expected-warning{{function with no prototype cannot use the callee-cleanup stdcall calling convention}}
-void __thiscall CrcGenerateTableNoProtoThiscall() {} // expected-error{{function with no prototype cannot use the callee-cleanup thiscall calling convention}}
-void __pascal CrcGenerateTableNoProtoPascal() {} // expected-error{{function with no prototype cannot use the callee-cleanup pascal calling convention}}
+void __fastcall CrcGenerateTableNoProtoFastcall() {} // expected-error{{function with no prototype cannot use the fastcall calling convention}}
+void __stdcall CrcGenerateTableNoProtoStdcall() {} // expected-warning{{function with no prototype cannot use the stdcall calling convention}}
+void __thiscall CrcGenerateTableNoProtoThiscall() {} // expected-error{{function with no prototype cannot use the thiscall calling convention}}
+void __pascal CrcGenerateTableNoProtoPascal() {} // expected-error{{function with no prototype cannot use the pascal calling convention}}
+void __vectorcall CrcGenerateTableNoProtoVectorcall() {} // expected-error{{function with no prototype cannot use the vectorcall calling convention}}
 
 // Regular calling convention is fine.
 void CrcGenerateTableNoProto() {}
diff --git a/clang/test/Sema/stdcall-fastcall.c b/clang/test/Sema/stdcall-fastcall.c
index e19b110..256f558 100644
--- a/clang/test/Sema/stdcall-fastcall.c
+++ b/clang/test/Sema/stdcall-fastcall.c
@@ -6,7 +6,7 @@
 
 // Different CC qualifiers are not compatible
 void __attribute__((stdcall, fastcall)) foo3(void); // expected-error{{fastcall and stdcall attributes are not compatible}}
-void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}} expected-warning{{function with no prototype cannot use the callee-cleanup stdcall calling convention}}
+void __attribute__((stdcall)) foo4(); // expected-note{{previous declaration is here}} expected-warning{{function with no prototype cannot use the stdcall calling convention}}
 void __attribute__((fastcall)) foo4(void); // expected-error{{function declared 'fastcall' here was previously declared 'stdcall'}}
 
 // rdar://8876096
diff --git a/clang/test/SemaCXX/decl-microsoft-call-conv.cpp b/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
index eb6c850..a4b68cd 100644
--- a/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
+++ b/clang/test/SemaCXX/decl-microsoft-call-conv.cpp
@@ -10,6 +10,7 @@
 void __cdecl    free_func_cdecl(); // expected-note 2 {{previous declaration is here}}
 void __stdcall  free_func_stdcall(); // expected-note 2 {{previous declaration is here}}
 void __fastcall free_func_fastcall(); // expected-note 2 {{previous declaration is here}}
+void __vectorcall free_func_vectorcall(); // expected-note 2 {{previous declaration is here}}
 
 void __cdecl    free_func_default();
 void __stdcall  free_func_default(); // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
@@ -27,6 +28,10 @@
 void __stdcall  free_func_fastcall(); // expected-error {{function declared 'stdcall' here was previously declared 'fastcall'}}
 void            free_func_fastcall();
 
+void __cdecl    free_func_vectorcall(); // expected-error {{function declared 'cdecl' here was previously declared 'vectorcall'}}
+void __stdcall  free_func_vectorcall(); // expected-error {{function declared 'stdcall' here was previously declared 'vectorcall'}}
+void            free_func_vectorcall();
+
 // Overloaded functions may have different calling conventions
 void __fastcall free_func_default(int);
 void __cdecl    free_func_default(int *);
@@ -45,6 +50,8 @@
   void __cdecl    member_cdecl2(); // expected-note {{previous declaration is here}}
   void __thiscall member_thiscall1();
   void __thiscall member_thiscall2(); // expected-note {{previous declaration is here}}
+  void __vectorcall member_vectorcall1();
+  void __vectorcall member_vectorcall2(); // expected-note {{previous declaration is here}}
 
   // Typedefs carrying the __cdecl convention are adjusted to __thiscall.
   void_fun_t           member_typedef_default; // expected-note {{previous declaration is here}}
@@ -83,6 +90,9 @@
 void            S::member_thiscall1() {}
 void __cdecl    S::member_thiscall2() {} // expected-error {{function declared 'cdecl' here was previously declared 'thiscall'}}
 
+void            S::member_vectorcall1() {}
+void __cdecl    S::member_vectorcall2() {} // expected-error {{function declared 'cdecl' here was previously declared 'vectorcall'}}
+
 void            S::static_member_default1() {}
 void __cdecl    S::static_member_default2() {}
 void __stdcall  S::static_member_default3() {} // expected-error {{function declared 'stdcall' here was previously declared without calling convention}}
@@ -143,9 +153,10 @@
 void multi_attribute(int x) { __builtin_unreachable(); }
 
 
+// expected-error@+3 {{vectorcall and cdecl attributes are not compatible}}
 // expected-error@+2 {{stdcall and cdecl attributes are not compatible}}
 // expected-error@+1 {{fastcall and cdecl attributes are not compatible}}
-void __cdecl __cdecl __stdcall __cdecl __fastcall multi_cc(int x);
+void __cdecl __cdecl __stdcall __cdecl __fastcall __vectorcall multi_cc(int x);
 
 template <typename T> void __stdcall StdcallTemplate(T) {}
 template <> void StdcallTemplate<int>(int) {}