sys.stdout.write("ERROR: {0}\n".format(s)) sys.exit(1) def msgb(b, s=''): sys.stdout.write("[{0}] {1}\n".format(b, s)) def msge(b, s=''): sys.stderr.write("[{0}] {1}\n".format(b, s)) def work(args): # main function msge("READING XED DB") xeddb = gen_setup.read_db(args) xeddb.recs.sort(key=lambda x: x.iclass) for r in xeddb.recs: for fld in sorted(r.__dict__.keys()): print("{}: {}".format(fld, getattr(r, fld))) print("EOSZ_LIST: {}".format(r.get_eosz_list())) print("\n\n") return 0 if __name__ == "__main__": args = gen_setup.setup("Dump all instructions and fields") r = work(args) sys.exit(r)
for inst in xeddb.recs: if classes[inst.isa_set] == 'general' and inst.scalar: print("GPR SCALAR", inst.iclass) tlist = [] for s in chip_icount_histo_tup: t = [] (chip, icount, histo) = s t.append("{0:20s} {1:4d}".format(chip, icount)) for scalar in ['.sc', '']: for x in groups: k = x + scalar t.append("{0:7s}:{1:4d}".format(k, histo[k])) tlist.append((icount, " ".join(t))) def keyfn(x): return x[0] tlist.sort(key=keyfn) for x, y in tlist: print(y) return 0 if __name__ == "__main__": args = gen_setup.setup("Generate instruction counts per chip") r = work(args) sys.exit(r)
msgb("READING XED DB") xeddb = read_xed_db.xed_reader_t(args.state_bits_filename, args.instructions_filename, args.widths_filename, args.element_types_filename) d = {} for r in xeddb.recs: if hasattr(r,'flags'): if hasattr(r,'isa_set'): isa_set = r.isa_set else: isa_set = r.extension s= "{:<20} {:<20} {}".format(r.iclass, isa_set, r.flags) d[s]=True k = d.keys() k.sort() for a in k: msg(a) return 0 if __name__ == "__main__": args = gen_setup.setup('Generate EFLAGS report') r = work(args) sys.exit(r)
xeddb = read_xed_db.xed_reader_t(args.state_bits_filename, args.instructions_filename, args.widths_filename, args.element_types_filename) histo = collections.defaultdict(int) for r in xeddb.recs: if hasattr(r, 'operands'): s = re.sub(r'[ ]+', ' ', r.operands) if 0: histo[s] = histo[s] + 1 if 1: for t in s.split(): if t.startswith('REG'): t = 'REG' + t[4:] if t.startswith('MEM'): t = 'MEM' + t[4:] histo[t] = histo[t] + 1 for k, v in sorted(list(histo.items()), key=lambda t: t[1]): print("{0:4d} {1}".format(v, k)) print("TOTAL: ", len(histo)) return 0 if __name__ == "__main__": args = gen_setup.setup('Generate operand lists') r = work(args) sys.exit(r)
def die(s): sys.stdout.write("ERROR: {0}\n".format(s)) sys.exit(1) def msgb(b, s=''): sys.stdout.write("[{0}] {1}\n".format(b, s)) def work(args): # main function msgb("READING XED DB") xeddb = gen_setup.read_db(args) xeddb.recs.sort(key=lambda x: x.iclass) for r in xeddb.recs: if r.space in ['vex', 'evex']: print("{}: {}/{}: {}".format(r.iclass, r.space, r.vl, " ".join(r.cpuid))) else: print("{}: {}: {}".format(r.iclass, r.space, " ".join(r.cpuid))) return 0 if __name__ == "__main__": args = gen_setup.setup('Generate cpuid info') r = work(args) sys.exit(r)