mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[GlobalISel][X86] Allow graceful fallback for struct/array argument/return value lowering. Going to support it in follow patch.
llvm-svn: 307125
This commit is contained in:
parent
e589b2a942
commit
7287cfe2fc
@ -19,6 +19,7 @@
|
||||
#include "X86InstrInfo.h"
|
||||
#include "X86TargetMachine.h"
|
||||
|
||||
#include "llvm/CodeGen/Analysis.h"
|
||||
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/MachineValueType.h"
|
||||
@ -35,7 +36,7 @@ using namespace llvm;
|
||||
X86CallLowering::X86CallLowering(const X86TargetLowering &TLI)
|
||||
: CallLowering(&TLI) {}
|
||||
|
||||
void X86CallLowering::splitToValueTypes(const ArgInfo &OrigArg,
|
||||
bool X86CallLowering::splitToValueTypes(const ArgInfo &OrigArg,
|
||||
SmallVectorImpl<ArgInfo> &SplitArgs,
|
||||
const DataLayout &DL,
|
||||
MachineRegisterInfo &MRI,
|
||||
@ -43,14 +44,24 @@ void X86CallLowering::splitToValueTypes(const ArgInfo &OrigArg,
|
||||
|
||||
const X86TargetLowering &TLI = *getTLI<X86TargetLowering>();
|
||||
LLVMContext &Context = OrigArg.Ty->getContext();
|
||||
EVT VT = TLI.getValueType(DL, OrigArg.Ty);
|
||||
|
||||
SmallVector<EVT, 4> SplitVTs;
|
||||
SmallVector<uint64_t, 4> Offsets;
|
||||
ComputeValueVTs(TLI, DL, OrigArg.Ty, SplitVTs, &Offsets, 0);
|
||||
|
||||
if (SplitVTs.size() != 1) {
|
||||
// TODO: support struct/array split
|
||||
return false;
|
||||
}
|
||||
|
||||
EVT VT = SplitVTs[0];
|
||||
unsigned NumParts = TLI.getNumRegisters(Context, VT);
|
||||
|
||||
if (NumParts == 1) {
|
||||
// replace the original type ( pointer -> GPR ).
|
||||
SplitArgs.emplace_back(OrigArg.Reg, VT.getTypeForEVT(Context),
|
||||
OrigArg.Flags, OrigArg.IsFixed);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
SmallVector<unsigned, 8> SplitRegs;
|
||||
@ -67,6 +78,7 @@ void X86CallLowering::splitToValueTypes(const ArgInfo &OrigArg,
|
||||
}
|
||||
|
||||
PerformArgSplit(SplitRegs);
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -113,9 +125,11 @@ bool X86CallLowering::lowerReturn(MachineIRBuilder &MIRBuilder,
|
||||
setArgFlags(OrigArg, AttributeList::ReturnIndex, DL, F);
|
||||
|
||||
SmallVector<ArgInfo, 8> SplitArgs;
|
||||
splitToValueTypes(
|
||||
OrigArg, SplitArgs, DL, MRI,
|
||||
[&](ArrayRef<unsigned> Regs) { MIRBuilder.buildUnmerge(Regs, VReg); });
|
||||
if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
|
||||
[&](ArrayRef<unsigned> Regs) {
|
||||
MIRBuilder.buildUnmerge(Regs, VReg);
|
||||
}))
|
||||
return false;
|
||||
|
||||
FuncReturnHandler Handler(MIRBuilder, MRI, MIB, RetCC_X86);
|
||||
if (!handleAssignments(MIRBuilder, SplitArgs, Handler))
|
||||
@ -183,10 +197,11 @@ bool X86CallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
|
||||
for (auto &Arg : F.args()) {
|
||||
ArgInfo OrigArg(VRegs[Idx], Arg.getType());
|
||||
setArgFlags(OrigArg, Idx + 1, DL, F);
|
||||
splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
|
||||
[&](ArrayRef<unsigned> Regs) {
|
||||
MIRBuilder.buildMerge(VRegs[Idx], Regs);
|
||||
});
|
||||
if (!splitToValueTypes(OrigArg, SplitArgs, DL, MRI,
|
||||
[&](ArrayRef<unsigned> Regs) {
|
||||
MIRBuilder.buildMerge(VRegs[Idx], Regs);
|
||||
}))
|
||||
return false;
|
||||
Idx++;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ private:
|
||||
/// A function of this type is used to perform value split action.
|
||||
typedef std::function<void(ArrayRef<unsigned>)> SplitArgTy;
|
||||
|
||||
void splitToValueTypes(const ArgInfo &OrigArgInfo,
|
||||
bool splitToValueTypes(const ArgInfo &OrigArgInfo,
|
||||
SmallVectorImpl<ArgInfo> &SplitArgs,
|
||||
const DataLayout &DL, MachineRegisterInfo &MRI,
|
||||
SplitArgTy SplitArg) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user