xref: /llvm-project/polly/utils/jscop2cloog.py (revision 515bc8c1554f03515565878ea3d35cffdc6fd195)
1#!/usr/bin/env python
2import argparse, os
3import json
4
5def getDomains(scop):
6  statements = scop['statements'];
7  numStatements = len(statements)
8
9  output = "%s\n\n" % str(numStatements)
10
11  for statement in scop['statements']:
12    output += "%s\n\n" % statement['domain']
13    output += "0  0  0               # for future options\n\n"
14
15
16  return output
17
18def getSchedules(scop):
19  statements = scop['statements'];
20  numStatements = len(statements)
21
22  output = "%s\n\n" % str(numStatements)
23
24  for statement in scop['statements']:
25    output += "%s\n\n" % statement['schedule']
26
27  return output
28
29def writeCloog(scop):
30  template = """
31# ---------------------- CONTEXT ----------------------
32c # language is C
33
34# Context (no constraints on two parameters)
35%s
36
370 # We do not want to set manually the parameter names
38
39# --------------------- STATEMENTS --------------------
40%s
41
420 # We do not want to set manually the iterator names
43
44# --------------------- SCATTERING --------------------
45%s
46
470 # We do not want to set manually the schedule dimension names
48"""
49
50  context = scop['context']
51  domains = getDomains(scop)
52  schedules = getSchedules(scop)
53  print template % (context, domains, schedules)
54
55def __main__():
56  description = 'Translate JSCoP into iscc input'
57  parser = argparse.ArgumentParser(description)
58  parser.add_argument('inputFile', metavar='N', type=file,
59                      help='The JSCoP file')
60
61  args = parser.parse_args()
62  inputFile = args.inputFile
63  scop = json.load(inputFile)
64
65  writeCloog(scop)
66
67__main__()
68
69