[llvm-commits] CVS: llvm-gcc/gcc/config/rs6000/darwin.h

Chris Lattner lattner at cs.uiuc.edu
Thu Jul 28 11:52:18 PDT 2005



Changes in directory llvm-gcc/gcc/config/rs6000:

darwin.h updated: 1.5 -> 1.6
---
Log message:

Fix PR609: http://llvm.cs.uiuc.edu/PR609 , by adding a description of the darwin calling conventions.  Darwin
wants to pass FP values in integer registers in some cases.

This fixes 252.eon, 168.wupwise, 178.galgel, and 301.apsi on darwin.


---
Diffs of the changes:  (+49 -6)

 darwin.h |   55 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 49 insertions(+), 6 deletions(-)


Index: llvm-gcc/gcc/config/rs6000/darwin.h
diff -u llvm-gcc/gcc/config/rs6000/darwin.h:1.5 llvm-gcc/gcc/config/rs6000/darwin.h:1.6
--- llvm-gcc/gcc/config/rs6000/darwin.h:1.5	Tue Jul 26 13:02:42 2005
+++ llvm-gcc/gcc/config/rs6000/darwin.h	Thu Jul 28 13:52:07 2005
@@ -22,6 +22,55 @@
 #undef  TARGET_VERSION
 #define TARGET_VERSION fprintf (stderr, " (Darwin/PowerPC)");
 
+
+/* The maximum alignment for this target (according to LLVM) is 4 bytes,
+* this prevents the type layout machinery from thinking darwin's doubles
+* and 'long long's are 64-bit aligned.
+*/
+#define LLVM_TARGET_MAX_ALIGN_IS_POINTER_SIZE 1
+
+/*===---------------------------------------------------------------------===
+* LLVM Argument passing ABI hooks.
+*
+* The darwin ABI specifies that structure elements passed through the first
+* 8 words of memory should be passed in the GPRs, even if the element is a
+* floating point value.  The exception to this is single-element structures
+* and arrays,  which are passed in either the FP or integer regs depending on
+* their type.
+*
+* To implement this, we just have a little state machine in an integer.  The
+* low bit is a 'transform next element' flag.  The upper bits are a count of
+* the number of integer registers have been used.
+*/
+#define LLVM_TARGET_ARG_ACCUM_TYPE unsigned
+#define LLVM_TARGET_ARG_ACCUM_INIT 0
+#define LLVM_TARGET_ARG_DEFINE_COMPOSITE_ACCUM(NAME) unsigned NAME = 0
+#define LLVM_TARGET_ARG_ENTER_COMPOSITE(ACCUM, COMPACCUM, TY)      \
+do {                                                               \
+  COMPACCUM = ACCUM & 1;  /* Save old flag */                      \
+  if (COMPACCUM == 0)                                              \
+    if ((TY->ID == StructTyID && TY->NumElements != 1) ||          \
+        (TY->ID == ArrayTyID && TY->x.Array.Size != 1))            \
+      ACCUM |= 1;   /* Start transforming elements. */             \
+} while (0)
+
+#define LLVM_TARGET_ARG_EXIT_COMPOSITE(ACCUM, COMPACCUM, TY)       \
+do {                                                               \
+  ACCUM = (ACCUM & ~1) | COMPACCUM; /* restore flag */             \
+} while (0)
+
+#define LLVM_TARGET_ARG_MODIFY_ARG_TYPE_IF_NEEDED(ACCUM, TY)       \
+do {                                                               \
+  if ((ACCUM >> 1) < 8) { /* Not already on the stack? */          \
+    if (ACCUM & 1) {  /* If we are converting this, do so. */      \
+      if (llvm_type_is_fp(TY))                                     \
+        TY = TY->ID == FloatTyID ? IntTy : LongTy;                 \
+    }                                                              \
+    ACCUM += (TY->ID == DoubleTyID || TY->ID == LongTyID) ? 4 : 2; \
+  }                                                                \
+} while (0)
+
+
 /* The "Darwin ABI" is mostly like AIX, but with some key differences.  */
 
 #define DEFAULT_ABI ABI_DARWIN
@@ -270,12 +319,6 @@
 	      : TREE_TYPE (FIELD))) & ((1 << DFmode)|(1 << DImode))) \
    ? MIN ((COMPUTED), 32) : (COMPUTED)))
 
-/* The maximum alignment for this target (according to LLVM) is 4 bytes,
- * this prevents the type layout machinery from thinking darwin's doubles
- * and 'long long's are 64-bit aligned.
- */
-#define LLVM_TARGET_MAX_ALIGN_IS_POINTER_SIZE 1
-
 /* Darwin increases natural record alignment to doubleword if the first
    field is an FP double while the FP fields remain word aligned.  */
 #define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED)	\






More information about the llvm-commits mailing list