diff options
Diffstat (limited to 'src/chess.h')
| -rwxr-xr-x | src/chess.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/chess.h b/src/chess.h index 1f874b9..5c5bbf2 100755 --- a/src/chess.h +++ b/src/chess.h @@ -658,6 +658,17 @@ typedef struct _POSITION // (cNonPawns[color][0]), a bitboard adds nothing. BITBOARD bbPieces[2][8]; + // Per-color pawn location bitboard -- same incremental-maintenance + // idea as bbPieces above, but for pawns (which bbPieces + // deliberately excludes). Exists so _BuildOccupiedBB (see.c) can + // build full-board occupancy via two ORs instead of looping + // cPawns[2][8] (up to 16 iterations) on every call -- see + // board_representation/MIGRATION.md section 3. Distinct from + // pHash->bbPawnLocations[2] (pawn-hash-keyed, tied to pawn-eval + // caching); this one is plain POSITION state, reachable without a + // SEARCHER_THREAD_CONTEXT. + BITBOARD bbPawns[2]; + ULONG uWhiteSqBishopCount[2]; // num bishops on white squares SCORE iMaterialBalance[2]; // material balance @@ -2027,12 +2038,15 @@ extern BITBOARD BBADJACENT_RANKS[9]; // board_representation/MIGRATION.md) the planned bbPieces-backed // GetAttacks/CountKingSafetyDefects primitive. extern BITBOARD g_RookRayToEdge[4][128]; +extern BITBOARD g_RookRayAll[128]; extern const int g_RookRayDeltas[4]; extern const FLAG g_RookRayPositiveDir[4]; extern BITBOARD g_BishopRayToEdge[4][128]; +extern BITBOARD g_BishopRayAll[128]; extern const int g_BishopRayDeltas[4]; extern const FLAG g_BishopRayPositiveDir[4]; extern BITBOARD g_KnightAttacksBB[128]; +extern BITBOARD g_PawnAttackOriginBB[2][128]; void InitializeWhiteSquaresTable(void); @@ -2055,6 +2069,9 @@ InitializeBishopRayTables(void); void InitializeKnightAttackTables(void); +void +InitializePawnAttackOriginTable(void); + #ifdef DEBUG ULONG CheckVectorWithIndex(int i, ULONG uColor); #define CHECK_VECTOR_WITH_INDEX(i, color) \ @@ -2797,6 +2814,31 @@ SlowFirstBit(BITBOARD bb); ULONG CDECL SlowLastBit(BITBOARD bb); +// Compiler-builtin (__builtin_ctzll/__builtin_clzll) bsf/bsr -- same +// 1-based/0-for-empty contract as FirstBit/LastBit below, and the +// exact same bsf/bsr instruction the asm FirstBit/LastBit use (this +// build passes no -mbmi, so __builtin_ctzll still lowers to bsf, not +// tzcnt) -- but static inline, so a call site pays for the +// instruction itself and nothing else, no CDECL call/ret/arg-marshal +// overhead. That overhead is exactly what makes it worth having a +// second copy instead of just calling FirstBit/LastBit everywhere: +// worthwhile in a per-move-generated, per-search-node hot path, +// pointless as a blanket replacement elsewhere. static (not extern) +// deliberately -- a plain non-static C99 "inline" definition with no +// out-of-line instantiation anywhere is a link-time trap, not just a +// style choice. +static ULONG INLINE +FastFirstBit(IN BITBOARD bb) +{ + return bb ? ((ULONG)__builtin_ctzll(bb) + 1) : 0; +} + +static ULONG INLINE +FastLastBit(IN BITBOARD bb) +{ + return bb ? (ULONG)(64 - __builtin_clzll(bb)) : 0; +} + #ifdef CROUTINES #define CountBits SlowCountBits #define FirstBit SlowFirstBit @@ -2856,6 +2898,14 @@ SlowGetAttacks(SEE_LIST *pList, #define GetAttacks SlowGetAttacks #endif +// board_representation/MIGRATION.md section 3: bbPieces-backed +// GetAttacks PoC -- not wired into the GetAttacks macro above yet. +void CDECL +_GetAttacksBB(SEE_LIST *pList, + POSITION *pos, + COOR cSquare, + ULONG uSide); + #ifdef _X86_ // // Note: this is most of the stuff that x86.asm assumes about the |
