LLVM API Documentation

TwoAddressInstructionPass.cpp File Reference

#include "llvm/CodeGen/Passes.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/LiveVariables.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"

Include dependency graph for TwoAddressInstructionPass.cpp:

Go to the source code of this file.

Defines

#define DEBUG_TYPE   "twoaddrinstr"

Functions

 STATISTIC (NumTwoAddressInstrs,"Number of two-address instructions")
 STATISTIC (NumCommuted,"Number of instructions commuted to coalesce")
 STATISTIC (NumAggrCommuted,"Number of instructions aggressively commuted")
 STATISTIC (NumConvertedTo3Addr,"Number of instructions promoted to 3-address")
 STATISTIC (Num3AddrSunk,"Number of 3-address instructions sunk")
 STATISTIC (NumReMats,"Number of instructions re-materialized")
 STATISTIC (NumDeletes,"Number of dead instructions deleted")
static bool isTwoAddrUse (MachineInstr *UseMI, unsigned Reg)
static bool isCopyToReg (MachineInstr &MI, const TargetInstrInfo *TII, unsigned &SrcReg, unsigned &DstReg, bool &IsSrcPhys, bool &IsDstPhys)
static bool isKilled (MachineInstr &MI, unsigned Reg, const MachineRegisterInfo *MRI, const TargetInstrInfo *TII)
static bool isTwoAddrUse (MachineInstr &MI, unsigned Reg, unsigned &DstReg)
static MachineInstr * findOnlyInterestingUse (unsigned Reg, MachineBasicBlock *MBB, MachineRegisterInfo *MRI, const TargetInstrInfo *TII, bool &IsCopy, unsigned &DstReg, bool &IsDstPhys)
static unsigned getMappedReg (unsigned Reg, DenseMap< unsigned, unsigned > &RegMap)
static bool regsAreCompatible (unsigned RegA, unsigned RegB, const TargetRegisterInfo *TRI)
static bool isSafeToDelete (MachineInstr *MI, unsigned Reg, const TargetInstrInfo *TII, SmallVector< unsigned, 4 > &Kills)

Variables

static RegisterPass
< TwoAddressInstructionPass > 
X ("twoaddressinstruction","Two-Address instruction pass")


Define Documentation

#define DEBUG_TYPE   "twoaddrinstr"

Definition at line 30 of file TwoAddressInstructionPass.cpp.


Function Documentation

static MachineInstr* findOnlyInterestingUse ( unsigned  Reg,
MachineBasicBlock *  MBB,
MachineRegisterInfo *  MRI,
const TargetInstrInfo *  TII,
bool &  IsCopy,
unsigned &  DstReg,
bool &  IsDstPhys 
) [static]

findOnlyInterestingUse - Given a register, if has a single in-basic block use, return the use instruction if it's a copy or a two-address use.

Definition at line 435 of file TwoAddressInstructionPass.cpp.

References llvm::MachineInstr::getParent(), isCopyToReg(), isTwoAddrUse(), llvm::MachineRegisterInfo::use_begin(), and llvm::MachineRegisterInfo::use_end().

static unsigned getMappedReg ( unsigned  Reg,
DenseMap< unsigned, unsigned > &  RegMap 
) [static]

getMappedReg - Return the physical register the specified virtual register might be mapped to.

Definition at line 466 of file TwoAddressInstructionPass.cpp.

References llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::end(), and llvm::DenseMap< KeyT, ValueT, KeyInfoT, ValueInfoT >::find().

static bool isCopyToReg ( MachineInstr &  MI,
const TargetInstrInfo *  TII,
unsigned &  SrcReg,
unsigned &  DstReg,
bool &  IsSrcPhys,
bool &  IsDstPhys 
) [static]

isCopyToReg - Return true if the specified MI is a copy instruction or a extract_subreg instruction. It also returns the source and destination registers and whether they are physical registers by reference.

Definition at line 346 of file TwoAddressInstructionPass.cpp.

References llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), and llvm::TargetInstrInfo::isMoveInstr().

Referenced by findOnlyInterestingUse(), and isKilled().

static bool isKilled ( MachineInstr &  MI,
unsigned  Reg,
const MachineRegisterInfo *  MRI,
const TargetInstrInfo *  TII 
) [static]

isKilled - Test if the given register value, which is used by the given instruction, is killed by the given instruction. This looks through coalescable copies to see if the original value is potentially not killed.

For example, in this code:

reg1034 = copy reg1024 reg1035 = copy reg1025<kill> reg1036 = add reg1034<kill>, reg1035<kill>

reg1034 is not considered to be killed, since it is copied from a register which is not killed. Treating it as not killed lets the normal heuristics commute the (two-address) add, which lets coalescing eliminate the extra copy.

Definition at line 388 of file TwoAddressInstructionPass.cpp.

References llvm::MachineRegisterInfo::def_begin(), llvm::MachineRegisterInfo::def_end(), isCopyToReg(), llvm::MachineInstr::killsRegister(), and llvm::next().

static bool isSafeToDelete ( MachineInstr *  MI,
unsigned  Reg,
const TargetInstrInfo *  TII,
SmallVector< unsigned, 4 > &  Kills 
) [static]

static bool isTwoAddrUse ( MachineInstr &  MI,
unsigned  Reg,
unsigned &  DstReg 
) [static]

static bool isTwoAddrUse ( MachineInstr *  UseMI,
unsigned  Reg 
) [static]

static bool regsAreCompatible ( unsigned  RegA,
unsigned  RegB,
const TargetRegisterInfo *  TRI 
) [static]

regsAreCompatible - Return true if the two registers are equal or aliased.

Definition at line 481 of file TwoAddressInstructionPass.cpp.

References llvm::TargetRegisterInfo::regsOverlap().

STATISTIC ( NumDeletes  ,
"Number of dead instructions deleted"   
)

STATISTIC ( NumReMats  ,
"Number of instructions re-materialized"   
)

STATISTIC ( Num3AddrSunk  ,
"Number of 3-address instructions sunk"   
)

STATISTIC ( NumConvertedTo3Addr  ,
"Number of instructions promoted to 3-address"   
)

STATISTIC ( NumAggrCommuted  ,
"Number of instructions aggressively commuted"   
)

STATISTIC ( NumCommuted  ,
"Number of instructions commuted to coalesce"   
)

STATISTIC ( NumTwoAddressInstrs  ,
"Number of two-address instructions"   
)


Variable Documentation

Definition at line 68 of file TwoAddressInstructionPass.cpp.

Definition at line 78 of file TwoAddressInstructionPass.cpp.

char ID [static]

Definition at line 113 of file TwoAddressInstructionPass.cpp.

Definition at line 63 of file TwoAddressInstructionPass.cpp.

Definition at line 73 of file TwoAddressInstructionPass.cpp.

Definition at line 61 of file TwoAddressInstructionPass.cpp.

Definition at line 62 of file TwoAddressInstructionPass.cpp.

RegisterPass<TwoAddressInstructionPass> X("twoaddressinstruction","Two-Address instruction pass") [static]