All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kingMobility.h
Go to the documentation of this file.
1 /* kingMobility.h
2  */
3 #ifndef _KING_MOBILITY_H
4 #define _KING_MOBILITY_H
5 
6 #include "osl/misc/carray.h"
7 #include "osl/player.h"
8 #include "osl/config.h"
9 #include <cassert>
10 
11 #ifndef OSL_USE_SSE
12 #if !(defined _MSC_VER) && ! defined OSL_NO_SSE
13 #define OSL_USE_SSE 1
14 #endif
15 #endif
16 
17 namespace osl
18 {
19  namespace mobility
20  {
21 #if OSL_USE_SSE
22  typedef long long v2di __attribute__ ((vector_size (16)));
23 #endif
24  class KingMobility{
25  union b128{
26  CArray<CArray<unsigned char,8>,2> uc16;
27  unsigned long long ul[2];
28 #if OSL_USE_SSE
30 #endif
31  } v
32 #ifdef __GNUC__
33  __attribute__((aligned(16)))
34 #endif
35  ;
36  public:
38  assert(reinterpret_cast<size_t>(this) % 16 == 0);
39  }
40  const CArray<unsigned char,8>& operator[](Player p) const{
41  return v.uc16[p];
42  }
43  CArray<unsigned char,8>& operator[](Player p){
44  return v.uc16[p];
45  }
47 #if OSL_USE_SSE
48  v.v2=km.v.v2;
49 #else
50  v.uc16=km.v.uc16;
51 #endif
52  return *this;
53  }
54  bool operator==(KingMobility const& km) const{
55 #if 0 && OSL_USE_SSE41
56  return __builtin_ia32_ptestz128(v.v2,km.v.v2);
57 #else
58  return ((v.ul[0]^km.v.ul[0])|(v.ul[1]^km.v.ul[1]))==0;
59 #endif
60  }
61  };
62  }
63  using mobility::KingMobility;
64 }
65 #endif /* _KING_MOBILITY_H */
66 // ;;; Local Variables:
67 // ;;; mode:c++
68 // ;;; c-basic-offset:2
69 // ;;; End: