From ea97fd6f72052f9d1bc994d8bd5471670b923501 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sun, 29 Nov 2020 17:07:09 +0000 Subject: [PATCH] move instruction analysis programs to correct location --- lxo/532/insn-histogram.py | 69 --------------------- {lxo/532 => openpower/sv}/comp16-v1-skel.py | 0 {lxo/532 => openpower/sv}/comp16-v2-skel.py | 0 3 files changed, 69 deletions(-) delete mode 100644 lxo/532/insn-histogram.py rename {lxo/532 => openpower/sv}/comp16-v1-skel.py (100%) rename {lxo/532 => openpower/sv}/comp16-v2-skel.py (100%) diff --git a/lxo/532/insn-histogram.py b/lxo/532/insn-histogram.py deleted file mode 100644 index 9d6602342..000000000 --- a/lxo/532/insn-histogram.py +++ /dev/null @@ -1,69 +0,0 @@ -#! /bin/env python3 - -# Feed this script the output of objdump -M raw --no-show-raw-insn ppc-prog - -# It will print the occurrence count of each opcode, -# and under it, indented by one character, -# the occurrence count of each operand. - -# Registers used as operands or as base addresses are counted -# separately; immediates and offsets are grouped per bit length; -# branch target offsets are grouped by range bit length. - -import sys -import re - -insn = re.compile('\s+(?P[0-9a-f]+):\s+(?P[^ \n]+) *(?P.*)[\n]?') - -opkind = re.compile('(?P-?[0-9]+)|(?P[0-9a-f]+)(?: <.*>)?|(?P-?[0-9]+)\((?Pr[0-9]+)\)') - -histogram = {} - -def count(ops, op): - match = opkind.fullmatch(op) - - if match is None: - op = op - elif match['immediate'] is not None: - op = "%i-bit" % int (op).bit_length () - elif match['branch'] is not None: - op = "%i-bit range" % (int (match['branch'], 16) - int (addr, 16)).bit_length () - elif match['offset'] is not None: - count(ops, match['offset']) - op = match['basereg'] - else: - raise "unrecognized operand kind" - - if op not in ops: - ops[op] = 1 - else: - ops[op] += 1 - -for line in sys.stdin: - match = insn.fullmatch(line) - if match is None: - continue - - addr = match['addr'] - opcode = match['opcode'] - operands = match['operands'] - - if opcode not in histogram: - ops = {} - histogram[opcode] = [1,ops] - else: - histogram[opcode][0] += 1 - ops = histogram[opcode][1] - - if len(operands) > 0: - for operand in operands.split(','): - count(ops, operand) - -hist = list(histogram.items()) -hist.sort(key = (lambda x : x[1][0])) -for x in hist: - print('%6i %s:' % (x[1][0], x[0])) - ops = list(x[1][1].items()) - ops.sort(key = (lambda x : x[1])) - for x in ops: - print(' %6i %s' % (x[1], x[0])) diff --git a/lxo/532/comp16-v1-skel.py b/openpower/sv/comp16-v1-skel.py similarity index 100% rename from lxo/532/comp16-v1-skel.py rename to openpower/sv/comp16-v1-skel.py diff --git a/lxo/532/comp16-v2-skel.py b/openpower/sv/comp16-v2-skel.py similarity index 100% rename from lxo/532/comp16-v2-skel.py rename to openpower/sv/comp16-v2-skel.py -- 2.30.2