summaryrefslogtreecommitdiffstats
path: root/polly/utils/jscop2cloog.py
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2011-11-29 14:50:52 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2011-11-29 14:50:52 +0000
commita66b37d7aec068bec7244b2bd836b775b6c11e80 (patch)
treec5828100072b33d20f7af7457b0d796a44e878bd /polly/utils/jscop2cloog.py
parent1e06003227fa5251fe3a7664fb1e3e605883a08d (diff)
downloadbcm5719-llvm-a66b37d7aec068bec7244b2bd836b775b6c11e80.tar.gz
bcm5719-llvm-a66b37d7aec068bec7244b2bd836b775b6c11e80.zip
Add utils/jscop2cloog.py
This tool takes a jscop file and translates it into a cloog input file. llvm-svn: 145401
Diffstat (limited to 'polly/utils/jscop2cloog.py')
-rwxr-xr-xpolly/utils/jscop2cloog.py68
1 files changed, 68 insertions, 0 deletions
diff --git a/polly/utils/jscop2cloog.py b/polly/utils/jscop2cloog.py
new file mode 100755
index 00000000000..668f08509e2
--- /dev/null
+++ b/polly/utils/jscop2cloog.py
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+import argparse, os
+import json
+
+def getDomains(scop):
+ statements = scop['statements'];
+ numStatements = len(statements)
+
+ output = "%s\n\n" % str(numStatements)
+
+ for statement in scop['statements']:
+ output += "%s\n\n" % statement['domain']
+ output += "0 0 0 # for future options\n\n"
+
+
+ return output
+
+def getSchedules(scop):
+ statements = scop['statements'];
+ numStatements = len(statements)
+
+ output = "%s\n\n" % str(numStatements)
+
+ for statement in scop['statements']:
+ output += "%s\n\n" % statement['schedule']
+
+ return output
+
+def writeCloog(scop):
+ template = """
+# ---------------------- CONTEXT ----------------------
+c # language is C
+
+# Context (no constraints on two parameters)
+%s
+
+0 # We do not want to set manually the parameter names
+
+# --------------------- STATEMENTS --------------------
+%s
+
+0 # We do not want to set manually the iterator names
+
+# --------------------- SCATTERING --------------------
+%s
+
+0 # We do not want to set manually the scattering dimension names
+"""
+
+ context = scop['context']
+ domains = getDomains(scop)
+ schedules = getSchedules(scop)
+ print template % (context, domains, schedules)
+
+def __main__():
+ description = 'Translate JSCoP into iscc input'
+ parser = argparse.ArgumentParser(description)
+ parser.add_argument('inputFile', metavar='N', type=file,
+ help='The JSCoP file')
+
+ args = parser.parse_args()
+ inputFile = args.inputFile
+ scop = json.load(inputFile)
+
+ writeCloog(scop)
+
+__main__()
+
OpenPOWER on IntegriCloud