public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Mohamed Shafi" <shafitvm@gmail.com>
To: GCC <gcc@gcc.gnu.org>
Subject: How to insert nops
Date: Thu, 05 Jun 2008 05:20:00 -0000	[thread overview]
Message-ID: <ba0bd44d0806042219h627fc9a1q2a5e8b60f1a54575@mail.gmail.com> (raw)

Hello all,

For the big endian 16bit target that i am porting to gcc 4.1.2 a nop
is needed after a load instruction if the destination register of the
load instruction is used as the source in the next instruction. So

load R0, R3[2]
add R2, R0

needs a nop inserted in between the instructions. I have issues when
the operation is that of 32bit data types. The target doesn't have any
32bit instructions. All the 32bit move instructions are split after
reload. The following is an example where i am having issues

(set (reg:HI 2 R2)
        (mem/s:HI (reg/f:HI 8 R8)

(set (reg:HI 3 R3)
        (mem/s:HI (plus:HI (reg/f:HI 8 R8)
                       (const_int 2 [0x2]))

(set (reg:SI 0 R0)
        (minus:SI (reg:SI 0 R0)
                       (reg:SI 2 R2)))


load R2, R8
load R3, R8[2]
sub R1, R3
subc R0, R2

For the above case no nop inserted. But because of the endianess src
reg gets used in the next instructions. How do i solve this?
I do nop insertion in reorg pass where i first do delay slot
scheduling. The follwoing is what i have in reorg() for nop insertion

          attr = get_attr_type (insn);
          if (next_insn && attr == TYPE_LOAD) {
              if (insn_true_dependent_p (insn, next_insn))
                emit_insn_after (gen_nop (), insn);
            }

........

static bool
insn_true_dependent_p (rtx x, rtx y)
{
  rtx tmp;

  if (! INSN_P (x) || ! INSN_P (y))
    return 0;

  tmp = PATTERN (y);
  note_stores (PATTERN (x), insn_dependent_p_1, &tmp);
  return (tmp == NULL_RTX);
}

static void
insn_dependent_p_1 (rtx x, rtx pat ATTRIBUTE_UNUSED, void *data)
{
  rtx * pinsn = (rtx *) data;

  if (*pinsn && reg_mentioned_p (x, *pinsn))
    *pinsn = NULL_RTX;
}


I think apart from the above cases i will also have cases where nop
gets inserted when it's not really required.
How will it be possible to solve this issue?

Regards,
Shafi

                 reply	other threads:[~2008-06-05  5:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=ba0bd44d0806042219h627fc9a1q2a5e8b60f1a54575@mail.gmail.com \
    --to=shafitvm@gmail.com \
    --cc=gcc@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).