[llvm-commits] [llvm-gcc-4.2] r46765 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h llvm-types.cpp

Dale Johannesen dalej at apple.com
Tue Feb 5 12:48:34 PST 2008


Author: johannes
Date: Tue Feb  5 14:48:34 2008
New Revision: 46765

URL: http://llvm.org/viewvc/llvm-project?rev=46765&view=rev
Log:
Implement sseregparm in llvm.


Modified:
    llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
    llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=46765&r1=46764&r2=46765&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Tue Feb  5 14:48:34 2008
@@ -28,8 +28,11 @@
       CC = CallingConv::X86_StdCall;                            \
     } else if (lookup_attribute("fastcall", type_attributes)) { \
       CC = CallingConv::X86_FastCall;                           \
+    } else if (!TARGET_64BIT &&                                 \
+               lookup_attribute("sseregparm", type_attributes)){\
+      CC = CallingConv::X86_SSECall;                            \
     }                                                           \
-  }                                                             \
+  }
 
 /* LLVM specific stuff for converting gcc's `regparm` attribute to LLVM's
    `inreg` parameter attribute */
@@ -37,28 +40,46 @@
 
 extern int ix86_regparm;
 
-#define LLVM_TARGET_INIT_REGPARM(local_regparm, type)           \
+#define LLVM_TARGET_INIT_REGPARM(local_regparm, local_fp_regparm, type) \
   {                                                             \
     tree attr;                                                  \
     local_regparm = ix86_regparm;                               \
+    local_fp_regparm = TARGET_SSEREGPARM ? 3 : 0;               \
     attr = lookup_attribute ("regparm",                         \
                               TYPE_ATTRIBUTES (type));          \
     if (attr) {                                                 \
       local_regparm = TREE_INT_CST_LOW (TREE_VALUE              \
                                         (TREE_VALUE (attr)));   \
     }                                                           \
+    attr = lookup_attribute("sseregparm",                       \
+                              TYPE_ATTRIBUTES (type));          \
+    if (attr)                                                   \
+      local_fp_regparm = 3;                                     \
   }
 
-#define LLVM_ADJUST_REGPARM_ATTRIBUTE(Attribute, Size,          \
-                                      local_regparm)            \
+#define LLVM_ADJUST_REGPARM_ATTRIBUTE(Attribute, Type, Size,    \
+                                      local_regparm,            \
+                                      local_fp_regparm)         \
   {                                                             \
     if (!TARGET_64BIT) {                                        \
-      int words = (Size + BITS_PER_WORD - 1) / BITS_PER_WORD;   \
-      local_regparm -= words;                                   \
-      if (local_regparm>=0) {                                   \
-        Attribute |= ParamAttr::InReg;                          \
-      } else                                                    \
-        local_regparm = 0;                                      \
+      if (TREE_CODE(Type) == REAL_TYPE &&                       \
+          (TYPE_PRECISION(Type)==32 ||                          \
+           TYPE_PRECISION(Type)==64)) {                         \
+          local_fp_regparm -= 1;                                \
+          if (local_fp_regparm >= 0)                            \
+            Attribute |= ParamAttr::InReg;                      \
+          else                                                  \
+            local_fp_regparm = 0;                               \
+      } else if (TREE_CODE(Type) == INTEGER_TYPE ||             \
+                 TREE_CODE(Type) == ENUMERAL_TYPE) {            \
+          int words =                                           \
+                  (Size + BITS_PER_WORD - 1) / BITS_PER_WORD;   \
+          local_regparm -= words;                               \
+          if (local_regparm>=0)                                 \
+            Attribute |= ParamAttr::InReg;                      \
+          else                                                  \
+            local_regparm = 0;                                  \
+      }                                                         \
     }                                                           \
   }
 

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=46765&r1=46764&r2=46765&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Tue Feb  5 14:48:34 2008
@@ -1161,8 +1161,9 @@
   // If the target has regparam parameters, allow it to inspect the function
   // type.
   int local_regparam = 0;
+  int local_fp_regparam = 0;
 #ifdef LLVM_TARGET_ENABLE_REGPARM
-  LLVM_TARGET_INIT_REGPARM(local_regparam, type);
+  LLVM_TARGET_INIT_REGPARM(local_regparam, local_fp_regparam, type);
 #endif // LLVM_TARGET_ENABLE_REGPARM
   
   // Keep track of whether we see a byval argument.
@@ -1208,10 +1209,11 @@
     
 #ifdef LLVM_TARGET_ENABLE_REGPARM
     // Allow the target to mark this as inreg.
-    if (TREE_CODE(ArgTy) == INTEGER_TYPE || TREE_CODE(ArgTy) == POINTER_TYPE)
-      LLVM_ADJUST_REGPARM_ATTRIBUTE(Attributes,
+    if (TREE_CODE(ArgTy) == INTEGER_TYPE || TREE_CODE(ArgTy) == POINTER_TYPE ||
+        TREE_CODE(ArgTy) == REAL_TYPE)
+      LLVM_ADJUST_REGPARM_ATTRIBUTE(Attributes, ArgTy,
                                     TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)),
-                                    local_regparam);
+                                    local_regparam, local_fp_regparam);
 #endif // LLVM_TARGET_ENABLE_REGPARM
     
     if (Attributes != ParamAttr::None) {





More information about the llvm-commits mailing list