From: Linus Torvalds <torvalds@linux-foundation.org>
To: Arjen Laarhoven <arjen@yaph.org>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [RFC/PATCH] Optimized PowerPC SHA1 generation for Darwin (OS X)
Date: Fri, 6 Apr 2007 18:40:53 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0704061830350.6730@woody.linux-foundation.org> (raw)
In-Reply-To: <20070406234826.GG3854@regex.yaph.org>
On Sat, 7 Apr 2007, Arjen Laarhoven wrote:
>
> The compiler toolchain supplied by Apple's Xcode environment has an old
> version (1.38) of the GNU assembler. It cannot assemble the optimized
> ppc/sha1ppc.S file. ppc/sha1ppc.S was rewritten into a Perl script
> which outputs the same code, but valid for the Xcode assembler.
Ugh. That's just too ugly.
The Linux version of the GNU assembler can certainly take the same limited
input as the old Apple one.
So how about instea dof having two totally different versions of this
file, just having *one*, and having a pre-processor that turns it into
something that is acceptable to both?
And yes, it could be your perl script, except your perl script is ugly as
*hell*. The old C preprocessor code is much nicer than your perl script
that does "print" statements.
How about something like the following instead?
(a) make the register macros expand to something easily
greppable/parseable
(b) have a *separate* preprocessor phase that actually then takes that
pattern, and evaluates it to a numeric value.
(c) assemble the end result
The (a) part is trivial. Just a patch like the appended will make sure
that all the registers are now written as "REG[int-expression]", and then
all you need is a perl-script or something that can trigger on the regexp
"REG\[\([^]]*\)\]"
and replace that regex with
"%eval(\1)"
which is somethign that perl should be designed for.
That way you just have *one* source file (the "sha1ppc.S" one), which is
readable, and a simple script to then evaluate the register numbers
statically instead of expecting that the assembler can do it (since the
Apple one apparently cannot).
So it would just require somebody who knows perl. What's a one-liner perl
script to turn a line like
add REG[((0)+0)%5+6],REG[((0)+0)%5+6],REG[(0)%16+11];
into
add %6,%6,%11
(ie it just evaluated the expression inside the [] things, and replaced it
with the "%<num>" string)?
<Taunting mode>Or maybe perl can't do that in a single line!</Taunting mode>
Linus
---
diff --git a/ppc/sha1ppc.S b/ppc/sha1ppc.S
index f132696..cc554a4 100644
--- a/ppc/sha1ppc.S
+++ b/ppc/sha1ppc.S
@@ -32,14 +32,14 @@
* We use registers 6 - 10 for this. (Registers 27 - 31 hold
* the previous values.)
*/
-#define RA(t) (((t)+4)%5+6)
-#define RB(t) (((t)+3)%5+6)
-#define RC(t) (((t)+2)%5+6)
-#define RD(t) (((t)+1)%5+6)
-#define RE(t) (((t)+0)%5+6)
+#define RA(t) REG[((t)+4)%5+6]
+#define RB(t) REG[((t)+3)%5+6]
+#define RC(t) REG[((t)+2)%5+6]
+#define RD(t) REG[((t)+1)%5+6]
+#define RE(t) REG[((t)+0)%5+6]
/* We use registers 11 - 26 for the W values */
-#define W(t) ((t)%16+11)
+#define W(t) REG[(t)%16+11]
/* Register 5 is used for the constant k */
next prev parent reply other threads:[~2007-04-07 1:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-06 23:48 [RFC/PATCH] Optimized PowerPC SHA1 generation for Darwin (OS X) Arjen Laarhoven
2007-04-07 0:47 ` Junio C Hamano
2007-04-07 1:40 ` Linus Torvalds [this message]
2007-04-08 20:09 ` Arjen Laarhoven
2007-04-10 9:48 ` Karl Hasselström
2007-04-10 11:45 ` Arjen Laarhoven
2007-04-10 13:00 ` Karl Hasselström
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.LNX.4.64.0704061830350.6730@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=arjen@yaph.org \
--cc=git@vger.kernel.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 NNTP newsgroup(s).