LLVM  6.0.0svn
Macros | Enumerations | Functions | Variables
MipsDelaySlotFiller.cpp File Reference
#include "MCTargetDesc/MipsMCNaCl.h"
#include "Mips.h"
#include "MipsInstrInfo.h"
#include "MipsRegisterInfo.h"
#include "MipsSubtarget.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <memory>
#include <utility>
Include dependency graph for MipsDelaySlotFiller.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "delay-slot-filler"
 

Enumerations

enum  CompactBranchPolicy { CB_Never, CB_Optimal, CB_Always }
 

Functions

 STATISTIC (FilledSlots, "Number of delay slots filled")
 
 STATISTIC (UsefulSlots, "Number of delay slots filled with instructions that" " are not NOP.")
 
static bool hasUnoccupiedSlot (const MachineInstr *MI)
 
static void insertDelayFiller (Iter Filler, const BB2BrMap &BrMap)
 This function inserts clones of Filler into predecessor blocks. More...
 
static void addLiveInRegs (Iter Filler, MachineBasicBlock &MBB)
 This function adds registers Filler defines to MBB's live-in register list. More...
 
static int getEquivalentCallShort (int Opcode)
 

Variables

static cl::opt< boolDisableDelaySlotFiller ("disable-mips-delay-filler", cl::init(false), cl::desc("Fill all delay slots with NOPs."), cl::Hidden)
 
static cl::opt< boolDisableForwardSearch ("disable-mips-df-forward-search", cl::init(true), cl::desc("Disallow MIPS delay filler to search forward."), cl::Hidden)
 
static cl::opt< boolDisableSuccBBSearch ("disable-mips-df-succbb-search", cl::init(true), cl::desc("Disallow MIPS delay filler to search successor basic blocks."), cl::Hidden)
 
static cl::opt< boolDisableBackwardSearch ("disable-mips-df-backward-search", cl::init(false), cl::desc("Disallow MIPS delay filler to search backward."), cl::Hidden)
 
static cl::opt< CompactBranchPolicyMipsCompactBranchPolicy ("mips-compact-branches", cl::Optional, cl::init(CB_Optimal), cl::desc("MIPS Specific: Compact branch policy."), cl::values(clEnumValN(CB_Never, "never", "Do not use compact branches if possible."), clEnumValN(CB_Optimal, "optimal", "Use compact branches where appropiate (default)."), clEnumValN(CB_Always, "always", "Always use compact branches if possible.")))
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "delay-slot-filler"

Definition at line 54 of file MipsDelaySlotFiller.cpp.

Enumeration Type Documentation

◆ CompactBranchPolicy

Enumerator
CB_Never 

The policy 'never' may in some circumstances or for some ISAs not be absolutely adhered to.

CB_Optimal 

Optimal is the default and will produce compact branches when delay slots cannot be filled.

CB_Always 

'always' may in some circumstances may not be absolutely adhered to there may not be a corresponding compact form of a branch.

Definition at line 84 of file MipsDelaySlotFiller.cpp.

Function Documentation

◆ addLiveInRegs()

static void addLiveInRegs ( Iter  Filler,
MachineBasicBlock MBB 
)
static

This function adds registers Filler defines to MBB's live-in register list.

Definition at line 322 of file MipsDelaySlotFiller.cpp.

References llvm::MachineBasicBlock::addLiveIn(), assert(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::MCID::Branch, llvm::MachineInstr::definesRegister(), E, llvm::SmallVectorTemplateCommon< T >::end(), llvm::WebAssembly::End, llvm::BitVector::flip(), llvm::TargetRegisterInfo::getAllocatableSet(), llvm::TargetRegisterInfo::getCalleeSavedRegs(), llvm::MachineInstr::getDesc(), llvm::MipsInstrInfo::getEquivalentCompactForm(), llvm::MipsSubtarget::getInstrInfo(), llvm::MCInstrDesc::getNumOperands(), llvm::MachineInstr::getNumOperands(), llvm::MCRegisterInfo::getNumRegs(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getReg(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::GetUnderlyingObjects(), getUnderlyingObjects(), llvm::MachineInstr::hasOneMemOperand(), llvm::MachineInstr::hasOrderedMemoryRef(), I, llvm::cl::init(), llvm::MachineInstr::isBranch(), llvm::MachineInstr::isCall(), llvm::MachineOperand::isDef(), llvm::isIdentifiedObject(), llvm::MachineBasicBlock::isLiveIn(), llvm::MachineOperand::isReg(), llvm::MCRegAliasIterator::isValid(), llvm::MachineInstr::mayLoad(), llvm::MCID::MayStore, llvm::MachineInstr::mayStore(), llvm::MachineInstr::memoperands_begin(), MI, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), RA, llvm::BitVector::reset(), llvm::BitVector::set(), llvm::BitVector::set_bits(), SI, llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_end(), llvm::BitVector::test(), and TII.

Referenced by getEquivalentCallShort().

◆ getEquivalentCallShort()

static int getEquivalentCallShort ( int  Opcode)
static

Definition at line 571 of file MipsDelaySlotFiller.cpp.

References addLiveInRegs(), llvm::MipsInstrInfo::analyzeBranch(), assert(), B, llvm::baseRegNeedsLoadStoreMask(), llvm::MachineBasicBlock::begin(), llvm::MipsInstrInfo::BT_Cond, llvm::MipsInstrInfo::BT_CondUncond, llvm::MipsInstrInfo::BT_NoBranch, llvm::MipsInstrInfo::BT_None, llvm::MipsInstrInfo::BT_Uncond, llvm::BuildMI(), CB_Always, CB_Never, DisableBackwardSearch, DisableDelaySlotFiller, DisableForwardSearch, DisableSuccBBSearch, llvm::WebAssembly::End, llvm::MachineBasicBlock::end(), llvm::MipsInstrInfo::getEquivalentCompactForm(), llvm::MipsSubtarget::getInstrInfo(), llvm::MipsInstrInfo::getInstSizeInBytes(), llvm::MachineInstr::getNumOperands(), llvm::MachineBasicBlock::getParent(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MipsSubtarget::getRegisterInfo(), llvm::MachineInstrBundleIterator< Ty, IsReverse >::getReverse(), llvm::MachineFunction::getSubtarget(), llvm::MipsSubtarget::hasMips32r6(), llvm::MachineInstr::hasUnmodeledSideEffects(), hasUnoccupiedSlot(), I, llvm::MipsSubtarget::inMicroMipsMode(), insertDelayFiller(), llvm::isBasePlusOffsetMemoryAccess(), llvm::MachineInstr::isCall(), llvm::MachineBasicBlock::isEHPad(), llvm::MachineInstr::isImplicitDef(), llvm::MachineInstr::isInlineAsm(), llvm::MachineInstr::isKill(), llvm::MachineInstr::isPosition(), llvm::MipsSubtarget::isTargetNaCl(), llvm::MachineInstr::isTerminator(), llvm_unreachable, MipsCompactBranchPolicy, llvm::CodeGenOpt::None, P, llvm::MachineBasicBlock::pred_begin(), llvm::MachineBasicBlock::pred_end(), llvm::MachineBasicBlock::rend(), llvm::MachineBasicBlock::splice(), llvm::MachineBasicBlock::succ_begin(), llvm::MachineBasicBlock::succ_empty(), llvm::MachineBasicBlock::succ_end(), TII, and llvm::SystemZISD::TM.

◆ hasUnoccupiedSlot()

static bool hasUnoccupiedSlot ( const MachineInstr MI)
static

◆ insertDelayFiller()

static void insertDelayFiller ( Iter  Filler,
const BB2BrMap &  BrMap 
)
static

This function inserts clones of Filler into predecessor blocks.

Definition at line 308 of file MipsDelaySlotFiller.cpp.

References llvm::MIBundleBuilder::append(), llvm::MachineFunction::CloneMachineInstr(), and I.

Referenced by getEquivalentCallShort().

◆ STATISTIC() [1/2]

STATISTIC ( FilledSlots  ,
"Number of delay slots filled"   
)

◆ STATISTIC() [2/2]

STATISTIC ( UsefulSlots  ,
"Number of delay slots filled with instructions that" " are not NOP."   
)

Variable Documentation

◆ DisableBackwardSearch

cl::opt<bool> DisableBackwardSearch("disable-mips-df-backward-search", cl::init(false), cl::desc("Disallow MIPS delay filler to search backward."), cl::Hidden)
static

Referenced by getEquivalentCallShort().

◆ DisableDelaySlotFiller

cl::opt<bool> DisableDelaySlotFiller("disable-mips-delay-filler", cl::init(false), cl::desc("Fill all delay slots with NOPs."), cl::Hidden)
static

Referenced by getEquivalentCallShort().

◆ DisableForwardSearch

cl::opt<bool> DisableForwardSearch("disable-mips-df-forward-search", cl::init(true), cl::desc("Disallow MIPS delay filler to search forward."), cl::Hidden)
static

Referenced by getEquivalentCallShort().

◆ DisableSuccBBSearch

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

Referenced by getEquivalentCallShort().

◆ MipsCompactBranchPolicy

cl::opt<CompactBranchPolicy> MipsCompactBranchPolicy("mips-compact-branches", cl::Optional, cl::init(CB_Optimal), cl::desc("MIPS Specific: Compact branch policy."), cl::values( clEnumValN(CB_Never, "never", "Do not use compact branches if possible."), clEnumValN(CB_Optimal, "optimal", "Use compact branches where appropiate (default)."), clEnumValN(CB_Always, "always", "Always use compact branches if possible.")))
static

Referenced by getEquivalentCallShort().