All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: Aurelien Jarno <aurelien@aurel32.net>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v3 2/7] target/m68k: add fmovecr
Date: Tue, 27 Jun 2017 18:04:15 -0300	[thread overview]
Message-ID: <9fa0ca46-7751-bad7-a18a-c74d9b33c996@amsat.org> (raw)
In-Reply-To: <20170627191221.31650-3-laurent@vivier.eu>

On 06/27/2017 04:12 PM, Laurent Vivier wrote:
> fmovecr moves a floating point constant from the
> FPU ROM to a floating point register.
> 
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> Reviewed-by: Richard Henderson <rth@twiddle.net>
> ---
>   target/m68k/fpu_helper.c | 30 ++++++++++++++++++++++++++++++
>   target/m68k/helper.h     |  1 +
>   target/m68k/translate.c  | 13 ++++++++++++-
>   3 files changed, 43 insertions(+), 1 deletion(-)
> 
> diff --git a/target/m68k/fpu_helper.c b/target/m68k/fpu_helper.c
> index a9e17f5..912c0b7 100644
> --- a/target/m68k/fpu_helper.c
> +++ b/target/m68k/fpu_helper.c
> @@ -23,6 +23,31 @@
>   #include "exec/helper-proto.h"
>   #include "exec/exec-all.h"
>   
> +static const floatx80 fpu_rom[128] = {

"The values contained at offsets other than those defined above are
reserved for the use of Motorola and may be different on various mask
sets of the floating-point coprocessor. These undefined values yield the
value 0.0 [ floatx80_zero ] in the M68040FPSP."

^ with a such comment around:

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> +    [0x00] = floatx80_pi,                                   /* Pi */
> +    [0x0b] = make_floatx80(0x3ffd, 0x9a209a84fbcff798ULL),  /* Log10(2) */
> +    [0x0c] = make_floatx80(0x4000, 0xadf85458a2bb4a9aULL),  /* e        */
> +    [0x0d] = make_floatx80(0x3fff, 0xb8aa3b295c17f0bcULL),  /* Log2(e)  */
> +    [0x0e] = make_floatx80(0x3ffd, 0xde5bd8a937287195ULL),  /* Log10(e) */
> +    [0x0f] = floatx80_zero,                                 /* Zero     */
> +    [0x30] = floatx80_ln2,                                  /* ln(2)    */
> +    [0x31] = make_floatx80(0x4000, 0x935d8dddaaa8ac17ULL),  /* ln(10)   */
> +    [0x32] = floatx80_one,                                  /* 10^0     */
> +    [0x33] = make_floatx80(0x4002, 0xa000000000000000ULL),  /* 10^1     */
> +    [0x34] = make_floatx80(0x4005, 0xc800000000000000ULL),  /* 10^2     */
> +    [0x35] = make_floatx80(0x400c, 0x9c40000000000000ULL),  /* 10^4     */
> +    [0x36] = make_floatx80(0x4019, 0xbebc200000000000ULL),  /* 10^8     */
> +    [0x37] = make_floatx80(0x4034, 0x8e1bc9bf04000000ULL),  /* 10^16    */
> +    [0x38] = make_floatx80(0x4069, 0x9dc5ada82b70b59eULL),  /* 10^32    */
> +    [0x39] = make_floatx80(0x40d3, 0xc2781f49ffcfa6d5ULL),  /* 10^64    */
> +    [0x3a] = make_floatx80(0x41a8, 0x93ba47c980e98ce0ULL),  /* 10^128   */
> +    [0x3b] = make_floatx80(0x4351, 0xaa7eebfb9df9de8eULL),  /* 10^256   */
> +    [0x3c] = make_floatx80(0x46a3, 0xe319a0aea60e91c7ULL),  /* 10^512   */
> +    [0x3d] = make_floatx80(0x4d48, 0xc976758681750c17ULL),  /* 10^1024  */
> +    [0x3e] = make_floatx80(0x5a92, 0x9e8b3b5dc53d5de5ULL),  /* 10^2048  */
> +    [0x3f] = make_floatx80(0x7525, 0xc46052028a20979bULL),  /* 10^4096  */
> +};
> +
>   int32_t HELPER(reds32)(CPUM68KState *env, FPReg *val)
>   {
>       return floatx80_to_int32(val->d, &env->fp_status);
> @@ -204,3 +229,8 @@ void HELPER(ftst)(CPUM68KState *env, FPReg *val)
>       }
>       env->fpsr = (env->fpsr & ~FPSR_CC_MASK) | cc;
>   }
> +
> +void HELPER(fconst)(CPUM68KState *env, FPReg *val, uint32_t offset)
> +{
> +    val->d = fpu_rom[offset];
> +}
> diff --git a/target/m68k/helper.h b/target/m68k/helper.h
> index 98cbf18..d6e80e4 100644
> --- a/target/m68k/helper.h
> +++ b/target/m68k/helper.h
> @@ -35,6 +35,7 @@ DEF_HELPER_4(fdiv, void, env, fp, fp, fp)
>   DEF_HELPER_FLAGS_3(fcmp, TCG_CALL_NO_RWG, void, env, fp, fp)
>   DEF_HELPER_FLAGS_2(set_fpcr, TCG_CALL_NO_RWG, void, env, i32)
>   DEF_HELPER_FLAGS_2(ftst, TCG_CALL_NO_RWG, void, env, fp)
> +DEF_HELPER_3(fconst, void, env, fp, i32)
>   
>   DEF_HELPER_3(mac_move, void, env, i32, i32)
>   DEF_HELPER_3(macmulf, i64, env, i32, i32)
> diff --git a/target/m68k/translate.c b/target/m68k/translate.c
> index dff604c..0bb3300 100644
> --- a/target/m68k/translate.c
> +++ b/target/m68k/translate.c
> @@ -4518,10 +4518,21 @@ DISAS_INSN(fpu)
>       ext = read_im16(env, s);
>       opmode = ext & 0x7f;
>       switch ((ext >> 13) & 7) {
> -    case 0: case 2:
> +    case 0:
>           break;
>       case 1:
>           goto undef;
> +    case 2:
> +        if (insn == 0xf200 && (ext & 0xfc00) == 0x5c00) {
> +            /* fmovecr */
> +            TCGv rom_offset = tcg_const_i32(opmode);

you could reuse tmp32:

tmp32 = tcg_const_i32(opmode); /* rom offset */

but it's good like that ;)

> +            cpu_dest = gen_fp_ptr(REG(ext, 7));
> +            gen_helper_fconst(cpu_env, cpu_dest, rom_offset);
> +            tcg_temp_free_ptr(cpu_dest);
> +            tcg_temp_free(rom_offset);

Oh this was a leak in v2? I didn't notice.

> +            return;
> +        }
> +        break;
>       case 3: /* fmove out */
>           cpu_src = gen_fp_ptr(REG(ext, 7));
>           opsize = ext_opsize(ext, 10);
> 

  reply	other threads:[~2017-06-27 21:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-27 19:12 [Qemu-devel] [PATCH v3 0/7] target/m68k: implement 680x0 FPU (part 2) Laurent Vivier
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 1/7] target/m68k: add fscc Laurent Vivier
2017-06-27 20:00   ` Richard Henderson
2017-06-28  0:03     ` Laurent Vivier
2017-06-28 20:05     ` Laurent Vivier
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 2/7] target/m68k: add fmovecr Laurent Vivier
2017-06-27 21:04   ` Philippe Mathieu-Daudé [this message]
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 3/7] target/m68k: add explicit single and double precision operations Laurent Vivier
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 4/7] softfloat: define floatx80_round() Laurent Vivier
2017-06-27 20:15   ` Aurelien Jarno
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 5/7] target/m68k: add fsglmul and fsgldiv Laurent Vivier
2017-06-27 20:05   ` Richard Henderson
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 6/7] target/m68k: add explicit single and double precision operations (part 2) Laurent Vivier
2017-06-27 19:12 ` [Qemu-devel] [PATCH v3 7/7] target/m68k: add fmovem Laurent Vivier

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=9fa0ca46-7751-bad7-a18a-c74d9b33c996@amsat.org \
    --to=f4bug@amsat.org \
    --cc=aurelien@aurel32.net \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.