9#ifndef LLVM_CODEGEN_RDFREGISTERS_H
10#define LLVM_CODEGEN_RDFREGISTERS_H
36bool disjoint(
const std::set<T> &
A,
const std::set<T> &
B) {
37 auto ItA =
A.begin(), EndA =
A.end();
38 auto ItB =
B.begin(), EndB =
B.end();
39 while (ItA != EndA && ItB != EndB) {
54template <
typename T,
unsigned N = 32>
struct IndexedSet {
59 assert(Idx != 0 && !Map.empty() && Idx - 1 < Map.size());
67 return F - Map.begin() + 1;
75 return F - Map.begin() + 1;
91 static constexpr RegisterId MaskFlag = 1u << 30;
92 static constexpr RegisterId UnitFlag = 1u << 31;
115 return static_cast<MCRegUnit
>(
Id & ~UnitFlag);
120 return Id & ~MaskFlag;
123 explicit constexpr operator bool()
const {
128 return std::hash<RegisterId>{}(
Id) ^
129 std::hash<LaneBitmask::Type>{}(
Mask.getAsInteger());
133 return Id != 0 && !(
Id & UnitFlag) && !(
Id & MaskFlag);
175 return AliasInfos[U].Regs;
202 const TargetRegisterInfo &TRI;
203 IndexedSet<const uint32_t *> RegMasks;
204 std::vector<RegInfo> RegInfos;
205 IndexedMap<UnitInfo, MCRegUnitToIndex> UnitInfos;
206 std::vector<MaskInfo> MaskInfos;
207 IndexedMap<AliasInfo, MCRegUnitToIndex> AliasInfos;
215 return PRI->equal_to(
A,
B);
228 return PRI->less(
A,
B);
239 : Units(pri.getTRI().getNumRegUnits()), PRI(pri) {}
242 unsigned size()
const {
return Units.count(); }
243 bool empty()
const {
return Units.none(); }
272 using MapType = std::map<RegisterId, LaneBitmask>;
276 MapType::iterator Pos;
296 return Index ==
I.Index;
327 return Map.emplace(
Key, Empty).first->second;
330 auto begin() {
return Map.begin(); }
331 auto end() {
return Map.end(); }
332 auto begin()
const {
return Map.begin(); }
333 auto end()
const {
return Map.end(); }
334 auto find(
const KeyType &
Key)
const {
return Map.find(
Key); }
338 std::map<KeyType, RegisterAggr> Map;
360template <>
struct hash<
llvm::rdf::RegisterRef> {
366template <>
struct hash<
llvm::rdf::RegisterAggr> {
375using RegisterSet = std::set<RegisterRef, RegisterRefLess>;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file implements an indexed map.
A common definition of LaneBitmask for use in TableGen and CodeGen.
SI optimize exec mask operations pre RA
LocallyHashedType DenseMapInfo< LocallyHashedType >::Empty
const_set_bits_iterator_impl< BitVector > const_set_bits_iterator
Wrapper class representing physical registers. Should be passed by value.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
std::set< RegisterRef, RegisterRefLess > RegisterSet
raw_ostream & operator<<(raw_ostream &OS, const Print< RegisterRef > &P)
bool disjoint(const std::set< T > &A, const std::set< T > &B)
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Implement std::hash so that hash_code can be used in STL containers.
An information struct used to provide DenseMap with the various necessary components for a given valu...
static constexpr LaneBitmask getAll()
static constexpr LaneBitmask getNone()
const_iterator end() const
typename std::vector< T >::const_iterator const_iterator
T get(uint32_t Idx) const
const_iterator begin() const
uint32_t find(T Val) const
RegisterRef getRefForUnit(MCRegUnit U) const
RegisterId getRegMaskId(const uint32_t *RM) const
PhysicalRegisterInfo(const TargetRegisterInfo &tri, const MachineFunction &mf)
void print(raw_ostream &OS, RegisterRef A) const
const TargetRegisterInfo & getTRI() const
const BitVector & getMaskUnits(RegisterRef RR) const
bool equal_to(RegisterRef A, RegisterRef B) const
const uint32_t * getRegMaskBits(RegisterRef RR) const
bool alias(RegisterRef RA, RegisterRef RB) const
std::set< RegisterId > getAliasSet(RegisterRef RR) const
bool less(RegisterRef A, RegisterRef B) const
RegisterRef mapTo(RegisterRef RR, RegisterId R) const
const BitVector & getUnitAliases(MCRegUnit U) const
std::set< RegisterId > getUnits(RegisterRef RR) const
PrintLaneMaskShort(LaneBitmask M)
RegisterAggrMap(const PhysicalRegisterInfo &pri)
auto find(const KeyType &Key) const
typename decltype(Map)::mapped_type mapped_type
typename decltype(Map)::key_type key_type
RegisterAggr & operator[](KeyType Key)
typename decltype(Map)::value_type value_type
RegisterRef operator*() const
ref_iterator(const RegisterAggr &RG, bool End)
ref_iterator & operator++()
std::map< RegisterId, LaneBitmask > MapType
bool operator!=(const ref_iterator &I) const
bool operator==(const ref_iterator &I) const
iterator_range< ref_iterator > refs() const
RegisterAggr & insert(RegisterRef RR)
iterator_range< unit_iterator > units() const
RegisterAggr(const PhysicalRegisterInfo &pri)
const PhysicalRegisterInfo & getPRI() const
RegisterRef clearIn(RegisterRef RR) const
unit_iterator unit_end() const
RegisterAggr(const RegisterAggr &RG)=default
RegisterAggr & clear(RegisterRef RR)
ref_iterator ref_begin() const
RegisterRef makeRegRef() const
RegisterAggr & intersect(RegisterRef RR)
bool hasAliasOf(RegisterRef RR) const
RegisterRef intersectWith(RegisterRef RR) const
bool operator==(const RegisterAggr &A) const
BitVector::const_set_bits_iterator unit_iterator
bool hasCoverOf(RegisterRef RR) const
unit_iterator unit_begin() const
static bool isCoverOf(RegisterRef RA, RegisterRef RB, const PhysicalRegisterInfo &PRI)
ref_iterator ref_end() const
bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const
constexpr RegisterRefEqualTo(const llvm::rdf::PhysicalRegisterInfo &pri)
constexpr RegisterRefLess(const llvm::rdf::PhysicalRegisterInfo &pri)
bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const
constexpr RegisterRef(RegisterId R, LaneBitmask M=LaneBitmask::getAll())
bool operator!=(RegisterRef) const =delete
static constexpr RegisterId toUnitId(unsigned Idx)
constexpr unsigned asMaskIdx() const
constexpr RegisterRef()=default
constexpr bool isReg() const
constexpr bool isMask() const
static constexpr bool isMaskId(RegisterId Id)
static constexpr bool isUnitId(RegisterId Id)
static constexpr bool isRegId(RegisterId Id)
constexpr MCRegUnit asMCRegUnit() const
static constexpr RegisterId toMaskId(unsigned Idx)
constexpr bool isUnit() const
bool operator<(RegisterRef) const =delete
constexpr MCRegister asMCReg() const
bool operator==(RegisterRef) const =delete
size_t operator()(const llvm::rdf::RegisterAggr &A) const
size_t operator()(llvm::rdf::RegisterRef A) const