Re: [RFC/PATCH] Optimized PowerPC SHA1 generation for Darwin (OS X)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Arjen Laarhoven <arjen@...>
Cc: Git Mailing List <git@...>
Date: Friday, April 6, 2007 - 9:40 pm

On Sat, 7 Apr 2007, Arjen Laarhoven wrote:

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 */
 
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [RFC/PATCH] Optimized PowerPC SHA1 generation for Darwin..., Linus Torvalds, (Fri Apr 6, 9:40 pm)