[llvm-commits] [llvm-gcc-4.2] r47403 - in /llvm-gcc-4.2/trunk/gcc: config/i386/i386-protos.h config/i386/i386.c config/i386/llvm-i386-target.h llvm-abi.h

Dale Johannesen dalej at apple.com
Wed Feb 20 13:18:06 PST 2008


Author: johannes
Date: Wed Feb 20 15:18:06 2008
New Revision: 47403

URL: http://llvm.org/viewvc/llvm-project?rev=47403&view=rev
Log:
Add hook for passing alignment on ByVal parameters.
Implement it for x86.


Modified:
    llvm-gcc-4.2/trunk/gcc/config/i386/i386-protos.h
    llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
    llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
    llvm-gcc-4.2/trunk/gcc/llvm-abi.h

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/i386-protos.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/i386-protos.h Wed Feb 20 15:18:06 2008
@@ -171,6 +171,8 @@
 extern rtx function_arg (CUMULATIVE_ARGS *, enum machine_mode, tree, int);
 extern void function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
 				  tree, int);
+/* LLVM LOCAL make this global */
+extern bool contains_128bit_aligned_vector_p (tree);
 extern rtx ix86_function_value (tree, tree, bool);
 #endif
 

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

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Wed Feb 20 15:18:06 2008
@@ -1224,7 +1224,8 @@
 static bool ix86_function_ok_for_sibcall (tree, tree);
 static tree ix86_handle_cconv_attribute (tree *, tree, tree, int, bool *);
 static int ix86_value_regno (enum machine_mode, tree, tree);
-static bool contains_128bit_aligned_vector_p (tree);
+/* LLVM LOCAL make global */
+/*static bool contains_128bit_aligned_vector_p (tree);*/
 static rtx ix86_struct_value_rtx (tree, int);
 static bool ix86_ms_bitfield_layout_p (tree);
 static tree ix86_handle_struct_attribute (tree *, tree, tree, int, bool *);
@@ -4020,7 +4021,8 @@
 
 /* Return true when TYPE should be 128bit aligned for 32bit argument passing
    ABI.  Only called if TARGET_SSE.  */
-static bool
+/* LLVM LOCAL make global */
+bool
 contains_128bit_aligned_vector_p (tree type)
 {
   enum machine_mode mode = TYPE_MODE (type);

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=47403&r1=47402&r2=47403&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 Wed Feb 20 15:18:06 2008
@@ -84,6 +84,12 @@
   }
 
 #ifdef LLVM_ABI_H
+
+/* Objects containing SSE vectors are 16 byte aligned, everything else 4. */
+extern "C" bool contains_128bit_aligned_vector_p(tree);
+#define LLVM_BYVAL_ALIGNMENT(T) \
+  (TARGET_SSE && contains_128bit_aligned_vector_p(T) ? 16 : 4)
+
 extern bool llvm_x86_should_pass_aggregate_in_memory(tree, const Type *);
 
 #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY)      \

Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=47403&r1=47402&r2=47403&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Feb 20 15:18:06 2008
@@ -153,6 +153,15 @@
     false
 #endif
 
+// LLVM_BYVAL_ALIGNMENT - Returns the alignment of the type in bytes, if known,
+// in the context of its use as a function parameter.
+// Note that the alignment in the TYPE node is usually the alignment appropriate
+// when the type is used within a struct, which may or may not be appropriate
+// here.
+#ifndef LLVM_BYVAL_ALIGNMENT
+#define LLVM_BYVAL_ALIGNMENT(T)  0
+#endif
+
 // LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS - Return true if this aggregate
 // value should be passed in integer registers.  By default, we do this for all
 // values that are not single-element structs.  This ensures that things like
@@ -241,8 +250,10 @@
       PassInMixedRegisters(type, Ty, Elts);
     } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) {
       C.HandleByValArgument(Ty, type);
-      if (Attributes)
+      if (Attributes) {
         *Attributes |= ParamAttr::ByVal;
+        *Attributes |= (LLVM_BYVAL_ALIGNMENT(type) << 16);
+      }
     } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) {
       PassInIntegerRegisters(type, Ty);
     } else if (isZeroSizedStructOrUnion(type)) {





More information about the llvm-commits mailing list