public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Michael Meissner <meissner@linux.ibm.com>,
	gcc-patches@gcc.gnu.org,        dje.gcc@gmail.com
Subject: Re: [PATCH, V3, #3 of 10], Add prefixed RTL insn attribute
Date: Fri, 30 Aug 2019 01:58:00 -0000	[thread overview]
Message-ID: <20190829224454.GN31406@gate.crashing.org> (raw)
In-Reply-To: <20190826203102.GC11790@ibm-toto.the-meissners.org>

Hi Mike,

On Mon, Aug 26, 2019 at 04:31:02PM -0400, Michael Meissner wrote:
> 	(rs6000_asm_output_opcode): New function for prifixed memory.

Typo.  Just say "New." or "New function." please.

> --- gcc/config/rs6000/rs6000.c	(revision 274871)
> +++ gcc/config/rs6000/rs6000.c	(working copy)
> @@ -13827,23 +13827,23 @@ addr_mask_to_trad_insn (machine_mode mod
>       early RTL stages before register allocation has been done.  */
>    if ((addr_mask & flags) == RELOAD_REG_MULTIPLE)
>      {
> -      machine_mode inner = word_mode;
> +      machine_mode mode2 = mode;

So what is "mode2" for?  A meaningful name and/or some comments would help.

> +	  if ((reg_addr[E_DFmode].default_addr_mask & RELOAD_REG_OFFSET) != 0)
> +	    mode = DFmode;

(Don't use E_ if you do not need it -- i.e. most of the time).

> +/* Helper function to take a REG and a MODE and turn it into the traditional
> +   instruction format (D/DS/DQ) used for offset memory.  */

Is this the form of the preferred insn to do this?  Or ths minimum required
to do it at all?  Something else?

> +  /* If it isn't a register, use the defaults.  */
> +  if (!REG_P (reg) && !SUBREG_P (reg))
> +    addr_mask = reg_addr[mode].default_addr_mask;
> +
> +  else
> +    {
> +      unsigned int r = reg_or_subregno (reg);

This ICEs if it is a subreg of something else than a reg.

You can just start with

  if (SUBREG_P (reg))
    reg = SUBREG_REG (reg);

  if (REG_P (reg))
   ... etc.

> +/* Whether a load instruction is a prefixed instruction.  This is called from
> +   the prefixed attribute processing.  */
> +
> +bool
> +prefixed_load_p (rtx_insn *insn)
> +{
> +  /* Validate the insn to make sure it is a normal load insn.  */
> +  extract_insn_cached (insn);
> +  if (recog_data.n_operands < 2)
> +    return false;

Why don't you handle this the same way "indexed" and "update" are already
handled?  That is *easy* and it *works*, it trivially verifiably works.
It also doesn't care whether something is a load or a store.  You hardcode
the few exceptions (okay, twenty or whatever update insns -- but all are
similar, so that is easy), and everything else just works.

The way you code it you just hope to exclude all of the exceptions,
instead of handling them directly.

> +void
> +rs6000_asm_output_opcode (FILE *stream)
> +{
> +  if (next_insn_prefixed_p)
> +    fputc ('p', stream);
> +
> +  return;
> +}

You can just write fprintf fwiw, the compile can optimise it for you
just fine.

> +#define ASM_OUTPUT_OPCODE(STREAM, OPCODE)				\
> +  do									\
> +    {									\
> +     if (TARGET_PREFIXED_ADDR)						\
> +       rs6000_asm_output_opcode (STREAM);				\
> +    }									\
> +  while (0)

(Indentation of the "if" is weird?)

> +;; Whether an insn is a prefixed insn, and an initial 'p' should be printed
> +;; before the instruction.  A prefixed instruction has a prefix instruction

Whether it is a prefixed insn, period.

> +;; word that extends the immediate value of the instructions from 12-16 bits to
> +;; 34 bits.  The macro ASM_OUTPUT_OPCODE emits a leading 'p' for prefixed
> +;; insns.  The default "length" attribute will also be adjusted by default to
> +;; be 12 bytes.

Don't say all the effects here, say that where you make it happen?

> +;; Length in bytes of instructions that use prefixed addressing and length in
> +;; bytes of instructions that does not use prefixed addressing.  This allows
> +;; both lengths to be defined as constants, and the length attribute can pick
> +;; the size as appropriate.
> +(define_attr "prefixed_length" "" (const_int 12))
> +(define_attr "non_prefixed_length" "" (const_int 4))

Do you mean a define_insn can override either to something else?  Then
say that, please?

> +;; Length of the instruction (in bytes).  Prefixed insns are 8 bytes, but the
> +;; assembler might issue need to issue a NOP so that the prefixed instruction
> +;; does not cross a cache boundary, which makes them possibly 12 bytes.

s/issue //

> @@ -9883,8 +9926,8 @@ (define_insn "pcrel_local_addr"
>    [(set (match_operand:DI 0 "gpc_reg_operand" "=b*r")
>  	(match_operand:DI 1 "pcrel_local_address"))]
>    "TARGET_PCREL"
> -  "pla %0,%a1"
> -  [(set_attr "length" "12")])
> +  "la %0,%a1"
> +  [(set_attr "prefixed" "yes")])

And just like this you can set the few insns that do not have operands 0
and 1 as source and dest to "no", exactly like is already done for "update"
and "indexed".


Segher

  reply	other threads:[~2019-08-29 22:44 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-26 19:21 PowerPC future machine, version 3 Michael Meissner
2019-08-26 20:41 ` [PATCH V3, #1 of 10], Add basic pc-relative support Michael Meissner
2019-08-28 18:46   ` Segher Boessenkool
2019-08-28 21:48     ` Michael Meissner
2019-08-30  0:08       ` Segher Boessenkool
2019-09-06  0:18         ` Michael Meissner
2019-09-06 12:50           ` Segher Boessenkool
2019-09-09 20:28             ` Michael Meissner
2019-08-26 21:07 ` [PATCH, V3, #3 of 10], Add prefixed RTL insn attribute Michael Meissner
2019-08-30  1:58   ` Segher Boessenkool [this message]
2019-08-26 21:12 ` [PATCH, V3, #2 of 10], Improve rs6000_setup_addr_mask Michael Meissner
2019-08-29  2:59   ` Segher Boessenkool
2019-08-26 21:23 ` [PATCH, V3, #4 of 10], Add general prefixed/pcrel support Michael Meissner
2019-08-30 19:22   ` Segher Boessenkool
2019-08-31  3:08     ` Alan Modra
2019-08-31 14:13       ` Segher Boessenkool
2019-08-26 21:43 ` [PATCH, V3, #5 of 10], Make -mpcrel default on little endian Linux systems Michael Meissner
2019-08-30 19:46   ` Segher Boessenkool
2019-09-03 21:07     ` Michael Meissner
2019-09-03 22:25       ` Segher Boessenkool
2019-08-26 21:52 ` [PATCH, V3, #6 of 10], Fix vec_extract breakage Michael Meissner
2019-09-03 19:49   ` Segher Boessenkool
2019-09-05 20:48     ` Michael Meissner
2019-09-05 22:38       ` Segher Boessenkool
2019-09-06 10:26         ` Segher Boessenkool
2019-08-26 22:06 ` [PATCH, V3, #7 of 10], Implement PCREL_OPT relocation optimization Michael Meissner
2019-08-28 21:48   ` Michael Meissner
2019-09-03 22:56   ` Segher Boessenkool
2019-09-03 23:20     ` Michael Meissner
2019-09-03 23:33       ` Segher Boessenkool
2019-09-04 17:26         ` Michael Meissner
2019-09-06 12:09           ` Segher Boessenkool
2019-09-09 20:32             ` Michael Meissner
2019-09-09 20:56               ` Segher Boessenkool
2019-09-09 22:39                 ` Michael Meissner
2019-08-27  7:01 ` [PATCH, V3, #8 of 10], Miscellaneous prefixed addressing tests Michael Meissner
2019-09-03 23:17   ` Segher Boessenkool
2019-09-05 21:01     ` Michael Meissner
2019-09-05 22:57       ` Segher Boessenkool
2019-08-27  7:14 ` [PATCH, V3, #10 of #10], Pc-relative tests Michael Meissner
2019-08-27  7:55 ` [PATCH, V3, #9 of 10], Prefixed addressing tests with large offsets Michael Meissner
2019-09-03 23:22   ` Segher Boessenkool

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=20190829224454.GN31406@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=meissner@linux.ibm.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).