MLIR: include/mlir/Analysis/Presburger/PresburgerSpace.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14 #ifndef MLIR_ANALYSIS_PRESBURGER_PRESBURGERSPACE_H

15 #define MLIR_ANALYSIS_PRESBURGER_PRESBURGERSPACE_H

16

17 #include "llvm/ADT/ArrayRef.h"

18 #include "llvm/ADT/SmallVector.h"

19 #include "llvm/Support/PointerLikeTypeTraits.h"

20 #include "llvm/Support/TypeName.h"

21 #include "llvm/Support/raw_ostream.h"

22

23 namespace mlir {

24 namespace presburger {

27

28

29

30

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

71 public:

73

74

75 template

77 : value(llvm::PointerLikeTypeTraits::getAsVoidPointer(value)) {

78 #if LLVM_ENABLE_ABI_BREAKING_CHECKS

79 idType = llvm::getTypeName();

80 #endif

81 }

82

83

84

85 template

87 #if LLVM_ENABLE_ABI_BREAKING_CHECKS

88 assert(llvm::getTypeName() == idType &&

89 "Identifier was initialized with a different type than the one used "

90 "to retrieve it.");

91 #endif

92 return llvm::PointerLikeTypeTraits::getFromVoidPointer(value);

93 }

94

95 bool hasValue() const { return value != nullptr; }

96

97

98

100

103

104 void print(llvm::raw_ostream &os) const;

105 void dump() const;

106

107 private:

108

109 void *value = nullptr;

110

111 #if LLVM_ENABLE_ABI_BREAKING_CHECKS

112

113 llvm::StringRef idType;

114 #endif

115 };

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

162 public:

164 unsigned numRange = 0,

165 unsigned numSymbols = 0,

166 unsigned numLocals = 0) {

167 return PresburgerSpace(numDomain, numRange, numSymbols, numLocals);

168 }

169

171 unsigned numSymbols = 0,

172 unsigned numLocals = 0) {

173 return PresburgerSpace(0, numDims, numSymbols,

174 numLocals);

175 }

176

177

178

181

182

184

190

191 unsigned getNumDimVars() const { return numDomain + numRange; }

193 return numDomain + numRange + numSymbols;

194 }

196 return numDomain + numRange + numSymbols + numLocals;

197 }

198

199

201

202

204

205

207

208

209

211 unsigned varLimit) const;

212

213

215

216

217

218

219

220

221

222

224

225

226

228

229

230

231

232

233

235 VarKind dstKind, unsigned dstPos);

236

237

238

239

240

242

243

245

246

247

249

250

251

252

254

255

257 assert(kind != VarKind::Local && "Local variables have no identifiers");

258 if (!usingIds)

261 }

262

264 assert(kind != VarKind::Local && "Local variables have no identifiers");

265 assert(usingIds && "Identifiers not enabled for space");

267 }

268

270 assert(usingIds && "Identifiers not enabled for space");

271 return identifiers;

272 }

273

274

275

277 assert(kind != VarKind::Local && "Local variables have no identifiers");

278 if (!usingIds)

281 }

282

283

285

286

287

289 identifiers.clear();

291 usingIds = true;

292 }

293

294

296 identifiers.clear();

297 usingIds = false;

298 }

299

300

301

302

304

305

307

308

309

310

312

313 void print(llvm::raw_ostream &os) const;

314 void dump() const;

315

316 protected:

317 PresburgerSpace(unsigned numDomain, unsigned numRange, unsigned numSymbols,

318 unsigned numLocals)

319 : numDomain(numDomain), numRange(numRange), numSymbols(numSymbols),

320 numLocals(numLocals) {}

321

322 private:

323

324 unsigned numDomain;

325

326

327 unsigned numRange;

328

329

330

331 unsigned numSymbols;

332

333

334

335 unsigned numLocals;

336

337

338 bool usingIds = false;

339

340

342 };

343

344 }

345 }

346

347 #endif

union mlir::linalg::@1203::ArityGroupAndKind::Kind kind

An Identifier stores a pointer to an object, such as a Value or an Operation.

T getValue() const

Get the value of the identifier casted to type T.

bool operator!=(const Identifier &other) const

bool isEqual(const Identifier &other) const

Check if the two identifiers are equal.

void print(llvm::raw_ostream &os) const

bool operator==(const Identifier &other) const

PresburgerSpace is the space of all possible values of a tuple of integer valued variables/variables.

unsigned getNumRangeVars() const

ArrayRef< Identifier > getIds() const

PresburgerSpace getRangeSpace() const

void setId(VarKind kind, unsigned pos, Identifier id)

Set the identifier of pos^th variable of the specified kind.

unsigned getNumSymbolVars() const

unsigned getNumVarKind(VarKind kind) const

Get the number of vars of the specified kind.

void resetIds()

Reset the stored identifiers in the space.

unsigned getNumDimAndSymbolVars() const

bool isEqual(const PresburgerSpace &other) const

Returns true if both the spaces are equal including local variables i.e.

PresburgerSpace getDomainSpace() const

Get the domain/range space of this space.

void disableIds()

Disable identifiers being stored in space.

bool isUsingIds() const

Returns if identifiers are being used.

void convertVarKind(VarKind srcKind, unsigned srcPos, unsigned num, VarKind dstKind, unsigned dstPos)

Converts variables of the specified kind in the column range [srcPos, srcPos + num) to variables of t...

void removeVarRange(VarKind kind, unsigned varStart, unsigned varLimit)

Removes variables of the specified kind in the column range [varStart, varLimit).

unsigned getVarKindOffset(VarKind kind) const

Return the index at which the specified kind of var starts.

unsigned getVarKindEnd(VarKind kind) const

Return the index at Which the specified kind of var ends.

Identifier getId(VarKind kind, unsigned pos) const

Get the identifier of pos^th variable of the specified kind.

unsigned getNumVars() const

PresburgerSpace(unsigned numDomain, unsigned numRange, unsigned numSymbols, unsigned numLocals)

unsigned getNumLocalVars() const

VarKind getVarKindAt(unsigned pos) const

Return the VarKind of the var at the specified position.

unsigned getNumDomainVars() const

unsigned getVarKindOverlap(VarKind kind, unsigned varStart, unsigned varLimit) const

Get the number of elements of the specified kind in the range [varStart, varLimit).

static PresburgerSpace getSetSpace(unsigned numDims=0, unsigned numSymbols=0, unsigned numLocals=0)

ArrayRef< Identifier > getIds(VarKind kind) const

bool isCompatible(const PresburgerSpace &other) const

Returns true if both the spaces are compatible i.e.

void print(llvm::raw_ostream &os) const

void mergeAndAlignSymbols(PresburgerSpace &other)

Merge and align symbol variables of this and other with respect to identifiers.

void setVarSymbolSeparation(unsigned newSymbolCount)

Changes the partition between dimensions and symbols.

bool isAligned(const PresburgerSpace &other) const

Check if the spaces are compatible, and the non-local variables having same identifiers are in the sa...

PresburgerSpace getSpaceWithoutLocals() const

Get the space without local variables.

unsigned getNumDimVars() const

static PresburgerSpace getRelationSpace(unsigned numDomain=0, unsigned numRange=0, unsigned numSymbols=0, unsigned numLocals=0)

void swapVar(VarKind kindA, VarKind kindB, unsigned posA, unsigned posB)

Swaps the posA^th variable of kindA and posB^th variable of kindB.

unsigned getNumSetDimVars() const

unsigned insertVar(VarKind kind, unsigned pos, unsigned num=1)

Insert num variables of the specified kind at position pos.

The OpAsmOpInterface, see OpAsmInterface.td for more details.

Include the generated interface declarations.

Represents a range (offset, size, and stride) where each element of the triple may be dynamic or stat...