2013-02-15 07:20:15 +08:00
|
|
|
//===-- MipsDelaySlotFiller.cpp - Mips Delay Slot Filler ------------------===//
|
2007-08-18 09:50:47 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-08-18 09:50:47 +08:00
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-08-18 09:50:47 +08:00
|
|
|
//
|
2013-02-15 07:20:15 +08:00
|
|
|
// Simple pass to fill delay slots with useful instructions.
|
2007-08-18 09:50:47 +08:00
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-08-18 09:50:47 +08:00
|
|
|
|
2014-03-11 04:34:23 +08:00
|
|
|
#include "MCTargetDesc/MipsMCNaCl.h"
|
2007-08-18 09:50:47 +08:00
|
|
|
#include "Mips.h"
|
2013-03-01 10:03:51 +08:00
|
|
|
#include "MipsInstrInfo.h"
|
2007-08-18 09:50:47 +08:00
|
|
|
#include "MipsTargetMachine.h"
|
2013-02-15 07:40:57 +08:00
|
|
|
#include "llvm/ADT/BitVector.h"
|
2013-03-01 08:16:31 +08:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/ADT/Statistic.h"
|
2013-03-01 08:16:31 +08:00
|
|
|
#include "llvm/Analysis/AliasAnalysis.h"
|
|
|
|
#include "llvm/Analysis/ValueTracking.h"
|
2013-03-01 10:03:51 +08:00
|
|
|
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
|
2007-08-18 09:50:47 +08:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
[mips][mips64r6] Replace m[tf]hi, m[tf]lo, mult, multu, dmult, dmultu, div, ddiv, divu, ddivu for MIPS32r6/MIPS64.
Summary:
The accumulator-based (HI/LO) multiplies and divides from earlier ISA's have
been removed and replaced with GPR-based equivalents. For example:
div $1, $2
mflo $3
is now:
div $3, $1, $2
This patch disables the accumulator-based multiplies and divides for
MIPS32r6/MIPS64r6 and uses the GPR-based equivalents instead.
Renamed expandPseudoDiv to insertDivByZeroTrap to better describe the
behaviour of the function.
MipsDelaySlotFiller now invalidates the liveness information when moving
instructions to the delay slot. Without this, divrem.ll will abort since
%GP ends up used before it is defined.
Reviewers: vmedic, zoran.jovanovic, jkolek
Reviewed By: jkolek
Differential Revision: http://reviews.llvm.org/D3896
llvm-svn: 210760
2014-06-12 18:44:10 +08:00
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2013-03-01 08:16:31 +08:00
|
|
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
2011-09-30 07:52:13 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2007-08-18 09:50:47 +08:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2011-09-30 07:52:13 +08:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2007-08-18 09:50:47 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2014-04-22 10:41:26 +08:00
|
|
|
#define DEBUG_TYPE "delay-slot-filler"
|
|
|
|
|
2007-08-18 09:50:47 +08:00
|
|
|
STATISTIC(FilledSlots, "Number of delay slots filled");
|
2011-10-05 09:19:13 +08:00
|
|
|
STATISTIC(UsefulSlots, "Number of delay slots filled with instructions that"
|
2011-10-05 10:22:49 +08:00
|
|
|
" are not NOP.");
|
2007-08-18 09:50:47 +08:00
|
|
|
|
2012-08-22 10:51:28 +08:00
|
|
|
static cl::opt<bool> DisableDelaySlotFiller(
|
|
|
|
"disable-mips-delay-filler",
|
2011-09-30 07:52:13 +08:00
|
|
|
cl::init(false),
|
2013-02-15 07:20:15 +08:00
|
|
|
cl::desc("Fill all delay slots with NOPs."),
|
2011-09-30 07:52:13 +08:00
|
|
|
cl::Hidden);
|
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
static cl::opt<bool> DisableForwardSearch(
|
|
|
|
"disable-mips-df-forward-search",
|
|
|
|
cl::init(true),
|
|
|
|
cl::desc("Disallow MIPS delay filler to search forward."),
|
|
|
|
cl::Hidden);
|
|
|
|
|
2013-03-01 09:02:36 +08:00
|
|
|
static cl::opt<bool> DisableSuccBBSearch(
|
|
|
|
"disable-mips-df-succbb-search",
|
|
|
|
cl::init(true),
|
|
|
|
cl::desc("Disallow MIPS delay filler to search successor basic blocks."),
|
|
|
|
cl::Hidden);
|
|
|
|
|
|
|
|
static cl::opt<bool> DisableBackwardSearch(
|
|
|
|
"disable-mips-df-backward-search",
|
|
|
|
cl::init(false),
|
|
|
|
cl::desc("Disallow MIPS delay filler to search backward."),
|
|
|
|
cl::Hidden);
|
|
|
|
|
2007-08-18 09:50:47 +08:00
|
|
|
namespace {
|
2013-03-01 10:03:51 +08:00
|
|
|
typedef MachineBasicBlock::iterator Iter;
|
|
|
|
typedef MachineBasicBlock::reverse_iterator ReverseIter;
|
|
|
|
typedef SmallDenseMap<MachineBasicBlock*, MachineInstr*, 2> BB2BrMap;
|
|
|
|
|
2013-02-26 09:30:05 +08:00
|
|
|
class RegDefsUses {
|
|
|
|
public:
|
|
|
|
RegDefsUses(TargetMachine &TM);
|
|
|
|
void init(const MachineInstr &MI);
|
2013-03-01 08:50:52 +08:00
|
|
|
|
|
|
|
/// This function sets all caller-saved registers in Defs.
|
|
|
|
void setCallerSaved(const MachineInstr &MI);
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
/// This function sets all unallocatable registers in Defs.
|
|
|
|
void setUnallocatableRegs(const MachineFunction &MF);
|
|
|
|
|
|
|
|
/// Set bits in Uses corresponding to MBB's live-out registers except for
|
|
|
|
/// the registers that are live-in to SuccBB.
|
|
|
|
void addLiveOut(const MachineBasicBlock &MBB,
|
|
|
|
const MachineBasicBlock &SuccBB);
|
|
|
|
|
2013-02-26 09:30:05 +08:00
|
|
|
bool update(const MachineInstr &MI, unsigned Begin, unsigned End);
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool checkRegDefsUses(BitVector &NewDefs, BitVector &NewUses, unsigned Reg,
|
|
|
|
bool IsDef) const;
|
|
|
|
|
|
|
|
/// Returns true if Reg or its alias is in RegSet.
|
|
|
|
bool isRegInSet(const BitVector &RegSet, unsigned Reg) const;
|
|
|
|
|
|
|
|
const TargetRegisterInfo &TRI;
|
|
|
|
BitVector Defs, Uses;
|
|
|
|
};
|
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
/// Base class for inspecting loads and stores.
|
|
|
|
class InspectMemInstr {
|
|
|
|
public:
|
2013-03-01 10:03:51 +08:00
|
|
|
InspectMemInstr(bool ForbidMemInstr_)
|
|
|
|
: OrigSeenLoad(false), OrigSeenStore(false), SeenLoad(false),
|
|
|
|
SeenStore(false), ForbidMemInstr(ForbidMemInstr_) {}
|
|
|
|
|
|
|
|
/// Return true if MI cannot be moved to delay slot.
|
|
|
|
bool hasHazard(const MachineInstr &MI);
|
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
virtual ~InspectMemInstr() {}
|
2013-03-01 10:03:51 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Flags indicating whether loads or stores have been seen.
|
|
|
|
bool OrigSeenLoad, OrigSeenStore, SeenLoad, SeenStore;
|
|
|
|
|
|
|
|
/// Memory instructions are not allowed to move to delay slot if this flag
|
|
|
|
/// is true.
|
|
|
|
bool ForbidMemInstr;
|
|
|
|
|
|
|
|
private:
|
|
|
|
virtual bool hasHazard_(const MachineInstr &MI) = 0;
|
2013-03-01 08:50:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// This subclass rejects any memory instructions.
|
|
|
|
class NoMemInstr : public InspectMemInstr {
|
|
|
|
public:
|
2013-03-01 10:03:51 +08:00
|
|
|
NoMemInstr() : InspectMemInstr(true) {}
|
|
|
|
private:
|
2014-04-29 15:58:02 +08:00
|
|
|
bool hasHazard_(const MachineInstr &MI) override { return true; }
|
2013-03-01 10:03:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// This subclass accepts loads from stacks and constant loads.
|
|
|
|
class LoadFromStackOrConst : public InspectMemInstr {
|
|
|
|
public:
|
|
|
|
LoadFromStackOrConst() : InspectMemInstr(false) {}
|
|
|
|
private:
|
2014-04-29 15:58:02 +08:00
|
|
|
bool hasHazard_(const MachineInstr &MI) override;
|
2013-03-01 08:50:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/// This subclass uses memory dependence information to determine whether a
|
|
|
|
/// memory instruction can be moved to a delay slot.
|
|
|
|
class MemDefsUses : public InspectMemInstr {
|
2013-03-01 08:16:31 +08:00
|
|
|
public:
|
|
|
|
MemDefsUses(const MachineFrameInfo *MFI);
|
|
|
|
|
|
|
|
private:
|
2014-04-15 15:22:52 +08:00
|
|
|
typedef PointerUnion<const Value *, const PseudoSourceValue *> ValueType;
|
|
|
|
|
2014-04-29 15:58:02 +08:00
|
|
|
bool hasHazard_(const MachineInstr &MI) override;
|
2013-03-01 10:03:51 +08:00
|
|
|
|
2013-03-01 08:16:31 +08:00
|
|
|
/// Update Defs and Uses. Return true if there exist dependences that
|
2013-03-01 10:17:02 +08:00
|
|
|
/// disqualify the delay slot candidate between V and values in Uses and
|
|
|
|
/// Defs.
|
2014-04-15 15:22:52 +08:00
|
|
|
bool updateDefsUses(ValueType V, bool MayStore);
|
2013-03-01 08:16:31 +08:00
|
|
|
|
|
|
|
/// Get the list of underlying objects of MI's memory operand.
|
|
|
|
bool getUnderlyingObjects(const MachineInstr &MI,
|
2014-04-15 15:22:52 +08:00
|
|
|
SmallVectorImpl<ValueType> &Objects) const;
|
2013-03-01 08:16:31 +08:00
|
|
|
|
|
|
|
const MachineFrameInfo *MFI;
|
2014-04-15 15:22:52 +08:00
|
|
|
SmallPtrSet<ValueType, 4> Uses, Defs;
|
2013-03-01 08:16:31 +08:00
|
|
|
|
|
|
|
/// Flags indicating whether loads or stores with no underlying objects have
|
|
|
|
/// been seen.
|
|
|
|
bool SeenNoObjLoad, SeenNoObjStore;
|
|
|
|
};
|
|
|
|
|
2013-02-08 05:32:32 +08:00
|
|
|
class Filler : public MachineFunctionPass {
|
|
|
|
public:
|
2010-12-10 01:31:11 +08:00
|
|
|
Filler(TargetMachine &tm)
|
2013-06-07 15:04:14 +08:00
|
|
|
: MachineFunctionPass(ID), TM(tm) { }
|
2007-08-18 09:50:47 +08:00
|
|
|
|
2014-04-29 15:58:02 +08:00
|
|
|
const char *getPassName() const override {
|
2007-08-18 09:50:47 +08:00
|
|
|
return "Mips Delay Slot Filler";
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:58:02 +08:00
|
|
|
bool runOnMachineFunction(MachineFunction &F) override {
|
2007-08-18 09:50:47 +08:00
|
|
|
bool Changed = false;
|
|
|
|
for (MachineFunction::iterator FI = F.begin(), FE = F.end();
|
|
|
|
FI != FE; ++FI)
|
|
|
|
Changed |= runOnMachineBasicBlock(*FI);
|
[mips][mips64r6] Replace m[tf]hi, m[tf]lo, mult, multu, dmult, dmultu, div, ddiv, divu, ddivu for MIPS32r6/MIPS64.
Summary:
The accumulator-based (HI/LO) multiplies and divides from earlier ISA's have
been removed and replaced with GPR-based equivalents. For example:
div $1, $2
mflo $3
is now:
div $3, $1, $2
This patch disables the accumulator-based multiplies and divides for
MIPS32r6/MIPS64r6 and uses the GPR-based equivalents instead.
Renamed expandPseudoDiv to insertDivByZeroTrap to better describe the
behaviour of the function.
MipsDelaySlotFiller now invalidates the liveness information when moving
instructions to the delay slot. Without this, divrem.ll will abort since
%GP ends up used before it is defined.
Reviewers: vmedic, zoran.jovanovic, jkolek
Reviewed By: jkolek
Differential Revision: http://reviews.llvm.org/D3896
llvm-svn: 210760
2014-06-12 18:44:10 +08:00
|
|
|
|
|
|
|
// This pass invalidates liveness information when it reorders
|
|
|
|
// instructions to fill delay slot. Without this, -verify-machineinstrs
|
|
|
|
// will fail.
|
|
|
|
if (Changed)
|
|
|
|
F.getRegInfo().invalidateLiveness();
|
|
|
|
|
2007-08-18 09:50:47 +08:00
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
|
2014-04-29 15:58:02 +08:00
|
|
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
2013-03-01 10:03:51 +08:00
|
|
|
AU.addRequired<MachineBranchProbabilityInfo>();
|
|
|
|
MachineFunctionPass::getAnalysisUsage(AU);
|
|
|
|
}
|
2013-02-08 05:32:32 +08:00
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
private:
|
2013-02-08 05:32:32 +08:00
|
|
|
bool runOnMachineBasicBlock(MachineBasicBlock &MBB);
|
|
|
|
|
2013-02-15 07:40:57 +08:00
|
|
|
/// This function checks if it is valid to move Candidate to the delay slot
|
2013-03-01 08:16:31 +08:00
|
|
|
/// and returns true if it isn't. It also updates memory and register
|
|
|
|
/// dependence information.
|
|
|
|
bool delayHasHazard(const MachineInstr &Candidate, RegDefsUses &RegDU,
|
2013-03-01 08:50:52 +08:00
|
|
|
InspectMemInstr &IM) const;
|
2011-09-30 07:52:13 +08:00
|
|
|
|
2013-03-01 08:26:14 +08:00
|
|
|
/// This function searches range [Begin, End) for an instruction that can be
|
|
|
|
/// moved to the delay slot. Returns true on success.
|
|
|
|
template<typename IterTy>
|
|
|
|
bool searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End,
|
2013-03-01 10:17:02 +08:00
|
|
|
RegDefsUses &RegDU, InspectMemInstr &IM,
|
|
|
|
IterTy &Filler) const;
|
2013-03-01 08:26:14 +08:00
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
/// This function searches in the backward direction for an instruction that
|
|
|
|
/// can be moved to the delay slot. Returns true on success.
|
|
|
|
bool searchBackward(MachineBasicBlock &MBB, Iter Slot) const;
|
|
|
|
|
|
|
|
/// This function searches MBB in the forward direction for an instruction
|
|
|
|
/// that can be moved to the delay slot. Returns true on success.
|
|
|
|
bool searchForward(MachineBasicBlock &MBB, Iter Slot) const;
|
2013-02-15 07:11:24 +08:00
|
|
|
|
2013-03-26 04:11:16 +08:00
|
|
|
/// This function searches one of MBB's successor blocks for an instruction
|
|
|
|
/// that can be moved to the delay slot and inserts clones of the
|
|
|
|
/// instruction into the successor's predecessor blocks.
|
2013-03-01 10:03:51 +08:00
|
|
|
bool searchSuccBBs(MachineBasicBlock &MBB, Iter Slot) const;
|
|
|
|
|
2013-03-01 10:17:02 +08:00
|
|
|
/// Pick a successor block of MBB. Return NULL if MBB doesn't have a
|
|
|
|
/// successor block that is not a landing pad.
|
2013-03-01 10:03:51 +08:00
|
|
|
MachineBasicBlock *selectSuccBB(MachineBasicBlock &B) const;
|
|
|
|
|
|
|
|
/// This function analyzes MBB and returns an instruction with an unoccupied
|
|
|
|
/// slot that branches to Dst.
|
|
|
|
std::pair<MipsInstrInfo::BranchType, MachineInstr *>
|
|
|
|
getBranch(MachineBasicBlock &MBB, const MachineBasicBlock &Dst) const;
|
|
|
|
|
|
|
|
/// Examine Pred and see if it is possible to insert an instruction into
|
|
|
|
/// one of its branches delay slot or its end.
|
|
|
|
bool examinePred(MachineBasicBlock &Pred, const MachineBasicBlock &Succ,
|
|
|
|
RegDefsUses &RegDU, bool &HasMultipleSuccs,
|
|
|
|
BB2BrMap &BrMap) const;
|
|
|
|
|
2013-02-15 07:11:24 +08:00
|
|
|
bool terminateSearch(const MachineInstr &Candidate) const;
|
2011-09-30 07:52:13 +08:00
|
|
|
|
2013-02-08 05:32:32 +08:00
|
|
|
TargetMachine &TM;
|
2011-09-30 07:52:13 +08:00
|
|
|
|
2013-02-08 05:32:32 +08:00
|
|
|
static char ID;
|
2007-08-18 09:50:47 +08:00
|
|
|
};
|
|
|
|
char Filler::ID = 0;
|
|
|
|
} // end of anonymous namespace
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
static bool hasUnoccupiedSlot(const MachineInstr *MI) {
|
|
|
|
return MI->hasDelaySlot() && !MI->isBundledWithSucc();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This function inserts clones of Filler into predecessor blocks.
|
|
|
|
static void insertDelayFiller(Iter Filler, const BB2BrMap &BrMap) {
|
|
|
|
MachineFunction *MF = Filler->getParent()->getParent();
|
|
|
|
|
|
|
|
for (BB2BrMap::const_iterator I = BrMap.begin(); I != BrMap.end(); ++I) {
|
|
|
|
if (I->second) {
|
|
|
|
MIBundleBuilder(I->second).append(MF->CloneMachineInstr(&*Filler));
|
|
|
|
++UsefulSlots;
|
|
|
|
} else {
|
|
|
|
I->first->insert(I->first->end(), MF->CloneMachineInstr(&*Filler));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// This function adds registers Filler defines to MBB's live-in register list.
|
|
|
|
static void addLiveInRegs(Iter Filler, MachineBasicBlock &MBB) {
|
|
|
|
for (unsigned I = 0, E = Filler->getNumOperands(); I != E; ++I) {
|
|
|
|
const MachineOperand &MO = Filler->getOperand(I);
|
|
|
|
unsigned R;
|
|
|
|
|
|
|
|
if (!MO.isReg() || !MO.isDef() || !(R = MO.getReg()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
#ifndef NDEBUG
|
|
|
|
const MachineFunction &MF = *MBB.getParent();
|
2014-08-05 05:25:23 +08:00
|
|
|
assert(MF.getTarget()
|
|
|
|
.getSubtargetImpl()
|
|
|
|
->getRegisterInfo()
|
|
|
|
->getAllocatableSet(MF)
|
|
|
|
.test(R) &&
|
2013-03-01 10:03:51 +08:00
|
|
|
"Shouldn't move an instruction with unallocatable registers across "
|
|
|
|
"basic block boundaries.");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (!MBB.isLiveIn(R))
|
|
|
|
MBB.addLiveIn(R);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-26 09:30:05 +08:00
|
|
|
RegDefsUses::RegDefsUses(TargetMachine &TM)
|
2014-08-05 05:25:23 +08:00
|
|
|
: TRI(*TM.getSubtargetImpl()->getRegisterInfo()),
|
|
|
|
Defs(TRI.getNumRegs(), false), Uses(TRI.getNumRegs(), false) {}
|
2013-02-26 09:30:05 +08:00
|
|
|
|
|
|
|
void RegDefsUses::init(const MachineInstr &MI) {
|
|
|
|
// Add all register operands which are explicit and non-variadic.
|
|
|
|
update(MI, 0, MI.getDesc().getNumOperands());
|
|
|
|
|
|
|
|
// If MI is a call, add RA to Defs to prevent users of RA from going into
|
|
|
|
// delay slot.
|
|
|
|
if (MI.isCall())
|
|
|
|
Defs.set(Mips::RA);
|
|
|
|
|
|
|
|
// Add all implicit register operands of branch instructions except
|
|
|
|
// register AT.
|
|
|
|
if (MI.isBranch()) {
|
|
|
|
update(MI, MI.getDesc().getNumOperands(), MI.getNumOperands());
|
|
|
|
Defs.reset(Mips::AT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
void RegDefsUses::setCallerSaved(const MachineInstr &MI) {
|
|
|
|
assert(MI.isCall());
|
|
|
|
|
|
|
|
// If MI is a call, add all caller-saved registers to Defs.
|
|
|
|
BitVector CallerSavedRegs(TRI.getNumRegs(), true);
|
|
|
|
|
|
|
|
CallerSavedRegs.reset(Mips::ZERO);
|
|
|
|
CallerSavedRegs.reset(Mips::ZERO_64);
|
|
|
|
|
|
|
|
for (const MCPhysReg *R = TRI.getCalleeSavedRegs(); *R; ++R)
|
|
|
|
for (MCRegAliasIterator AI(*R, &TRI, true); AI.isValid(); ++AI)
|
|
|
|
CallerSavedRegs.reset(*AI);
|
|
|
|
|
|
|
|
Defs |= CallerSavedRegs;
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
void RegDefsUses::setUnallocatableRegs(const MachineFunction &MF) {
|
|
|
|
BitVector AllocSet = TRI.getAllocatableSet(MF);
|
|
|
|
|
|
|
|
for (int R = AllocSet.find_first(); R != -1; R = AllocSet.find_next(R))
|
|
|
|
for (MCRegAliasIterator AI(R, &TRI, false); AI.isValid(); ++AI)
|
|
|
|
AllocSet.set(*AI);
|
|
|
|
|
|
|
|
AllocSet.set(Mips::ZERO);
|
|
|
|
AllocSet.set(Mips::ZERO_64);
|
|
|
|
|
|
|
|
Defs |= AllocSet.flip();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RegDefsUses::addLiveOut(const MachineBasicBlock &MBB,
|
|
|
|
const MachineBasicBlock &SuccBB) {
|
|
|
|
for (MachineBasicBlock::const_succ_iterator SI = MBB.succ_begin(),
|
|
|
|
SE = MBB.succ_end(); SI != SE; ++SI)
|
|
|
|
if (*SI != &SuccBB)
|
|
|
|
for (MachineBasicBlock::livein_iterator LI = (*SI)->livein_begin(),
|
|
|
|
LE = (*SI)->livein_end(); LI != LE; ++LI)
|
|
|
|
Uses.set(*LI);
|
|
|
|
}
|
|
|
|
|
2013-02-26 09:30:05 +08:00
|
|
|
bool RegDefsUses::update(const MachineInstr &MI, unsigned Begin, unsigned End) {
|
|
|
|
BitVector NewDefs(TRI.getNumRegs()), NewUses(TRI.getNumRegs());
|
|
|
|
bool HasHazard = false;
|
|
|
|
|
|
|
|
for (unsigned I = Begin; I != End; ++I) {
|
|
|
|
const MachineOperand &MO = MI.getOperand(I);
|
|
|
|
|
|
|
|
if (MO.isReg() && MO.getReg())
|
|
|
|
HasHazard |= checkRegDefsUses(NewDefs, NewUses, MO.getReg(), MO.isDef());
|
|
|
|
}
|
|
|
|
|
|
|
|
Defs |= NewDefs;
|
|
|
|
Uses |= NewUses;
|
|
|
|
|
|
|
|
return HasHazard;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RegDefsUses::checkRegDefsUses(BitVector &NewDefs, BitVector &NewUses,
|
|
|
|
unsigned Reg, bool IsDef) const {
|
|
|
|
if (IsDef) {
|
|
|
|
NewDefs.set(Reg);
|
|
|
|
// check whether Reg has already been defined or used.
|
|
|
|
return (isRegInSet(Defs, Reg) || isRegInSet(Uses, Reg));
|
|
|
|
}
|
|
|
|
|
|
|
|
NewUses.set(Reg);
|
|
|
|
// check whether Reg has already been defined.
|
|
|
|
return isRegInSet(Defs, Reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RegDefsUses::isRegInSet(const BitVector &RegSet, unsigned Reg) const {
|
|
|
|
// Check Reg and all aliased Registers.
|
|
|
|
for (MCRegAliasIterator AI(Reg, &TRI, true); AI.isValid(); ++AI)
|
|
|
|
if (RegSet.test(*AI))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
bool InspectMemInstr::hasHazard(const MachineInstr &MI) {
|
2013-03-01 08:16:31 +08:00
|
|
|
if (!MI.mayStore() && !MI.mayLoad())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (ForbidMemInstr)
|
|
|
|
return true;
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
OrigSeenLoad = SeenLoad;
|
|
|
|
OrigSeenStore = SeenStore;
|
2013-03-01 08:16:31 +08:00
|
|
|
SeenLoad |= MI.mayLoad();
|
|
|
|
SeenStore |= MI.mayStore();
|
|
|
|
|
|
|
|
// If MI is an ordered or volatile memory reference, disallow moving
|
|
|
|
// subsequent loads and stores to delay slot.
|
|
|
|
if (MI.hasOrderedMemoryRef() && (OrigSeenLoad || OrigSeenStore)) {
|
|
|
|
ForbidMemInstr = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
return hasHazard_(MI);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LoadFromStackOrConst::hasHazard_(const MachineInstr &MI) {
|
|
|
|
if (MI.mayStore())
|
|
|
|
return true;
|
|
|
|
|
2014-04-15 15:22:52 +08:00
|
|
|
if (!MI.hasOneMemOperand() || !(*MI.memoperands_begin())->getPseudoValue())
|
2013-03-01 10:03:51 +08:00
|
|
|
return true;
|
|
|
|
|
2014-04-15 15:22:52 +08:00
|
|
|
if (const PseudoSourceValue *PSV =
|
|
|
|
(*MI.memoperands_begin())->getPseudoValue()) {
|
|
|
|
if (isa<FixedStackPseudoSourceValue>(PSV))
|
|
|
|
return false;
|
2014-04-25 13:30:21 +08:00
|
|
|
return !PSV->isConstant(nullptr) && PSV != PseudoSourceValue::getStack();
|
2014-04-15 15:22:52 +08:00
|
|
|
}
|
2013-03-01 10:03:51 +08:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MemDefsUses::MemDefsUses(const MachineFrameInfo *MFI_)
|
|
|
|
: InspectMemInstr(false), MFI(MFI_), SeenNoObjLoad(false),
|
|
|
|
SeenNoObjStore(false) {}
|
|
|
|
|
|
|
|
bool MemDefsUses::hasHazard_(const MachineInstr &MI) {
|
2013-03-01 08:16:31 +08:00
|
|
|
bool HasHazard = false;
|
2014-04-15 15:22:52 +08:00
|
|
|
SmallVector<ValueType, 4> Objs;
|
2013-03-01 08:16:31 +08:00
|
|
|
|
|
|
|
// Check underlying object list.
|
|
|
|
if (getUnderlyingObjects(MI, Objs)) {
|
2014-04-15 15:22:52 +08:00
|
|
|
for (SmallVectorImpl<ValueType>::const_iterator I = Objs.begin();
|
2013-03-01 08:16:31 +08:00
|
|
|
I != Objs.end(); ++I)
|
|
|
|
HasHazard |= updateDefsUses(*I, MI.mayStore());
|
|
|
|
|
|
|
|
return HasHazard;
|
|
|
|
}
|
|
|
|
|
|
|
|
// No underlying objects found.
|
|
|
|
HasHazard = MI.mayStore() && (OrigSeenLoad || OrigSeenStore);
|
|
|
|
HasHazard |= MI.mayLoad() || OrigSeenStore;
|
|
|
|
|
|
|
|
SeenNoObjLoad |= MI.mayLoad();
|
|
|
|
SeenNoObjStore |= MI.mayStore();
|
|
|
|
|
|
|
|
return HasHazard;
|
|
|
|
}
|
|
|
|
|
2014-04-15 15:22:52 +08:00
|
|
|
bool MemDefsUses::updateDefsUses(ValueType V, bool MayStore) {
|
2013-03-01 08:16:31 +08:00
|
|
|
if (MayStore)
|
|
|
|
return !Defs.insert(V) || Uses.count(V) || SeenNoObjStore || SeenNoObjLoad;
|
|
|
|
|
|
|
|
Uses.insert(V);
|
|
|
|
return Defs.count(V) || SeenNoObjStore;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MemDefsUses::
|
|
|
|
getUnderlyingObjects(const MachineInstr &MI,
|
2014-04-15 15:22:52 +08:00
|
|
|
SmallVectorImpl<ValueType> &Objects) const {
|
|
|
|
if (!MI.hasOneMemOperand() ||
|
|
|
|
(!(*MI.memoperands_begin())->getValue() &&
|
|
|
|
!(*MI.memoperands_begin())->getPseudoValue()))
|
2013-03-01 08:16:31 +08:00
|
|
|
return false;
|
|
|
|
|
2014-04-15 15:22:52 +08:00
|
|
|
if (const PseudoSourceValue *PSV =
|
|
|
|
(*MI.memoperands_begin())->getPseudoValue()) {
|
|
|
|
if (!PSV->isAliased(MFI))
|
|
|
|
return false;
|
|
|
|
Objects.push_back(PSV);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:16:31 +08:00
|
|
|
const Value *V = (*MI.memoperands_begin())->getValue();
|
|
|
|
|
|
|
|
SmallVector<Value *, 4> Objs;
|
|
|
|
GetUnderlyingObjects(const_cast<Value *>(V), Objs);
|
|
|
|
|
2013-07-03 23:07:05 +08:00
|
|
|
for (SmallVectorImpl<Value *>::iterator I = Objs.begin(), E = Objs.end();
|
2013-03-01 08:16:31 +08:00
|
|
|
I != E; ++I) {
|
2014-04-15 15:22:52 +08:00
|
|
|
if (!isIdentifiedObject(V))
|
2013-03-01 08:16:31 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
Objects.push_back(*I);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-08-18 09:50:47 +08:00
|
|
|
/// runOnMachineBasicBlock - Fill in delay slots for the given basic block.
|
2011-09-30 07:52:13 +08:00
|
|
|
/// We assume there is only one delay slot per delayed instruction.
|
2013-02-15 07:20:15 +08:00
|
|
|
bool Filler::runOnMachineBasicBlock(MachineBasicBlock &MBB) {
|
2007-08-18 09:50:47 +08:00
|
|
|
bool Changed = false;
|
2011-10-05 09:30:09 +08:00
|
|
|
|
2013-02-15 07:11:24 +08:00
|
|
|
for (Iter I = MBB.begin(); I != MBB.end(); ++I) {
|
2013-03-01 10:03:51 +08:00
|
|
|
if (!hasUnoccupiedSlot(&*I))
|
2013-02-08 05:32:32 +08:00
|
|
|
continue;
|
|
|
|
|
|
|
|
++FilledSlots;
|
|
|
|
Changed = true;
|
|
|
|
|
|
|
|
// Delay slot filling is disabled at -O0.
|
2013-03-01 10:03:51 +08:00
|
|
|
if (!DisableDelaySlotFiller && (TM.getOptLevel() != CodeGenOpt::None)) {
|
|
|
|
if (searchBackward(MBB, I))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (I->isTerminator()) {
|
|
|
|
if (searchSuccBBs(MBB, I))
|
|
|
|
continue;
|
|
|
|
} else if (searchForward(MBB, I)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2011-09-30 07:52:13 +08:00
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
// Bundle the NOP to the instruction with the delay slot.
|
2014-08-05 05:25:23 +08:00
|
|
|
const MipsInstrInfo *TII = static_cast<const MipsInstrInfo *>(
|
|
|
|
TM.getSubtargetImpl()->getInstrInfo());
|
2014-03-02 20:27:27 +08:00
|
|
|
BuildMI(MBB, std::next(I), I->getDebugLoc(), TII->get(Mips::NOP));
|
|
|
|
MIBundleBuilder(MBB, I, std::next(I, 2));
|
2013-02-08 05:32:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return Changed;
|
2007-08-18 09:50:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createMipsDelaySlotFillerPass - Returns a pass that fills in delay
|
|
|
|
/// slots in Mips MachineFunctions
|
|
|
|
FunctionPass *llvm::createMipsDelaySlotFillerPass(MipsTargetMachine &tm) {
|
|
|
|
return new Filler(tm);
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:26:14 +08:00
|
|
|
template<typename IterTy>
|
|
|
|
bool Filler::searchRange(MachineBasicBlock &MBB, IterTy Begin, IterTy End,
|
2013-03-01 08:50:52 +08:00
|
|
|
RegDefsUses &RegDU, InspectMemInstr& IM,
|
2013-03-01 08:26:14 +08:00
|
|
|
IterTy &Filler) const {
|
|
|
|
for (IterTy I = Begin; I != End; ++I) {
|
2011-09-30 07:52:13 +08:00
|
|
|
// skip debug value
|
|
|
|
if (I->isDebugValue())
|
|
|
|
continue;
|
|
|
|
|
2013-02-15 07:11:24 +08:00
|
|
|
if (terminateSearch(*I))
|
2011-09-30 07:52:13 +08:00
|
|
|
break;
|
|
|
|
|
2013-03-01 08:16:31 +08:00
|
|
|
assert((!I->isCall() && !I->isReturn() && !I->isBranch()) &&
|
|
|
|
"Cannot put calls, returns or branches in delay slot.");
|
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
if (delayHasHazard(*I, RegDU, IM))
|
2011-09-30 07:52:13 +08:00
|
|
|
continue;
|
|
|
|
|
2014-03-11 04:34:23 +08:00
|
|
|
if (TM.getSubtarget<MipsSubtarget>().isTargetNaCl()) {
|
|
|
|
// In NaCl, instructions that must be masked are forbidden in delay slots.
|
|
|
|
// We only check for loads, stores and SP changes. Calls, returns and
|
|
|
|
// branches are not checked because non-NaCl targets never put them in
|
|
|
|
// delay slots.
|
|
|
|
unsigned AddrIdx;
|
2014-08-05 05:25:23 +08:00
|
|
|
if ((isBasePlusOffsetMemoryAccess(I->getOpcode(), &AddrIdx) &&
|
|
|
|
baseRegNeedsLoadStoreMask(I->getOperand(AddrIdx).getReg())) ||
|
|
|
|
I->modifiesRegister(Mips::SP,
|
|
|
|
TM.getSubtargetImpl()->getRegisterInfo()))
|
2014-03-11 04:34:23 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:26:14 +08:00
|
|
|
Filler = I;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
bool Filler::searchBackward(MachineBasicBlock &MBB, Iter Slot) const {
|
2013-03-01 10:03:51 +08:00
|
|
|
if (DisableBackwardSearch)
|
|
|
|
return false;
|
|
|
|
|
2013-03-01 08:26:14 +08:00
|
|
|
RegDefsUses RegDU(TM);
|
|
|
|
MemDefsUses MemDU(MBB.getParent()->getFrameInfo());
|
2013-03-01 08:50:52 +08:00
|
|
|
ReverseIter Filler;
|
2013-03-01 08:26:14 +08:00
|
|
|
|
|
|
|
RegDU.init(*Slot);
|
|
|
|
|
2013-10-08 03:33:02 +08:00
|
|
|
if (!searchRange(MBB, ReverseIter(Slot), MBB.rend(), RegDU, MemDU, Filler))
|
|
|
|
return false;
|
2013-03-01 08:50:52 +08:00
|
|
|
|
2014-03-02 20:27:27 +08:00
|
|
|
MBB.splice(std::next(Slot), &MBB, std::next(Filler).base());
|
|
|
|
MIBundleBuilder(MBB, Slot, std::next(Slot, 2));
|
2013-10-08 03:33:02 +08:00
|
|
|
++UsefulSlots;
|
|
|
|
return true;
|
2013-03-01 08:50:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Filler::searchForward(MachineBasicBlock &MBB, Iter Slot) const {
|
|
|
|
// Can handle only calls.
|
2013-03-01 10:03:51 +08:00
|
|
|
if (DisableForwardSearch || !Slot->isCall())
|
2013-03-01 08:50:52 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
RegDefsUses RegDU(TM);
|
|
|
|
NoMemInstr NM;
|
|
|
|
Iter Filler;
|
|
|
|
|
|
|
|
RegDU.setCallerSaved(*Slot);
|
|
|
|
|
2014-03-02 20:27:27 +08:00
|
|
|
if (!searchRange(MBB, std::next(Slot), MBB.end(), RegDU, NM, Filler))
|
2013-10-08 03:33:02 +08:00
|
|
|
return false;
|
2011-10-05 09:23:39 +08:00
|
|
|
|
2014-03-02 20:27:27 +08:00
|
|
|
MBB.splice(std::next(Slot), &MBB, Filler);
|
|
|
|
MIBundleBuilder(MBB, Slot, std::next(Slot, 2));
|
2013-10-08 03:33:02 +08:00
|
|
|
++UsefulSlots;
|
|
|
|
return true;
|
2011-09-30 07:52:13 +08:00
|
|
|
}
|
|
|
|
|
2013-03-01 10:03:51 +08:00
|
|
|
bool Filler::searchSuccBBs(MachineBasicBlock &MBB, Iter Slot) const {
|
|
|
|
if (DisableSuccBBSearch)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
MachineBasicBlock *SuccBB = selectSuccBB(MBB);
|
|
|
|
|
|
|
|
if (!SuccBB)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
RegDefsUses RegDU(TM);
|
|
|
|
bool HasMultipleSuccs = false;
|
|
|
|
BB2BrMap BrMap;
|
2014-04-21 17:34:48 +08:00
|
|
|
std::unique_ptr<InspectMemInstr> IM;
|
2013-03-01 10:03:51 +08:00
|
|
|
Iter Filler;
|
|
|
|
|
|
|
|
// Iterate over SuccBB's predecessor list.
|
|
|
|
for (MachineBasicBlock::pred_iterator PI = SuccBB->pred_begin(),
|
|
|
|
PE = SuccBB->pred_end(); PI != PE; ++PI)
|
|
|
|
if (!examinePred(**PI, *SuccBB, RegDU, HasMultipleSuccs, BrMap))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Do not allow moving instructions which have unallocatable register operands
|
|
|
|
// across basic block boundaries.
|
|
|
|
RegDU.setUnallocatableRegs(*MBB.getParent());
|
|
|
|
|
|
|
|
// Only allow moving loads from stack or constants if any of the SuccBB's
|
|
|
|
// predecessors have multiple successors.
|
|
|
|
if (HasMultipleSuccs) {
|
|
|
|
IM.reset(new LoadFromStackOrConst());
|
|
|
|
} else {
|
|
|
|
const MachineFrameInfo *MFI = MBB.getParent()->getFrameInfo();
|
|
|
|
IM.reset(new MemDefsUses(MFI));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!searchRange(MBB, SuccBB->begin(), SuccBB->end(), RegDU, *IM, Filler))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
insertDelayFiller(Filler, BrMap);
|
|
|
|
addLiveInRegs(Filler, *SuccBB);
|
|
|
|
Filler->eraseFromParent();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MachineBasicBlock *Filler::selectSuccBB(MachineBasicBlock &B) const {
|
|
|
|
if (B.succ_empty())
|
2014-04-25 13:30:21 +08:00
|
|
|
return nullptr;
|
2013-03-01 10:03:51 +08:00
|
|
|
|
|
|
|
// Select the successor with the larget edge weight.
|
2014-03-01 19:47:00 +08:00
|
|
|
auto &Prob = getAnalysis<MachineBranchProbabilityInfo>();
|
|
|
|
MachineBasicBlock *S = *std::max_element(B.succ_begin(), B.succ_end(),
|
|
|
|
[&](const MachineBasicBlock *Dst0,
|
|
|
|
const MachineBasicBlock *Dst1) {
|
|
|
|
return Prob.getEdgeWeight(&B, Dst0) < Prob.getEdgeWeight(&B, Dst1);
|
|
|
|
});
|
2014-04-25 13:30:21 +08:00
|
|
|
return S->isLandingPad() ? nullptr : S;
|
2013-03-01 10:03:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
std::pair<MipsInstrInfo::BranchType, MachineInstr *>
|
|
|
|
Filler::getBranch(MachineBasicBlock &MBB, const MachineBasicBlock &Dst) const {
|
|
|
|
const MipsInstrInfo *TII =
|
2014-08-05 05:25:23 +08:00
|
|
|
static_cast<const MipsInstrInfo *>(TM.getSubtargetImpl()->getInstrInfo());
|
2014-04-25 13:30:21 +08:00
|
|
|
MachineBasicBlock *TrueBB = nullptr, *FalseBB = nullptr;
|
2013-03-01 10:03:51 +08:00
|
|
|
SmallVector<MachineInstr*, 2> BranchInstrs;
|
|
|
|
SmallVector<MachineOperand, 2> Cond;
|
|
|
|
|
|
|
|
MipsInstrInfo::BranchType R =
|
|
|
|
TII->AnalyzeBranch(MBB, TrueBB, FalseBB, Cond, false, BranchInstrs);
|
|
|
|
|
|
|
|
if ((R == MipsInstrInfo::BT_None) || (R == MipsInstrInfo::BT_NoBranch))
|
2014-04-25 13:30:21 +08:00
|
|
|
return std::make_pair(R, nullptr);
|
2013-03-01 10:03:51 +08:00
|
|
|
|
|
|
|
if (R != MipsInstrInfo::BT_CondUncond) {
|
|
|
|
if (!hasUnoccupiedSlot(BranchInstrs[0]))
|
2014-04-25 13:30:21 +08:00
|
|
|
return std::make_pair(MipsInstrInfo::BT_None, nullptr);
|
2013-03-01 10:03:51 +08:00
|
|
|
|
|
|
|
assert(((R != MipsInstrInfo::BT_Uncond) || (TrueBB == &Dst)));
|
|
|
|
|
|
|
|
return std::make_pair(R, BranchInstrs[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert((TrueBB == &Dst) || (FalseBB == &Dst));
|
|
|
|
|
|
|
|
// Examine the conditional branch. See if its slot is occupied.
|
|
|
|
if (hasUnoccupiedSlot(BranchInstrs[0]))
|
|
|
|
return std::make_pair(MipsInstrInfo::BT_Cond, BranchInstrs[0]);
|
|
|
|
|
|
|
|
// If that fails, try the unconditional branch.
|
|
|
|
if (hasUnoccupiedSlot(BranchInstrs[1]) && (FalseBB == &Dst))
|
|
|
|
return std::make_pair(MipsInstrInfo::BT_Uncond, BranchInstrs[1]);
|
|
|
|
|
2014-04-25 13:30:21 +08:00
|
|
|
return std::make_pair(MipsInstrInfo::BT_None, nullptr);
|
2013-03-01 10:03:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Filler::examinePred(MachineBasicBlock &Pred, const MachineBasicBlock &Succ,
|
|
|
|
RegDefsUses &RegDU, bool &HasMultipleSuccs,
|
|
|
|
BB2BrMap &BrMap) const {
|
|
|
|
std::pair<MipsInstrInfo::BranchType, MachineInstr *> P =
|
|
|
|
getBranch(Pred, Succ);
|
|
|
|
|
|
|
|
// Return if either getBranch wasn't able to analyze the branches or there
|
|
|
|
// were no branches with unoccupied slots.
|
|
|
|
if (P.first == MipsInstrInfo::BT_None)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ((P.first != MipsInstrInfo::BT_Uncond) &&
|
|
|
|
(P.first != MipsInstrInfo::BT_NoBranch)) {
|
|
|
|
HasMultipleSuccs = true;
|
|
|
|
RegDU.addLiveOut(Pred, Succ);
|
|
|
|
}
|
|
|
|
|
|
|
|
BrMap[&Pred] = P.second;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:16:31 +08:00
|
|
|
bool Filler::delayHasHazard(const MachineInstr &Candidate, RegDefsUses &RegDU,
|
2013-03-01 08:50:52 +08:00
|
|
|
InspectMemInstr &IM) const {
|
2013-02-15 07:40:57 +08:00
|
|
|
bool HasHazard = (Candidate.isImplicitDef() || Candidate.isKill());
|
2011-09-30 07:52:13 +08:00
|
|
|
|
2013-03-01 08:50:52 +08:00
|
|
|
HasHazard |= IM.hasHazard(Candidate);
|
2013-02-26 09:30:05 +08:00
|
|
|
HasHazard |= RegDU.update(Candidate, 0, Candidate.getNumOperands());
|
2011-09-30 07:52:13 +08:00
|
|
|
|
2013-02-15 07:40:57 +08:00
|
|
|
return HasHazard;
|
2012-11-16 10:39:34 +08:00
|
|
|
}
|
|
|
|
|
2013-02-15 07:11:24 +08:00
|
|
|
bool Filler::terminateSearch(const MachineInstr &Candidate) const {
|
|
|
|
return (Candidate.isTerminator() || Candidate.isCall() ||
|
2014-03-07 14:08:31 +08:00
|
|
|
Candidate.isPosition() || Candidate.isInlineAsm() ||
|
2013-02-15 07:11:24 +08:00
|
|
|
Candidate.hasUnmodeledSideEffects());
|
|
|
|
}
|