qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Artyom Tarasenko <atar4qemu@googlemail.com>
Cc: blauwirbel@gmail.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] target-sparc: Simplify ICC generation; fix ADDX carry generation.
Date: Wed, 12 May 2010 10:08:25 -0700	[thread overview]
Message-ID: <4BEAE089.8010901@twiddle.net> (raw)
In-Reply-To: <AANLkTik1RtEoaqLDhINphl5d9EG-wNmj5k5MDOHPG6fj@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]

On 05/12/2010 08:18 AM, Artyom Tarasenko wrote:
> It is last year, but
>  3e6ba503400c34cbe0f9ad6e289921688bf303a3

>     The page 108 of the SPARC Version 8 Architecture Manual describes
>     that addcc and addxcc shall compute carry flag the same way.
>     The page 110 claims the same about subcc and subxcc instructions.
>     This patch fixes carry computation in corner cases and removes redundant cod
>     The most visible effect of the patch is enabling Solaris boot when using OBP

I'll contradict you right there by asserting that the manual
says no such thing about computing the carry flag "the same way".

What it says is:

p29:
# Carry is set on addition if there is a carry out of bit 31.
# Carry is set on subtraction if there is borrow into bit 31.

p108:
# ADDX and ADDXcc also add the PSR's carry (c) bit; that is
# they compute "r[rs1] + r[rs2] + c"...

How are the two computations "the same"?  First, it says that
carry is set if there is carry out.  Second, it says that there
is the extra addition of the (previous) C bit.  If there is an
extra addition, there must be an extra chance for carry, and
thus the carry flag *cannot* be computed in the same way.

Looking closely at the generation of the addx carry (with the
attached test program), I see that the original definition of
the ADDX carry, as still seen in the _xcc versions, does not
generate correct values, and your definition of the carry does.
However, that does not mean that we need to use your version
of the carry for plain ADD, only for ADDX.

I'll send a revised patch sequence shortly.


r~

[-- Attachment #2: z.c --]
[-- Type: text/x-csrc, Size: 1117 bytes --]

#include <stdio.h>


static inline int test_rolw(unsigned short *s)
{
  int i, start, end;
  asm volatile("rdtsc\n\t"
               "movl %%eax, %1\n\t"
               "movzwl %3,%2\n\t"
               "rolw $8, %w2\n\t"
               "addl $1,%2\n\t"
               "rdtsc"
               : "=&a"(end), "=r"(start), "=r"(i) : "m"(*s) : "edx");
  return end - start;
}

static inline int test_bswap(unsigned short *s)
{
  int i, start, end;
  asm volatile("rdtsc\n\t"
               "movl %%eax, %1\n\t"
               "movzwl %3,%2\n\t"
               "bswap %2\n\t"
               "shl $16,%2\n\t"
               "addl $1,%2\n\t"
               "rdtsc"
               : "=&a"(end), "=r"(start), "=r"(i) : "m"(*s) : "edx");
  return end - start;
}

#define N 10
int main()
{
  unsigned t_r[N], t_b[N];
  unsigned short s = 0;
  int i;

  for (i = 0; i < N; ++i)
    t_r[i] = test_rolw(&s);

  for (i = 0; i < N; ++i)
    t_b[i] = test_bswap(&s);

  printf("rolw\t");
  for (i = 0; i < N; ++i)
    printf("%5u", t_r[i]);
  printf("\nbswap\t");
  for (i = 0; i < N; ++i)
    printf("%5u", t_b[i]);
  printf("\n");
}

  reply	other threads:[~2010-05-12 17:08 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-10 22:23 [Qemu-devel] [PATCH 0/3] Fix ADDX compilation plus improvements Richard Henderson
2010-05-10 22:23 ` [Qemu-devel] [PATCH 1/3] target-sparc: Fix compilation with --enable-debug Richard Henderson
2010-05-10 22:23 ` [Qemu-devel] [PATCH 2/3] target-sparc: Simplify ICC generation; fix ADDX carry generation Richard Henderson
2010-05-11 19:14   ` [Qemu-devel] " Blue Swirl
2010-05-11 21:31   ` [Qemu-devel] " Artyom Tarasenko
2010-05-12 14:56     ` Richard Henderson
2010-05-12 15:18       ` Artyom Tarasenko
2010-05-12 17:08         ` Richard Henderson [this message]
2010-05-12 15:04     ` Richard Henderson
2010-05-10 22:23 ` [Qemu-devel] [PATCH 3/3] target-sparc: Inline some generation of carry for ADDX/SUBX Richard Henderson
2010-05-11 19:28   ` [Qemu-devel] " Blue Swirl
2010-05-12 14:48     ` Richard Henderson
2010-05-12 18:04 ` [Qemu-devel] [PATCH 0/3] Fix ADDX compilation plus improvements, v2 Richard Henderson
2010-05-12 18:04   ` [Qemu-devel] [PATCH 1/3] target-sparc: Fix compilation with --enable-debug Richard Henderson
2010-05-12 18:04   ` [Qemu-devel] [PATCH 2/3] target-sparc: Simplify ICC generation Richard Henderson
2010-05-14  9:04     ` [Qemu-devel] " Artyom Tarasenko
2010-05-12 18:04   ` [Qemu-devel] [PATCH 3/3] target-sparc: Inline some generation of carry for ADDX/SUBX Richard Henderson
2010-05-20 19:59     ` [Qemu-devel] " Blue Swirl

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=4BEAE089.8010901@twiddle.net \
    --to=rth@twiddle.net \
    --cc=atar4qemu@googlemail.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.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).