]> granicus.if.org Git - clang/commitdiff
Provide sema proper values of maximal number of arguments passed in registers.
authorAnton Korobeynikov <asl@math.spbu.ru>
Fri, 3 Apr 2009 23:38:25 +0000 (23:38 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Fri, 3 Apr 2009 23:38:25 +0000 (23:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68413 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/TargetInfo.h
lib/Basic/Targets.cpp
lib/Sema/SemaDeclAttr.cpp

index 815b8b5ae639b93129864b6b52b2cf43fc430d58..1bdabadf4509da16ef2e5682c04330e20b5507c6 100644 (file)
@@ -436,9 +436,9 @@ def err_attribute_cleanup_func_arg_incompatible_type : Error<
   "'cleanup' function %0 parameter has type %1 which is incompatible with "
   "type %2">;
 def err_attribute_regparm_wrong_platform : Error<
-  "'regparm' is not valid on platforms other than x86-32">;
+  "'regparm' is not valid on this platform">;
 def err_attribute_regparm_invalid_number : Error<
-  "'regparm' parameter must be between 0 and 3 inclusive">;
+  "'regparm' parameter must be between 0 and %0 inclusive">;
 
 
 // Clang-Specific Attributes
index 2cb15f12f30d2396ae08d96a137f68f957099ae9..8018a17c9e07def44f63f7e9ba0a34e449254cfe 100644 (file)
@@ -48,6 +48,7 @@ protected:
   const char *DescriptionString;
   const char *UserLabelPrefix;
   const llvm::fltSemantics *FloatFormat, *DoubleFormat, *LongDoubleFormat;
+  unsigned char RegParmMax, SSERegParmMax;
 
   // TargetInfo Constructor.  Default initializes all fields.
   TargetInfo(const std::string &T);
@@ -304,6 +305,12 @@ public:
       return -1;
     return 0;
   }
+
+  // getRegParmMax - Returns maximal number of args passed in registers.
+  unsigned getRegParmMax() const {
+    return RegParmMax;
+  }
+
 protected:
   virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
     return PointerWidth;
index 5f5ba60e85853f0b510ceac5a6264262e8caa8a9..40bc31381d1e186c9010d94bf5e4bf128b342689 100644 (file)
@@ -633,6 +633,7 @@ public:
     SizeType = UnsignedInt;
     PtrDiffType = SignedInt;
     IntPtrType = SignedInt;
+    RegParmMax = 3;
   }
   virtual const char *getVAListDeclaration() const {
     return "typedef char* __builtin_va_list;";
@@ -762,6 +763,7 @@ public:
     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-"
index 40e4971d2b8808fb6ac5fd795ed75e3dccc712ae..a68ddf6c003c3de2917298f0595cc070e25d4123 100644 (file)
@@ -1465,17 +1465,16 @@ static void HandleRegparmAttr(Decl *d, const AttributeList &Attr, Sema &S) {
     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;
   }