1 import argparse
as _argparse
6 from openpower
.decoder
.power_enums
import (
7 find_wiki_dir
as _find_wiki_dir
,
9 from openpower
.decoder
.power_insn
import (
10 Database
as _Database
,
11 WordInstruction
as _WordInstruction
,
12 PrefixedInstruction
as _PrefixedInstruction
,
13 SVP64Instruction
as _SVP64Instruction
,
17 class ByteOrder(_enum
.Enum
):
22 return self
.name
.lower()
25 def load(ifile
, byteorder
, **_
):
26 byteorder
= str(byteorder
)
35 insn
= _WordInstruction
.integer(value
=insn
, byteorder
=byteorder
)
37 suffix
= ifile
.read(4)
46 suffix
= _WordInstruction
.integer(value
=suffix
, byteorder
=byteorder
)
47 insn
= _SVP64Instruction
.pair(prefix
=prefix
, suffix
=suffix
)
48 if insn
.prefix
.id != 0b11:
49 insn
= _PrefixedInstruction
.pair(prefix
=prefix
, suffix
=suffix
)
53 def dump(insns
, verbose
, **_
):
54 db
= _Database(_find_wiki_dir())
56 yield from insn
.disassemble(db
=db
, verbose
=verbose
)
59 # this is the entry-point for the console-script pysvp64dis
61 parser
= _argparse
.ArgumentParser()
62 parser
.add_argument("ifile", nargs
="?",
63 type=_argparse
.FileType("rb"), default
=_sys
.stdin
.buffer)
64 parser
.add_argument("ofile", nargs
="?",
65 type=_argparse
.FileType("w"), default
=_sys
.stdout
)
66 parser
.add_argument("-b", "--byteorder",
67 type=ByteOrder
, default
=ByteOrder
.LITTLE
)
68 parser
.add_argument("-v", "--verbose",
69 action
="store_true", default
=False)
70 parser
.add_argument("-l", "--log",
71 action
="store_true", default
=False)
73 args
= dict(vars(parser
.parse_args()))
75 # if logging requested do not disable it.
77 os
.environ
['SILENCELOG'] = '1'
79 # load instructions and dump them
81 for line
in dump(insns
, **args
):
82 print(line
, file=args
["ofile"])
85 # still here but use "python3 setup.py develop" then run the
86 # command "pysvp64dis" instead of "python3 src/openpower/sv/trans/pysvp64dis.py"
87 if __name__
== "__main__":