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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]