Provide sema proper values of maximal number of arguments passed in registers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68413 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp
index 5f5ba60..40bc313 100644
--- a/lib/Basic/Targets.cpp
+++ b/lib/Basic/Targets.cpp
@@ -633,6 +633,7 @@
     SizeType = UnsignedInt;
     PtrDiffType = SignedInt;
     IntPtrType = SignedInt;
+    RegParmMax = 3;
   }
   virtual const char *getVAListDeclaration() const {
     return "typedef char* __builtin_va_list;";
@@ -762,6 +763,7 @@
     LongDoubleAlign = 128;
     IntMaxType = SignedLong;
     UIntMaxType = UnsignedLong;
+    RegParmMax = 6;
 
     DescriptionString = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
                         "i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-"
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 40e4971..a68ddf6 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -1465,17 +1465,16 @@
     return;
   }
 
-  if (NumParams.getLimitedValue(4) > 3) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_regparm_invalid_number)
+  if (S.Context.Target.getRegParmMax() == 0) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_regparm_wrong_platform)
       << NumParamsExpr->getSourceRange();
     return;
   }
 
-  const char *TargetPrefix = S.Context.Target.getTargetPrefix();
-  unsigned PointerWidth = S.Context.Target.getPointerWidth(0);
-  if (strcmp(TargetPrefix, "x86") || PointerWidth != 32) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_regparm_wrong_platform)
-      << NumParamsExpr->getSourceRange();
+  // FIXME: we need to honour command line settings also...
+  if (NumParams.getLimitedValue(4) > S.Context.Target.getRegParmMax()) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_regparm_invalid_number)
+      << S.Context.Target.getRegParmMax() << NumParamsExpr->getSourceRange();
     return;
   }