|
LLVM 24.0.0git
|
#include "llvm/CodeGen/PeepholeOptimizer.h"#include "CodeGenOptions.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallSet.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/Statistic.h"#include "llvm/CodeGen/MachineBasicBlock.h"#include "llvm/CodeGen/MachineDominators.h"#include "llvm/CodeGen/MachineFunction.h"#include "llvm/CodeGen/MachineFunctionPass.h"#include "llvm/CodeGen/MachineInstr.h"#include "llvm/CodeGen/MachineInstrBuilder.h"#include "llvm/CodeGen/MachineLoopInfo.h"#include "llvm/CodeGen/MachineOperand.h"#include "llvm/CodeGen/MachinePassManager.h"#include "llvm/CodeGen/MachineRegisterInfo.h"#include "llvm/CodeGen/TargetInstrInfo.h"#include "llvm/CodeGen/TargetOpcodes.h"#include "llvm/CodeGen/TargetRegisterInfo.h"#include "llvm/CodeGen/TargetSubtargetInfo.h"#include "llvm/InitializePasses.h"#include "llvm/MC/LaneBitmask.h"#include "llvm/MC/MCInstrDesc.h"#include "llvm/Pass.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include <cassert>#include <cstdint>#include <utility>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "peephole-opt" |
Typedefs | |
| using | RegSubRegPairAndIdx = TargetInstrInfo::RegSubRegPairAndIdx |
Functions | |
| STATISTIC (NumReuse, "Number of extension results reused") | |
| STATISTIC (NumCmps, "Number of compares eliminated") | |
| STATISTIC (NumImmFold, "Number of move immediate folded") | |
| STATISTIC (NumLoadFold, "Number of loads folded") | |
| STATISTIC (NumSelects, "Number of selects optimized") | |
| STATISTIC (NumUncoalescableCopies, "Number of uncoalescable copies optimized") | |
| STATISTIC (NumRewrittenCopies, "Number of copies rewritten") | |
| STATISTIC (NumNAPhysCopies, "Number of non-allocatable physical copies removed") | |
| INITIALIZE_PASS_BEGIN (PeepholeOptimizerLegacy, DEBUG_TYPE, "Peephole Optimizations", false, false) INITIALIZE_PASS_END(PeepholeOptimizerLegacy | |
| static MachineInstr & | insertPHI (MachineRegisterInfo &MRI, const TargetInstrInfo &TII, const SmallVectorImpl< RegSubRegPair > &SrcRegs, MachineInstr &OrigPHI) |
Insert a PHI instruction with incoming edges SrcRegs that are guaranteed to have the same register class. | |
| static RegSubRegPair | getNewSource (MachineRegisterInfo *MRI, const TargetInstrInfo *TII, RegSubRegPair Def, const PeepholeOptimizer::RewriteMapTy &RewriteMap, bool HandleMultipleSources=true) |
Given a Def.Reg and Def.SubReg pair, use RewriteMap to find the new source to use for rewrite. | |
| static bool | isVirtualRegisterOperand (MachineOperand &MO) |
\bried Returns true if MO is a virtual register operand. | |
Variables | |
| static cl::opt< bool > | Aggressive ("aggressive-ext-opt", cl::Hidden, cl::desc("Aggressive extension optimization")) |
| DEBUG_TYPE | |
| Peephole | Optimizations |
| Peephole | false |
| #define DEBUG_TYPE "peephole-opt" |
Definition at line 104 of file PeepholeOptimizer.cpp.
Definition at line 102 of file PeepholeOptimizer.cpp.
|
static |
Given a Def.Reg and Def.SubReg pair, use RewriteMap to find the new source to use for rewrite.
If HandleMultipleSources is true and multiple sources for a given Def are found along the way, we found a PHI instructions that needs to be rewritten. TODO: HandleMultipleSources should be removed once we test PHI handling with coalescable copies.
Definition at line 1157 of file PeepholeOptimizer.cpp.
References llvm::dbgs(), getNewSource(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getSubReg(), insertPHI(), LLVM_DEBUG, llvm::DenseMapBase< StorageT, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), MRI, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::TargetInstrInfo::RegSubRegPair::Reg, llvm::TargetInstrInfo::RegSubRegPair::SubReg, and TII.
Referenced by getNewSource().
| INITIALIZE_PASS_BEGIN | ( | PeepholeOptimizerLegacy | , |
| DEBUG_TYPE | , | ||
| "Peephole Optimizations" | , | ||
| false | , | ||
| false | ) |
References DEBUG_TYPE, and INITIALIZE_PASS_DEPENDENCY.
|
static |
Insert a PHI instruction with incoming edges SrcRegs that are guaranteed to have the same register class.
This is necessary whenever we successfully traverse a PHI instruction and find suitable sources coming from its edges. By inserting a new PHI, we provide a rewritten PHI def suitable to be used in a new COPY instruction.
Definition at line 1125 of file PeepholeOptimizer.cpp.
References llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addReg(), assert(), llvm::BuildMI(), llvm::SmallVectorTemplateCommon< T, typename >::empty(), llvm::MachineInstr::getDebugLoc(), llvm::MachineOperand::getMBB(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), MBB, MRI, Reg, and TII.
Referenced by getNewSource().
|
static |
\bried Returns true if MO is a virtual register operand.
Definition at line 1609 of file PeepholeOptimizer.cpp.
References llvm::MachineOperand::getReg(), llvm::MachineOperand::isReg(), and llvm::Register::isVirtual().
| STATISTIC | ( | NumCmps | , |
| "Number of compares eliminated" | ) |
| STATISTIC | ( | NumImmFold | , |
| "Number of move immediate folded" | ) |
| STATISTIC | ( | NumLoadFold | , |
| "Number of loads folded" | ) |
| STATISTIC | ( | NumNAPhysCopies | , |
| "Number of non-allocatable physical copies removed" | ) |
| STATISTIC | ( | NumReuse | , |
| "Number of extension results reused" | ) |
| STATISTIC | ( | NumRewrittenCopies | , |
| "Number of copies rewritten" | ) |
| STATISTIC | ( | NumSelects | , |
| "Number of selects optimized" | ) |
| STATISTIC | ( | NumUncoalescableCopies | , |
| "Number of uncoalescable copies optimized" | ) |
|
static |
| DEBUG_TYPE |
Definition at line 751 of file PeepholeOptimizer.cpp.
| Peephole false |
Definition at line 752 of file PeepholeOptimizer.cpp.
| Peephole Optimizations |
Definition at line 752 of file PeepholeOptimizer.cpp.