9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Aram Hăvărneanu" <aram.h@mgk.ro>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>,
	Brantley Coile <brantley@coraid.com>
Subject: Re: [9fans] FP register usage in Plan9 assembler
Date: Thu,  4 Feb 2016 15:05:16 +0100	[thread overview]
Message-ID: <CAEAzY3_KUqnDZBL16n1pHbStpeLMxC-SsiLkGBmLkYQSxDHCVA@mail.gmail.com> (raw)
In-Reply-To: <A8CE1CB7-AA9C-4D15-9E04-34B5675581D9@me.com>

Brantley Coile <brantleycoile@me.com> wrote:
> Which plan 9 assembler uses right to left argument assignments,
> or compare argument order?

The CMP order is different (at least) between power and arm64. This
inconsistency is impossible to fix; I know because I tried to fix
it in the SPARC64 Go port.

The problem is that different architectures treat immediate constants
either as the first, or the second argument. For non-commutative
operations like subtractions, this matters.

However, in Plan 9, for three-argument instructions, we want to
have a two argument variant that works like this:

    OP      one, two -> OP    one, two, two

That is, the last argument is doubled, and serves as the (Plan 9)
second operand.

However, this means immediates must come first, because

    OP      $imm, R -> OP   $imm, R, R

makes sense, but

    OP      R, $imm, $imm

doesn't; $imm can't serve as destination.

So this forces immediates in Plan 9 assembly to be the first operands,
even though the machine might treat them as the first, or second
operands.

One might be tempted to allow immediates as second operands, and
simply forbit an instruction of the form "OP   R, $imm", mandating
one should always use the three-operand form "OP Rs, $imm, Rd".
Indeed this was what I did with the SPARC64 Go port. However, this
makes the compiler significantly more complex, and different, so
it's not a good idea.

As for instructions with different data flow order, atomic instructions
on ARM64 come to mind. Note that printing is still in "from, reg,
from3, to" order, so printing these instructions (7a -S) will print
something different than the input. This has been fixed in Go.

-- 
Aram Hăvărneanu



  parent reply	other threads:[~2016-02-04 14:05 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-01 16:47 Giacomo Tesio
2016-02-01 22:38 ` Charles Forsyth
2016-02-01 22:44   ` Charles Forsyth
2016-02-01 22:48 ` cinap_lenrek
2016-02-01 23:34   ` Giacomo Tesio
2016-02-02  0:36     ` Charles Forsyth
2016-02-02  0:58       ` Giacomo Tesio
2016-02-02 12:39         ` Aram Hăvărneanu
2016-02-02 16:42 ` Steven Stallion
2016-02-02 17:16   ` lucio
2016-02-03 15:24   ` erik quanstrom
2016-02-03 15:51     ` Steven Stallion
2016-02-03 16:36       ` erik quanstrom
2016-02-04 10:08     ` Aram Hăvărneanu
2016-02-04 12:04       ` lucio
2016-02-04 15:58         ` Ryan Gonzalez
2016-02-04 16:09           ` lucio
2016-02-04 18:06             ` Ryan Gonzalez
2016-02-04 18:14               ` balaji
2016-02-04 18:28             ` Ryan Gonzalez
2016-02-04 19:31           ` Skip Tavakkolian
2016-02-04 12:24       ` Brantley Coile
2016-02-04 12:53         ` lucio
2016-02-04 14:57           ` erik quanstrom
2016-02-04 14:05         ` Aram Hăvărneanu [this message]
2016-02-04 14:10           ` Aram Hăvărneanu
2016-02-04 14:30             ` Aram Hăvărneanu
2016-02-04 15:07         ` Charles Forsyth
2016-02-04 15:16           ` erik quanstrom
2016-02-04 15:11         ` erik quanstrom
2016-02-04 15:22           ` erik quanstrom
2016-02-04 15:26             ` Charles Forsyth
2016-02-04 20:34               ` erik quanstrom

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=CAEAzY3_KUqnDZBL16n1pHbStpeLMxC-SsiLkGBmLkYQSxDHCVA@mail.gmail.com \
    --to=aram.h@mgk.ro \
    --cc=9fans@9fans.net \
    --cc=brantley@coraid.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 NNTP newsgroup(s).