LLVM API Documentation
#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"
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 DEBUG_TYPE "twoaddrinstr" |
Definition at line 30 of file TwoAddressInstructionPass.cpp.
| 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().
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] |
isSafeToDelete - If the specified instruction does not produce any side effects and all of its defs are dead, then it's safe to delete.
Definition at line 717 of file TwoAddressInstructionPass.cpp.
References llvm::MachineInstr::getDesc(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::TargetInstrDesc::hasUnmodeledSideEffects(), llvm::TargetInstrDesc::isCall(), llvm::MachineOperand::isDead(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), llvm::TargetInstrDesc::isTerminator(), llvm::MachineOperand::isUse(), llvm::TargetInstrDesc::mayStore(), and llvm::SmallVectorImpl< T >::push_back().
| static bool isTwoAddrUse | ( | MachineInstr & | MI, | |
| unsigned | Reg, | |||
| unsigned & | DstReg | |||
| ) | [static] |
isTwoAddrUse - Return true if the specified MI uses the specified register as a two-address use. If so, return the destination register by reference.
Definition at line 415 of file TwoAddressInstructionPass.cpp.
References llvm::MachineInstr::getDesc(), llvm::TargetInstrDesc::getNumOperands(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::ISD::INLINEASM, llvm::MachineOperand::isReg(), llvm::MachineInstr::isRegTiedToDefOperand(), and llvm::MachineOperand::isUse().
| static bool isTwoAddrUse | ( | MachineInstr * | UseMI, | |
| unsigned | Reg | |||
| ) | [static] |
isTwoAddrUse - Return true if the specified MI is using the specified register as a two-address operand.
Definition at line 244 of file TwoAddressInstructionPass.cpp.
References llvm::MachineInstr::getDesc(), llvm::TargetInstrDesc::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::isDef(), llvm::MachineOperand::isReg(), and llvm::MachineInstr::isRegTiedToDefOperand().
Referenced by findOnlyInterestingUse().
| 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" | ||||
| ) |
Definition at line 68 of file TwoAddressInstructionPass.cpp.
char ID [static] |
Definition at line 113 of file TwoAddressInstructionPass.cpp.
Definition at line 64 of file TwoAddressInstructionPass.cpp.
Referenced by llvm::SparseSolver::getOrInitValueState(), and OptimizeGlobalAddressOfMalloc().
Definition at line 63 of file TwoAddressInstructionPass.cpp.
| const TargetInstrInfo* TII |
Definition at line 61 of file TwoAddressInstructionPass.cpp.
| const TargetRegisterInfo* TRI |
Definition at line 62 of file TwoAddressInstructionPass.cpp.
RegisterPass<TwoAddressInstructionPass> X("twoaddressinstruction","Two-Address instruction pass") [static] |