[cfe-commits] r63645 - /cfe/trunk/lib/CodeGen/CGCall.cpp
Daniel Dunbar
daniel at zuster.org
Tue Feb 3 11:12:30 PST 2009
Author: ddunbar
Date: Tue Feb 3 13:12:28 2009
New Revision: 63645
URL: http://llvm.org/viewvc/llvm-project?rev=63645&view=rev
Log:
ABI handling: Implement coercion for argument types (in addition to
return types).
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63645&r1=63644&r2=63645&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Feb 3 13:12:28 2009
@@ -926,6 +926,9 @@
break;
case ABIArgInfo::Coerce:
+ ArgTys.push_back(AI.getCoerceToType());
+ break;
+
case ABIArgInfo::StructRet:
assert(0 && "Invalid ABI kind for non-return argument");
@@ -1005,9 +1008,11 @@
switch (AI.getKind()) {
case ABIArgInfo::StructRet:
- case ABIArgInfo::Coerce:
assert(0 && "Invalid ABI kind for non-return argument");
-
+
+ case ABIArgInfo::Coerce:
+ break;
+
case ABIArgInfo::ByVal:
Attributes |= llvm::Attribute::ByVal;
assert(AI.getByValAlignment() == 0 && "FIXME: alignment unhandled");
@@ -1105,7 +1110,21 @@
case ABIArgInfo::Ignore:
break;
- case ABIArgInfo::Coerce:
+ case ABIArgInfo::Coerce: {
+ assert(AI != Fn->arg_end() && "Argument mismatch!");
+ // FIXME: This is very wasteful; EmitParmDecl is just going to
+ // drop the result in a new alloca anyway, so we could just
+ // store into that directly if we broke the abstraction down
+ // more.
+ llvm::Value *V = CreateTempAlloca(ConvertType(Ty), "coerce");
+ CreateCoercedStore(AI, V, *this);
+ // Match to what EmitParmDecl is expecting for this type.
+ if (!CodeGenFunction::hasAggregateLLVMType(Ty))
+ V = Builder.CreateLoad(V);
+ EmitParmDecl(*Arg, V);
+ break;
+ }
+
case ABIArgInfo::StructRet:
assert(0 && "Invalid ABI kind for non-return argument");
}
@@ -1213,8 +1232,23 @@
case ABIArgInfo::Ignore:
break;
+ case ABIArgInfo::Coerce: {
+ // FIXME: Avoid the conversion through memory if possible.
+ llvm::Value *SrcPtr;
+ if (RV.isScalar()) {
+ SrcPtr = CreateTempAlloca(ConvertType(I->second), "coerce");
+ Builder.CreateStore(RV.getScalarVal(), SrcPtr);
+ } else if (RV.isComplex()) {
+ SrcPtr = CreateTempAlloca(ConvertType(I->second), "coerce");
+ StoreComplexToAddr(RV.getComplexVal(), SrcPtr, false);
+ } else
+ SrcPtr = RV.getAggregateAddr();
+ Args.push_back(CreateCoercedLoad(SrcPtr, ArgInfo.getCoerceToType(),
+ *this));
+ break;
+ }
+
case ABIArgInfo::StructRet:
- case ABIArgInfo::Coerce:
assert(0 && "Invalid ABI kind for non-return argument");
break;
@@ -1266,6 +1300,7 @@
return RValue::get(llvm::UndefValue::get(ConvertType(RetTy)));
case ABIArgInfo::Coerce: {
+ // FIXME: Avoid the conversion through memory if possible.
llvm::Value *V = CreateTempAlloca(ConvertType(RetTy), "coerce");
CreateCoercedStore(CI, V, *this);
if (RetTy->isAnyComplexType())
More information about the cfe-commits
mailing list