225 #ifndef LLVM_LIB_TARGET_HEXAGON_RDFGRAPH_H 226 #define LLVM_LIB_TARGET_HEXAGON_RDFGRAPH_H 238 #include <unordered_map> 245 static_assert(
sizeof(
uint32_t) ==
sizeof(
unsigned),
"Those should be equal");
249 class MachineBasicBlock;
250 class MachineDominanceFrontier;
251 class MachineDominatorTree;
252 class MachineFunction;
254 class MachineOperand;
256 class TargetInstrInfo;
257 class TargetRegisterInfo;
314 uint16_t KB =
kind(B);
319 return KB ==
Phi || KB ==
Stmt;
342 : Addr(static_cast<
T>(NA.Addr)),
Id(NA.
Id) {}
346 return Addr == NA.
Addr;
376 enum { NodeMemSize = 32 };
379 : NodesPerBlock(NPB), BitsPerIndex(
Log2_32(NPB)),
380 IndexMask((1 << BitsPerIndex)-1) {
386 uint32_t BlockN = N1 >> BitsPerIndex;
396 void startNewBlock();
401 return ((Block << BitsPerIndex) | Index) + 1;
407 char *ActiveEnd =
nullptr;
408 std::vector<char*> Blocks;
419 virtual bool isPreserving(
const MachineInstr &
In,
unsigned OpNum)
const;
420 virtual bool isClobbering(
const MachineInstr &In,
unsigned OpNum)
const;
421 virtual bool isFixedReg(
const MachineInstr &In,
unsigned OpNum)
const;
441 return LM.
all() ? 0 : insert(LM);
446 return LM.
all() ? 0 :
find(LM);
511 "NodeBase must be at most NodeAllocator::NodeMemSize bytes");
553 template <
typename Predicate>
583 return Ref.PhiU.PredB;
593 return static_cast<T>(
Code.CP);
607 template <
typename Predicate>
623 return CodeNode::getCode<MachineInstr*>();
629 return CodeNode::getCode<MachineBasicBlock*>();
637 return CodeNode::getCode<MachineFunction*>();
652 return static_cast<T>(ptr(N));
658 return { ptr<T>(
N), N };
673 bool empty()
const {
return Stack.empty() || top() == bottom(); }
680 Iterator &up() { Pos =
DS.nextUp(Pos);
return *
this; }
681 Iterator &down() { Pos =
DS.nextDown(Pos);
return *
this; }
685 return DS.Stack[Pos-1];
689 return &
DS.Stack[Pos-1];
691 bool operator==(
const Iterator &It)
const {
return Pos == It.Pos; }
692 bool operator!=(
const Iterator &It)
const {
return Pos != It.Pos; }
697 Iterator(
const DefStack &S,
bool Top);
710 unsigned size()
const;
714 void start_block(
NodeId N);
715 void clear_block(
NodeId N);
718 friend struct Iterator;
720 using StorageType = std::vector<value_type>;
722 bool isDelimiter(
const StorageType::value_type &P,
NodeId N = 0)
const {
723 return (P.Addr ==
nullptr) && (N == 0 || P.Id ==
N);
726 unsigned nextUp(
unsigned P)
const;
727 unsigned nextDown(
unsigned P)
const;
742 return { RR.
Reg, LMI.getIndexForLaneMask(RR.
Mask) };
745 return { RR.
Reg, LMI.getIndexForLaneMask(RR.
Mask) };
770 return BlockNodes.at(BB);
786 template <u
int16_t Kind>
792 template <u
int16_t Kind>
814 uint16_t Flags = DA.
Addr->getFlags();
841 template <
typename Predicate>
846 using BlockRefsMap = std::map<NodeId, RegisterSet>;
850 void buildPhis(BlockRefsMap &PhiM,
RegisterSet &AllRefs,
852 void removeUnusedPhis();
858 template <
typename Predicate>
void linkStmtRefs(
DefStackMap &DefM,
867 IA.
Addr->removeMember(RA, *
this);
882 std::map<MachineBasicBlock*,NodeAddr<BlockNode*>> BlockNodes;
887 template <
typename Predicate>
894 while (NA.Addr !=
this) {
897 if (RA.
Addr->getRegRef(G) == RR &&
P(NA))
906 NA = CA.
Addr->getFirstMember(G);
913 template <
typename Predicate>
916 auto M = getFirstMember(G);
920 while (M.Addr !=
this) {
929 template <
typename T>
930 raw_ostream &operator<< (raw_ostream &OS, const Print<T> &
P);
932 template <
typename T>
940 template <
typename T>
950 #endif // LLVM_LIB_TARGET_HEXAGON_RDFGRAPH_H NodeAddr< BlockNode * > findBlock(MachineBasicBlock *BB) const
void setReachingDef(NodeId RD)
NodeId getReachedUse() const
A common definition of LaneBitmask for use in TableGen and CodeGen.
MachineFunction & getMF() const
uint16_t getFlags() const
static uint16_t kind(uint16_t T)
This class represents lattice values for constants.
static uint16_t type(uint16_t T)
void unlinkDef(NodeAddr< DefNode *> DA, bool RemoveFromOwner)
This class provides various memory handling functions that manipulate MemoryBlock instances...
static bool IsPreservingDef(const NodeAddr< DefNode *> DA)
void push_back(const T &Elt)
uint32_t getIndexForLaneMask(LaneBitmask LM) const
unsigned const TargetRegisterInfo * TRI
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
const TargetInstrInfo & TII
const TargetInstrInfo & getTII() const
SI optimize exec mask operations pre RA
NodeAddr< FuncNode * > getFunc() const
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
const HexagonInstrInfo * TII
A Use represents the edge between a Value definition and its users.
std::set< RegisterRef > RegisterSet
static constexpr LaneBitmask getAll()
void unlinkUse(NodeAddr< UseNode *> UA, bool RemoveFromOwner)
APInt operator*(APInt a, uint64_t RHS)
uint16_t getAttrs() const
static uint16_t set_flags(uint16_t A, uint16_t F)
const MachineDominatorTree & getDT() const
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
TargetInstrInfo - Interface to description of machine instruction set.
NodeAllocator(uint32_t NPB=4096)
void setFlags(uint16_t F)
void setReachedDef(NodeId D)
Error build(ArrayRef< Module *> Mods, SmallVector< char, 0 > &Symtab, StringTableBuilder &StrtabBuilder, BumpPtrAllocator &Alloc)
Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.
static bool IsUse(const NodeAddr< NodeBase *> BA)
Control flow instructions. These all have token chains.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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< T > addr(NodeId N) const
const TargetRegisterInfo & getTRI() const
LaneBitmask getLaneMaskForIndex(uint32_t K) const
MachineInstr * getCode() const
static bool IsPhi(const NodeAddr< NodeBase *> BA)
static uint16_t flags(uint16_t T)
TargetOperandInfo(const TargetInstrInfo &tii)
NodeId getPredecessor() const
constexpr bool all() const
static bool contains(uint16_t A, uint16_t B)
NodeList members_if(Predicate P, const DataFlowGraph &G) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
static wasm::ValType getType(const TargetRegisterClass *RC)
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
RegisterRef unpack(PackedRegisterRef PR) const
const PhysicalRegisterInfo & getPRI() const
void setPredecessor(NodeId B)
MachineFunction * getCode() const
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
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...
NodeAddr(const NodeAddr< S > &NA)
MachineInstr * getCode() const
Predicate
Predicate - These are "(BI << 5) | BO" for various predicates.
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
void setAttrs(uint16_t A)
static uint16_t set_type(uint16_t A, uint16_t T)
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
const MachineDominanceFrontier & getDF() const
NodeId getReachedDef() const
static void clear(coro::Shape &Shape)
const RegisterAggr & getLiveIns() const
std::set< NodeId > NodeSet
bool operator!=(uint64_t V1, const APInt &V2)
Representation of each machine instruction.
NodeId getReachingDef() const
static uint16_t set_kind(uint16_t A, uint16_t K)
PackedRegisterRef pack(RegisterRef RR)
constexpr bool any() const
static bool IsCode(const NodeAddr< NodeBase *> BA)
NodeBase * ptr(NodeId N) const
void push(NodeAddr< DefNode *> DA)
PackedRegisterRef pack(RegisterRef RR) const
Print(const T &x, const DataFlowGraph &g)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineBasicBlock * getCode() const
This class implements an extremely fast bulk output stream that can only output to a stream...
static bool IsDef(const NodeAddr< NodeBase *> BA)
bool operator==(uint64_t V1, const APInt &V2)
NodeId getSibling() const
static bool IsRef(const NodeAddr< NodeBase *> BA)
NodeAddr< RefNode * > getNextRef(RegisterRef RR, Predicate P, bool NextOnly, const DataFlowGraph &G)
std::unordered_map< RegisterId, DefStack > DefStackMap
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
void setReachedUse(NodeId U)
uint32_t getIndexForLaneMask(LaneBitmask LM)
void setSibling(NodeId Sib)