From: Alessandro Di Federico via <qemu-devel@nongnu.org>
To: Taylor Simpson <tsimpson@quicinc.com>
Cc: qemu-devel@nongnu.org, richard.henderson@linaro.org,
at.org@qualcomm.com, laurent@vivier.eu, bcain@quicinc.com
Subject: Re: [RFC PATCH v5 22/33] Hexagon (target/hexagon) generater phase 4 - decode tree
Date: Thu, 19 Nov 2020 23:53:39 +0100 [thread overview]
Message-ID: <20201119235339.039ba041@orange> (raw)
In-Reply-To: <1604016519-28065-23-git-send-email-tsimpson@quicinc.com>
On Thu, 29 Oct 2020 19:08:28 -0500
Taylor Simpson <tsimpson@quicinc.com> wrote:
> +if __name__ == '__main__':
> + f = io.StringIO()
> + print_tree(f, dectree_normal)
> + print_tree(f, dectree_16bit)
> + if subinsn_groupings:
> + print_tree(f, dectree_subinsn_groupings)
> + for (name, dectree_subinsn) in sorted(dectree_subinsns.items()):
> + print_tree(f, dectree_subinsn)
> + for (name, dectree_ext) in sorted(dectree_extensions.items()):
> + print_tree(f, dectree_ext)
> + print_match_info(f)
> + print_op_info(f)
> + open(sys.argv[1], 'w').write(f.getvalue())
Is there any specific reason why (here and elsewhere) you use
`StringIO` instead of writing to the file directly?
I'd expect something like:
```
if __name__ == '__main__':
with open(sys.argv[1], 'w') as f:
print_tree(f, dectree_normal)
print_tree(f, dectree_16bit)
if subinsn_groupings:
print_tree(f, dectree_subinsn_groupings)
for (name, dectree_subinsn) in sorted(dectree_subinsns.items()):
print_tree(f, dectree_subinsn)
for (name, dectree_ext) in sorted(dectree_extensions.items()):
print_tree(f, dectree_ext)
print_match_info(f)
print_op_info(f)
```
Maybe you're trying to avoid leaving a corrupted file in case of error,
but I guess that's more of a concern for the build system.
Elsewhere, you invoke `.close()`. I'd suggest to use a `with`-statement
there too.
--
Alessandro Di Federico
rev.ng
next prev parent reply other threads:[~2020-11-19 22:55 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 0:08 [RFC PATCH v5 00/33] Hexagon patch series Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 01/33] Hexagon Update MAINTAINERS file Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 02/33] Hexagon (target/hexagon) README Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 03/33] Hexagon (include/elf.h) ELF machine definition Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 04/33] Hexagon (target/hexagon) scalar core definition Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 05/33] Hexagon (disas) disassembler Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 06/33] Hexagon (target/hexagon) register names Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 07/33] Hexagon (target/hexagon) scalar core helpers Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 08/33] Hexagon (target/hexagon) GDB Stub Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 09/33] Hexagon (target/hexagon) architecture types Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 10/33] Hexagon (target/hexagon) instruction and packet types Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 11/33] Hexagon (target/hexagon) register fields Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 12/33] Hexagon (target/hexagon) instruction attributes Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 13/33] Hexagon (target/hexagon) instruction/packet decode Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 14/33] Hexagon (target/hexagon) instruction printing Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 15/33] Hexagon (target/hexagon/arch.[ch]) utility functions Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 16/33] Hexagon (target/hexagon/conv_emu.[ch]) " Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 17/33] Hexagon (target/hexagon/fma_emu.[ch]) " Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 18/33] Hexagon (target/hexagon/imported) arch import Taylor Simpson
2020-11-19 22:53 ` Alessandro Di Federico via
2020-12-02 1:54 ` Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 19/33] Hexagon (target/hexagon) generator phase 1 - C preprocessor for semantics Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 20/33] Hexagon (target/hexagon) generator phase 2 - generate header files Taylor Simpson
2020-11-19 22:53 ` Alessandro Di Federico via
2020-12-02 1:47 ` Taylor Simpson
2020-11-21 9:49 ` Alessandro Di Federico via
2020-10-30 0:08 ` [RFC PATCH v5 21/33] Hexagon (target/hexagon) generator phase 3 - C preprocessor for decode tree Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 22/33] Hexagon (target/hexagon) generater phase 4 - " Taylor Simpson
2020-11-19 22:53 ` Alessandro Di Federico via [this message]
2020-12-02 1:46 ` Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 23/33] Hexagon (target/hexagon) opcode data structures Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 24/33] Hexagon (target/hexagon) macros Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 25/33] Hexagon (target/hexagon) instruction classes Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 26/33] Hexagon (target/hexagon) TCG generation Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 27/33] Hexagon (target/hexagon) TCG for instructions with multiple definitions Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 28/33] Hexagon (target/hexagon) TCG for floating point instructions Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 29/33] Hexagon (target/hexagon) translation Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 30/33] Hexagon (linux-user/hexagon) Linux user emulation Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 31/33] Hexagon (tests/tcg/hexagon) TCG tests Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 32/33] Hexagon build infrastructure Taylor Simpson
2020-10-30 0:08 ` [RFC PATCH v5 33/33] Add Dockerfile for hexagon Taylor Simpson
2020-10-30 1:13 ` [RFC PATCH v5 00/33] Hexagon patch series no-reply
[not found] <1604015931-23005-1-git-send-email-tsimpson@quicinc.com>
2020-10-29 23:58 ` [RFC PATCH v5 22/33] Hexagon (target/hexagon) generater phase 4 - decode tree Taylor Simpson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201119235339.039ba041@orange \
--to=qemu-devel@nongnu.org \
--cc=ale.qemu@rev.ng \
--cc=at.org@qualcomm.com \
--cc=bcain@quicinc.com \
--cc=laurent@vivier.eu \
--cc=richard.henderson@linaro.org \
--cc=tsimpson@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).