Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-24 Thread John McCall via cfe-commits
rjmccall added a comment.

LGTM.


http://reviews.llvm.org/D14864



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


Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-24 Thread David Kreitzer via cfe-commits
DavidKreitzer added a comment.

Looks good, Alexey!  I have no further comments.

- Dave


http://reviews.llvm.org/D14864



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


Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-23 Thread Alexey Bataev via cfe-commits
ABataev added a comment.

Ok, extracted all MCU specific changes to separate target class.


http://reviews.llvm.org/D14864



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


Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-23 Thread Alexey Bataev via cfe-commits
ABataev updated this revision to Diff 40904.

http://reviews.llvm.org/D14864

Files:
  lib/Basic/Targets.cpp
  test/Sema/callingconv-iamcu.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3391,11 +3391,6 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
-
-  if (getTriple().isOSIAMCU()) {
-Builder.defineMacro("__iamcu");
-Builder.defineMacro("__iamcu__");
-  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
@@ -3644,11 +3639,6 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
-if (getTriple().isOSIAMCU()) {
-  LongDoubleWidth = 64;
-  LongDoubleFormat = ::APFloat::IEEEdouble;
-}
-
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
@@ -3881,6 +3871,27 @@
   }
 };
 
+// X86-32 MCU target
+class MCUI386TargetInfo : public X86_32TargetInfo {
+public:
+  MCUI386TargetInfo(const llvm::Triple ) : X86_32TargetInfo(Triple) {
+LongDoubleWidth = 64;
+LongDoubleFormat = ::APFloat::IEEEdouble;
+  }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+// On MCU we support only C calling convention.
+return CC == CC_C ? CCCR_OK : CCCR_Warning;
+  }
+
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override {
+X86_32TargetInfo::getTargetDefines(Opts, Builder);
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
+};
+
 // RTEMS Target
 template
 class RTEMSTargetInfo : public OSTargetInfo {
@@ -7769,6 +7780,8 @@
   return new RTEMSX86_32TargetInfo(Triple);
 case llvm::Triple::NaCl:
   return new NaClTargetInfo(Triple);
+case llvm::Triple::ELFIAMCU:
+  return new MCUI386TargetInfo(Triple);
 default:
   return new X86_32TargetInfo(Triple);
 }
Index: test/Sema/callingconv-iamcu.c
===
--- test/Sema/callingconv-iamcu.c
+++ test/Sema/callingconv-iamcu.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning {{calling convention 'thiscall' ignored for this target}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning {{calling convention 'fastcall' ignored for this target}}
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning {{calling convention 'stdcall' ignored for this target}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+Handler H = foo;
+
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+   // expected-error {{invalid PCS type}}
+int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
+/* These are ignored because the target is i386 and not ARM */
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
+
+void ctest3();
+void __attribute__((cdecl)) ctest3() {}
+
+typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{calling convention 'stdcall' ignored for this target}}
+PROC __attribute__((cdecl)) ctest4(const char *x) {}
+
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // expected-warning {{calling convention 'intel_ocl_bicc' ignored for this 

Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-23 Thread Alexey Bataev via cfe-commits
ABataev updated this revision to Diff 41004.
ABataev added a comment.

Renamed MCU target class


http://reviews.llvm.org/D14864

Files:
  lib/Basic/Targets.cpp
  test/Sema/callingconv-iamcu.c

Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -3391,11 +3391,6 @@
   }
   if (CPU >= CK_i586)
 Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
-
-  if (getTriple().isOSIAMCU()) {
-Builder.defineMacro("__iamcu");
-Builder.defineMacro("__iamcu__");
-  }
 }
 
 bool X86TargetInfo::hasFeature(StringRef Feature) const {
@@ -3644,11 +3639,6 @@
 IntPtrType = SignedInt;
 RegParmMax = 3;
 
-if (getTriple().isOSIAMCU()) {
-  LongDoubleWidth = 64;
-  LongDoubleFormat = ::APFloat::IEEEdouble;
-}
-
 // Use fpret for all types.
 RealTypeUsesObjCFPRet = ((1 << TargetInfo::Float) |
  (1 << TargetInfo::Double) |
@@ -3881,6 +3871,27 @@
   }
 };
 
+// X86-32 MCU target
+class MCUX86_32TargetInfo : public X86_32TargetInfo {
+public:
+  MCUX86_32TargetInfo(const llvm::Triple ) : X86_32TargetInfo(Triple) {
+LongDoubleWidth = 64;
+LongDoubleFormat = ::APFloat::IEEEdouble;
+  }
+
+  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
+// On MCU we support only C calling convention.
+return CC == CC_C ? CCCR_OK : CCCR_Warning;
+  }
+
+  void getTargetDefines(const LangOptions ,
+MacroBuilder ) const override {
+X86_32TargetInfo::getTargetDefines(Opts, Builder);
+Builder.defineMacro("__iamcu");
+Builder.defineMacro("__iamcu__");
+  }
+};
+
 // RTEMS Target
 template
 class RTEMSTargetInfo : public OSTargetInfo {
@@ -7769,6 +7780,8 @@
   return new RTEMSX86_32TargetInfo(Triple);
 case llvm::Triple::NaCl:
   return new NaClTargetInfo(Triple);
+case llvm::Triple::ELFIAMCU:
+  return new MCUX86_32TargetInfo(Triple);
 default:
   return new X86_32TargetInfo(Triple);
 }
Index: test/Sema/callingconv-iamcu.c
===
--- test/Sema/callingconv-iamcu.c
+++ test/Sema/callingconv-iamcu.c
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-intel-elfiamcu -verify
+
+void __attribute__((fastcall)) foo(float *a) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+
+void __attribute__((stdcall)) bar(float *a) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+
+void __attribute__((fastcall(1))) baz(float *a) { // expected-error {{'fastcall' attribute takes no arguments}}
+}
+
+void __attribute__((fastcall)) test2(int a, ...) { // expected-warning {{calling convention 'fastcall' ignored for this target}}
+}
+void __attribute__((stdcall)) test3(int a, ...) { // expected-warning {{calling convention 'stdcall' ignored for this target}}
+}
+void __attribute__((thiscall)) test4(int a, ...) { // expected-warning {{calling convention 'thiscall' ignored for this target}}
+}
+
+void __attribute__((cdecl)) ctest0() {}
+
+void __attribute__((cdecl(1))) ctest1(float x) {} // expected-error {{'cdecl' attribute takes no arguments}}
+
+void (__attribute__((fastcall)) *pfoo)(float*) = foo; // expected-warning {{calling convention 'fastcall' ignored for this target}}
+
+void (__attribute__((stdcall)) *pbar)(float*) = bar; // expected-warning {{calling convention 'stdcall' ignored for this target}}
+
+void (*pctest0)() = ctest0;
+
+void ctest2() {}
+void (__attribute__((cdecl)) *pctest2)() = ctest2;
+
+typedef void (__attribute__((fastcall)) *Handler) (float *); // expected-warning {{calling convention 'fastcall' ignored for this target}}
+Handler H = foo;
+
+int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
+int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
+   // expected-error {{invalid PCS type}}
+int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
+/* These are ignored because the target is i386 and not ARM */
+int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{calling convention 'pcs' ignored for this target}}
+int __attribute__((pcs("foo"))) pcs7(void); // expected-error {{invalid PCS type}}
+
+void ctest3();
+void __attribute__((cdecl)) ctest3() {}
+
+typedef __attribute__((stdcall)) void (*PROC)(); // expected-warning {{calling convention 'stdcall' ignored for this target}}
+PROC __attribute__((cdecl)) ctest4(const char *x) {}
+
+void __attribute__((intel_ocl_bicc)) inteloclbifunc(float *a) {} // 

Re: [PATCH] D14864: [X86] Support for C calling convention only for MCU target.

2015-11-23 Thread David Kreitzer via cfe-commits
DavidKreitzer added a comment.

Thanks, Alexey! I think this is an improvement.

I don't know if anyone else has an opinion on the name of the new class, but I 
would prefer X86 over I386, possibly even MCUX86_32TargetInfo.

Thanks,

- Dave


http://reviews.llvm.org/D14864



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