225 #ifndef LLVM_LIB_TARGET_HEXAGON_RDFGRAPH_H
226 #define LLVM_LIB_TARGET_HEXAGON_RDFGRAPH_H
239 #include <functional>
242 #include <unordered_map>
249 static_assert(
sizeof(
uint32_t) ==
sizeof(
unsigned),
"Those should be equal");
253 class MachineBasicBlock;
254 class MachineFunction;
256 class MachineOperand;
257 class MachineDominanceFrontier;
258 class MachineDominatorTree;
259 class TargetInstrInfo;
316 uint16_t KB =
kind(B);
321 return KB ==
Phi || KB ==
Stmt;
381 : NodesPerBlock(NPB), BitsPerIndex(
Log2_32(NPB)),
382 IndexMask((1 << BitsPerIndex)-1) {
388 uint32_t BlockN = N1 >> BitsPerIndex;
398 void startNewBlock();
403 return ((Block << BitsPerIndex) | Index) + 1;
409 char *ActiveEnd =
nullptr;
410 std::vector<char*> Blocks;
446 return LM.
all() ? 0 :
find(LM);
467 void init() { memset(
this, 0,
sizeof *
this); }
509 "NodeBase must be at most NodeAllocator::NodeMemSize bytes");
552 template <
typename Predicate>
592 return static_cast<T>(
Code.
CP);
606 template <
typename Predicate>
622 return CodeNode::getCode<MachineInstr*>();
628 return CodeNode::getCode<MachineBasicBlock*>();
636 return CodeNode::getCode<MachineFunction*>();
651 return static_cast<T>(
ptr(N));
657 return { ptr<T>(
N), N };
679 Iterator &up() { Pos = DS.nextUp(Pos);
return *
this; }
680 Iterator &down() { Pos = DS.nextDown(Pos);
return *
this; }
684 return DS.Stack[Pos-1];
686 const value_type *operator->()
const {
688 return &DS.Stack[Pos-1];
707 unsigned size()
const;
716 typedef std::vector<value_type> StorageType;
718 bool isDelimiter(
const StorageType::value_type &
P,
NodeId N = 0)
const {
719 return (P.Addr ==
nullptr) && (N == 0 || P.Id ==
N);
722 unsigned nextUp(
unsigned P)
const;
723 unsigned nextDown(
unsigned P)
const;
766 return BlockNodes.at(BB);
782 template <u
int16_t Kind>
788 template <u
int16_t Kind>
837 template <
typename Predicate>
842 typedef std::map<NodeId,RegisterSet> BlockRefsMap;
846 void recordDefsForDF(BlockRefsMap &PhiM, BlockRefsMap &RefM,
848 void buildPhis(BlockRefsMap &PhiM, BlockRefsMap &RefM,
850 void removeUnusedPhis();
856 template <
typename Predicate>
void linkStmtRefs(DefStackMap &DefM,
865 IA.
Addr->removeMember(RA, *
this);
871 const PhysicalRegisterInfo PRI;
874 const TargetOperandInfo &TOI;
876 RegisterAggr LiveIns;
877 NodeAddr<FuncNode*> Func;
880 std::map<MachineBasicBlock*,NodeAddr<BlockNode*>> BlockNodes;
885 template <
typename Predicate>
892 while (NA.Addr !=
this) {
895 if (RA.
Addr->getRegRef(G) == RR &&
P(NA))
904 NA = CA.
Addr->getFirstMember(G);
911 template <
typename Predicate>
914 auto M = getFirstMember(G);
918 while (M.Addr !=
this) {
928 template <
typename T>
929 raw_ostream &operator<< (raw_ostream &OS, const Print<T> &
P);
931 template <
typename T>
938 template <
typename T>
948 #endif // LLVM_LIB_TARGET_HEXAGON_RDFGRAPH_H
NodeList members(const DataFlowGraph &G) const
void setReachingDef(NodeId RD)
void push_back(const T &Elt)
MachineFunction & getMF() const
A common definition of LaneBitmask for use in TableGen and CodeGen.
RegisterRef restrictRef(RegisterRef AR, RegisterRef BR) const
static uint16_t kind(uint16_t T)
LaneBitmask getLaneMaskForIndex(uint32_t K) const
virtual ~TargetOperandInfo()=default
NodeAddr< RefNode * > getNextRelated(NodeAddr< InstrNode * > IA, NodeAddr< RefNode * > RA) const
void linkToDef(NodeId Self, NodeAddr< DefNode * > DA)
NodeAddr< NodeBase * > New()
NodeId getReachedDef() const
uint16_t getFlags() const
bool operator!=(const NodeAddr< T > &NA) const
static uint16_t type(uint16_t T)
NodeBase * ptr(NodeId N) const
This class provides various memory handling functions that manipulate MemoryBlock instances...
static LaneBitmask getAll()
void push(NodeAddr< DefNode * > DA)
static bool IsPreservingDef(const NodeAddr< DefNode * > DA)
const TargetInstrInfo & getTII() const
virtual bool isPreserving(const MachineInstr &In, unsigned OpNum) const
DataFlowGraph(MachineFunction &mf, const TargetInstrInfo &tii, const TargetRegisterInfo &tri, const MachineDominatorTree &mdt, const MachineDominanceFrontier &mdf, const TargetOperandInfo &toi)
uint16_t getAttrs() const
bool operator==(const NodeAddr< T > &NA) const
MachineInstr * getCode() const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
const PhysicalRegisterInfo & getPRI() const
void unlinkUse(NodeAddr< UseNode * > UA, bool RemoveFromOwner)
void releaseBlock(NodeId B, DefStackMap &DefM)
const TargetInstrInfo & TII
PackedRegisterRef pack(RegisterRef RR) const
const HexagonInstrInfo * TII
NodeList getRelatedRefs(NodeAddr< InstrNode * > IA, NodeAddr< RefNode * > RA) const
A Use represents the edge between a Value definition and its users.
NodeId getReachedUse() const
Reg
All possible values of the reg field in the ModR/M byte.
NodeAddr< NodeBase * > getFirstMember(const DataFlowGraph &G) const
constexpr bool any() const
APInt operator*(APInt a, uint64_t RHS)
void append(NodeAddr< NodeBase * > NA)
static bool IsDef(const NodeAddr< NodeBase * > BA)
MachineFunction * getCode() const
uint32_t find(LaneBitmaskVal) const
uint32_t insert(LaneBitmaskVal)
virtual bool isClobbering(const MachineInstr &In, unsigned OpNum) const
static uint16_t set_flags(uint16_t A, uint16_t F)
void clear_block(NodeId N)
NodeAddr< BlockNode * > findBlock(const MachineBasicBlock *BB, const DataFlowGraph &G) const
void addMember(NodeAddr< NodeBase * > NA, const DataFlowGraph &G)
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
NodeList members_if(Predicate P, const DataFlowGraph &G) const
const TargetRegisterInfo & getTRI() const
TargetInstrInfo - Interface to description of machine instruction set.
void linkToDef(NodeId Self, NodeAddr< DefNode * > DA)
NodeAllocator(uint32_t NPB=4096)
void setFlags(uint16_t F)
void setReachedDef(NodeId D)
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
static bool IsRef(const NodeAddr< NodeBase * > BA)
Control flow instructions. These all have token chains.
PrintNode(const NodeAddr< T > &x, const DataFlowGraph &g)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
NodeAddr< BlockNode * > getEntryBlock(const DataFlowGraph &G)
static uint16_t flags(uint16_t T)
TargetOperandInfo(const TargetInstrInfo &tii)
static bool IsCode(const NodeAddr< NodeBase * > BA)
NodeAddr< RefNode * > getNextImp(NodeAddr< InstrNode * > IA, NodeAddr< RefNode * > RA, bool Create)
static bool IsPhi(const NodeAddr< NodeBase * > BA)
static bool contains(uint16_t A, uint16_t B)
virtual bool isFixedReg(const MachineInstr &In, unsigned OpNum) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void pushAllDefs(NodeAddr< InstrNode * > IA, DefStackMap &DM)
NodeId getPredecessor() const
NodeAddr< NodeBase * > getLastMember(const DataFlowGraph &G) const
void setPredecessor(NodeId B)
void markBlock(NodeId B, DefStackMap &DefM)
const MachineDominanceFrontier & getDF() const
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
NodeId getSibling() const
NodeAddr(const NodeAddr< S > &NA)
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
NodeId id(const NodeBase *P) const
void setAttrs(uint16_t A)
static uint16_t set_type(uint16_t A, uint16_t T)
void addPhi(NodeAddr< PhiNode * > PA, const DataFlowGraph &G)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
std::unordered_map< RegisterId, DefStack > DefStackMap
const MachineDominatorTree & getDT() const
std::set< NodeId > NodeSet
NodeAddr< FuncNode * > getFunc() const
RegisterRef getRegRef(const DataFlowGraph &G) const
static bool IsUse(const NodeAddr< NodeBase * > BA)
RegisterRef unpack(PackedRegisterRef PR) const
static std::vector< std::string > Flags
bool operator!=(uint64_t V1, const APInt &V2)
Representation of each machine instruction.
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
static uint16_t set_kind(uint16_t A, uint16_t K)
void setRegRef(RegisterRef RR, DataFlowGraph &G)
PackedRegisterRef pack(RegisterRef RR)
RegisterRef makeRegRef(unsigned Reg, unsigned Sub) const
void addMemberAfter(NodeAddr< NodeBase * > MA, NodeAddr< NodeBase * > NA, const DataFlowGraph &G)
void build(unsigned Options=BuildOptions::None)
constexpr bool all() const
MachineBasicBlock * getCode() const
Print(const T &x, const DataFlowGraph &g)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void removeMember(NodeAddr< NodeBase * > NA, const DataFlowGraph &G)
NodeId id(const NodeBase *P) const
void unlinkDef(NodeAddr< DefNode * > DA, bool RemoveFromOwner)
MachineInstr * getCode() const
const RegisterAggr & getLiveIns() const
NodeAddr< T > addr(NodeId N) const
NodeId getReachingDef() const
This class implements an extremely fast bulk output stream that can only output to a stream...
NodeBase * ptr(NodeId N) const
std::set< RegisterRef > RegisterSet
bool operator==(uint64_t V1, const APInt &V2)
SmallVector< NodeAddr< NodeBase * >, 4 > NodeList
uint32_t getIndexForLaneMask(LaneBitmask LM) const
NodeAddr< RefNode * > getNextRef(RegisterRef RR, Predicate P, bool NextOnly, const DataFlowGraph &G)
void start_block(NodeId N)
NodeAddr< BlockNode * > findBlock(MachineBasicBlock *BB) const
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
NodeAddr< RefNode * > getNextShadow(NodeAddr< InstrNode * > IA, NodeAddr< RefNode * > RA, bool Create)
void setReachedUse(NodeId U)
uint32_t getIndexForLaneMask(LaneBitmask LM)
void setSibling(NodeId Sib)