From fcc8418db10cc0f6abe63e78e1fdca948d872c2d Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Thu, 29 Aug 2019 17:22:11 +0200 Subject: Updated test/mppa/coverage.sh to check which instruction isn't tested yet --- test/mppa/coverage.sh | 22 +++++++++----- test/mppa/coverage_helper.py | 70 +++++++++++++++++++++++++------------------- 2 files changed, 55 insertions(+), 37 deletions(-) mode change 100644 => 100755 test/mppa/coverage.sh (limited to 'test/mppa') diff --git a/test/mppa/coverage.sh b/test/mppa/coverage.sh old mode 100644 new mode 100755 index 0a057ff9..2b3dafc0 --- a/test/mppa/coverage.sh +++ b/test/mppa/coverage.sh @@ -1,17 +1,25 @@ -asmdir=$1 +#!/bin/bash + +asmdir=instr/asm/ to_cover_raw=/tmp/to_cover_raw to_cover=/tmp/to_cover covered_raw=/tmp/covered_raw covered=/tmp/covered -sed -n "s/^.*fprintf oc \" \(.*\) .*/\1/p" ../../mppa_k1c/TargetPrinter.ml > $to_cover_raw -sed -n "s/^.*fprintf oc \" \(.*\)\\n.*/\1/p" ../../mppa_k1c/TargetPrinter.ml >> $to_cover_raw -python2.7 coverage_helper.py $to_cover_raw > $to_cover +# Stop at any error +set -e +# Pipes do not mask errors +set -o pipefail + +sed -n "s/^.*fprintf oc \" \([^.].*\) .*/\1/p" ../../mppa_k1c/TargetPrinter.ml | sort -u > $to_cover_raw +sed -n "s/^.*fprintf oc \" \([^.].*\)\\n.*/\1/p" ../../mppa_k1c/TargetPrinter.ml | sort -u >> $to_cover_raw +python2.7 coverage_helper.py $to_cover_raw | sort -u > $to_cover rm -f $covered_raw -for asm in $(ls $asmdir/*.s); do - bash asm_coverage/asm-coverage.sh $asm >> $covered_raw +for asm in $(ls $asmdir/*.ccomp.s); do + grep -v ":" $asm | sed -n "s/^\s*\([a-z][a-z0-9.]*\).*/\1/p" | sort -u >> $covered_raw done -python2.7 coverage_helper.py $covered_raw > $covered +python2.7 coverage_helper.py $covered_raw | sort -u > $covered vimdiff $to_cover $covered + diff --git a/test/mppa/coverage_helper.py b/test/mppa/coverage_helper.py index b086aca9..42e0c887 100644 --- a/test/mppa/coverage_helper.py +++ b/test/mppa/coverage_helper.py @@ -1,35 +1,45 @@ import fileinput +import sys -occurs = {} +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 all nall any none".split(" ") + +all_fconds = "one ueq oeq une olt uge oge ult".split(" ") + +replaces_a = [(["cb."], 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(): - line_noc = line.replace('\n', '') - if line_noc not in occurs: - occurs[line_noc] = 0 - occurs[line_noc] += 1 - -# HACK: Removing all the instructions with "%a", replacing them with all their variations -# Also removing all instructions starting with '.' -pruned_occurs = dict(occurs) -for inst in occurs: - if inst[0] == '.': - del pruned_occurs[inst] - if "%a" not in inst: - continue - inst_no_a = inst.replace(".%a", "") - if inst_no_a in ("compw", "compd"): - del pruned_occurs[inst] - for mod in ("ne", "eq", "lt", "gt", "le", "ge", "ltu", "leu", "geu", - "gtu", "all", "any", "nall", "none"): - pruned_occurs[inst_no_a + "." + mod] = 1 - elif inst_no_a in ("cb"): - del pruned_occurs[inst] - for mod in ("wnez", "weqz", "wltz", "wgez", "wlez", "wgtz", "deqz", "dnez", - "dltz", "dgez", "dlez", "dgtz"): - pruned_occurs[inst_no_a + "." + mod] = 1 - else: - assert False, "Found instruction with %a: " + inst -occurs = pruned_occurs - -for inst in sorted(occurs): + 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 = {} -- cgit