[llvm-commits] [llvm-gcc-4.2] r52695 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp
Dale Johannesen
dalej at apple.com
Tue Jun 24 15:19:13 PDT 2008
Author: johannes
Date: Tue Jun 24 17:19:13 2008
New Revision: 52695
URL: http://llvm.org/viewvc/llvm-project?rev=52695&view=rev
Log:
Add hook for passing vectors byval. Used on
x86-64 for vectors > 128 bits.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-convert.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=52695&r1=52694&r2=52695&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 Jun 24 17:19:13 2008
@@ -112,33 +112,39 @@
#define LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(X, Y, Z) \
llvm_x86_should_pass_aggregate_in_integer_regs((X), (Y), (Z))
-extern bool llvm_x86_should_pass_vector_in_integer_regs(tree);
+extern const Type *llvm_x86_scalar_type_for_struct_return(tree type,
+ unsigned *Offset);
/* LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be
returned as a scalar, otherwise return NULL. */
#define LLVM_SCALAR_TYPE_FOR_STRUCT_RETURN(X, Y) \
llvm_x86_scalar_type_for_struct_return((X), (Y))
-extern const Type *llvm_x86_scalar_type_for_struct_return(tree type,
- unsigned *Offset);
+extern const Type *llvm_x86_aggr_type_for_struct_return(tree type);
/* LLVM_AGGR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be
returned as an aggregate, otherwise return NULL. */
#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X) \
llvm_x86_aggr_type_for_struct_return(X)
-extern const Type *llvm_x86_aggr_type_for_struct_return(tree type);
+extern void llvm_x86_extract_multiple_return_value(Value *Src, Value *Dest,
+ bool isVolatile,
+ IRBuilder &B);
/* LLVM_EXTRACT_MULTIPLE_RETURN_VALUE - Extract multiple return value from
SRC and assign it to DEST. */
#define LLVM_EXTRACT_MULTIPLE_RETURN_VALUE(Src,Dest,V,B) \
llvm_x86_extract_multiple_return_value((Src),(Dest),(V),(B))
-extern void llvm_x86_extract_multiple_return_value(Value *Src, Value *Dest,
- bool isVolatile,
- IRBuilder &B);
+extern bool llvm_x86_should_pass_vector_using_byval_attr(tree);
+
+/* On x86-64, vectors which are not MMX nor SSE should be passed byval. */
+#define LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(X) \
+ llvm_x86_should_pass_vector_using_byval_attr((X))
+
+extern bool llvm_x86_should_pass_vector_in_integer_regs(tree);
-/* Vectors which are not MMX nor SSE should be passed as integers. */
+/* On x86-32, vectors which are not MMX nor SSE should be passed as integers. */
#define LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(X) \
llvm_x86_should_pass_vector_in_integer_regs((X))
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=52695&r1=52694&r2=52695&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 Tue Jun 24 17:19:13 2008
@@ -845,7 +845,9 @@
return !totallyEmpty;
}
-/* On Darwin, vectors which are not MMX nor SSE should be passed as integers. */
+/* On Darwin x86-32, vectors which are not MMX nor SSE should be passed as
+ integers. On Darwin x86-64, such vectors bigger than 128 bits should be
+ passed in memory (byval). */
bool llvm_x86_should_pass_vector_in_integer_regs(tree type) {
if (!TARGET_MACHO)
return false;
@@ -856,6 +858,24 @@
return false;
if (TREE_INT_CST_LOW(TYPE_SIZE(type))==128 && TARGET_SSE)
return false;
+ if (TARGET_64BIT && TREE_INT_CST_LOW(TYPE_SIZE(type)) > 128)
+ return false;
+ }
+ return true;
+}
+
+/* On Darwin x86-64, vectors which are bigger than 128 bits should be passed
+ byval (in memory). */
+bool llvm_x86_should_pass_vector_using_byval_attr(tree type) {
+ if (!TARGET_MACHO)
+ return false;
+ if (!TARGET_64BIT)
+ return false;
+ if (TREE_CODE(type) == VECTOR_TYPE &&
+ TYPE_SIZE(type) &&
+ TREE_CODE(TYPE_SIZE(type))==INTEGER_CST) {
+ if (TREE_INT_CST_LOW(TYPE_SIZE(type))<=128)
+ return false;
}
return true;
}
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=52695&r1=52694&r2=52695&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Tue Jun 24 17:19:13 2008
@@ -236,6 +236,13 @@
false
#endif
+// LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR - Return true if this vector
+// type should be passed byval. Used for generic vectors on x86-64.
+#ifndef LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR
+#define LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(X) \
+ false
+#endif
+
// LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR - Return true if this aggregate
// value should be passed by value, i.e. passing its address with the byval
// attribute bit set. The default is false.
@@ -420,6 +427,13 @@
} else if (Ty->getTypeID()==Type::VectorTyID) {
if (LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(type)) {
PassInIntegerRegisters(type, Ty, ScalarElts, 0, false);
+ } else if (LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(type)) {
+ C.HandleByValArgument(Ty, type);
+ if (Attributes) {
+ *Attributes |= ParamAttr::ByVal;
+ *Attributes |=
+ ParamAttr::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type));
+ }
} else {
C.HandleScalarArgument(Ty, type);
ScalarElts.push_back(Ty);
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=52695&r1=52694&r2=52695&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jun 24 17:19:13 2008
@@ -717,6 +717,8 @@
const Type *ArgTy = ConvertType(TREE_TYPE(Args));
bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args));
if (isInvRef ||
+ (ArgTy->getTypeID()==Type::VectorTyID &&
+ LLVM_SHOULD_PASS_VECTOR_USING_BYVAL_ATTR(TREE_TYPE(Args))) ||
(!ArgTy->isSingleValueType() &&
isPassedByVal(TREE_TYPE(Args), ArgTy, ScalarArgs))) {
// If the value is passed by 'invisible reference' or 'byval reference',
More information about the llvm-commits
mailing list