aboutsummaryrefslogtreecommitdiffstats
path: root/test/mppa/coverage_helper.py
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2020-03-03 08:17:40 +0100
commit1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch)
tree210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/mppa/coverage_helper.py
parent222c9047d61961db9c6b19fed5ca49829223fd33 (diff)
parent12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff)
downloadcompcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz
compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/mppa/coverage_helper.py')
-rw-r--r--test/mppa/coverage_helper.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/mppa/coverage_helper.py b/test/mppa/coverage_helper.py
new file mode 100644
index 00000000..e5b1907c
--- /dev/null
+++ b/test/mppa/coverage_helper.py
@@ -0,0 +1,45 @@
+import fileinput
+import sys
+
+all_loads_stores = "lbs lbz lhz lo lq ld lhs lws sb sd sh so sq sw".split(" ")
+
+all_bconds = "wnez weqz wltz wgez wlez wgtz dnez deqz dltz dgez dlez dgtz".split(" ")
+
+all_iconds = "ne eq lt ge le gt ltu geu leu gtu".split(" ")
+
+all_fconds = "one ueq oeq une olt uge oge ult".split(" ")
+
+replaces_a = [(["cb.", "cmoved."], all_bconds),
+ (["compd.", "compw."], all_iconds),
+ (["fcompd.", "fcompw."], all_fconds),
+ (all_loads_stores, [".xs", ""])]
+
+replaces_dd = [(["addx", "sbfx"], ["2d", "4d", "8d", "16d"])]
+replaces_dw = [(["addx", "sbfx"], ["2w", "4w", "8w", "16w"])]
+
+macros_binds = {"%a": replaces_a, "%dd": replaces_dd, "%dw": replaces_dw}
+
+def expand_macro(fullinst, macro, replaceTable):
+ inst = fullinst.replace(macro, "")
+ for (searchlist, mods) in replaceTable:
+ if inst in searchlist:
+ return [fullinst.replace(macro, mod) for mod in mods]
+ raise NameError
+
+insts = []
+for line in fileinput.input():
+ fullinst = line[:-1]
+ try:
+ for macro in macros_binds:
+ if macro in fullinst:
+ insts.extend(expand_macro(fullinst, macro, macros_binds[macro]))
+ break
+ else:
+ insts.append(fullinst)
+ except NameError:
+ print >> sys.stderr, fullinst + " could not be found any match for macro " + macro
+ sys.exit(1)
+
+for inst in insts:
+ print inst
+occurs = {}