LLVM: include/llvm/CodeGen/RDFRegisters.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CODEGEN_RDFREGISTERS_H

10#define LLVM_CODEGEN_RDFREGISTERS_H

11

19#include

20#include

21#include

22#include

23#include

24

25namespace llvm {

26

29

30namespace rdf {

32

34

35template

36bool disjoint(const std::set &A, const std::set &B) {

37 auto ItA = A.begin(), EndA = A.end();

38 auto ItB = B.begin(), EndB = B.end();

39 while (ItA != EndA && ItB != EndB) {

40 if (*ItA < *ItB)

41 ++ItA;

42 else if (*ItB < *ItA)

43 ++ItB;

44 else

45 return false;

46 }

47 return true;

48}

49

50

51

52

53

54template <typename T, unsigned N = 32> struct IndexedSet {

56

58

59 assert(Idx != 0 && !Map.empty() && Idx - 1 < Map.size());

60 return Map[Idx - 1];

61 }

62

64

66 if (F != Map.end())

67 return F - Map.begin() + 1;

68 Map.push_back(Val);

69 return Map.size();

70 }

71

75 return F - Map.begin() + 1;

76 }

77

79

80 using const_iterator = typename std::vector::const_iterator;

81

84

85private:

86 std::vector Map;

87};

88

90private:

91 static constexpr RegisterId MaskFlag = 1u << 30;

92 static constexpr RegisterId UnitFlag = 1u << 31;

93

94public:

97

102

103

107

112

115 return static_cast<MCRegUnit>(Id & ~UnitFlag);

116 }

117

120 return Id & ~MaskFlag;

121 }

122

123 explicit constexpr operator bool() const {

124 return isReg() || (Id != 0 && Mask.any());

125 }

126

128 return std::hash{}(Id) ^

129 std::hashLaneBitmask::Type{}(Mask.getAsInteger());

130 }

131

133 return Id != 0 && !(Id & UnitFlag) && !(Id & MaskFlag);

134 }

137

139

141

145};

146

150

154

156 return RegMasks.get(RR.asMaskIdx());

157 }

158

160

161

163

167

169 return MaskInfos[RR.asMaskIdx()].Units;

170 }

171

173

175 return AliasInfos[U].Regs;

176 }

177

180

183

186

187private:

190 };

191 struct UnitInfo {

192 RegisterId Reg = 0;

194 };

195 struct MaskInfo {

196 BitVector Units;

197 };

198 struct AliasInfo {

199 BitVector Regs;

200 };

201

202 const TargetRegisterInfo &TRI;

203 IndexedSet<const uint32_t *> RegMasks;

204 std::vector RegInfos;

205 IndexedMap<UnitInfo, MCRegUnitToIndex> UnitInfos;

206 std::vector MaskInfos;

207 IndexedMap<AliasInfo, MCRegUnitToIndex> AliasInfos;

208};

209

213

215 return PRI->equal_to(A, B);

216 }

217

218private:

219

221};

222

226

228 return PRI->less(A, B);

229 }

230

231private:

232

233

235};

236

239 : Units(pri.getTRI().getNumRegUnits()), PRI(pri) {}

241

242 unsigned size() const { return Units.count(); }

243 bool empty() const { return Units.none(); }

246

248

252

257

264

268

270

272 using MapType = std::map<RegisterId, LaneBitmask>;

273

274 private:

276 MapType::iterator Pos;

277 unsigned Index;

279

280 public:

282

286

288 ++Pos;

289 ++Index;

290 return *this;

291 }

292

294 assert(Owner == I.Owner);

295 (void)Owner;

296 return Index == I.Index;

297 }

298

300 };

301

304

308

315

316private:

319};

320

321

322

325

327 return Map.emplace(Key, Empty).first->second;

328 }

329

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); }

335

336private:

338 std::map<KeyType, RegisterAggr> Map;

339

340public:

344};

345

347

348

354

355}

356}

357

358namespace std {

359

360template <> struct hash<llvm::rdf::RegisterRef> {

362 return A.hash();

363 }

364};

365

366template <> struct hash<llvm::rdf::RegisterAggr> {

368 return A.hash();

369 }

370};

371

372}

373

375using RegisterSet = std::set<RegisterRef, RegisterRefLess>;

376}

377

378#endif

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

uint32_t RegisterId

Definition RDFRegisters.h:33

raw_ostream & operator<<(raw_ostream &OS, const Print< RegisterRef > &P)

bool disjoint(const std::set< T > &A, const std::set< T > &B)

Definition RDFRegisters.h:36

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()

IndexedSet()

Definition RDFRegisters.h:55

const_iterator end() const

Definition RDFRegisters.h:83

typename std::vector< T >::const_iterator const_iterator

Definition RDFRegisters.h:80

T get(uint32_t Idx) const

Definition RDFRegisters.h:57

uint32_t size() const

Definition RDFRegisters.h:78

uint32_t insert(T Val)

Definition RDFRegisters.h:63

const_iterator begin() const

Definition RDFRegisters.h:82

uint32_t find(T Val) const

Definition RDFRegisters.h:72

Definition RDFRegisters.h:147

RegisterRef getRefForUnit(MCRegUnit U) const

Definition RDFRegisters.h:164

RegisterId getRegMaskId(const uint32_t *RM) const

Definition RDFRegisters.h:151

PhysicalRegisterInfo(const TargetRegisterInfo &tri, const MachineFunction &mf)

void print(raw_ostream &OS, RegisterRef A) const

const TargetRegisterInfo & getTRI() const

Definition RDFRegisters.h:179

const BitVector & getMaskUnits(RegisterRef RR) const

Definition RDFRegisters.h:168

bool equal_to(RegisterRef A, RegisterRef B) const

const uint32_t * getRegMaskBits(RegisterRef RR) const

Definition RDFRegisters.h:155

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

Definition RDFRegisters.h:174

std::set< RegisterId > getUnits(RegisterRef RR) const

Definition RDFRegisters.h:349

PrintLaneMaskShort(LaneBitmask M)

Definition RDFRegisters.h:350

LaneBitmask Mask

Definition RDFRegisters.h:351

RegisterAggrMap(const PhysicalRegisterInfo &pri)

Definition RDFRegisters.h:324

auto find(const KeyType &Key) const

Definition RDFRegisters.h:334

auto begin()

Definition RDFRegisters.h:330

typename decltype(Map)::mapped_type mapped_type

Definition RDFRegisters.h:342

auto begin() const

Definition RDFRegisters.h:332

typename decltype(Map)::key_type key_type

Definition RDFRegisters.h:341

RegisterAggr & operator[](KeyType Key)

Definition RDFRegisters.h:326

typename decltype(Map)::value_type value_type

Definition RDFRegisters.h:343

auto end() const

Definition RDFRegisters.h:333

auto end()

Definition RDFRegisters.h:331

Definition RDFRegisters.h:271

RegisterRef operator*() const

Definition RDFRegisters.h:283

ref_iterator(const RegisterAggr &RG, bool End)

ref_iterator & operator++()

Definition RDFRegisters.h:287

std::map< RegisterId, LaneBitmask > MapType

Definition RDFRegisters.h:272

bool operator!=(const ref_iterator &I) const

Definition RDFRegisters.h:299

bool operator==(const ref_iterator &I) const

Definition RDFRegisters.h:293

Definition RDFRegisters.h:237

iterator_range< ref_iterator > refs() const

Definition RDFRegisters.h:309

RegisterAggr & insert(RegisterRef RR)

iterator_range< unit_iterator > units() const

Definition RDFRegisters.h:312

RegisterAggr(const PhysicalRegisterInfo &pri)

Definition RDFRegisters.h:238

unsigned size() const

Definition RDFRegisters.h:242

size_t hash() const

Definition RDFRegisters.h:269

const PhysicalRegisterInfo & getPRI() const

Definition RDFRegisters.h:247

RegisterRef clearIn(RegisterRef RR) const

unit_iterator unit_end() const

Definition RDFRegisters.h:307

RegisterAggr(const RegisterAggr &RG)=default

RegisterAggr & clear(RegisterRef RR)

ref_iterator ref_begin() const

Definition RDFRegisters.h:302

RegisterRef makeRegRef() const

bool empty() const

Definition RDFRegisters.h:243

RegisterAggr & intersect(RegisterRef RR)

bool hasAliasOf(RegisterRef RR) const

RegisterRef intersectWith(RegisterRef RR) const

bool operator==(const RegisterAggr &A) const

Definition RDFRegisters.h:249

BitVector::const_set_bits_iterator unit_iterator

Definition RDFRegisters.h:305

bool hasCoverOf(RegisterRef RR) const

unit_iterator unit_begin() const

Definition RDFRegisters.h:306

static bool isCoverOf(RegisterRef RA, RegisterRef RB, const PhysicalRegisterInfo &PRI)

Definition RDFRegisters.h:253

ref_iterator ref_end() const

Definition RDFRegisters.h:303

bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const

Definition RDFRegisters.h:214

constexpr RegisterRefEqualTo(const llvm::rdf::PhysicalRegisterInfo &pri)

Definition RDFRegisters.h:211

constexpr RegisterRefLess(const llvm::rdf::PhysicalRegisterInfo &pri)

Definition RDFRegisters.h:224

bool operator()(llvm::rdf::RegisterRef A, llvm::rdf::RegisterRef B) const

Definition RDFRegisters.h:227

Definition RDFRegisters.h:89

constexpr RegisterRef(RegisterId R, LaneBitmask M=LaneBitmask::getAll())

Definition RDFRegisters.h:99

bool operator!=(RegisterRef) const =delete

static constexpr RegisterId toUnitId(unsigned Idx)

Definition RDFRegisters.h:138

constexpr unsigned asMaskIdx() const

Definition RDFRegisters.h:118

LaneBitmask Mask

Definition RDFRegisters.h:96

constexpr RegisterRef()=default

constexpr bool isReg() const

Definition RDFRegisters.h:104

constexpr bool isMask() const

Definition RDFRegisters.h:106

static constexpr bool isMaskId(RegisterId Id)

Definition RDFRegisters.h:136

static constexpr bool isUnitId(RegisterId Id)

Definition RDFRegisters.h:135

static constexpr bool isRegId(RegisterId Id)

Definition RDFRegisters.h:132

constexpr MCRegUnit asMCRegUnit() const

Definition RDFRegisters.h:113

static constexpr RegisterId toMaskId(unsigned Idx)

Definition RDFRegisters.h:140

constexpr bool isUnit() const

Definition RDFRegisters.h:105

RegisterId Id

Definition RDFRegisters.h:95

size_t hash() const

Definition RDFRegisters.h:127

bool operator<(RegisterRef) const =delete

constexpr MCRegister asMCReg() const

Definition RDFRegisters.h:108

bool operator==(RegisterRef) const =delete

size_t operator()(const llvm::rdf::RegisterAggr &A) const

Definition RDFRegisters.h:367

size_t operator()(llvm::rdf::RegisterRef A) const

Definition RDFRegisters.h:361