LLVM
8.0.1
|
This file implements the machine register scavenger. More...
#include "llvm/CodeGen/RegisterScavenging.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LiveRegUnits.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <iterator>
#include <limits>
#include <string>
#include <utility>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "reg-scavenging" |
Functions | |
STATISTIC (NumScavengedRegs, "Number of frame index regs scavenged") | |
static std::pair< MCPhysReg, MachineBasicBlock::iterator > | findSurvivorBackwards (const MachineRegisterInfo &MRI, MachineBasicBlock::iterator From, MachineBasicBlock::iterator To, const LiveRegUnits &LiveOut, ArrayRef< MCPhysReg > AllocationOrder, bool RestoreAfter) |
Given the bitvector Available of free register units at position From . More... | |
static unsigned | getFrameIndexOperandNum (MachineInstr &MI) |
static unsigned | scavengeVReg (MachineRegisterInfo &MRI, RegScavenger &RS, unsigned VReg, bool ReserveAfter) |
Allocate a register for the virtual register VReg . More... | |
static bool | scavengeFrameVirtualRegsInBlock (MachineRegisterInfo &MRI, RegScavenger &RS, MachineBasicBlock &MBB) |
Allocate (scavenge) vregs inside a single basic block. More... | |
This file implements the machine register scavenger.
It can provide information, such as unused registers, at any point in a machine basic block. It also provides a mechanism to make registers available by evicting them to spill slots.
Definition in file RegisterScavenging.cpp.
#define DEBUG_TYPE "reg-scavenging" |
Definition at line 49 of file RegisterScavenging.cpp.
|
static |
Given the bitvector Available
of free register units at position From
.
Search backwards to find a register that is part of Candidates
and not used/clobbered until the point To
. If there is multiple candidates continue searching and pick the one that is not used/ clobbered for the longest time. Returns the register and the earliest position we know it to be free or the position MBB.end() if no register is available.
Definition at line 379 of file RegisterScavenging.cpp.
References llvm::LiveRegUnits::accumulate(), llvm::LiveRegUnits::available(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), I, InstrLimit, llvm::MachineRegisterInfo::isReserved(), llvm::TargetRegisterInfo::isVirtualRegister(), MI, llvm::MachineInstr::operands(), Reg, and TRI.
Referenced by llvm::RegScavenger::scavengeRegisterBackwards().
|
static |
Definition at line 451 of file RegisterScavenging.cpp.
References assert(), D, llvm::ISD::FrameIndex, llvm::MachineFunction::getFrameInfo(), llvm::MachineInstr::getNumOperands(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectIndexBegin(), llvm::MachineFrameInfo::getObjectIndexEnd(), llvm::MachineFrameInfo::getObjectSize(), llvm::MachineInstr::getOperand(), I, llvm::MachineOperand::isFI(), llvm::HexagonInstrInfo::loadRegFromStackSlot(), llvm::max(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), Reg, llvm::report_fatal_error(), SI, llvm::SmallVectorBase::size(), llvm::HexagonInstrInfo::storeRegToStackSlot(), TII, and TRI.
|
static |
Allocate (scavenge) vregs inside a single basic block.
Returns true if the target spill callback created new vregs and a 2nd pass is necessary.
Definition at line 670 of file RegisterScavenging.cpp.
References assert(), llvm::RegScavenger::backward(), llvm::MachineBasicBlock::begin(), llvm::MachineBasicBlock::end(), llvm::RegScavenger::enterBasicBlockEnd(), llvm::MachineBasicBlock::front(), llvm::MachineRegisterInfo::getNumVirtRegs(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), I, llvm::TargetRegisterInfo::isVirtualRegister(), MI, N, llvm::MachineInstr::operands(), scavengeVReg(), llvm::RegScavenger::setRegUsed(), TRI, and llvm::TargetRegisterInfo::virtReg2Index().
Referenced by llvm::scavengeFrameVirtualRegs().
|
static |
Allocate a register for the virtual register VReg
.
The last use of VReg
is around the current position of the register scavenger RS
. ReserveAfter
controls whether the scavenged register needs to be reserved after the current instruction, otherwise it will only be reserved before the current instruction.
Definition at line 616 of file RegisterScavenging.cpp.
References assert(), llvm::MachineRegisterInfo::def_begin(), llvm::MachineRegisterInfo::def_end(), DefMI, llvm::find_if(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getParent(), llvm::MachineRegisterInfo::getRegClass(), llvm::MachineRegisterInfo::getTargetRegisterInfo(), MI, llvm::MachineInstr::readsRegister(), llvm::MachineRegisterInfo::reg_nodbg_operands(), llvm::MachineRegisterInfo::replaceRegWith(), llvm::RegScavenger::scavengeRegisterBackwards(), and TRI.
Referenced by scavengeFrameVirtualRegsInBlock().
STATISTIC | ( | NumScavengedRegs | , |
"Number of frame index regs scavenged" | |||
) |