[llvm-commits] [llvm-gcc-4.2] r48059 - in /llvm-gcc-4.2/trunk/gcc/config/rs6000: llvm-rs6000.cpp rs6000.h
Dale Johannesen
dalej at apple.com
Sat Mar 8 15:56:00 PST 2008
Author: johannes
Date: Sat Mar 8 17:55:59 2008
New Revision: 48059
URL: http://llvm.org/viewvc/llvm-project?rev=48059&view=rev
Log:
Enable byval parameter passing for ppc32.
Modified:
llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp
llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h
Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=48059&r1=48058&r2=48059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Sat Mar 8 17:55:59 2008
@@ -365,5 +365,46 @@
return false;
}
+/* Target hook for llvm-abi.h. It returns true if an aggregate of the
+ specified type should be passed using the byval mechanism. */
+bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, const Type *Ty) {
+
+ /* FIXME byval not implemented for ppc64. */
+ if (TARGET_64BIT)
+ return false;
+
+ HOST_WIDE_INT Bytes = (TYPE_MODE(TreeType) == BLKmode) ?
+ int_size_in_bytes(TreeType) :
+ (int) GET_MODE_SIZE(TYPE_MODE(TreeType));
+
+ // Zero sized array, struct, or class, ignored.
+ if (Bytes == 0)
+ return false;
+
+ // If this is a small fixed size type, investigate it.
+ if (Bytes <= 0 || Bytes > 16)
+ return true;
+
+ // ppc32 passes aggregates by copying, either in int registers or on the
+ // stack. If this is an extremely simple aggregate whose elements would be
+ // passed the same if passed as scalars, pass them that way in order to
+ // promote SROA on the caller and callee side.
+ // Note that we can't support passing all structs this way. For example,
+ // {i16, i16} should be passed in on 32-bit unit, which is not how "i16, i16"
+ // would be passed as stand-alone arguments. And any floating point element
+ // would be passed in float regs, not int.
+ const StructType *STy = dyn_cast<StructType>(Ty);
+ if (!STy || STy->isPacked()) return true;
+
+ for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
+ const Type *EltTy = STy->getElementType(i);
+ // 32 and 64-bit integers are fine, as are pointers.
+ // Shorter ints do not work, nor do floating point or vectors.
+ if (EltTy != Type::Int32Ty && EltTy != Type::Int64Ty &&
+ !isa<PointerType>(EltTy))
+ return true;
+ }
+ return false;
+}
/* LLVM LOCAL end (ENTIRE FILE!) */
Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h?rev=48059&r1=48058&r2=48059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Sat Mar 8 17:55:59 2008
@@ -3473,6 +3473,13 @@
DESTTY, OPS) \
TargetIntrinsicLower(EXP, BUILTIN_CODE, DESTLOC, RESULT, DESTTY, OPS);
+#ifdef LLVM_ABI_H
+extern bool llvm_rs6000_should_pass_aggregate_byval(tree, const Type *);
+
+#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \
+ llvm_rs6000_should_pass_aggregate_byval(X, TY)
+#endif
+
/* LLVM LOCAL end */
enum rs6000_builtin_type_index
More information about the llvm-commits
mailing list