[cfe-commits] r114114 - in /cfe/trunk/lib/CodeGen: ABIInfo.h CGCall.cpp TargetInfo.cpp
Daniel Dunbar
daniel at zuster.org
Thu Sep 16 13:42:03 PDT 2010
Author: ddunbar
Date: Thu Sep 16 15:42:02 2010
New Revision: 114114
URL: http://llvm.org/viewvc/llvm-project?rev=114114&view=rev
Log:
IRgen/ABI: Add support for realigning structures which are passed by indirect
reference.
Modified:
cfe/trunk/lib/CodeGen/ABIInfo.h
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/lib/CodeGen/TargetInfo.cpp
Modified: cfe/trunk/lib/CodeGen/ABIInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ABIInfo.h?rev=114114&r1=114113&r2=114114&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ABIInfo.h (original)
+++ cfe/trunk/lib/CodeGen/ABIInfo.h Thu Sep 16 15:42:02 2010
@@ -70,11 +70,12 @@
Kind TheKind;
llvm::PATypeHolder TypeData;
unsigned UIntData;
- bool BoolData;
+ bool BoolData0;
+ bool BoolData1;
ABIArgInfo(Kind K, const llvm::Type *TD=0,
- unsigned UI=0, bool B = false)
- : TheKind(K), TypeData(TD), UIntData(UI), BoolData(B) {}
+ unsigned UI=0, bool B0 = false, bool B1 = false)
+ : TheKind(K), TypeData(TD), UIntData(UI), BoolData0(B0), BoolData1(B1) {}
public:
ABIArgInfo() : TheKind(Direct), TypeData(0), UIntData(0) {}
@@ -88,8 +89,9 @@
static ABIArgInfo getIgnore() {
return ABIArgInfo(Ignore);
}
- static ABIArgInfo getIndirect(unsigned Alignment, bool ByVal = true) {
- return ABIArgInfo(Indirect, 0, Alignment, ByVal);
+ static ABIArgInfo getIndirect(unsigned Alignment, bool ByVal = true
+ , bool Realign = false) {
+ return ABIArgInfo(Indirect, 0, Alignment, ByVal, Realign);
}
static ABIArgInfo getExpand() {
return ABIArgInfo(Expand);
@@ -129,7 +131,12 @@
bool getIndirectByVal() const {
assert(TheKind == Indirect && "Invalid kind!");
- return BoolData;
+ return BoolData0;
+ }
+
+ bool getIndirectRealign() const {
+ assert(TheKind == Indirect && "Invalid kind!");
+ return BoolData1;
}
void dump() const;
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=114114&r1=114113&r2=114114&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Sep 16 15:42:02 2010
@@ -866,9 +866,29 @@
switch (ArgI.getKind()) {
case ABIArgInfo::Indirect: {
llvm::Value *V = AI;
+
if (hasAggregateLLVMType(Ty)) {
- // Do nothing, aggregates and complex variables are accessed by
- // reference.
+ // Aggregates and complex variables are accessed by reference. All we
+ // need to do is realign the value, if requested
+ if (ArgI.getIndirectRealign()) {
+ llvm::Value *AlignedTemp = CreateMemTemp(Ty, "coerce");
+
+ // Copy from the incoming argument pointer to the temporary with the
+ // appropriate alignment.
+ //
+ // FIXME: We should have a common utility for generating an aggregate
+ // copy.
+ const llvm::Type *I8PtrTy = llvm::Type::getInt8PtrTy(VMContext, 0);
+ unsigned Size = getContext().getTypeSize(Ty) / 8;
+ Builder.CreateCall5(CGM.getMemCpyFn(I8PtrTy, I8PtrTy, IntPtrTy),
+ Builder.CreateBitCast(AlignedTemp, I8PtrTy),
+ Builder.CreateBitCast(V, I8PtrTy),
+ llvm::ConstantInt::get(IntPtrTy, Size),
+ Builder.getInt32(ArgI.getIndirectAlign()),
+ /*Volatile=*/Builder.getInt1(false));
+
+ V = AlignedTemp;
+ }
} else {
// Load scalar value from indirect argument.
unsigned Alignment = getContext().getTypeAlignInChars(Ty).getQuantity();
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=114114&r1=114113&r2=114114&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Sep 16 15:42:02 2010
@@ -75,7 +75,8 @@
break;
case Indirect:
OS << "Indirect Align=" << getIndirectAlign()
- << " Byal=" << getIndirectByVal();
+ << " Byal=" << getIndirectByVal()
+ << " Realign=" << getIndirectRealign();
break;
case Expand:
OS << "Expand";
More information about the cfe-commits
mailing list