|
LLVM
3.7.0
|
#include "AArch64.h"#include "AArch64InstrInfo.h"#include "AArch64MachineFunctionInfo.h"#include "AArch64Subtarget.h"#include "MCTargetDesc/AArch64AddressingModes.h"#include "llvm/ADT/BitVector.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/MapVector.h"#include "llvm/ADT/SetVector.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/CodeGen/MachineBasicBlock.h"#include "llvm/CodeGen/MachineDominators.h"#include "llvm/CodeGen/MachineFunctionPass.h"#include "llvm/CodeGen/MachineInstr.h"#include "llvm/CodeGen/MachineInstrBuilder.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Target/TargetInstrInfo.h"#include "llvm/Target/TargetMachine.h"#include "llvm/Target/TargetRegisterInfo.h"Go to the source code of this file.
Namespaces | |
| llvm | |
| Compute iterated dominance frontiers using a linear time algorithm. | |
Macros | |
| #define | DEBUG_TYPE "aarch64-collect-loh" |
Functions | |
| STATISTIC (NumADRPSimpleCandidate,"Number of simplifiable ADRP dominate by another") | |
| STATISTIC (NumADRPComplexCandidate2,"Number of simplifiable ADRP reachable by 2 defs") | |
| STATISTIC (NumADRPComplexCandidate3,"Number of simplifiable ADRP reachable by 3 defs") | |
| STATISTIC (NumADRPComplexCandidateOther,"Number of simplifiable ADRP reachable by 4 or more defs") | |
| STATISTIC (NumADDToSTRWithImm,"Number of simplifiable STR with imm reachable by ADD") | |
| STATISTIC (NumLDRToSTRWithImm,"Number of simplifiable STR with imm reachable by LDR") | |
| STATISTIC (NumADDToSTR,"Number of simplifiable STR reachable by ADD") | |
| STATISTIC (NumLDRToSTR,"Number of simplifiable STR reachable by LDR") | |
| STATISTIC (NumADDToLDRWithImm,"Number of simplifiable LDR with imm reachable by ADD") | |
| STATISTIC (NumLDRToLDRWithImm,"Number of simplifiable LDR with imm reachable by LDR") | |
| STATISTIC (NumADDToLDR,"Number of simplifiable LDR reachable by ADD") | |
| STATISTIC (NumLDRToLDR,"Number of simplifiable LDR reachable by LDR") | |
| STATISTIC (NumADRPToLDR,"Number of simplifiable LDR reachable by ADRP") | |
| STATISTIC (NumCplxLvl1,"Number of complex case of level 1") | |
| STATISTIC (NumTooCplxLvl1,"Number of too complex case of level 1") | |
| STATISTIC (NumCplxLvl2,"Number of complex case of level 2") | |
| STATISTIC (NumTooCplxLvl2,"Number of too complex case of level 2") | |
| STATISTIC (NumADRSimpleCandidate,"Number of simplifiable ADRP + ADD") | |
| STATISTIC (NumADRComplexCandidate,"Number of too complex ADRP + ADD") | |
| void | llvm::initializeAArch64CollectLOHPass (PassRegistry &) |
| INITIALIZE_PASS_BEGIN (AArch64CollectLOH,"aarch64-collect-loh","AArch64 Collect Linker Optimization Hint (LOH)", false, false) INITIALIZE_PASS_END(AArch64CollectLOH | |
| aarch64 collect AArch64 Collect Linker Optimization | Hint (LOH)" |
| aarch64 collect AArch64 Collect Linker Optimization static false SetOfMachineInstr & | getSet (BlockToSetOfInstrsPerColor &sets, const MachineBasicBlock &MBB, unsigned reg, unsigned nbRegs) |
| Given a couple (MBB, reg) get the corresponding set of instruction from the given "sets". More... | |
| static SetOfMachineInstr & | getUses (InstrToInstrs *sets, unsigned reg, const MachineInstr &MI) |
| Given a couple (reg, MI) get the corresponding set of instructions from the the given "sets". More... | |
| static const SetOfMachineInstr * | getUses (const InstrToInstrs *sets, unsigned reg, const MachineInstr &MI) |
| Same as getUses but does not modify the input map: sets. More... | |
| static void | initReachingDef (const MachineFunction &MF, InstrToInstrs *ColorOpToReachedUses, BlockToInstrPerColor &Gen, BlockToRegSet &Kill, BlockToSetOfInstrsPerColor &ReachableUses, const MapRegToId &RegToId, const MachineInstr *DummyOp, bool ADRPMode) |
| Initialize the reaching definition algorithm: For each basic block BB in MF, record: More... | |
| static void | reachingDefAlgorithm (const MachineFunction &MF, InstrToInstrs *ColorOpToReachedUses, BlockToSetOfInstrsPerColor &In, BlockToSetOfInstrsPerColor &Out, BlockToInstrPerColor &Gen, BlockToRegSet &Kill, BlockToSetOfInstrsPerColor &ReachableUses, unsigned NbReg) |
| Reaching def core algorithm: while an Out has changed for each bb for each color In[bb][color] = U Out[bb.predecessors][color] insert reachableUses[bb][color] in each in[bb][color] op.reachedUses. More... | |
| static void | reachingDef (const MachineFunction &MF, InstrToInstrs *ColorOpToReachedUses, const MapRegToId &RegToId, bool ADRPMode=false, const MachineInstr *DummyOp=nullptr) |
| Reaching definition algorithm. More... | |
| static void | printReachingDef (const InstrToInstrs *ColorOpToReachedUses, unsigned NbReg, const TargetRegisterInfo *TRI, const MapIdToReg &IdToReg) |
| print the result of the reaching definition algorithm. More... | |
| static bool | canDefBePartOfLOH (const MachineInstr *Def) |
| Answer the following question: Can Def be one of the definition involved in a part of a LOH? More... | |
| static bool | isCandidateStore (const MachineInstr *Instr) |
| Check whether the given instruction can the end of a LOH chain involving a store. More... | |
| static void | reachedUsesToDefs (InstrToInstrs &UseToReachingDefs, const InstrToInstrs *ColorOpToReachedUses, const MapRegToId &RegToId, bool ADRPMode=false) |
| Given the result of a reaching definition algorithm in ColorOpToReachedUses, Build the Use to Defs information and filter out obvious non-LOH candidates. More... | |
| static void | computeADRP (const InstrToInstrs &UseToDefs, AArch64FunctionInfo &AArch64FI, const MachineDominatorTree *MDT) |
| Based on the use to defs information (in ADRPMode), compute the opportunities of LOH ADRP-related. More... | |
| static bool | isCandidateLoad (const MachineInstr *Instr) |
| Check whether the given instruction can be the end of a LOH chain involving a load. More... | |
| static bool | supportLoadFromLiteral (const MachineInstr *Instr) |
| Check whether the given instruction can load a litteral. More... | |
| static bool | isCandidate (const MachineInstr *Instr, const InstrToInstrs &UseToDefs, const MachineDominatorTree *MDT) |
| Check whether the given instruction is a LOH candidate. More... | |
| static bool | registerADRCandidate (const MachineInstr &Use, const InstrToInstrs &UseToDefs, const InstrToInstrs *DefsPerColorToUses, AArch64FunctionInfo &AArch64FI, SetOfMachineInstr *InvolvedInLOHs, const MapRegToId &RegToId) |
| static void | computeOthers (const InstrToInstrs &UseToDefs, const InstrToInstrs *DefsPerColorToUses, AArch64FunctionInfo &AArch64FI, const MapRegToId &RegToId, const MachineDominatorTree *MDT) |
| Based on the use to defs information (in non-ADRPMode), compute the opportunities of LOH non-ADRP-related. More... | |
| static void | collectInvolvedReg (const MachineFunction &MF, MapRegToId &RegToId, MapIdToReg &IdToReg, const TargetRegisterInfo *TRI) |
| Look for every register defined by potential LOHs candidates. More... | |
Variables | |
| static cl::opt< bool > | PreCollectRegister ("aarch64-collect-loh-pre-collect-register", cl::Hidden, cl::desc("Restrict analysis to registers invovled"" in LOHs"), cl::init(true)) |
| static cl::opt< bool > | BasicBlockScopeOnly ("aarch64-collect-loh-bb-only", cl::Hidden, cl::desc("Restrict analysis at basic block scope"), cl::init(true)) |
| aarch64 collect | loh |
| aarch64 collect AArch64 Collect Linker Optimization | false |
| #define DEBUG_TYPE "aarch64-collect-loh" |
Definition at line 126 of file AArch64CollectLOH.cpp.
|
static |
Answer the following question: Can Def be one of the definition involved in a part of a LOH?
Definition at line 488 of file AArch64CollectLOH.cpp.
References llvm::AArch64ISD::ADRP, llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getType(), llvm::MachineOperand::MO_BlockAddress, llvm::MachineOperand::MO_ConstantPoolIndex, llvm::MachineOperand::MO_GlobalAddress, and llvm::MachineOperand::MO_JumpTableIndex.
Referenced by collectInvolvedReg(), and reachedUsesToDefs().
|
static |
Look for every register defined by potential LOHs candidates.
Map these registers with dense id in RegToId and vice-versa in IdToReg. IdToReg is populated only in DEBUG mode.
Definition at line 986 of file AArch64CollectLOH.cpp.
References canDefBePartOfLOH(), llvm::dbgs(), DEBUG, llvm::MCRegisterInfo::getNumRegs(), llvm::MCRegAliasIterator::isValid(), llvm::AArch64CC::MI, and PreCollectRegister.
|
static |
Based on the use to defs information (in ADRPMode), compute the opportunities of LOH ADRP-related.
Definition at line 599 of file AArch64CollectLOH.cpp.
References llvm::AArch64FunctionInfo::addLOHDirective(), llvm::dbgs(), DEBUG, llvm::MachineDominatorTree::dominates(), llvm::MCLOH_AdrpAdrp, and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().
|
static |
Based on the use to defs information (in non-ADRPMode), compute the opportunities of LOH non-ADRP-related.
Definition at line 765 of file AArch64CollectLOH.cpp.
References llvm::AArch64FunctionInfo::addLOHDirective(), llvm::AArch64ISD::ADRP, llvm::dbgs(), DEBUG, llvm::tgtok::Def, Found(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getTargetFlags(), getUses(), isCandidate(), isCandidateLoad(), Kind, llvm::MCLOH_AdrpAddLdr, llvm::MCLOH_AdrpAddStr, llvm::MCLOH_AdrpLdr, llvm::MCLOH_AdrpLdrGotLdr, llvm::MCLOH_AdrpLdrGotStr, llvm::AArch64CC::MI, llvm::AArch64II::MO_GOT, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), registerADRCandidate(), supportLoadFromLiteral(), and Users.
|
static |
Given a couple (MBB, reg) get the corresponding set of instruction from the given "sets".
If this couple does not reference any set, an empty set is added to "sets" for this couple and returned.
| nbRegs | is used internally allocate some memory. It must be consistent with the way sets is used. |
Definition at line 236 of file AArch64CollectLOH.cpp.
Referenced by initReachingDef(), and reachingDefAlgorithm().
|
static |
Given a couple (reg, MI) get the corresponding set of instructions from the the given "sets".
This is used to get the uses record in sets of a definition identified by MI and reg, i.e., MI defines reg. If the couple does not reference anything, an empty set is added to "sets[reg]".
Definition at line 256 of file AArch64CollectLOH.cpp.
References llvm::AArch64CC::MI.
Referenced by computeOthers(), initReachingDef(), reachingDefAlgorithm(), and registerADRCandidate().
|
static |
Same as getUses but does not modify the input map: sets.
Definition at line 263 of file AArch64CollectLOH.cpp.
References llvm::sys::path::end().
| aarch64 collect AArch64 Collect Linker Optimization Hint | ( | LOH | ) |
Referenced by DecodeCacheOp(), DecodeCacheOpMM(), DecodeCacheOpR6(), llvm::ARMBaseRegisterInfo::getRegAllocationHints(), llvm::TargetRegisterInfo::getRegAllocationHints(), llvm::MachineRegisterInfo::getSimpleHint(), llvm::VirtRegMap::hasKnownPreference(), llvm::VirtRegMap::hasPreferredPhys(), LowerINTRINSIC_W_CHAIN(), and llvm::ARMBaseRegisterInfo::updateRegAllocHint().
| INITIALIZE_PASS_BEGIN | ( | AArch64CollectLOH | , |
| "aarch64-collect-loh" | , | ||
| "AArch64 Collect Linker Optimization Hint (LOH)" | , | ||
| false | , | ||
| false | |||
| ) |
|
static |
Initialize the reaching definition algorithm: For each basic block BB in MF, record:
| DummyOp | if not NULL, specifies a Dummy Operation to be added to the list of uses of exposed defintions. |
| ADRPMode | specifies to only consider ADRP instructions for generated definition. It also consider definitions of ADRP instructions as uses and ignore other uses. The ADRPMode is used to collect the information for LHO that involve ADRP operation only. |
Definition at line 282 of file AArch64CollectLOH.cpp.
References llvm::AArch64ISD::ADRP, llvm::MachineOperand::clobbersPhysReg(), llvm::TargetSubtargetInfo::getRegisterInfo(), getSet(), llvm::MachineFunction::getSubtarget(), getUses(), llvm::MCRegAliasIterator::isValid(), llvm::AArch64CC::MI, and llvm::BitVector::resize().
Referenced by reachingDef().
|
static |
Check whether the given instruction is a LOH candidate.
| UseToDefs | is used to check that Instr is at the end of LOH supported chain. |
Definition at line 683 of file AArch64CollectLOH.cpp.
References llvm::AArch64ISD::ADRP, llvm::tgtok::Def, llvm::MachineDominatorTree::dominates(), llvm::MachineInstr::getOpcode(), isCandidateLoad(), and isCandidateStore().
Referenced by computeOthers().
|
static |
Check whether the given instruction can be the end of a LOH chain involving a load.
Definition at line 637 of file AArch64CollectLOH.cpp.
References llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getTargetFlags(), and llvm::AArch64II::MO_GOT.
Referenced by computeOthers(), and isCandidate().
|
static |
Check whether the given instruction can the end of a LOH chain involving a store.
Definition at line 522 of file AArch64CollectLOH.cpp.
References llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), and llvm::MachineOperand::getReg().
Referenced by isCandidate(), and reachedUsesToDefs().
|
static |
print the result of the reaching definition algorithm.
Definition at line 465 of file AArch64CollectLOH.cpp.
References llvm::dbgs(), DEBUG, llvm::AArch64CC::MI, and llvm::MachineInstr::print().
|
static |
Given the result of a reaching definition algorithm in ColorOpToReachedUses, Build the Use to Defs information and filter out obvious non-LOH candidates.
In ADRPMode, non-LOH candidates are "uses" with non-ADRP definitions. In non-ADRPMode, non-LOH candidates are "uses" with several definition, i.e., no simple chain.
| ADRPMode | – |
Definition at line 548 of file AArch64CollectLOH.cpp.
References llvm::AArch64ISD::ADRP, canDefBePartOfLOH(), llvm::dbgs(), DEBUG, llvm::tgtok::Def, llvm::MachineInstr::getOpcode(), getReg(), isCandidateStore(), llvm::AArch64CC::MI, and size.
|
static |
Reaching definition algorithm.
| MF | function on which the algorithm will operate. | |
| [out] | ColorOpToReachedUses | will contain the result of the reaching def algorithm. |
| ADRPMode | specify whether the reaching def algorithm should be tuned for ADRP optimization. |
| DummyOp | if not NULL, the algorithm will work at basic block scope and will set for every exposed definition a use to DummyOp. |
Definition at line 436 of file AArch64CollectLOH.cpp.
References llvm::tgtok::In, initReachingDef(), llvm::RegState::Kill, reachingDefAlgorithm(), and llvm::MachineFunction::size().
|
static |
Reaching def core algorithm: while an Out has changed for each bb for each color In[bb][color] = U Out[bb.predecessors][color] insert reachableUses[bb][color] in each in[bb][color] op.reachedUses.
Out[bb] = Gen[bb] U (In[bb] - Kill[bb])
Definition at line 385 of file AArch64CollectLOH.cpp.
References getSet(), getUses(), llvm::AArch64CC::MI, and llvm::MachineBasicBlock::predecessors().
Referenced by reachingDef().
|
static |
Definition at line 718 of file AArch64CollectLOH.cpp.
References llvm::AArch64FunctionInfo::addLOHDirective(), llvm::AArch64ISD::ADRP, llvm::dbgs(), DEBUG, llvm::tgtok::Def, llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getTargetFlags(), getUses(), llvm::MCLOH_AdrpAdd, llvm::MCLOH_AdrpLdrGot, llvm::AArch64II::MO_GOT, llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), and Users.
Referenced by computeOthers().
| STATISTIC | ( | NumADRPSimpleCandidate | , |
| "Number of simplifiable ADRP dominate by another" | |||
| ) |
| STATISTIC | ( | NumADRPComplexCandidate2 | , |
| "Number of simplifiable ADRP reachable by 2 defs" | |||
| ) |
| STATISTIC | ( | NumADRPComplexCandidate3 | , |
| "Number of simplifiable ADRP reachable by 3 defs" | |||
| ) |
| STATISTIC | ( | NumADRPComplexCandidateOther | , |
| "Number of simplifiable ADRP reachable by 4 or more defs" | |||
| ) |
| STATISTIC | ( | NumADDToSTRWithImm | , |
| "Number of simplifiable STR with imm reachable by ADD" | |||
| ) |
| STATISTIC | ( | NumLDRToSTRWithImm | , |
| "Number of simplifiable STR with imm reachable by LDR" | |||
| ) |
| STATISTIC | ( | NumADDToSTR | , |
| "Number of simplifiable STR reachable by ADD" | |||
| ) |
| STATISTIC | ( | NumLDRToSTR | , |
| "Number of simplifiable STR reachable by LDR" | |||
| ) |
| STATISTIC | ( | NumADDToLDRWithImm | , |
| "Number of simplifiable LDR with imm reachable by ADD" | |||
| ) |
| STATISTIC | ( | NumLDRToLDRWithImm | , |
| "Number of simplifiable LDR with imm reachable by LDR" | |||
| ) |
| STATISTIC | ( | NumADDToLDR | , |
| "Number of simplifiable LDR reachable by ADD" | |||
| ) |
| STATISTIC | ( | NumLDRToLDR | , |
| "Number of simplifiable LDR reachable by LDR" | |||
| ) |
| STATISTIC | ( | NumADRPToLDR | , |
| "Number of simplifiable LDR reachable by ADRP" | |||
| ) |
| STATISTIC | ( | NumCplxLvl1 | , |
| "Number of complex case of level 1" | |||
| ) |
| STATISTIC | ( | NumTooCplxLvl1 | , |
| "Number of too complex case of level 1" | |||
| ) |
| STATISTIC | ( | NumCplxLvl2 | , |
| "Number of complex case of level 2" | |||
| ) |
| STATISTIC | ( | NumTooCplxLvl2 | , |
| "Number of too complex case of level 2" | |||
| ) |
| STATISTIC | ( | NumADRSimpleCandidate | , |
| "Number of simplifiable ADRP + ADD" | |||
| ) |
| STATISTIC | ( | NumADRComplexCandidate | , |
| "Number of too complex ADRP + ADD" | |||
| ) |
|
static |
Check whether the given instruction can load a litteral.
Definition at line 662 of file AArch64CollectLOH.cpp.
References llvm::MachineInstr::getOpcode().
Referenced by computeOthers().
|
static |
| aarch64 collect AArch64 Collect Linker Optimization false |
Definition at line 227 of file AArch64CollectLOH.cpp.
| aarch64 collect loh |
Definition at line 226 of file AArch64CollectLOH.cpp.
1.8.6