kingMobility.h
Go to the documentation of this file.
00001 /* kingMobility.h
00002  */
00003 #ifndef _KING_MOBILITY_H
00004 #define _KING_MOBILITY_H
00005 
00006 #include "osl/misc/carray.h"
00007 #include "osl/player.h"
00008 #include "osl/config.h"
00009 #include <cassert>
00010 
00011 #ifndef OSL_USE_SSE
00012 #if !(defined _MSC_VER) && ! defined OSL_NO_SSE
00013 #define OSL_USE_SSE 1
00014 #endif
00015 #endif
00016 
00017 namespace osl
00018 {
00019   namespace mobility
00020   {
00021 #if OSL_USE_SSE
00022     typedef long long v2di __attribute__ ((vector_size (16)));
00023 #endif
00024     class KingMobility{
00025       union b128{
00026         CArray<CArray<unsigned char,8>,2> uc16;
00027         unsigned long long ul[2];
00028 #if OSL_USE_SSE
00029         v2di v2;
00030 #endif
00031       } v
00032 #ifdef __GNUC__
00033       __attribute__((aligned(16)))
00034 #endif
00035         ;
00036     public:
00037       KingMobility() {
00038         assert(reinterpret_cast<size_t>(this) % 16 == 0);
00039       }
00040       const CArray<unsigned char,8>& operator[](Player p) const{
00041         return v.uc16[p];
00042       }
00043       CArray<unsigned char,8>& operator[](Player p){
00044         return v.uc16[p];
00045       }
00046       KingMobility& operator=(KingMobility const& km){
00047 #if OSL_USE_SSE
00048         v.v2=km.v.v2;
00049 #else
00050         v.uc16=km.v.uc16;
00051 #endif
00052         return *this;
00053       }
00054       bool operator==(KingMobility const& km) const{
00055 #if 0 && OSL_USE_SSE41
00056         return __builtin_ia32_ptestz128(v.v2,km.v.v2);
00057 #else
00058         return ((v.ul[0]^km.v.ul[0])|(v.ul[1]^km.v.ul[1]))==0;
00059 #endif
00060       }
00061     };
00062   }
00063   using mobility::KingMobility;
00064 }
00065 #endif /* _KING_MOBILITY_H */
00066 // ;;; Local Variables:
00067 // ;;; mode:c++
00068 // ;;; c-basic-offset:2
00069 // ;;; End:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines