mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Do not pre-allocate for registers which form a REG_SEQUENCE.
llvm-svn: 103041
This commit is contained in:
parent
9cd91d458a
commit
85d27d4ab2
@ -12,12 +12,14 @@
|
||||
#include "ARMInstrInfo.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
class NEONPreAllocPass : public MachineFunctionPass {
|
||||
const TargetInstrInfo *TII;
|
||||
MachineRegisterInfo *MRI;
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
@ -30,6 +32,8 @@ namespace {
|
||||
}
|
||||
|
||||
private:
|
||||
bool FormsRegSequence(MachineInstr *MI,
|
||||
unsigned FirstOpnd, unsigned NumRegs);
|
||||
bool PreAllocNEONRegisters(MachineBasicBlock &MBB);
|
||||
};
|
||||
|
||||
@ -334,6 +338,27 @@ static bool isNEONMultiRegOp(int Opcode, unsigned &FirstOpnd, unsigned &NumRegs,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool NEONPreAllocPass::FormsRegSequence(MachineInstr *MI,
|
||||
unsigned FirstOpnd, unsigned NumRegs) {
|
||||
MachineInstr *RegSeq = 0;
|
||||
for (unsigned R = 0; R < NumRegs; ++R) {
|
||||
MachineOperand &MO = MI->getOperand(FirstOpnd + R);
|
||||
assert(MO.isReg() && MO.getSubReg() == 0 && "unexpected operand");
|
||||
unsigned VirtReg = MO.getReg();
|
||||
assert(TargetRegisterInfo::isVirtualRegister(VirtReg) &&
|
||||
"expected a virtual register");
|
||||
if (!MRI->hasOneNonDBGUse(VirtReg))
|
||||
return false;
|
||||
MachineInstr *UseMI = &*MRI->use_nodbg_begin(VirtReg);
|
||||
if (UseMI->getOpcode() != TargetOpcode::REG_SEQUENCE)
|
||||
return false;
|
||||
if (RegSeq && RegSeq != UseMI)
|
||||
return false;
|
||||
RegSeq = UseMI;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool NEONPreAllocPass::PreAllocNEONRegisters(MachineBasicBlock &MBB) {
|
||||
bool Modified = false;
|
||||
|
||||
@ -343,6 +368,8 @@ bool NEONPreAllocPass::PreAllocNEONRegisters(MachineBasicBlock &MBB) {
|
||||
unsigned FirstOpnd, NumRegs, Offset, Stride;
|
||||
if (!isNEONMultiRegOp(MI->getOpcode(), FirstOpnd, NumRegs, Offset, Stride))
|
||||
continue;
|
||||
if (FormsRegSequence(MI, FirstOpnd, NumRegs))
|
||||
continue;
|
||||
|
||||
MachineBasicBlock::iterator NextI = llvm::next(MBBI);
|
||||
for (unsigned R = 0; R < NumRegs; ++R) {
|
||||
@ -382,6 +409,7 @@ bool NEONPreAllocPass::PreAllocNEONRegisters(MachineBasicBlock &MBB) {
|
||||
|
||||
bool NEONPreAllocPass::runOnMachineFunction(MachineFunction &MF) {
|
||||
TII = MF.getTarget().getInstrInfo();
|
||||
MRI = &MF.getRegInfo();
|
||||
|
||||
bool Modified = false;
|
||||
for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); MFI != E;
|
||||
|
Loading…
Reference in New Issue
Block a user