Go to the documentation of this file.
21 #ifndef LLVM_CODEGEN_REACHINGDEFANALYSIS_H
22 #define LLVM_CODEGEN_REACHINGDEFANALYSIS_H
33 class MachineBasicBlock;
43 explicit ReachingDef(uintptr_t Encoded) : Encoded(Encoded) {}
47 ReachingDef(
int Instr) : Encoded(((uintptr_t) Instr << 2) | 2) {}
48 operator int()
const {
return ((
int) Encoded) >> 2; }
53 static constexpr
int NumLowBitsAvailable = 1;
56 return reinterpret_cast<void *
>(RD.Encoded);
79 using LiveRegsDefInfo = std::vector<int>;
80 LiveRegsDefInfo LiveRegs;
99 using MBBDefsInfo = std::vector<MBBRegUnitDefs>;
105 const int ReachingDefDefaultVal = -(1 << 20);
188 InstSet &
Uses)
const;
193 BlockSet &VisitedBBs)
const;
195 InstSet &Defs)
const;
201 InstSet &
Uses)
const;
210 InstSet &Defs)
const;
260 template<
typename Iterator>
281 #endif // LLVM_CODEGEN_REACHINGDEFANALYSIS_H
void reset()
Re-run the analysis.
void getLiveOuts(MachineBasicBlock *MBB, MCRegister PhysReg, InstSet &Defs, BlockSet &VisitedBBs) const
Search MBB for a definition of PhysReg and insert it into Defs.
bool hasSameReachingDef(MachineInstr *A, MachineInstr *B, MCRegister PhysReg) const
Return whether A and B use the same def of PhysReg.
This is an optimization pass for GlobalISel generic memory operations.
bool isSafeToRemove(MachineInstr *MI, InstSet &ToRemove) const
Return whether removing this instruction will have no effect on the program, returning the redundant ...
MachineInstr * getUniqueReachingMIDef(MachineInstr *MI, MCRegister PhysReg) const
If a single MachineInstr creates the reaching definition, then return it.
This class provides the reaching def analysis.
bool getLiveInUses(MachineBasicBlock *MBB, MCRegister PhysReg, InstSet &Uses) const
For the given block, collect the instructions that use the live-in value of the provided register.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
ReachingDefAnalysis InstSet InstSet & Ignore
static void * getAsVoidPointer(const ReachingDef &RD)
static ReachingDef getFromVoidPointer(void *P)
ReachingDefAnalysis InstSet & ToRemove
MachineFunctionProperties getRequiredProperties() const override
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Properties which a MachineFunction may have at a given point in time.
bool hasLocalDefBefore(MachineInstr *MI, MCRegister PhysReg) const
Provide whether the register has been defined in the same basic block as, and before,...
MachineInstr * getLocalLiveOutMIDef(MachineBasicBlock *MBB, MCRegister PhysReg) const
Return the local MI that produces the live out value for PhysReg, or nullptr for a non-live out or no...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
SmallPtrSet< MachineInstr *, 2 > Uses
bool isSafeToMoveBackwards(MachineInstr *From, MachineInstr *To) const
Return whether From can be moved backwards to just after To.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void getGlobalUses(MachineInstr *MI, MCRegister PhysReg, InstSet &Uses) const
Collect the users of the value stored in PhysReg, which is defined by MI.
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Represent the analysis usage information of a pass.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MachineOperand class - Representation of each machine instruction operand.
MachineFunctionProperties & set(Property P)
void init()
Initialize data structures.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Thin wrapper around "int" used to store reaching definitions, using an encoding that makes it compati...
Representation of each machine instruction.
int getReachingDef(MachineInstr *MI, MCRegister PhysReg) const
Provides the instruction id of the closest reaching def instruction of PhysReg that reaches MI,...
bool isRegDefinedAfter(MachineInstr *MI, MCRegister PhysReg) const
Return whether the given register is defined after MI.
ReachingDef(std::nullptr_t)
void getReachingLocalUses(MachineInstr *MI, MCRegister PhysReg, InstSet &Uses) const
Provides the uses, in the same block as MI, of register that MI defines.
void traverse()
Traverse the machine function, mapping definitions.
void initializeReachingDefAnalysisPass(PassRegistry &)
void collectKilledOperands(MachineInstr *MI, InstSet &Dead) const
Assuming MI is dead, recursively search the incoming operands which are killed by MI and collect thos...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
static ReachingDef getFromVoidPointer(const void *P)
bool isSafeToDefRegAt(MachineInstr *MI, MCRegister PhysReg) const
Return whether a MachineInstr could be inserted at MI and safely define the given register without af...
void setPreservesAll()
Set by analyses that do not transform their input at all.
void getGlobalReachingDefs(MachineInstr *MI, MCRegister PhysReg, InstSet &Defs) const
Collect all possible definitions of the value stored in PhysReg, which is used by MI.
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
bool isReachingDefLiveOut(MachineInstr *MI, MCRegister PhysReg) const
Return whether the reaching def for MI also is live out of its parent block.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
int getClearance(MachineInstr *MI, MCRegister PhysReg) const
Provides the clearance - the number of instructions since the closest reaching def instuction of Phys...
MachineInstr * getMIOperand(MachineInstr *MI, unsigned Idx) const
If a single MachineInstr creates the reaching definition, for MIs operand at Idx, then return it.
BlockVerifier::State From
TinyPtrVector - This class is specialized for cases where there are normally 0 or 1 element in a vect...
bool isRegUsedAfter(MachineInstr *MI, MCRegister PhysReg) const
Return whether the given register is used after MI, whether it's a local use or a live out.
bool isSafeToMoveForwards(MachineInstr *From, MachineInstr *To) const
Return whether From can be moved forwards to just before To.
Wrapper class representing physical registers. Should be passed by value.