9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Tim Newsham <newsham@lava.net>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: [9fans] assembler scheduling
Date: Fri,  5 Nov 2004 00:05:32 -1000	[thread overview]
Message-ID: <Pine.BSI.4.58.0411050001030.24294@malasada.lava.net> (raw)
In-Reply-To: <ACCF003CBA3D09458207DB0CB86AD17D2014AC@XMAIL.asuch.cas.cz>

Eek!  The assembler messed with my code.  Here's the original going
into ka.  Notice the *** line:

TEXT	syslink(SB), $-4
	MOVW	R2, R10
	MOVW	$setSB(SB), R2
	MOVW	$mach0(SB), R14
	MOVW	(4*2)(R14), R13		/* m->proc */
	MOVW	(4*2)(R13), R9		/* m->proc->kstack */
	MOVW	R1, (KSTACK-UREGSZ+4*1)(R9)	/* SP */
	MOVW	R10, (KSTACK-UREGSZ+4*2)(R9)	/* SB */
	MOVW	R5, (KSTACK-UREGSZ+4*5)(R9)	/* PROC */
	MOVW	R6, (KSTACK-UREGSZ+4*6)(R9)	/* MACH */
	ADD		$(KSTACK-UREGSZ), R9, R1
	MOVW	R13, R5
	MOVW	R14, R6

	MOVW	R2, (4*2)(R1)			/* SB */
	MOVW	R3, (4*3)(R1)			/* global register */
	MOVW	R4, (4*4)(R1)			/* global register */
	MOVW	R7, (4*7)(R1)			/* syscall # */
	MOVW	TBR, R20
	MOVW	R20, (4*(32+1))(R1)		/* TBR */
	AND		$~0x1F, R19
	MOVW	R19, (4*(32+2))(R1)		/* PSR */
	MOVW	R18, (4*(32+3))(R1)		/* nPC */
	MOVW	R17, (4*(32+4))(R1)		/* PC */
***	RESTORE	R0, R0
	/* now our registers R8-R31 are same as before trap */
	MOVW	R15, (4*15)(R1)

	MOVW	$setSB(SB), R2
	MOVW	R1, R7			/* pointer to Ureg */
	SUB		$8, R1
	MOVW	$SYSPSR, R8
	MOVW	R8, PSR
	JMPL	syscall(SB)
	/* R7 contains return value from syscall */

Got turned into:
syslink:                        or      %g0, %g2, %o2
syslink+0x4:                    sethi   %hi(0xe0071400), %sp
syslink+0x8:                    add     %sp, 0x128, %g2
syslink+0xc:                    ld      [%g2+0x46c], %sp
syslink+0x10:                   ld      [%sp+0x8], %o5
syslink+0x14:                   ld      [%o5+0x8], %o1
syslink+0x18:                   st      %g1, [%o1+0xf6c]
syslink+0x1c:                   st      %o2, [%o1+0xf70]
syslink+0x20:                   st      %g5, [%o1+0xf7c]
syslink+0x24:                   st      %g6, [%o1+0xf80]
syslink+0x28:                   add     %o1, 0xf68, %g1
syslink+0x2c:                   or      %g0, %o5, %g5
syslink+0x30:                   or      %g0, %sp, %g6
syslink+0x34:                   st      %g2, [%g1+0x8]
syslink+0x38:                   st      %g3, [%g1+0xc]
syslink+0x3c:                   st      %g4, [%g1+0x10]
syslink+0x40:                   st      %g7, [%g1+0x1c]
syslink+0x44:                   rd      %tbr, %l4
syslink+0x48:                   st      %l4, [%g1+0x84]
syslink+0x4c:                   and     %l3, 0xffffffe0, %l3
syslink+0x50:                   st      %l3, [%g1+0x88]
syslink+0x54:                   st      %l2, [%g1+0x8c]
syslink+0x58:                   st      %l1, [%g1+0x90]
syslink+0x5c:                   st      %o7, [%g1+0x3c]
syslink+0x60:                   sethi   %hi(0xe0071400), %sp
syslink+0x64:                   add     %sp, 0x128, %g2
syslink+0x68:                   or      %g0, %g1, %g7
syslink+0x6c:                   sub     %g1, 0x8, %g1
syslink+0x70:                   sethi   %hi(0x1c00), %sp
syslink+0x74:                   add     %sp, 0x3a0, %o0
syslink+0x78:                   wr      %o0, 0x0, %psr
syslink+0x7c:                   call    p9:syscall
syslink+0x80:       ***         restore %g0, %g0, %g0
syslink+0x84:                   add     %g1, 0x8, %g1
syslink+0x88:                   ld      [%g1+0x88], %o0

Notice it moved the RESTORE instruction into the delay slot of the
call.  In this case this causes bad things to happen, since RESTORE
changes the registers (I guess since ka doesn't use windows it is
unaware of this special meaning of restore).

How can I override this scheduling of the RESTORE instruction?
(I'd prefer to let it continue to schedule other statements and
not completely turn of scheduling).

Tim N.


  reply	other threads:[~2004-11-05 10:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-05  9:48 [9fans] replica problem cej
2004-11-05 10:05 ` Tim Newsham [this message]
2004-11-05 11:41   ` [9fans] assembler scheduling Charles Forsyth

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=Pine.BSI.4.58.0411050001030.24294@malasada.lava.net \
    --to=newsham@lava.net \
    --cc=9fans@cse.psu.edu \
    /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).