On Thursday, July 23, 2015 at 9:51:14 PM UTC-4, Mouse wrote:
>
> On Jul 23, 2015, at 20:58 , Jeffrey Walton <[email protected]
> <javascript:>> wrote:
> > The issues with Clang's integrated assembler has got me thinking….
>
> Me too... :-)
>
OK, I've been thinking about this some more. I think the way to proceed is
to:
(1) continue down the {NASM|YASM|Favorite Assembler} path
(2) allow the quick/dirty inline assembly on one-liners (like rotate)
(3) begin moving assembly blocks out of C++ source files, and into *.S
source files
(4) invoke the assembler on the blocks of assembly code in the *.S file
With respect to (2), we don't want to loose the ability to have this in the
source code:
// Well defined if y in [0,31], non-constant time due to branch
template <class T> inline T rotlFixed(T x, unsigned int y)
{
static const unsigned int THIS_SIZE = sizeof(T)*8;
CRYPTOPP_ASSERT(y < THIS_SIZE);
return y ? T((x<<y) | (x>>(THIS_SIZE-y))) : x;
}
#if __GNUC__
template<> inline byte rotlFixed<byte>(byte x, unsigned int y)
{
// The I constraint ensures we use the immediate-8 variant of the
// rotate amount y. However, y must be in [0, 31] inclusive. We
// rely on the constant being propagated and the modular reduction
// being performed early so the assembler generates the instruction.
__asm__ ("rolb %1, %0" : "+mq" (x) : "I" ((unsigned char)(y%8)));
return x;
}
#endif
With respect to (3), depending on the platform interactions, we might
simply be duplicating code. That is, we might leave it in-place for
Windows, but move it to an S file for OS X.
It should avoid the problem with Apple's GAS, and side step the problem
with Clang's integrated assembler. And for those who choose to do nothing
(like not install NASM) it still works for them, albeit a little slower.
Any thought?
Jeff
--
--
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups
"Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.