From: Richard Henderson <rth@twiddle.net>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Andreas Schwab <schwab@linux-m68k.org>,
gerg@uclinux.org
Subject: Re: [Qemu-devel] [PATCH for-2.5 00/30] 680x0 instructions emulation
Date: Wed, 12 Aug 2015 19:22:24 -0700 [thread overview]
Message-ID: <55CBFF60.7050107@twiddle.net> (raw)
In-Reply-To: <1439151229-27747-1-git-send-email-laurent@vivier.eu>
On 08/09/2015 01:13 PM, Laurent Vivier wrote:
> m68k: allow to update flags with operation on words and bytes
> m68k: update CPU flags management
> m68k: add X flag helpers
I wonder if we can talk about a different mechanism for tracking flags.
The x86 scheme tracks flags with 3 words: { op, dest, src }. This is easy to
handle arithmetic, logicals, and comparisons. But shifts and other weird
things require complex helpers.
The m68k scheme, which you're enhancing, is the same, except with an additional
word for X. It's this extra X flag that complicates things.
The arm scheme tracks 4 flags with 4 individual words. This is more
complicated for arithmetic (especially computing overflow), but it rarely
requires complicated helpers.
I propose using a hybrid between the two, using 6 words: { op, c, v, z, n, x }.
op = OP_FLAGS (i.e. fully computed state)
X = cc_x is 0/1
C = cc_c is 0/1
V = cc_v < 0
N = cc_n < 0
Z = cc_z == 0
op = OP_ADD
X = C = cc_x is 0/1
cc_n = result
cc_v = src1
cc_c = unused
cc_z = unused
N = cc_n < 0
Z = cc_n == 0
V = ((result ^ src1) & ~((result - src1) ^ src1)) < 0
op = OP_SUB
like OP_ADD, except
V = ((result ^ src1) & (src1 ^ (src1 - result))) < 0
op = OP_LOGIC
X = cc_x is 0/1
C = 0
V = 0
cc_n = result
N = cc_n < 0
Z = cc_n == 0
All of the byte and word variants are handled by sign-extending the quantities.
This keeps X up-to-date at all times. It minimizes the amount to data that
needs to be synced back to env before memory operations. It leaves enough data
to easily compute signed comparisons.
The more complicated cases of addx and shifts, now simply operate in OP_FLAGS
mode and don't require helpers.
I'll follow up with some patches...
r~
prev parent reply other threads:[~2015-08-13 2:22 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-09 20:13 [Qemu-devel] [PATCH for-2.5 00/30] 680x0 instructions emulation Laurent Vivier
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 01/30] m68k: define m680x0 CPUs and features Laurent Vivier
2015-08-11 23:13 ` Richard Henderson
2015-08-12 8:01 ` Laurent Vivier
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 02/30] m68k: manage scaled index Laurent Vivier
2015-08-12 3:42 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 03/30] m68k: introduce read_imXX() functions Laurent Vivier
2015-08-09 21:12 ` Andreas Schwab
2015-08-12 3:54 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 04/30] m68k: set disassembler mode to 680x0 or coldfire Laurent Vivier
2015-08-12 3:57 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 05/30] m68k: define operand sizes Laurent Vivier
2015-08-12 4:07 ` Richard Henderson
2015-08-12 8:44 ` Laurent Vivier
2015-08-12 8:52 ` Andreas Schwab
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 06/30] m68k: REG() macro cleanup Laurent Vivier
2015-08-12 4:11 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 07/30] m68k: allow to update flags with operation on words and bytes Laurent Vivier
2015-08-12 4:28 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 08/30] m68k: update CPU flags management Laurent Vivier
2015-08-12 5:12 ` Richard Henderson
2015-08-12 20:56 ` Laurent Vivier
2015-08-12 21:19 ` Richard Henderson
2015-08-12 21:21 ` Laurent Vivier
2015-08-13 18:09 ` Laurent Vivier
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 09/30] m68k: add X flag helpers Laurent Vivier
2015-08-12 5:18 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 10/30] m68k: tst bugfix Laurent Vivier
2015-08-12 5:18 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 11/30] m68k: improve clr/moveq Laurent Vivier
2015-08-12 5:20 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 12/30] m68k: Manage divw overflow Laurent Vivier
2015-08-12 6:03 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 13/30] m68k: set Z and N on divu/muls overflow as a real 68040 Laurent Vivier
2015-08-12 6:29 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 14/30] m68k: allow adda/suba to add/sub word Laurent Vivier
2015-08-12 7:32 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 15/30] m68k: add more modes to movem Laurent Vivier
2015-08-12 7:54 ` Richard Henderson
2015-08-12 8:07 ` Andreas Schwab
2015-08-12 15:13 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 16/30] m68k: Add all access modes and data sizes to some 680x0 instructions Laurent Vivier
2015-08-12 16:25 ` Richard Henderson
2015-08-12 16:27 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 17/30] m68k: ori/andi/subi/addi/eori/cmpi can modify SR/CCR Laurent Vivier
2015-08-12 16:44 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 18/30] m68k: addq/subq can work with all the data sizes Laurent Vivier
2015-08-12 16:48 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 19/30] m68k: add cmpm Laurent Vivier
2015-08-12 17:00 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 20/30] m68k: add exg Laurent Vivier
2015-08-12 17:05 ` Richard Henderson
2015-08-12 22:43 ` Laurent Vivier
2015-08-12 23:09 ` Richard Henderson
2015-08-12 23:10 ` Laurent Vivier
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 21/30] m68k: add bkpt Laurent Vivier
2015-08-12 17:07 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 22/30] m68k: add cas instruction Laurent Vivier
2015-08-12 17:14 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 23/30] m68k: add linkl Laurent Vivier
2015-08-12 17:33 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 24/30] m68k: add DBcc and Scc (memory operand) Laurent Vivier
2015-08-12 17:49 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 25/30] m68k: add abcd, sbcd, nbcd instructions Laurent Vivier
2015-08-12 17:57 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 26/30] m68k: add mull/divl Laurent Vivier
2015-08-12 18:36 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 27/30] m68k: add addx/subx/negx Laurent Vivier
2015-08-12 18:46 ` Richard Henderson
2015-08-13 0:11 ` Laurent Vivier
2015-08-13 2:23 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 28/30] m68k: shift/rotate bytes and words Laurent Vivier
2015-08-12 19:11 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 29/30] m68k: add rol/rox/ror/roxr Laurent Vivier
2015-08-12 19:40 ` Richard Henderson
2015-08-09 20:13 ` [Qemu-devel] [PATCH for-2.5 30/30] m68k: add bitfield instructions Laurent Vivier
2015-08-12 21:05 ` Richard Henderson
2015-08-13 2:22 ` Richard Henderson [this message]
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=55CBFF60.7050107@twiddle.net \
--to=rth@twiddle.net \
--cc=gerg@uclinux.org \
--cc=laurent@vivier.eu \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=schwab@linux-m68k.org \
/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).