qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stuart Brady <sdb@zubnet.me.uk>
To: Richard Henderson <rth@twiddle.net>
Cc: blauwirbel@gmail.com, qemu-devel@nongnu.org, aurelien@aurel32.net
Subject: Re: [Qemu-devel] [PATCH 13/14] tcg-sparc: Fix 32-bit constant arguments tests
Date: Sat, 22 Mar 2014 09:48:44 +0000	[thread overview]
Message-ID: <20140322094844.GB12223@zubnet.me.uk> (raw)
In-Reply-To: <1395081476-6038-14-git-send-email-rth@twiddle.net>

On Mon, Mar 17, 2014 at 11:37:55AM -0700, Richard Henderson wrote:
> We need to discard garbage high bits before testing
> for 32-bit I and J constraints.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/sparc/tcg-target.c | 73 +++++++++++++++++++++++++++++---------------------
>  tcg/sparc/tcg-target.h |  4 ---
>  2 files changed, 43 insertions(+), 34 deletions(-)
> 
> diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c
> index 6498999..29d7a48 100644
> --- a/tcg/sparc/tcg-target.c
> +++ b/tcg/sparc/tcg-target.c
> @@ -89,6 +89,11 @@ static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = {
>  # define TCG_GUEST_BASE_REG TCG_REG_G0
>  #endif
>  
> +#define TCG_CT_CONST_S11  0x100
> +#define TCG_CT_CONST_S13  0x200
> +#define TCG_CT_CONST_ZERO 0x400
> +#define TCG_CT_CONST_IS32 0x800
> +
>  static const int tcg_target_reg_alloc_order[] = {
>      TCG_REG_L0,
>      TCG_REG_L1,
> @@ -357,6 +362,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str)
>      case 'Z':
>          ct->ct |= TCG_CT_CONST_ZERO;
>          break;
> +    case 'w':
> +        ct->ct |= TCG_CT_CONST_IS32;
> +        break;

It might be neater just to expose ts->type to tcg_target_const_match(),
which the TCG target can just ignore if it wants, but that might not
belong in this series, as this seems to affect PPC64 and IA64 too.

>      default:
>          return -1;
>      }
> @@ -373,7 +381,12 @@ static inline int tcg_target_const_match(tcg_target_long val,
>  
>      if (ct & TCG_CT_CONST) {
>          return 1;
> -    } else if ((ct & TCG_CT_CONST_ZERO) && val == 0) {
> +    }
> +    if (ct & TCG_CT_CONST_IS32) {
> +        val = (int32_t)val;
> +    }
> +
> +    if ((ct & TCG_CT_CONST_ZERO) && val == 0) {
>          return 1;
>      } else if ((ct & TCG_CT_CONST_S11) && check_fit_tl(val, 11)) {
>          return 1;
> @@ -679,7 +692,7 @@ static void tcg_out_setcond_i32(TCGContext *s, TCGCond cond, TCGReg ret,
>             swap the operands on GTU/LEU.  There's no benefit to loading
>             the constant into a temporary register.  */
>          if (!c2const || c2 == 0) {
> -            TCGArg t = c1;
> +            TCGReg t = c1;

I guess this was meant for 11/14?

>              c1 = c2;
>              c2 = t;
>              c2const = 0;
> @@ -1391,32 +1404,32 @@ static const TCGTargetOpDef sparc_op_defs[] = {
>      { INDEX_op_st16_i32, { "rZ", "r" } },
>      { INDEX_op_st_i32, { "rZ", "r" } },
>  
> -    { INDEX_op_add_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_mul_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_div_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_divu_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_sub_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_and_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_andc_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_or_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_orc_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_xor_i32, { "r", "rZ", "rJ" } },
> -
> -    { INDEX_op_shl_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_shr_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_sar_i32, { "r", "rZ", "rJ" } },
> -
> -    { INDEX_op_neg_i32, { "r", "rJ" } },
> -    { INDEX_op_not_i32, { "r", "rJ" } },
> -
> -    { INDEX_op_brcond_i32, { "rZ", "rJ" } },
> -    { INDEX_op_setcond_i32, { "r", "rZ", "rJ" } },
> -    { INDEX_op_movcond_i32, { "r", "rZ", "rJ", "rI", "0" } },
> -
> -    { INDEX_op_add2_i32, { "r", "r", "rZ", "rZ", "rJ", "rJ" } },
> -    { INDEX_op_sub2_i32, { "r", "r", "rZ", "rZ", "rJ", "rJ" } },
> -    { INDEX_op_mulu2_i32, { "r", "r", "rZ", "rJ" } },
> -    { INDEX_op_muls2_i32, { "r", "r", "rZ", "rJ" } },
> +    { INDEX_op_add_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_mul_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_div_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_divu_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_sub_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_and_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_andc_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_or_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_orc_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_xor_i32, { "r", "rZ", "rwJ" } },
> +
> +    { INDEX_op_shl_i32, { "r", "rZ", "ri" } },
> +    { INDEX_op_shr_i32, { "r", "rZ", "ri" } },
> +    { INDEX_op_sar_i32, { "r", "rZ", "ri" } },

Relaxation of the shift argument for shl/shr/sar seems fine, but it's not
mentioned in the description.

> +
> +    { INDEX_op_neg_i32, { "r", "r" } },
> +    { INDEX_op_not_i32, { "r", "r" } },

Right, constant folding deals with these... but likewise.

> +
> +    { INDEX_op_brcond_i32, { "rZ", "rwJ" } },
> +    { INDEX_op_setcond_i32, { "r", "rZ", "rwJ" } },
> +    { INDEX_op_movcond_i32, { "r", "rZ", "rwJ", "rwI", "0" } },
> +
> +    { INDEX_op_add2_i32, { "r", "r", "rZ", "rZ", "rwJ", "rwJ" } },
> +    { INDEX_op_sub2_i32, { "r", "r", "rZ", "rZ", "rwJ", "rwJ" } },
> +    { INDEX_op_mulu2_i32, { "r", "r", "rZ", "rwJ" } },
> +    { INDEX_op_muls2_i32, { "r", "r", "rZ", "rwJ" } },
>  
>      { INDEX_op_mov_i64, { "R", "R" } },
>      { INDEX_op_movi_i64, { "R" } },
> @@ -1447,8 +1460,8 @@ static const TCGTargetOpDef sparc_op_defs[] = {
>      { INDEX_op_shr_i64, { "R", "RZ", "RJ" } },
>      { INDEX_op_sar_i64, { "R", "RZ", "RJ" } },

As above.

>  
> -    { INDEX_op_neg_i64, { "R", "RJ" } },
> -    { INDEX_op_not_i64, { "R", "RJ" } },
> +    { INDEX_op_neg_i64, { "R", "R" } },
> +    { INDEX_op_not_i64, { "R", "R" } },

As above.

>  
>      { INDEX_op_ext32s_i64, { "R", "r" } },
>      { INDEX_op_ext32u_i64, { "R", "r" } },
> diff --git a/tcg/sparc/tcg-target.h b/tcg/sparc/tcg-target.h
> index 091224c..47fce69 100644
> --- a/tcg/sparc/tcg-target.h
> +++ b/tcg/sparc/tcg-target.h
> @@ -65,10 +65,6 @@ typedef enum {
>      TCG_REG_I7,
>  } TCGReg;
>  
> -#define TCG_CT_CONST_S11  0x100
> -#define TCG_CT_CONST_S13  0x200
> -#define TCG_CT_CONST_ZERO 0x400
> -
>  /* used for function call generation */
>  #define TCG_REG_CALL_STACK TCG_REG_O6
>  
> -- 
> 1.8.5.3
> 
> 
>  

Cheers,
Stuart

  reply	other threads:[~2014-03-22  9:49 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17 18:37 [Qemu-devel] [PATCH 00/14] tcg/sparc v8plus code generation Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 01/14] tcg: Fix missed pointer size != TCG_TARGET_REG_BITS changes Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 02/14] tcg: Add INDEX_op_trunc_i32 Richard Henderson
2014-03-21 23:35   ` Stuart Brady
2014-03-21 23:39     ` Stuart Brady
2014-03-17 18:37 ` [Qemu-devel] [PATCH 03/14] tcg-sparc: Remove most uses of TCG_TARGET_REG_BITS Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 04/14] tcg-sparc: Support trunc_i32 Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 05/14] tcg-sparc: Use 64-bit registers with sparcv8plus Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 06/14] tcg-sparc: Use the RETURN instruction Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 07/14] tcg-sparc: Implement muls2_i32 Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 08/14] tcg-sparc: Tidy check_fit_* tests Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 09/14] tcg-sparc: Don't handle mov/movi in tcg_out_op Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 10/14] tcg-sparc: Hoist common argument loads " Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 11/14] tcg-sparc: Fixup function argument types Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 12/14] tcg-sparc: Fix small 32-bit movi Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 13/14] tcg-sparc: Fix 32-bit constant arguments tests Richard Henderson
2014-03-22  9:48   ` Stuart Brady [this message]
2014-03-22 17:08     ` Richard Henderson
2014-03-17 18:37 ` [Qemu-devel] [PATCH 14/14] tcg-sparc: Accept stores of zero Richard Henderson

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=20140322094844.GB12223@zubnet.me.uk \
    --to=sdb@zubnet.me.uk \
    --cc=aurelien@aurel32.net \
    --cc=blauwirbel@gmail.com \
    --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 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).