Dan McDonald (danmcd@Eng.Sun.COM)
Mon, 5 Oct 1998 09:19:31 -0700 (PDT)
<SNIP!>
> most modern CPUs provide single instructions that accomplish
> these operations.
Bzzzzt. Wrong. One of the "reductions" in RISC was to eliminate the
explicit rotate instruction. Back then, people thought that rotates were
fairly uncommon. Back then, people didn't think crypto had everyday uses,
either.
SPARC has no rotate instruction, and neither does MIPS or PowerPC. Instead,
it requires two shifts, an OR, and a scratch register. Good thing SPARC and
these others have 24+ to play with. (I say 24+, because you may get more,
depending on calling conventions, and if you're a leaf routine or not.)
> Can someone tell me how best to write a C function (that can be "inlined")
> that invokes the appropriate assembly language instruction??
>
> The platform I am working on is Sun/64-bit/Ultra/Unix/Solaris 2.6
Which compiler? The GCC folks have already come out of the woodwork, so I
won't repeat their hints here.
> In particular, how do you invoke an assembley language instruction
> and cause it to operate on the appropriate registers that correspond
> to specific local variables in your C program???
For Sun's DevPro compilers, you need to generate a .il file, and compile it
in. RTFM on "inline"; you may need to rewhack your MANPATH or use -M.
(e.g. "man -M /opt/SUNWspro/man inline".)
And also, make sure you turn on -xO3 when compiling with inlines, so register
usage can be optimized.
EXERCISE: Find a real use for .il files. There are plenty, but I
don't want to spoil your fun. :) An answer will appear
in the upcoming Solaris release. We have a kernel
implementation of a well-known algorithm that uses an
UltraSPARC trick for better performance.
Dan
The following archive was created by hippie-mail 7.98617-22 on Sat Apr 10 1999 - 01:15:19