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

Dale Johannesen dalej at apple.com
Fri Jun 6 18:19:34 PDT 2008


Author: johannes
Date: Fri Jun  6 20:19:33 2008
New Revision: 52068

URL: http://llvm.org/viewvc/llvm-project?rev=52068&view=rev
Log:
MMX vectors return in XMM0 on darwin x86-64.
(Maybe linux too?  but not win64).


Modified:
    llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
    llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.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=52068&r1=52067&r2=52068&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 Fri Jun  6 20:19:33 2008
@@ -91,12 +91,15 @@
   (TARGET_64BIT ? 0 : \
    TARGET_SSE && contains_128bit_aligned_vector_p(T) ? 16 : 4)
 
+extern tree llvm_x86_should_return_selt_struct_as_scalar(tree);
+
 /* Structs containing a single data field plus zero-length fields are
-   considered as if they were the type of the data field. */
-#ifndef LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR
+   considered as if they were the type of the data field.  On x86-64,
+   if the element type is an MMX vector, return it as double (which will
+   get it into XMM0). */
+
 #define LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(X) \
-  isSingleElementStructOrArray(X, true, false)
-#endif
+  llvm_x86_should_return_selt_struct_as_scalar((X))
 
 extern bool llvm_x86_should_pass_aggregate_in_integer_regs(tree, 
                                                           unsigned*, bool*);

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=52068&r1=52067&r2=52068&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Fri Jun  6 20:19:33 2008
@@ -872,6 +872,22 @@
   return 0;
 }
 
+/* MMX vectors are returned in XMM0 on x86-64 Darwin.  The easiest way to
+   communicate this is pretend they're doubles.
+   Judging from comments, this would not be right for Win64.  Don't know
+   about Linux.  */
+tree llvm_x86_should_return_selt_struct_as_scalar(tree type) {
+  tree retType = isSingleElementStructOrArray(type, true, false);
+  if (!retType || !TARGET_64BIT || !TARGET_MACHO)
+    return retType;
+  if (TREE_CODE(retType) == VECTOR_TYPE &&
+      TYPE_SIZE(retType) &&
+      TREE_CODE(TYPE_SIZE(retType))==INTEGER_CST &&
+      TREE_INT_CST_LOW(TYPE_SIZE(retType))==64)
+    return double_type_node;
+  return retType;
+}
+
 /* MMX vectors v2i32, v4i16, v8i8, v2f32 are returned using sret on Darwin
    32-bit.  Vectors bigger than 128 are returned using sret.  */
 bool llvm_x86_should_return_vector_as_shadow(tree type, bool isBuiltin) {





More information about the llvm-commits mailing list