Tree @release_34 (Download .tar.gz)
- ..
- AsmPrinter
- SelectionDAG
- AggressiveAntiDepBreaker.cpp
- AggressiveAntiDepBreaker.h
- AllocationOrder.cpp
- AllocationOrder.h
- Analysis.cpp
- AntiDepBreaker.h
- BasicTargetTransformInfo.cpp
- BranchFolding.cpp
- BranchFolding.h
- CalcSpillWeights.cpp
- CallingConvLower.cpp
- CMakeLists.txt
- CodeGen.cpp
- CriticalAntiDepBreaker.cpp
- CriticalAntiDepBreaker.h
- DeadMachineInstructionElim.cpp
- DFAPacketizer.cpp
- DwarfEHPrepare.cpp
- EarlyIfConversion.cpp
- EdgeBundles.cpp
- ErlangGC.cpp
- ExecutionDepsFix.cpp
- ExpandISelPseudos.cpp
- ExpandPostRAPseudos.cpp
- GCMetadata.cpp
- GCMetadataPrinter.cpp
- GCStrategy.cpp
- IfConversion.cpp
- InlineSpiller.cpp
- InterferenceCache.cpp
- InterferenceCache.h
- IntrinsicLowering.cpp
- JITCodeEmitter.cpp
- LatencyPriorityQueue.cpp
- LexicalScopes.cpp
- LiveDebugVariables.cpp
- LiveDebugVariables.h
- LiveInterval.cpp
- LiveIntervalAnalysis.cpp
- LiveIntervalUnion.cpp
- LiveRangeCalc.cpp
- LiveRangeCalc.h
- LiveRangeEdit.cpp
- LiveRegMatrix.cpp
- LiveRegUnits.cpp
- LiveStackAnalysis.cpp
- LiveVariables.cpp
- LLVMBuild.txt
- LLVMTargetMachine.cpp
- LocalStackSlotAllocation.cpp
- MachineBasicBlock.cpp
- MachineBlockFrequencyInfo.cpp
- MachineBlockPlacement.cpp
- MachineBranchProbabilityInfo.cpp
- MachineCodeEmitter.cpp
- MachineCopyPropagation.cpp
- MachineCSE.cpp
- MachineDominators.cpp
- MachineFunction.cpp
- MachineFunctionAnalysis.cpp
- MachineFunctionPass.cpp
- MachineFunctionPrinterPass.cpp
- MachineInstr.cpp
- MachineInstrBundle.cpp
- MachineLICM.cpp
- MachineLoopInfo.cpp
- MachineModuleInfo.cpp
- MachineModuleInfoImpls.cpp
- MachinePassRegistry.cpp
- MachinePostDominators.cpp
- MachineRegisterInfo.cpp
- MachineScheduler.cpp
- MachineSink.cpp
- MachineSSAUpdater.cpp
- MachineTraceMetrics.cpp
- MachineVerifier.cpp
- Makefile
- OcamlGC.cpp
- OptimizePHIs.cpp
- Passes.cpp
- PeepholeOptimizer.cpp
- PHIElimination.cpp
- PHIEliminationUtils.cpp
- PHIEliminationUtils.h
- PostRASchedulerList.cpp
- ProcessImplicitDefs.cpp
- PrologEpilogInserter.cpp
- PrologEpilogInserter.h
- PseudoSourceValue.cpp
- README.txt
- RegAllocBase.cpp
- RegAllocBase.h
- RegAllocBasic.cpp
- RegAllocFast.cpp
- RegAllocGreedy.cpp
- RegAllocPBQP.cpp
- RegisterClassInfo.cpp
- RegisterCoalescer.cpp
- RegisterCoalescer.h
- RegisterPressure.cpp
- RegisterScavenging.cpp
- ScheduleDAG.cpp
- ScheduleDAGInstrs.cpp
- ScheduleDAGPrinter.cpp
- ScoreboardHazardRecognizer.cpp
- ShadowStackGC.cpp
- SjLjEHPrepare.cpp
- SlotIndexes.cpp
- Spiller.cpp
- Spiller.h
- SpillPlacement.cpp
- SpillPlacement.h
- SplitKit.cpp
- SplitKit.h
- StackColoring.cpp
- StackMaps.cpp
- StackProtector.cpp
- StackSlotColoring.cpp
- TailDuplication.cpp
- TargetFrameLoweringImpl.cpp
- TargetInstrInfo.cpp
- TargetLoweringBase.cpp
- TargetLoweringObjectFileImpl.cpp
- TargetOptionsImpl.cpp
- TargetRegisterInfo.cpp
- TargetSchedule.cpp
- TwoAddressInstructionPass.cpp
- UnreachableBlockElim.cpp
- VirtRegMap.cpp
BranchFolding.h @release_34 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | //===-- BranchFolding.h - Fold machine code branch instructions -*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_BRANCHFOLDING_HPP
#define LLVM_CODEGEN_BRANCHFOLDING_HPP
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include <vector>
namespace llvm {
class MachineFunction;
class MachineModuleInfo;
class RegScavenger;
class TargetInstrInfo;
class TargetRegisterInfo;
class BranchFolder {
public:
explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist);
bool OptimizeFunction(MachineFunction &MF,
const TargetInstrInfo *tii,
const TargetRegisterInfo *tri,
MachineModuleInfo *mmi);
private:
class MergePotentialsElt {
unsigned Hash;
MachineBasicBlock *Block;
public:
MergePotentialsElt(unsigned h, MachineBasicBlock *b)
: Hash(h), Block(b) {}
unsigned getHash() const { return Hash; }
MachineBasicBlock *getBlock() const { return Block; }
void setBlock(MachineBasicBlock *MBB) {
Block = MBB;
}
bool operator<(const MergePotentialsElt &) const;
};
typedef std::vector<MergePotentialsElt>::iterator MPIterator;
std::vector<MergePotentialsElt> MergePotentials;
SmallPtrSet<const MachineBasicBlock*, 2> TriedMerging;
class SameTailElt {
MPIterator MPIter;
MachineBasicBlock::iterator TailStartPos;
public:
SameTailElt(MPIterator mp, MachineBasicBlock::iterator tsp)
: MPIter(mp), TailStartPos(tsp) {}
MPIterator getMPIter() const {
return MPIter;
}
MergePotentialsElt &getMergePotentialsElt() const {
return *getMPIter();
}
MachineBasicBlock::iterator getTailStartPos() const {
return TailStartPos;
}
unsigned getHash() const {
return getMergePotentialsElt().getHash();
}
MachineBasicBlock *getBlock() const {
return getMergePotentialsElt().getBlock();
}
bool tailIsWholeBlock() const {
return TailStartPos == getBlock()->begin();
}
void setBlock(MachineBasicBlock *MBB) {
getMergePotentialsElt().setBlock(MBB);
}
void setTailStartPos(MachineBasicBlock::iterator Pos) {
TailStartPos = Pos;
}
};
std::vector<SameTailElt> SameTails;
bool EnableTailMerge;
bool EnableHoistCommonCode;
const TargetInstrInfo *TII;
const TargetRegisterInfo *TRI;
MachineModuleInfo *MMI;
RegScavenger *RS;
bool TailMergeBlocks(MachineFunction &MF);
bool TryTailMergeBlocks(MachineBasicBlock* SuccBB,
MachineBasicBlock* PredBB);
void MaintainLiveIns(MachineBasicBlock *CurMBB,
MachineBasicBlock *NewMBB);
void ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst,
MachineBasicBlock *NewDest);
MachineBasicBlock *SplitMBBAt(MachineBasicBlock &CurMBB,
MachineBasicBlock::iterator BBI1,
const BasicBlock *BB);
unsigned ComputeSameTails(unsigned CurHash, unsigned minCommonTailLength,
MachineBasicBlock *SuccBB,
MachineBasicBlock *PredBB);
void RemoveBlocksWithHash(unsigned CurHash, MachineBasicBlock* SuccBB,
MachineBasicBlock* PredBB);
bool CreateCommonTailOnlyBlock(MachineBasicBlock *&PredBB,
MachineBasicBlock *SuccBB,
unsigned maxCommonTailLength,
unsigned &commonTailIndex);
bool OptimizeBranches(MachineFunction &MF);
bool OptimizeBlock(MachineBasicBlock *MBB);
void RemoveDeadBlock(MachineBasicBlock *MBB);
bool OptimizeImpDefsBlock(MachineBasicBlock *MBB);
bool HoistCommonCode(MachineFunction &MF);
bool HoistCommonCodeInSuccs(MachineBasicBlock *MBB);
};
}
#endif /* LLVM_CODEGEN_BRANCHFOLDING_HPP */
|