[cfe-commits] r63850 - in /cfe/trunk/lib/CodeGen: ABIInfo.h CGCall.cpp
Daniel Dunbar
daniel at zuster.org
Thu Feb 5 00:00:54 PST 2009
Author: ddunbar
Date: Thu Feb 5 02:00:50 2009
New Revision: 63850
URL: http://llvm.org/viewvc/llvm-project?rev=63850&view=rev
Log:
Merge ABIInfo StructRet/ByVal into Indirect.
- No (intended) functionality change, the semantic changes are to come.
Modified:
cfe/trunk/lib/CodeGen/ABIInfo.h
cfe/trunk/lib/CodeGen/CGCall.cpp
Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=63850&r1=63849&r2=63850&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Thu Feb 5 02:00:50 2009
@@ -35,12 +35,12 @@
public:
enum Kind {
Direct, /// Pass the argument directly using the normal
- /// converted LLVM type.
-
- StructRet, /// Only valid for return values. The return value
- /// should be passed through a pointer to a caller
- /// allocated location passed as an implicit first
- /// argument to the function.
+ /// converted LLVM type. Complex and structure types
+ /// are passed using first class aggregates.
+
+ Indirect, /// Pass the argument indirectly via a hidden pointer
+ /// with the specified alignment (0 indicates default
+ /// alignment).
Ignore, /// Ignore the argument (treat as void). Useful for
/// void and empty structs.
@@ -48,11 +48,6 @@
Coerce, /// Only valid for aggregate return types, the argument
/// should be accessed by coercion to a provided type.
- ByVal, /// Only valid for aggregate argument types. The
- /// structure should be passed "byval" with the
- /// specified alignment (0 indicates default
- /// alignment).
-
Expand, /// Only valid for aggregate argument types. The
/// structure should be expanded into consecutive
/// arguments for its constituent fields. Currently
@@ -78,17 +73,14 @@
static ABIArgInfo getDirect() {
return ABIArgInfo(Direct);
}
- static ABIArgInfo getStructRet() {
- return ABIArgInfo(StructRet);
- }
static ABIArgInfo getIgnore() {
return ABIArgInfo(Ignore);
}
static ABIArgInfo getCoerce(const llvm::Type *T) {
return ABIArgInfo(Coerce, T);
}
- static ABIArgInfo getByVal(unsigned Alignment) {
- return ABIArgInfo(ByVal, 0, Alignment);
+ static ABIArgInfo getIndirect(unsigned Alignment) {
+ return ABIArgInfo(Indirect, 0, Alignment);
}
static ABIArgInfo getExpand() {
return ABIArgInfo(Expand);
@@ -96,10 +88,9 @@
Kind getKind() const { return TheKind; }
bool isDirect() const { return TheKind == Direct; }
- bool isStructRet() const { return TheKind == StructRet; }
bool isIgnore() const { return TheKind == Ignore; }
bool isCoerce() const { return TheKind == Coerce; }
- bool isByVal() const { return TheKind == ByVal; }
+ bool isIndirect() const { return TheKind == Indirect; }
bool isExpand() const { return TheKind == Expand; }
// Coerce accessors
@@ -109,8 +100,8 @@
}
// ByVal accessors
- unsigned getByValAlignment() const {
- assert(TheKind == ByVal && "Invalid kind!");
+ unsigned getIndirectAlign() const {
+ assert(TheKind == Indirect && "Invalid kind!");
return UIntData;
}
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=63850&r1=63849&r2=63850&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Feb 5 02:00:50 2009
@@ -119,9 +119,6 @@
case Direct:
fprintf(stderr, "Direct");
break;
- case StructRet:
- fprintf(stderr, "StructRet");
- break;
case Ignore:
fprintf(stderr, "Ignore");
break;
@@ -131,8 +128,8 @@
// FIXME: This is ridiculous.
llvm::errs().flush();
break;
- case ByVal:
- fprintf(stderr, "ByVal Align=%d", getByValAlignment());
+ case Indirect:
+ fprintf(stderr, "Indirect Align=%d", getIndirectAlign());
break;
case Expand:
fprintf(stderr, "Expand");
@@ -307,7 +304,7 @@
} else if (Size == 64) {
return ABIArgInfo::getCoerce(llvm::Type::Int64Ty);
} else {
- return ABIArgInfo::getStructRet();
+ return ABIArgInfo::getIndirect(0);
}
} else {
return ABIArgInfo::getDirect();
@@ -316,12 +313,12 @@
ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
ASTContext &Context) const {
- // FIXME: Set alignment on byval arguments.
+ // FIXME: Set alignment on indirect arguments.
if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
- // Structures with flexible arrays are always byval.
+ // Structures with flexible arrays are always indirect.
if (const RecordType *RT = Ty->getAsStructureType())
if (RT->getDecl()->hasFlexibleArrayMember())
- return ABIArgInfo::getByVal(0);
+ return ABIArgInfo::getIndirect(0);
// Ignore empty structs.
uint64_t Size = Context.getTypeSize(Ty);
@@ -337,7 +334,7 @@
return ABIArgInfo::getExpand();
}
- return ABIArgInfo::getByVal(0);
+ return ABIArgInfo::getIndirect(0);
} else {
return ABIArgInfo::getDirect();
}
@@ -636,9 +633,9 @@
assert(0 && "Invalid classification for lo word.");
// AMD64-ABI 3.2.3p4: Rule 2. Types of class memory are returned via
- // hidden argument, i.e. structret.
+ // hidden argument.
case Memory:
- return ABIArgInfo::getStructRet();
+ return ABIArgInfo::getIndirect(0);
// AMD64-ABI 3.2.3p4: Rule 3. If the class is INTEGER, the next
// available register of the sequence %rax, %rdx is used.
@@ -730,7 +727,7 @@
case ComplexX87:
// Choose appropriate in memory type.
if (CodeGenFunction::hasAggregateLLVMType(Ty))
- return ABIArgInfo::getByVal(0);
+ return ABIArgInfo::getIndirect(0);
else
return ABIArgInfo::getDirect();
@@ -795,7 +792,7 @@
} else {
// Choose appropriate in memory type.
if (CodeGenFunction::hasAggregateLLVMType(Ty))
- return ABIArgInfo::getByVal(0);
+ return ABIArgInfo::getIndirect(0);
else
return ABIArgInfo::getDirect();
}
@@ -819,7 +816,7 @@
if (RetTy->isVoidType()) {
return ABIArgInfo::getIgnore();
} else if (CodeGenFunction::hasAggregateLLVMType(RetTy)) {
- return ABIArgInfo::getStructRet();
+ return ABIArgInfo::getIndirect(0);
} else {
return ABIArgInfo::getDirect();
}
@@ -828,7 +825,7 @@
ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty,
ASTContext &Context) const {
if (CodeGenFunction::hasAggregateLLVMType(Ty)) {
- return ABIArgInfo::getByVal(0);
+ return ABIArgInfo::getIndirect(0);
} else {
return ABIArgInfo::getDirect();
}
@@ -1012,7 +1009,7 @@
/***/
bool CodeGenModule::ReturnTypeUsesSret(const CGFunctionInfo &FI) {
- return FI.getReturnInfo().isStructRet();
+ return FI.getReturnInfo().isIndirect();
}
const llvm::FunctionType *
@@ -1024,7 +1021,6 @@
QualType RetTy = FI.getReturnType();
const ABIArgInfo &RetAI = FI.getReturnInfo();
switch (RetAI.getKind()) {
- case ABIArgInfo::ByVal:
case ABIArgInfo::Expand:
assert(0 && "Invalid ABI kind for return argument");
@@ -1032,7 +1028,8 @@
ResultType = ConvertType(RetTy);
break;
- case ABIArgInfo::StructRet: {
+ case ABIArgInfo::Indirect: {
+ assert(!RetAI.getIndirectAlign() && "Align unused on indirect return.");
ResultType = llvm::Type::VoidTy;
const llvm::Type *STy = ConvertType(RetTy);
ArgTys.push_back(llvm::PointerType::get(STy, RetTy.getAddressSpace()));
@@ -1061,11 +1058,8 @@
ArgTys.push_back(AI.getCoerceToType());
break;
- case ABIArgInfo::StructRet:
- assert(0 && "Invalid ABI kind for non-return argument");
-
- case ABIArgInfo::ByVal:
- // byval arguments are always on the stack, which is addr space #0.
+ case ABIArgInfo::Indirect:
+ // indirect arguments are always on the stack, which is addr space #0.
ArgTys.push_back(llvm::PointerType::getUnqual(Ty));
break;
@@ -1113,7 +1107,7 @@
}
break;
- case ABIArgInfo::StructRet:
+ case ABIArgInfo::Indirect:
PAL.push_back(llvm::AttributeWithIndex::get(Index,
llvm::Attribute::StructRet |
llvm::Attribute::NoAlias));
@@ -1124,7 +1118,6 @@
case ABIArgInfo::Coerce:
break;
- case ABIArgInfo::ByVal:
case ABIArgInfo::Expand:
assert(0 && "Invalid ABI kind for return argument");
}
@@ -1138,16 +1131,13 @@
unsigned Attributes = 0;
switch (AI.getKind()) {
- case ABIArgInfo::StructRet:
- assert(0 && "Invalid ABI kind for non-return argument");
-
case ABIArgInfo::Coerce:
break;
- case ABIArgInfo::ByVal:
+ case ABIArgInfo::Indirect:
Attributes |= llvm::Attribute::ByVal;
Attributes |=
- llvm::Attribute::constructAlignmentFromInt(AI.getByValAlignment());
+ llvm::Attribute::constructAlignmentFromInt(AI.getIndirectAlign());
break;
case ABIArgInfo::Direct:
@@ -1209,7 +1199,8 @@
const ABIArgInfo &ArgI = info_it->info;
switch (ArgI.getKind()) {
- case ABIArgInfo::ByVal:
+ // FIXME: Implement correct [in]direct semantics.
+ case ABIArgInfo::Indirect:
case ABIArgInfo::Direct: {
assert(AI != Fn->arg_end() && "Argument mismatch!");
llvm::Value* V = AI;
@@ -1265,9 +1256,6 @@
EmitParmDecl(*Arg, V);
break;
}
-
- case ABIArgInfo::StructRet:
- assert(0 && "Invalid ABI kind for non-return argument");
}
++AI;
@@ -1285,7 +1273,8 @@
const ABIArgInfo &RetAI = FI.getReturnInfo();
switch (RetAI.getKind()) {
- case ABIArgInfo::StructRet:
+ // FIXME: Implement correct [in]direct semantics.
+ case ABIArgInfo::Indirect:
if (RetTy->isAnyComplexType()) {
// FIXME: Volatile
ComplexPairTy RT = LoadComplexFromAddr(ReturnValue, false);
@@ -1310,7 +1299,6 @@
break;
}
- case ABIArgInfo::ByVal:
case ABIArgInfo::Expand:
assert(0 && "Invalid ABI kind for return argument");
}
@@ -1335,7 +1323,7 @@
QualType RetTy = CallInfo.getReturnType();
const ABIArgInfo &RetAI = CallInfo.getReturnInfo();
switch (RetAI.getKind()) {
- case ABIArgInfo::StructRet:
+ case ABIArgInfo::Indirect:
// Create a temporary alloca to hold the result of the call. :(
Args.push_back(CreateTempAlloca(ConvertType(RetTy)));
break;
@@ -1345,7 +1333,6 @@
case ABIArgInfo::Coerce:
break;
- case ABIArgInfo::ByVal:
case ABIArgInfo::Expand:
assert(0 && "Invalid ABI kind for return argument");
}
@@ -1359,7 +1346,8 @@
RValue RV = I->first;
switch (ArgInfo.getKind()) {
- case ABIArgInfo::ByVal: // Direct is byval
+ // FIXME: Implement correct [in]direct semantics.
+ case ABIArgInfo::Indirect:
case ABIArgInfo::Direct:
if (RV.isScalar()) {
Args.push_back(RV.getScalarVal());
@@ -1391,10 +1379,6 @@
break;
}
- case ABIArgInfo::StructRet:
- assert(0 && "Invalid ABI kind for non-return argument");
- break;
-
case ABIArgInfo::Expand:
ExpandTypeToArgs(I->second, RV, Args);
break;
@@ -1415,7 +1399,8 @@
CI->setName("call");
switch (RetAI.getKind()) {
- case ABIArgInfo::StructRet:
+ // FIXME: Implement correct [in]direct semantics.
+ case ABIArgInfo::Indirect:
if (RetTy->isAnyComplexType())
return RValue::getComplex(LoadComplexFromAddr(Args[0], false));
else if (CodeGenFunction::hasAggregateLLVMType(RetTy))
@@ -1448,7 +1433,6 @@
return RValue::get(Builder.CreateLoad(V));
}
- case ABIArgInfo::ByVal:
case ABIArgInfo::Expand:
assert(0 && "Invalid ABI kind for return argument");
}
More information about the cfe-commits
mailing list