From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMHOM-0001Qe-Ji for qemu-devel@nongnu.org; Mon, 12 Nov 2018 13:56:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMHOG-00031s-TE for qemu-devel@nongnu.org; Mon, 12 Nov 2018 13:56:57 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:44288) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMHOB-0002zF-6e for qemu-devel@nongnu.org; Mon, 12 Nov 2018 13:56:48 -0500 Received: by mail-yb1-f194.google.com with SMTP id p144-v6so4305965yba.11 for ; Mon, 12 Nov 2018 10:56:41 -0800 (PST) MIME-Version: 1.0 References: <20181111233622.8976-1-f4bug@amsat.org> <20181111233622.8976-6-f4bug@amsat.org> <20181112170351.GU12503@habkost.net> In-Reply-To: From: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Date: Mon, 12 Nov 2018 19:56:29 +0100 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH 05/11] decodetree: Force Python to print unsigned values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eduardo Habkost Cc: Bastian Koppelmann , peer.adelt@hni.uni-paderborn.de, Richard Henderson , "qemu-devel@nongnu.org Developers" , Cleber Rosa > On Mon, Nov 12, 2018 at 6:03 PM Eduardo Habkost wro= te: > > On Mon, Nov 12, 2018 at 12:36:16AM +0100, Philippe Mathieu-Daud=C3=A9 w= rote: > > > Python internal representation is signed, so unsigned values > > > bigger than 31-bit are interpreted as signed (and printed with > > > a '-' signed). > > > Mask out to force unsigned values. > > > > I don't understand this commit description. Python surely > > supports integers larger than 2^31, and its internal > > representation shouldn't matter at all: > > > > >>> '0x{0:08x}'.format(0xffffffffffffffffffffffffffffffffffffffffffff= ffffffffffffffffffffffffffffffffffffff) > > '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff= ffffffffffffffff' >>> '0x{0:08x}'.format(-1) '0x-0000001' > > > > Can you explain how the code ends up with a negative value in the > > `self.thismask` or `b` variables? If `self.subs` contains > > negative values, this is likely to break other parts of the code. > > I guess I misunderstood the error, thus the description is invalid. > > > > > > > > > Signed-off-by: Philippe Mathieu-Daud=C3=A9 > > > --- > > > TODO: display error encountered: > > > > > > case 0x-1: > > > .... > > > > How can I reproduce it? > > $ scripts/decodetree.py /dev/null > > switch (insn & 0x-0000001) { > } > > main() -> > build_tree(patterns, 0, outermask =3D 0) -> > innermask =3D ~outermask # =3D -1 > Tree(fullmask, innermask =3D -1) -> > __init__(self, fm, tm =3D -1) -> > self.thismask =3D tm # -1 > t.output_code(4, False, 0, 0) -> > sh =3D is_contiguous(self.thismask) # -1 > output(ind, 'switch (', str_switch(self.thismask), ') {\n') > > with: > > def str_switch(b): > return 'insn & 0x{0:08x}'.format(b) > > So the fix is rather: > > -- >8 -- > diff --git a/scripts/decodetree.py b/scripts/decodetree.py > @@ -916,7 +916,7 @@ class Tree: > > def build_tree(pats, outerbits, outermask): > # Find the intersection of all remaining fixedmask. > - innermask =3D ~outermask > + innermask =3D ~outermask & insnmask > for i in pats: > innermask &=3D i.fixedmask > ---