a9fd349038534fa18c6cf0ac4f930ebbc551d63e
6 from openpower
.decoder
.power_enums
import (
9 from openpower
.insndb
.core
import (
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())
58 yield from insn
.disassemble(record
=record
, style
=style
)
61 # this is the entry-point for the console-script pysvp64dis
63 parser
= argparse
.ArgumentParser()
64 parser
.add_argument("ifile", nargs
="?",
65 type=argparse
.FileType("rb"), default
=sys
.stdin
.buffer)
66 parser
.add_argument("ofile", nargs
="?",
67 type=argparse
.FileType("w"), default
=sys
.stdout
)
68 parser
.add_argument("-b", "--byteorder",
69 type=ByteOrder
, default
=ByteOrder
.LITTLE
)
70 parser
.add_argument("-s", "--short",
71 dest
="style", default
=Style
.NORMAL
,
72 action
="store_const", const
=Style
.SHORT
)
73 parser
.add_argument("-v", "--verbose",
74 dest
="style", default
=Style
.NORMAL
,
75 action
="store_const", const
=Style
.VERBOSE
)
76 parser
.add_argument("-l", "--legacy",
77 dest
="style", default
=Style
.NORMAL
,
78 action
="store_const", const
=Style
.LEGACY
)
79 parser
.add_argument("-L", "--log",
80 action
="store_true", default
=False)
82 args
= dict(vars(parser
.parse_args()))
84 # if logging requested do not disable it.
86 os
.environ
['SILENCELOG'] = '1'
88 # load instructions and dump them
90 for line
in dump(insns
, **args
):
91 print(line
, file=args
["ofile"])
94 # still here but use "python3 setup.py develop" then run the
95 # command "pysvp64dis" instead of "python3 src/openpower/sv/trans/pysvp64dis.py"
96 if __name__
== "__main__":