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 (
11 Database
as _Database
,
12 WordInstruction
as _WordInstruction
,
13 PrefixedInstruction
as _PrefixedInstruction
,
14 SVP64Instruction
as _SVP64Instruction
,
18 class ByteOrder(_enum
.Enum
):
23 return self
.name
.lower()
26 def load(ifile
, byteorder
=ByteOrder
.LITTLE
, **_
):
27 byteorder
= str(byteorder
)
36 insn
= _WordInstruction
.integer(value
=insn
, byteorder
=byteorder
)
38 suffix
= ifile
.read(4)
47 suffix
= _WordInstruction
.integer(value
=suffix
, byteorder
=byteorder
)
48 insn
= _SVP64Instruction
.pair(prefix
=prefix
, suffix
=suffix
)
49 if insn
.prefix
.id != 0b11:
50 insn
= _PrefixedInstruction
.pair(prefix
=prefix
, suffix
=suffix
)
54 def dump(insns
, style
, **_
):
55 db
= _Database(_find_wiki_dir())
57 yield from insn
.disassemble(db
=db
, style
=style
)
60 # this is the entry-point for the console-script pysvp64dis
62 parser
= _argparse
.ArgumentParser()
63 parser
.add_argument("ifile", nargs
="?",
64 type=_argparse
.FileType("rb"), default
=_sys
.stdin
.buffer)
65 parser
.add_argument("ofile", nargs
="?",
66 type=_argparse
.FileType("w"), default
=_sys
.stdout
)
67 parser
.add_argument("-b", "--byteorder",
68 type=ByteOrder
, default
=ByteOrder
.LITTLE
)
69 parser
.add_argument("-s", "--short",
70 dest
="style", default
=_Style
.NORMAL
,
71 action
="store_const", const
=_Style
.SHORT
)
72 parser
.add_argument("-v", "--verbose",
73 dest
="style", default
=_Style
.NORMAL
,
74 action
="store_const", const
=_Style
.VERBOSE
)
75 parser
.add_argument("-l", "--legacy",
76 dest
="style", default
=_Style
.NORMAL
,
77 action
="store_const", const
=_Style
.LEGACY
)
78 parser
.add_argument("-L", "--log",
79 action
="store_true", default
=False)
81 args
= dict(vars(parser
.parse_args()))
83 # if logging requested do not disable it.
85 _os
.environ
['SILENCELOG'] = '1'
87 # load instructions and dump them
89 for line
in dump(insns
, **args
):
90 print(line
, file=args
["ofile"])
93 # still here but use "python3 setup.py develop" then run the
94 # command "pysvp64dis" instead of "python3 src/openpower/sv/trans/pysvp64dis.py"
95 if __name__
== "__main__":