mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Reduce types.h
This commit is contained in:
parent
c0fb31cac3
commit
460e64667a
3 changed files with 1 additions and 78 deletions
|
@ -271,9 +271,6 @@ namespace {
|
|||
occupancy[size] = b;
|
||||
reference[size] = sliding_attack(deltas, s, b);
|
||||
|
||||
if (HasPext)
|
||||
attacks[s][_pext_u64(b, masks[s])] = reference[size];
|
||||
|
||||
size++;
|
||||
b = (b - masks[s]) & masks[s];
|
||||
} while (b);
|
||||
|
@ -283,9 +280,6 @@ namespace {
|
|||
if (s < SQ_H8)
|
||||
attacks[s + 1] = attacks[s] + size;
|
||||
|
||||
if (HasPext)
|
||||
continue;
|
||||
|
||||
// Find a magic for square 's' picking up an (almost) random number
|
||||
// until we find the one that passes the verification test.
|
||||
do {
|
||||
|
|
|
@ -237,12 +237,6 @@ FORCE_INLINE unsigned magic_index(Square s, Bitboard occupied) {
|
|||
Bitboard* const Magics = Pt == ROOK ? RookMagics : BishopMagics;
|
||||
unsigned* const Shifts = Pt == ROOK ? RookShifts : BishopShifts;
|
||||
|
||||
if (HasPext)
|
||||
return unsigned(_pext_u64(occupied, Masks[s]));
|
||||
|
||||
if (Is64Bit)
|
||||
return unsigned(((occupied & Masks[s]) * Magics[s]) >> Shifts[s]);
|
||||
|
||||
unsigned lo = unsigned(occupied) & unsigned(Masks[s]);
|
||||
unsigned hi = unsigned(occupied >> 32) & unsigned(Masks[s] >> 32);
|
||||
return (lo * unsigned(Magics[s]) ^ hi * unsigned(Magics[s] >> 32)) >> Shifts[s];
|
||||
|
|
67
src/types.h
67
src/types.h
|
@ -1,69 +1,16 @@
|
|||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
|
||||
Copyright (C) 2008-2014 Marco Costalba, Joona Kiiski, Tord Romstad
|
||||
|
||||
Stockfish is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Stockfish is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TYPES_H_INCLUDED
|
||||
#define TYPES_H_INCLUDED
|
||||
|
||||
/// For Linux and OSX configuration is done automatically using Makefile. To get
|
||||
/// started type 'make help'.
|
||||
///
|
||||
/// For Windows, part of the configuration is detected automatically, but some
|
||||
/// switches need to be set manually:
|
||||
///
|
||||
/// -DNDEBUG | Disable debugging mode. Always use this.
|
||||
///
|
||||
/// -DNO_PREFETCH | Disable use of prefetch asm-instruction. A must if you want
|
||||
/// | the executable to run on some very old machines.
|
||||
///
|
||||
/// -DUSE_POPCNT | Add runtime support for use of popcnt asm-instruction. Works
|
||||
/// | only in 64-bit mode. For compiling requires hardware with
|
||||
/// | popcnt support.
|
||||
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
|
||||
#include <inttypes.h>
|
||||
const bool HasPopCnt = true;
|
||||
|
||||
#define unlikely(x) (x) // For code annotation purposes
|
||||
|
||||
#if defined(_WIN64) && !defined(IS_64BIT)
|
||||
# include <intrin.h> // MSVC popcnt and bsfq instrinsics
|
||||
# define IS_64BIT
|
||||
# define USE_BSFQ
|
||||
#endif
|
||||
|
||||
#if defined(USE_POPCNT) && defined(_MSC_VER) && defined(__INTEL_COMPILER)
|
||||
# include <nmmintrin.h> // Intel header for _mm_popcnt_u64() intrinsic
|
||||
#endif
|
||||
|
||||
#if defined(USE_PEXT)
|
||||
# include <immintrin.h> // Header for _pext_u64() intrinsic
|
||||
#else
|
||||
# define _pext_u64(b, m) (0)
|
||||
#endif
|
||||
|
||||
# if !defined(NO_PREFETCH) && (defined(__INTEL_COMPILER) || defined(_MSC_VER))
|
||||
# include <xmmintrin.h> // Intel and Microsoft header for _mm_prefetch()
|
||||
# endif
|
||||
|
||||
#define CACHE_LINE_SIZE 64
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -74,18 +21,6 @@
|
|||
# define FORCE_INLINE inline
|
||||
#endif
|
||||
|
||||
#ifdef USE_POPCNT
|
||||
const bool HasPopCnt = true;
|
||||
#else
|
||||
const bool HasPopCnt = false;
|
||||
#endif
|
||||
|
||||
#ifdef USE_PEXT
|
||||
const bool HasPext = true;
|
||||
#else
|
||||
const bool HasPext = false;
|
||||
#endif
|
||||
|
||||
#ifdef IS_64BIT
|
||||
const bool Is64Bit = true;
|
||||
#else
|
||||
|
|
Loading…
Add table
Reference in a new issue