[llvm-commits] [llvm-gcc-4.2] r49017 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp config/rs6000/llvm-rs6000.cpp config/rs6000/rs6000.h llvm-abi.h
Devang Patel
dpatel at apple.com
Mon Mar 31 19:29:32 PDT 2008
Author: dpatel
Date: Mon Mar 31 21:29:32 2008
New Revision: 49017
URL: http://llvm.org/viewvc/llvm-project?rev=49017&view=rev
Log:
Simplify. Move target specific code into the area where target specific code lives.
This patch does not introduce any functionality change, at least that is the intent.
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/config/rs6000/llvm-rs6000.cpp
llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
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=49017&r1=49016&r2=49017&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 Mon Mar 31 21:29:32 2008
@@ -98,6 +98,13 @@
isSingleElementStructOrArray(X, true, false)
#endif
+#ifndef LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR
+#define LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(X) \
+ llvm_x86_should_return_struct_as_scalar(X)
+#endif
+
+extern bool llvm_x86_should_return_struct_as_scalar(tree);
+
extern bool llvm_x86_should_pass_vector_in_integer_regs(tree);
/* Vectors which are not MMX nor SSE should be passed as integers. */
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=49017&r1=49016&r2=49017&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 Mon Mar 31 21:29:32 2008
@@ -674,6 +674,17 @@
return true;
}
+/* Returns true if TYPE should be pass as scalar. */
+bool llvm_x86_should_return_struct_as_scalar(tree type) {
+ // FIXME without this, 64-bit _Complex long double crashes. With it, we
+ // just produce incorrect code.
+ if (!TARGET_64BIT)
+ return true;
+ if (TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type)) << 8)
+ return true;
+ return false;
+}
+
/* Target hook for llvm-abi.h. It returns true if an aggregate of the
specified type should be passed in a number of registers of mixed types.
It also returns a vector of types that correspond to the registers used
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=49017&r1=49016&r2=49017&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 Mon Mar 31 21:29:32 2008
@@ -487,5 +487,20 @@
return false;
}
+/* Returns true if TYPE should be pass as scalar. */
+bool llvm_rs6000_should_return_struct_as_scalar(tree type) {
+ // FIXME darwin ppc64 often returns structs partly in memory and partly
+ // in regs. The binary interface of return_in_memory (which does the
+ // work for aggregate_value_p) is not a good match for this; in fact
+ // this target returns false if any part of it goes in registers. Which
+ // means aggregate_value_p is not useful on this target for this purpose.
+ // This is a big nasty longterm problem. For now put things back the
+ // way they used to be (wrong, but fewer crashes).
+ if (!TARGET_64BIT)
+ return true;
+ if (TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type))<=8)
+ 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=49017&r1=49016&r2=49017&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Mon Mar 31 21:29:32 2008
@@ -3507,6 +3507,12 @@
#define LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(X,isBuiltin)\
llvm_rs6000_should_return_vector_as_shadow((X), (isBuiltin))
+#ifndef LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR
+#define LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(X) \
+ llvm_rs6000_should_return_struct_as_scalar(X)
+#endif
+
+extern bool llvm_rs6000_should_return_struct_as_scalar(tree);
#endif /* LLVM_ABI_H */
/* LLVM LOCAL end */
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=49017&r1=49016&r2=49017&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Mar 31 21:29:32 2008
@@ -96,6 +96,15 @@
TREE_CODE(type) == COMPLEX_TYPE;
}
+// isAggregateFunctionParam - Return true if the specified GCC type
+// satisfies function.c:aggregate_value_p()
+static bool isAggregateFunctionParam(tree type) {
+ if (TYPE_SIZE(type) && TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST
+ && !aggregate_value_p(type, current_function_decl))
+ return true;
+ return false;
+}
+
/// isSingleElementStructOrArray - If this is (recursively) a structure with one
/// field or an array with one element, return the field type, otherwise return
/// null. If ignoreZeroLength, the struct (recursively) may include zero-length
@@ -216,6 +225,13 @@
isSingleElementStructOrArray(X, false, false)
#endif
+// LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR - Return true if TYPE tree should
+// be returned as a scalar.
+#ifndef LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR
+#define LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(x) \
+ false
+#endif
+
// LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR - Return a TYPE tree if this vector type
// should be returned using the convention for that scalar TYPE, 0 otherwise.
// X may be evaluated more than once.
@@ -263,24 +279,8 @@
} else if (Ty->isFirstClassType() || Ty == Type::VoidTy) {
// Return scalar values normally.
C.HandleScalarResult(Ty);
- } else if (TYPE_SIZE(type) && TREE_CODE(TYPE_SIZE(type)) == INTEGER_CST &&
- !aggregate_value_p(type, current_function_decl)
-#if defined(TARGET_386)
- // FIXME without this, 64-bit _Complex long double crashes. With it, we
- // just produce incorrect code.
- && (!TARGET_64BIT || TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type))<=8)
-#endif
-#if defined(TARGET_POWERPC)
- // FIXME darwin ppc64 often returns structs partly in memory and partly
- // in regs. The binary interface of return_in_memory (which does the
- // work for aggregate_value_p) is not a good match for this; in fact
- // this target returns false if any part of it goes in registers. Which
- // means aggregate_value_p is not useful on this target for this purpose.
- // This is a big nasty longterm problem. For now put things back the
- // way they used to be (wrong, but fewer crashes).
- && (!TARGET_64BIT || TREE_INT_CST_LOW(TYPE_SIZE_UNIT(type))<=8)
-#endif
- ) {
+ } else if (isAggregateFunctionParam(type)
+ && LLVM_SHOULD_RETURN_STRUCT_AS_SCALAR(type)) {
tree SingleElt = LLVM_SHOULD_RETURN_SELT_STRUCT_AS_SCALAR(type);
if (SingleElt && TYPE_SIZE(SingleElt) &&
TREE_CODE(TYPE_SIZE(SingleElt)) == INTEGER_CST &&
More information about the llvm-commits
mailing list