mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-02 00:36:36 +00:00
Remove the explicit MachineInstrBuilder(MI) constructor.
Use the version that also takes an MF reference instead. It would technically be possible to extract an MF reference from the MI as MI->getParent()->getParent(), but that would not work for MIs that are not inserted into any basic block. Given the reasonably small number of places this constructor was used at all, I preferred the compile time check to a run time assertion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@170588 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
521396ab37
commit
37a942cd52
@ -46,7 +46,6 @@ class MachineInstrBuilder {
|
||||
MachineInstr *MI;
|
||||
public:
|
||||
MachineInstrBuilder() : MF(0), MI(0) {}
|
||||
explicit MachineInstrBuilder(MachineInstr *mi) : MF(0), MI(mi) {}
|
||||
|
||||
/// Create a MachineInstrBuilder for manipulating an existing instruction.
|
||||
/// F must be the machine function that was used to allocate I.
|
||||
|
@ -109,7 +109,7 @@ unsigned LookForIdenticalPHI(MachineBasicBlock *BB,
|
||||
/// a value of the given register class at the start of the specified basic
|
||||
/// block. It returns the virtual register defined by the instruction.
|
||||
static
|
||||
MachineInstr *InsertNewDef(unsigned Opcode,
|
||||
MachineInstrBuilder InsertNewDef(unsigned Opcode,
|
||||
MachineBasicBlock *BB, MachineBasicBlock::iterator I,
|
||||
const TargetRegisterClass *RC,
|
||||
MachineRegisterInfo *MRI,
|
||||
@ -183,13 +183,12 @@ unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) {
|
||||
|
||||
// Otherwise, we do need a PHI: insert one now.
|
||||
MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->begin();
|
||||
MachineInstr *InsertedPHI = InsertNewDef(TargetOpcode::PHI, BB,
|
||||
Loc, VRC, MRI, TII);
|
||||
MachineInstrBuilder InsertedPHI = InsertNewDef(TargetOpcode::PHI, BB,
|
||||
Loc, VRC, MRI, TII);
|
||||
|
||||
// Fill in all the predecessors of the PHI.
|
||||
MachineInstrBuilder MIB(InsertedPHI);
|
||||
for (unsigned i = 0, e = PredValues.size(); i != e; ++i)
|
||||
MIB.addReg(PredValues[i].second).addMBB(PredValues[i].first);
|
||||
InsertedPHI.addReg(PredValues[i].second).addMBB(PredValues[i].first);
|
||||
|
||||
// See if the PHI node can be merged to a single value. This can happen in
|
||||
// loop cases when we get a PHI of itself and one other value.
|
||||
|
@ -1154,6 +1154,7 @@ bool ARMBaseInstrInfo::expandPostRAPseudo(MachineBasicBlock::iterator MI) const{
|
||||
|
||||
// All clear, widen the COPY.
|
||||
DEBUG(dbgs() << "widening: " << *MI);
|
||||
MachineInstrBuilder MIB(*MI->getParent()->getParent(), MI);
|
||||
|
||||
// Get rid of the old <imp-def> of DstRegD. Leave it if it defines a Q-reg
|
||||
// or some other super-register.
|
||||
@ -1165,14 +1166,14 @@ bool ARMBaseInstrInfo::expandPostRAPseudo(MachineBasicBlock::iterator MI) const{
|
||||
MI->setDesc(get(ARM::VMOVD));
|
||||
MI->getOperand(0).setReg(DstRegD);
|
||||
MI->getOperand(1).setReg(SrcRegD);
|
||||
AddDefaultPred(MachineInstrBuilder(MI));
|
||||
AddDefaultPred(MIB);
|
||||
|
||||
// We are now reading SrcRegD instead of SrcRegS. This may upset the
|
||||
// register scavenger and machine verifier, so we need to indicate that we
|
||||
// are reading an undefined value from SrcRegD, but a proper value from
|
||||
// SrcRegS.
|
||||
MI->getOperand(1).setIsUndef();
|
||||
MachineInstrBuilder(MI).addReg(SrcRegS, RegState::Implicit);
|
||||
MIB.addReg(SrcRegS, RegState::Implicit);
|
||||
|
||||
// SrcRegD may actually contain an unrelated value in the ssub_1
|
||||
// sub-register. Don't kill it. Only kill the ssub_0 sub-register.
|
||||
@ -3819,7 +3820,7 @@ void
|
||||
ARMBaseInstrInfo::setExecutionDomain(MachineInstr *MI, unsigned Domain) const {
|
||||
unsigned DstReg, SrcReg, DReg;
|
||||
unsigned Lane;
|
||||
MachineInstrBuilder MIB(MI);
|
||||
MachineInstrBuilder MIB(*MI->getParent()->getParent(), MI);
|
||||
const TargetRegisterInfo *TRI = &getRegisterInfo();
|
||||
switch (MI->getOpcode()) {
|
||||
default:
|
||||
|
@ -6612,7 +6612,7 @@ EmitSjLjDispatchBlock(MachineInstr *MI, MachineBasicBlock *MBB) const {
|
||||
DefRegs[OI->getReg()] = true;
|
||||
}
|
||||
|
||||
MachineInstrBuilder MIB(&*II);
|
||||
MachineInstrBuilder MIB(*MF, &*II);
|
||||
|
||||
for (unsigned i = 0; SavedRegs[i] != 0; ++i) {
|
||||
unsigned Reg = SavedRegs[i];
|
||||
|
@ -390,6 +390,7 @@ rewriteFrameIndex(MachineBasicBlock::iterator II, unsigned FrameRegIdx,
|
||||
MachineInstr &MI = *II;
|
||||
MachineBasicBlock &MBB = *MI.getParent();
|
||||
DebugLoc dl = MI.getDebugLoc();
|
||||
MachineInstrBuilder MIB(*MBB.getParent(), &MI);
|
||||
unsigned Opcode = MI.getOpcode();
|
||||
const MCInstrDesc &Desc = MI.getDesc();
|
||||
unsigned AddrMode = (Desc.TSFlags & ARMII::AddrModeMask);
|
||||
@ -417,7 +418,6 @@ rewriteFrameIndex(MachineBasicBlock::iterator II, unsigned FrameRegIdx,
|
||||
MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg, false);
|
||||
// Remove offset
|
||||
MI.RemoveOperand(FrameRegIdx+1);
|
||||
MachineInstrBuilder MIB(&MI);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -428,7 +428,6 @@ rewriteFrameIndex(MachineBasicBlock::iterator II, unsigned FrameRegIdx,
|
||||
if (Opcode == ARM::tADDi3) {
|
||||
MI.setDesc(TII.get(Opcode));
|
||||
removeOperands(MI, FrameRegIdx);
|
||||
MachineInstrBuilder MIB(&MI);
|
||||
AddDefaultPred(AddDefaultT1CC(MIB).addReg(FrameReg)
|
||||
.addImm(Offset / Scale));
|
||||
} else {
|
||||
@ -457,7 +456,6 @@ rewriteFrameIndex(MachineBasicBlock::iterator II, unsigned FrameRegIdx,
|
||||
if (Opcode == ARM::tADDi3) {
|
||||
MI.setDesc(TII.get(Opcode));
|
||||
removeOperands(MI, FrameRegIdx);
|
||||
MachineInstrBuilder MIB(&MI);
|
||||
AddDefaultPred(AddDefaultT1CC(MIB).addReg(FrameReg).addImm(Mask));
|
||||
} else {
|
||||
MI.getOperand(FrameRegIdx).ChangeToRegister(FrameReg, false);
|
||||
@ -603,6 +601,7 @@ Thumb1RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
MachineFunction &MF = *MBB.getParent();
|
||||
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||
DebugLoc dl = MI.getDebugLoc();
|
||||
MachineInstrBuilder MIB(*MBB.getParent(), &MI);
|
||||
|
||||
while (!MI.getOperand(i).isFI()) {
|
||||
++i;
|
||||
@ -719,8 +718,6 @@ Thumb1RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
||||
}
|
||||
|
||||
// Add predicate back if it's needed.
|
||||
if (MI.isPredicable()) {
|
||||
MachineInstrBuilder MIB(&MI);
|
||||
if (MI.isPredicable())
|
||||
AddDefaultPred(MIB);
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ bool llvm::rewriteT2FrameIndex(MachineInstr &MI, unsigned FrameRegIdx,
|
||||
// Remove offset and remaining explicit predicate operands.
|
||||
do MI.RemoveOperand(FrameRegIdx+1);
|
||||
while (MI.getNumOperands() > FrameRegIdx+1);
|
||||
MachineInstrBuilder MIB(&MI);
|
||||
MachineInstrBuilder MIB(*MI.getParent()->getParent(), &MI);
|
||||
AddDefaultPred(MIB);
|
||||
return true;
|
||||
}
|
||||
|
@ -3525,43 +3525,44 @@ optimizeLoadInstr(MachineInstr *MI, const MachineRegisterInfo *MRI,
|
||||
/// to:
|
||||
/// %xmm4 = PXORrr %xmm4<undef>, %xmm4<undef>
|
||||
///
|
||||
static bool Expand2AddrUndef(MachineInstr *MI, const MCInstrDesc &Desc) {
|
||||
static bool Expand2AddrUndef(MachineInstrBuilder &MIB,
|
||||
const MCInstrDesc &Desc) {
|
||||
assert(Desc.getNumOperands() == 3 && "Expected two-addr instruction.");
|
||||
unsigned Reg = MI->getOperand(0).getReg();
|
||||
MI->setDesc(Desc);
|
||||
unsigned Reg = MIB->getOperand(0).getReg();
|
||||
MIB->setDesc(Desc);
|
||||
|
||||
// MachineInstr::addOperand() will insert explicit operands before any
|
||||
// implicit operands.
|
||||
MachineInstrBuilder(MI).addReg(Reg, RegState::Undef)
|
||||
.addReg(Reg, RegState::Undef);
|
||||
MIB.addReg(Reg, RegState::Undef).addReg(Reg, RegState::Undef);
|
||||
// But we don't trust that.
|
||||
assert(MI->getOperand(1).getReg() == Reg &&
|
||||
MI->getOperand(2).getReg() == Reg && "Misplaced operand");
|
||||
assert(MIB->getOperand(1).getReg() == Reg &&
|
||||
MIB->getOperand(2).getReg() == Reg && "Misplaced operand");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool X86InstrInfo::expandPostRAPseudo(MachineBasicBlock::iterator MI) const {
|
||||
bool HasAVX = TM.getSubtarget<X86Subtarget>().hasAVX();
|
||||
MachineInstrBuilder MIB(*MI->getParent()->getParent(), MI);
|
||||
switch (MI->getOpcode()) {
|
||||
case X86::SETB_C8r:
|
||||
return Expand2AddrUndef(MI, get(X86::SBB8rr));
|
||||
return Expand2AddrUndef(MIB, get(X86::SBB8rr));
|
||||
case X86::SETB_C16r:
|
||||
return Expand2AddrUndef(MI, get(X86::SBB16rr));
|
||||
return Expand2AddrUndef(MIB, get(X86::SBB16rr));
|
||||
case X86::SETB_C32r:
|
||||
return Expand2AddrUndef(MI, get(X86::SBB32rr));
|
||||
return Expand2AddrUndef(MIB, get(X86::SBB32rr));
|
||||
case X86::SETB_C64r:
|
||||
return Expand2AddrUndef(MI, get(X86::SBB64rr));
|
||||
return Expand2AddrUndef(MIB, get(X86::SBB64rr));
|
||||
case X86::V_SET0:
|
||||
case X86::FsFLD0SS:
|
||||
case X86::FsFLD0SD:
|
||||
return Expand2AddrUndef(MI, get(HasAVX ? X86::VXORPSrr : X86::XORPSrr));
|
||||
return Expand2AddrUndef(MIB, get(HasAVX ? X86::VXORPSrr : X86::XORPSrr));
|
||||
case X86::AVX_SET0:
|
||||
assert(HasAVX && "AVX not supported");
|
||||
return Expand2AddrUndef(MI, get(X86::VXORPSYrr));
|
||||
return Expand2AddrUndef(MIB, get(X86::VXORPSYrr));
|
||||
case X86::V_SETALLONES:
|
||||
return Expand2AddrUndef(MI, get(HasAVX ? X86::VPCMPEQDrr : X86::PCMPEQDrr));
|
||||
return Expand2AddrUndef(MIB, get(HasAVX ? X86::VPCMPEQDrr : X86::PCMPEQDrr));
|
||||
case X86::AVX2_SETALLONES:
|
||||
return Expand2AddrUndef(MI, get(X86::VPCMPEQDYrr));
|
||||
return Expand2AddrUndef(MIB, get(X86::VPCMPEQDYrr));
|
||||
case X86::TEST8ri_NOREX:
|
||||
MI->setDesc(get(X86::TEST8ri));
|
||||
return true;
|
||||
@ -3587,9 +3588,10 @@ static MachineInstr *FuseTwoAddrInst(MachineFunction &MF, unsigned Opcode,
|
||||
MachineInstr *MI,
|
||||
const TargetInstrInfo &TII) {
|
||||
// Create the base instruction with the memory operand as the first part.
|
||||
// Omit the implicit operands, something BuildMI can't do.
|
||||
MachineInstr *NewMI = MF.CreateMachineInstr(TII.get(Opcode),
|
||||
MI->getDebugLoc(), true);
|
||||
MachineInstrBuilder MIB(NewMI);
|
||||
MachineInstrBuilder MIB(MF, NewMI);
|
||||
unsigned NumAddrOps = MOs.size();
|
||||
for (unsigned i = 0; i != NumAddrOps; ++i)
|
||||
MIB.addOperand(MOs[i]);
|
||||
@ -3613,9 +3615,10 @@ static MachineInstr *FuseInst(MachineFunction &MF,
|
||||
unsigned Opcode, unsigned OpNo,
|
||||
const SmallVectorImpl<MachineOperand> &MOs,
|
||||
MachineInstr *MI, const TargetInstrInfo &TII) {
|
||||
// Omit the implicit operands, something BuildMI can't do.
|
||||
MachineInstr *NewMI = MF.CreateMachineInstr(TII.get(Opcode),
|
||||
MI->getDebugLoc(), true);
|
||||
MachineInstrBuilder MIB(NewMI);
|
||||
MachineInstrBuilder MIB(MF, NewMI);
|
||||
|
||||
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
||||
MachineOperand &MO = MI->getOperand(i);
|
||||
@ -4155,7 +4158,7 @@ bool X86InstrInfo::unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
||||
|
||||
// Emit the data processing instruction.
|
||||
MachineInstr *DataMI = MF.CreateMachineInstr(MCID, MI->getDebugLoc(), true);
|
||||
MachineInstrBuilder MIB(DataMI);
|
||||
MachineInstrBuilder MIB(MF, DataMI);
|
||||
|
||||
if (FoldedStore)
|
||||
MIB.addReg(Reg, RegState::Define);
|
||||
|
Loading…
Reference in New Issue
Block a user