Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@oss.sgi.com>
To: "Maciej W. Rozycki" <macro@ds2.pg.gda.pl>
Cc: Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>, linux-mips@oss.sgi.com
Subject: Re: sti() does not work.
Date: Sat, 14 Jul 2001 13:04:48 +0200	[thread overview]
Message-ID: <20010714130448.C6713@bacchus.dhis.org> (raw)
In-Reply-To: <Pine.GSO.3.96.1010713151359.3193D-100000@delta.ds2.pg.gda.pl>; from macro@ds2.pg.gda.pl on Fri, Jul 13, 2001 at 04:01:29PM +0200

On Fri, Jul 13, 2001 at 04:01:29PM +0200, Maciej W. Rozycki wrote:

>  Sure, but sometimes ".set reorder" allows you to achieve better
> optimization across various ISAs without a need to resort to the
> preprocessor.  Consider the following code: 
> 
> 	lw	$1,($2)
> 	addu	$3,$1
> 
> You need an instruction between the two for a MIPS I CPU but MIPS II+ CPUs
> interlock here if no instruction is placed.  Assuming no real instruction
> can be reordered here, a nop must be inserted if the code gets compiled
> for a MIPS I CPU but no instruction is preferred otherwise.  The assembler
> does it automatically if the ".set reorder" directive is active, but you
> need to decide yourself if it is not.
> 
>  Actually with mfc0 there is no problem -- you need a nop in the case like
> the above one as coprocessor transfers never interlock; at least docs
> state so.  But who believes docs without a grain of salt, so please
> correct me if I am wrong (I don't have appropriate hardware to perform a
> test). 

Real wild pig hackers on R3000 were writing code which knows that in the
load delay slot they still have the old register value available.  So you
can implement var1++; var2++ as:

	.set	noreorder
	lw	$reg, var1($gp)
	nop
	addiu	$reg, $reg, 1
	lw	$reg, var2($gp)
	sw	$reg, var1($gp)
	addiu	$reg, $reg, 1
	sw	$reg, var2($gp)

	.common	var1, 4, 4
	.common	var2, 4, 4

Of course only safe with interrupts disabled.  So in a sense introducing
the load interlock broke semantics of MIPS machine code ;-)

  Ralf

  reply	other threads:[~2001-07-14 11:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-03 22:48 sti() does not work Steven Liu
2001-07-03 22:48 ` Steven Liu
2001-07-04 10:23 ` Thiemo Seufer
2001-07-04 12:23   ` Gleb O. Raiko
2001-07-04 13:26   ` Ralf Baechle
2001-07-05 11:35     ` Maciej W. Rozycki
2001-07-13 11:35       ` Ralf Baechle
2001-07-13 14:01         ` Maciej W. Rozycki
2001-07-14 11:04           ` Ralf Baechle [this message]
2001-07-14 11:39             ` Kevin D. Kissell
2001-07-14 11:39               ` Kevin D. Kissell
2001-07-16 12:46             ` Maciej W. Rozycki
2001-07-04 13:29 ` Ralf Baechle

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=20010714130448.C6713@bacchus.dhis.org \
    --to=ralf@oss.sgi.com \
    --cc=ica2_ts@csv.ica.uni-stuttgart.de \
    --cc=linux-mips@oss.sgi.com \
    --cc=macro@ds2.pg.gda.pl \
    /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