[flang] Use object before converts in fir.dispatch (#68589)
[llvm-project.git] / polly / utils / pyscop / pyscop.py
blob382e23d8791b6aa0bb2cd183de1e781b0b2cc81a
1 import json
2 from isl import *
5 class Scop:
6 def __init__(self, filename):
7 f = open(filename, "r")
8 self.json = json.load(f)
9 return
11 def __str__(self):
12 return json.dumps(self.json, indent=2)
14 def __repr__(self):
15 return str(self)
17 @property
18 def statements(self):
19 return self.json["statements"]
22 class Transforms:
23 """
24 Create a map that interchanges two dimensions 'A' and 'B'
26 numberDimensions: The overall number of dimensions
27 dimensionA: The dimension of dimension 'A'
28 dimensionB: The dimension of dimension 'B'
30 getInterchange(2, 0, 1):
31 {[d0, d1] -> [d1, d0]}
32 """
34 @staticmethod
35 def getInterchange(numberDimensions, dimensionA, dimensionB):
37 dims = ["d" + str(i) for i in range(numberDimensions)]
38 dimString = ",".join(dims)
40 changedDims = dims
41 first = dims[dimensionA]
42 second = dims[dimensionB]
43 changedDims[dimensionA] = second
44 changedDims[dimensionB] = first
45 changedDimString = ",".join(changedDims)
47 return Map("{[%s] -> [%s]}" % (dimString, changedDimString))
49 """
50 Create a map that strip mines one dimension
52 numberDimensions: The overall number of dimensions
53 stripMineDim: The dimension to strip mine
54 factor: The strip mining factor
56 getStripMine(2, 1, 64):
57 {[d0, d1] -> [d0, o, d1] : o % 64 = 0 and o <= d1 <= d1 + 63}
58 """
60 @staticmethod
61 def getStripMine(numberDimensions, stripMineDim, factor):
63 dims = ["d" + str(i) for i in range(numberDimensions)]
64 dimString = ",".join(dims)
66 changedDims = dims
67 smd = dims[stripMineDim]
68 changedDims[stripMineDim] = "o,%s" % smd
69 changedDimString = ",".join(changedDims)
70 string = "{[%s] -> [%s]: o %% %i = 0 and o <= %s <= o + %i}" % (
71 dimString,
72 changedDimString,
73 factor,
74 smd,
75 factor - 1,
77 return Map(string)