[llvm-commits] [llvm-gcc-4.2] r47984 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h llvm-abi.h llvm-convert.cpp llvm-types.cpp
Dale Johannesen
dalej at apple.com
Wed Mar 5 18:50:06 PST 2008
Author: johannes
Date: Wed Mar 5 20:50:05 2008
New Revision: 47984
URL: http://llvm.org/viewvc/llvm-project?rev=47984&view=rev
Log:
Believe it or not, MMX builtins use a different
calling convention from non-builtins on Darwin
x86-32. Fix builtins.
Modified:
llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-types.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=47984&r1=47983&r2=47984&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 Wed Mar 5 20:50:05 2008
@@ -100,8 +100,9 @@
/* The MMX vector v1i64 is returned in EAX and EDX on Darwin. Communicate
this by returning i64 here. */
-#define LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(X) \
+#define LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(X,isBuiltin)\
((TARGET_MACHO && \
+ !isBuiltin && \
!TARGET_64BIT && \
TREE_CODE(X) == VECTOR_TYPE && \
TYPE_SIZE(X) && \
@@ -111,8 +112,9 @@
/* MMX vectors v2i32, v4i16, v8i8, v2f32 are returned using sret on Darwin
32-bit. */
-#define LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(X) \
+#define LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(X,isBuiltin)\
((TARGET_MACHO && \
+ !isBuiltin && \
!TARGET_64BIT && \
TREE_CODE(X) == VECTOR_TYPE && \
TYPE_SIZE(X) && \
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=47984&r1=47983&r2=47984&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Wed Mar 5 20:50:05 2008
@@ -199,7 +199,7 @@
// should be returned using the convention for that scalar TYPE, 0 otherwise.
// X may be evaluated more than once.
#ifndef LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR
-#define LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(X) 0
+#define LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(X,Y) 0
#endif
// LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW - Return true if this vector type
@@ -226,14 +226,16 @@
/// return type. It potentially breaks down the argument and invokes methods
/// on the client that indicate how its pieces should be handled. This
/// handles things like returning structures via hidden parameters.
- void HandleReturnType(tree type) {
+ void HandleReturnType(tree type, bool isBuiltin) {
const Type *Ty = ConvertType(type);
if (Ty->getTypeID() == Type::VectorTyID) {
- // Vector handling is weird on x86.
- tree ScalarType = LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(type);
+ // Vector handling is weird on x86. In particular builtin and
+ // non-builtin function of the same return types can use different
+ // calling conventions.
+ tree ScalarType = LLVM_SHOULD_RETURN_VECTOR_AS_SCALAR(type, isBuiltin);
if (ScalarType)
C.HandleAggregateResultAsScalar(ConvertType(ScalarType));
- else if (LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(type))
+ else if (LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(type, isBuiltin))
C.HandleAggregateShadowArgument(PointerType::getUnqual(Ty), false);
else
C.HandleScalarResult(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=47984&r1=47983&r2=47984&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Mar 5 20:50:05 2008
@@ -660,7 +660,8 @@
TheLLVMABI<FunctionPrologArgumentConversion> ABIConverter(Client);
// Handle the DECL_RESULT.
- ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)));
+ ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)),
+ DECL_BUILT_IN(FnDecl));
// Prepend the static chain (if any) to the list of arguments.
tree Args = static_chain ? static_chain : DECL_ARGUMENTS(FnDecl);
@@ -2493,7 +2494,9 @@
TheLLVMABI<FunctionCallArgumentConversion> ABIConverter(Client);
// Handle the result, including struct returns.
- ABIConverter.HandleReturnType(TREE_TYPE(exp));
+ tree fndecl = get_callee_fndecl(exp);
+ ABIConverter.HandleReturnType(TREE_TYPE(exp),
+ fndecl ? DECL_BUILT_IN(fndecl) : false);
// Pass the static chain, if any, as the first parameter.
if (TREE_OPERAND(exp, 2))
Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=47984&r1=47983&r2=47984&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Wed Mar 5 20:50:05 2008
@@ -1044,7 +1044,8 @@
FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/);
TheLLVMABI<FunctionTypeConversion> ABIConverter(Client);
- ABIConverter.HandleReturnType(ReturnType);
+ // Builtins are always prototyped, so this isn't one.
+ ABIConverter.HandleReturnType(ReturnType, false);
ParamAttrsVector Attrs;
@@ -1098,7 +1099,8 @@
FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/);
TheLLVMABI<FunctionTypeConversion> ABIConverter(Client);
- ABIConverter.HandleReturnType(TREE_TYPE(type));
+ ABIConverter.HandleReturnType(TREE_TYPE(type),
+ decl ? DECL_BUILT_IN(decl) : false);
// Allow the target to set the CC for things like fastcall etc.
#ifdef TARGET_ADJUST_LLVM_CC
More information about the llvm-commits
mailing list