[llvm-commits] [llvm-gcc-4.2] r49741 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
Devang Patel
dpatel at apple.com
Tue Apr 15 14:19:38 PDT 2008
Author: dpatel
Date: Tue Apr 15 16:19:37 2008
New Revision: 49741
URL: http://llvm.org/viewvc/llvm-project?rev=49741&view=rev
Log:
Piggyback gcc's ix86_ClassifyArgument()
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp
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=49741&r1=49740&r2=49741&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 Apr 15 16:19:37 2008
@@ -923,8 +923,9 @@
// llvm_suitable_multiple_ret_value_type - Return TRUE if return value
// of type TY should be returned using multiple value return instruction.
-static bool llvm_suitable_multiple_ret_value_type(const Type *Ty) {
-
+static bool llvm_suitable_multiple_ret_value_type(const Type *Ty,
+ tree TreeType,
+ std::vector<const Type *>&Elts) {
//NOTE: Work in progress. Do not open the flood gate yet.
return false;
@@ -934,27 +935,28 @@
const StructType *STy = dyn_cast<StructType>(Ty);
if (!STy)
return false;
-
- unsigned NumElements = STy->getNumElements();
- bool useMultipleReturnVals = true;
- for (unsigned i = 0; i < NumElements; ++i) {
- const Type *T = STy->getElementType(i);
-
- if (T->isFirstClassType())
- continue;
+ //Let gcc specific routine answer the question.
+ enum x86_64_reg_class Class[MAX_CLASSES];
+ enum machine_mode Mode = ix86_getNaturalModeForType(TreeType);
+ if (llvm_x86_64_type_needs_multiple_regs(Mode, TreeType, Class)) {
+
+ llvm_x86_64_should_pass_aggregate_in_mixed_regs(TreeType, Ty, Elts);
+ assert (!Elts.empty() && "Unable to handle aggregate return type!");
+ // If it is a singleton structure, e.g. { long double ld;} then use the type
+ // directly.
+ if (Elts.size() == 1)
+ return true;
- if (const ArrayType *ATy = dyn_cast<ArrayType>(T)) {
- // Allow { float f[4]; } but block { float f[10]; } or { char c[4]; }
- // FIXME :Double check '5'.
- if (ATy->getElementType()->isFloatingPoint()
- && ATy->getNumElements() < 5)
- continue;
- }
- return false;
+ bool foundFloat = false;
+ for (unsigned i = 0; i < Elts.size(); ++i)
+ if (Elts[i]->isFloatingPoint())
+ foundFloat = true;
+
+ return foundFloat;
}
-
- return true;
+
+ return false;
}
// llvm_x86_scalar_type_for_struct_return - Return LLVM type if TYPE
@@ -972,8 +974,12 @@
return Type::Int32Ty;
// Check if Ty should be returned using multiple value return instruction.
- if (llvm_suitable_multiple_ret_value_type(Ty))
+ std::vector<const Type *>Elts;
+ if (llvm_suitable_multiple_ret_value_type(Ty, type, Elts)) {
+ if (Elts.size() == 1)
+ return Elts[0];
return NULL;
+ }
if (Size <= 8)
return Type::Int64Ty;
@@ -988,7 +994,8 @@
// Return LLVM Type if TYPE can be returned as an aggregate, otherwise return NULL.
const Type *llvm_x86_aggr_type_for_struct_return(tree type) {
const Type *Ty = ConvertType(type);
- if (!llvm_suitable_multiple_ret_value_type(Ty))
+ std::vector<const Type *>Elts;
+ if (!llvm_suitable_multiple_ret_value_type(Ty, type, Elts))
return NULL;
const StructType *STy = cast<StructType>(Ty);
More information about the llvm-commits
mailing list