Botan  1.11.15
Public Member Functions | Static Public Member Functions
Botan::SIMD_Scalar< T, N > Class Template Reference

#include <simd_scalar.h>

List of all members.

Public Member Functions

SIMD_Scalar< T, N > andc (const SIMD_Scalar< T, N > &other)
SIMD_Scalar< T, N > bswap () const
SIMD_Scalar< T, N > operator& (const SIMD_Scalar< T, N > &other)
void operator&= (const SIMD_Scalar< T, N > &other)
SIMD_Scalar< T, N > operator+ (const SIMD_Scalar< T, N > &other) const
void operator+= (const SIMD_Scalar< T, N > &other)
SIMD_Scalar< T, N > operator- (const SIMD_Scalar< T, N > &other) const
void operator-= (const SIMD_Scalar< T, N > &other)
SIMD_Scalar< T, N > operator<< (size_t shift) const
SIMD_Scalar< T, N > operator>> (size_t shift) const
SIMD_Scalar< T, N > operator^ (const SIMD_Scalar< T, N > &other) const
void operator^= (const SIMD_Scalar< T, N > &other)
void operator|= (const SIMD_Scalar< T, N > &other)
SIMD_Scalar< T, N > operator~ () const
void rotate_left (size_t rot)
void rotate_right (size_t rot)
 SIMD_Scalar ()
 SIMD_Scalar (const T B[N])
 SIMD_Scalar (T B)
void store_be (byte out[]) const
void store_le (byte out[]) const

Static Public Member Functions

static bool enabled ()
static SIMD_Scalar< T, N > load_be (const void *in)
static SIMD_Scalar< T, N > load_le (const void *in)
static size_t size ()
static void transpose (SIMD_Scalar< T, N > &B0, SIMD_Scalar< T, N > &B1, SIMD_Scalar< T, N > &B2, SIMD_Scalar< T, N > &B3)

Detailed Description

template<typename T, size_t N>
class Botan::SIMD_Scalar< T, N >

Fake SIMD, using plain scalar operations Often still faster than iterative on superscalar machines

Definition at line 21 of file simd_scalar.h.


Constructor & Destructor Documentation

template<typename T, size_t N>
Botan::SIMD_Scalar< T, N >::SIMD_Scalar ( ) [inline]

Definition at line 28 of file simd_scalar.h.

{ /* uninitialized */ }
template<typename T, size_t N>
Botan::SIMD_Scalar< T, N >::SIMD_Scalar ( const T  B[N]) [inline]

Definition at line 30 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] = B[i];
         }
template<typename T, size_t N>
Botan::SIMD_Scalar< T, N >::SIMD_Scalar ( B) [inline]

Definition at line 36 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] = B;
         }

Member Function Documentation

template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::andc ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 171 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out;
         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] = (~m_v[i]) & other.m_v[i];
         return out;
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::bswap ( ) const [inline]

Definition at line 179 of file simd_scalar.h.

References Botan::reverse_bytes(), and Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out;
         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] = reverse_bytes(m_v[i]);
         return out;
         }
template<typename T, size_t N>
static bool Botan::SIMD_Scalar< T, N >::enabled ( ) [inline, static]

Definition at line 24 of file simd_scalar.h.

{ return true; }
template<typename T, size_t N>
static SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::load_be ( const void *  in) [inline, static]

Definition at line 53 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out;
         const byte* in_b = static_cast<const byte*>(in);

         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] = Botan::load_be<T>(in_b, i);

         return out;
         }
template<typename T, size_t N>
static SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::load_le ( const void *  in) [inline, static]

Definition at line 42 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out;
         const byte* in_b = static_cast<const byte*>(in);

         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] = Botan::load_le<T>(in_b, i);

         return out;
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator& ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 139 of file simd_scalar.h.

         {
         SIMD_Scalar<T,N> out = *this;
         out &= other;
         return out;
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::operator&= ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 133 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] &= other.m_v[i];
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator+ ( const SIMD_Scalar< T, N > &  other) const [inline]

Definition at line 100 of file simd_scalar.h.

         {
         SIMD_Scalar<T,N> out = *this;
         out += other;
         return out;
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::operator+= ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 88 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] += other.m_v[i];
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator- ( const SIMD_Scalar< T, N > &  other) const [inline]

Definition at line 107 of file simd_scalar.h.

         {
         SIMD_Scalar<T,N> out = *this;
         out -= other;
         return out;
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::operator-= ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 94 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] -= other.m_v[i];
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator<< ( size_t  shift) const [inline]

Definition at line 146 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out = *this;
         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] <<= shift;
         return out;
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator>> ( size_t  shift) const [inline]

Definition at line 154 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out = *this;
         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] >>= shift;
         return out;
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator^ ( const SIMD_Scalar< T, N > &  other) const [inline]

Definition at line 120 of file simd_scalar.h.

         {
         SIMD_Scalar<T,N> out = *this;
         out ^= other;
         return out;
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::operator^= ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 114 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] ^= other.m_v[i];
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::operator|= ( const SIMD_Scalar< T, N > &  other) [inline]

Definition at line 127 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] |= other.m_v[i];
         }
template<typename T, size_t N>
SIMD_Scalar<T,N> Botan::SIMD_Scalar< T, N >::operator~ ( ) const [inline]

Definition at line 162 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size().

         {
         SIMD_Scalar<T,N> out = *this;
         for(size_t i = 0; i != size(); ++i)
            out.m_v[i] = ~out.m_v[i];
         return out;
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::rotate_left ( size_t  rot) [inline]

Definition at line 76 of file simd_scalar.h.

References Botan::rotate_left(), and Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] = Botan::rotate_left(m_v[i], rot);
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::rotate_right ( size_t  rot) [inline]

Definition at line 82 of file simd_scalar.h.

References Botan::rotate_right(), and Botan::SIMD_Scalar< T, N >::size().

         {
         for(size_t i = 0; i != size(); ++i)
            m_v[i] = Botan::rotate_right(m_v[i], rot);
         }
template<typename T, size_t N>
static size_t Botan::SIMD_Scalar< T, N >::size ( ) [inline, static]
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::store_be ( byte  out[]) const [inline]

Definition at line 70 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size(), and Botan::store_be().

         {
         for(size_t i = 0; i != size(); ++i)
            Botan::store_be(m_v[i], out + i*sizeof(T));
         }
template<typename T, size_t N>
void Botan::SIMD_Scalar< T, N >::store_le ( byte  out[]) const [inline]

Definition at line 64 of file simd_scalar.h.

References Botan::SIMD_Scalar< T, N >::size(), and Botan::store_le().

         {
         for(size_t i = 0; i != size(); ++i)
            Botan::store_le(m_v[i], out + i*sizeof(T));
         }
template<typename T, size_t N>
static void Botan::SIMD_Scalar< T, N >::transpose ( SIMD_Scalar< T, N > &  B0,
SIMD_Scalar< T, N > &  B1,
SIMD_Scalar< T, N > &  B2,
SIMD_Scalar< T, N > &  B3 
) [inline, static]

Definition at line 187 of file simd_scalar.h.

         {
         static_assert(N == 4, "4x4 transpose");
         SIMD_Scalar<T,N> T0({B0.m_v[0], B1.m_v[0], B2.m_v[0], B3.m_v[0]});
         SIMD_Scalar<T,N> T1({B0.m_v[1], B1.m_v[1], B2.m_v[1], B3.m_v[1]});
         SIMD_Scalar<T,N> T2({B0.m_v[2], B1.m_v[2], B2.m_v[2], B3.m_v[2]});
         SIMD_Scalar<T,N> T3({B0.m_v[3], B1.m_v[3], B2.m_v[3], B3.m_v[3]});

         B0 = T0;
         B1 = T1;
         B2 = T2;
         B3 = T3;
         }

The documentation for this class was generated from the following file: