[llvm-commits] [llvm-gcc-4.2] r93898 - in /llvm-gcc-4.2/trunk/gcc/config/mips: llvm-mips-target.h llvm-mips.cpp

Bruno Cardoso Lopes bruno.cardoso at gmail.com
Tue Jan 19 12:11:23 PST 2010


Author: bruno
Date: Tue Jan 19 14:11:23 2010
New Revision: 93898

URL: http://llvm.org/viewvc/llvm-project?rev=93898&view=rev
Log:
One more step towards PR5445. Return type { double, double } instead
of i128 for mips.

Modified:
    llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h
    llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp

Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h?rev=93898&r1=93897&r2=93898&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h Tue Jan 19 14:11:23 2010
@@ -24,9 +24,28 @@
 
 extern bool llvm_mips_should_pass_aggregate_in_memory(tree, const Type *);
 
-#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY)      \
+/* 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.  */
+#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \
   llvm_mips_should_pass_aggregate_in_memory(X, TY)
 
+extern bool
+llvm_mips_should_not_return_complex_in_memory(tree type);
+
+/* LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY - A hook to allow
+   special _Complex handling. Return true if X should be returned using
+   multiple value return instruction.  */
+#define LLVM_SHOULD_NOT_RETURN_COMPLEX_IN_MEMORY(X) \
+  llvm_mips_should_not_return_complex_in_memory((X))
+
+extern const Type *llvm_mips_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, CC) \
+  llvm_mips_aggr_type_for_struct_return(X)
+
 #endif /* LLVM_ABI_H */
 
 /* LLVM LOCAL end (ENTIRE FILE!)  */

Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp?rev=93898&r1=93897&r2=93898&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp Tue Jan 19 14:11:23 2010
@@ -27,6 +27,8 @@
 #include "llvm-abi.h"
 #include "llvm-mips-target.h"
 
+static LLVMContext &Context = getGlobalContext();
+
 /* Target hook for llvm-abi.h. It returns true if an aggregate of the
    specified type should be passed in memory. In mips EABI this is 
    true for aggregates with size > 32-bits. */
@@ -45,4 +47,36 @@
   return false; // TODO: support o32 ABI
 }
 
+// llvm_mips_should_not_return_complex_in_memory -  Return true if TYPE 
+// should be returned using multiple value return instruction. This 
+// implementation is based on mips_function_value in mips.c
+bool llvm_mips_should_not_return_complex_in_memory(tree type) {
+
+  enum machine_mode mode = TYPE_MODE(type);
+
+  if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT
+      && GET_MODE_SIZE (mode) <= UNITS_PER_HWFPVALUE * 2)
+    return true;
+
+  return false;
+}
+
+// Return LLVM Type if TYPE can be returned as an aggregate, 
+// otherwise return NULL.
+const Type *llvm_mips_aggr_type_for_struct_return(tree type) {
+  const Type *Ty = ConvertType(type);
+
+  const StructType *STy = cast<StructType>(Ty);
+  std::vector<const Type *> ElementTypes;
+
+  // Special handling for _Complex.
+  if (llvm_mips_should_not_return_complex_in_memory(type)) {
+    ElementTypes.push_back(Type::getDoubleTy(Context));
+    ElementTypes.push_back(Type::getDoubleTy(Context));
+    return StructType::get(Context, ElementTypes, STy->isPacked());
+  } 
+
+  return NULL;
+}
+
 /* LLVM LOCAL end (ENTIRE FILE!)  */





More information about the llvm-commits mailing list