Two separate things hid behind "32 bit works": * tests/byte_op_test.cc could not compile at 32 bits at all (`1 << 32` in a constexpr plus an int typed mask), so the whole 32 bit build stopped there -- only `r8forge` and the core library came out. kCellMod is now clamped at 31+ bits and main() prints "skipped" above 16 bits (every sweep there is 2^W rows) and exits green. All ten targets build at 32 bits with MSVC, and the same tree builds clean on a Gentoo box with GCC 16 -- the missing <cstring> in asm_test.cc that stopped GCC first is in the previous commit. * the digit drivers hardcoded a 4 cell window, so byte_op_test's digits / digits_signed / undigits failed at every other width (16 bits wants 5 digits, 8 bits 3). drv/digits.r8asm, drv/digits_signed.r8asm and drv/undigits_byte.r8asm now derive D = _CELL_SIZE * 30103 / 100000 + 1 and space their cells by it, and the C++ side uses the same kDigits instead of a literal 4 (including the T/F cells clb_digits_signed leaves behind). With that, byte_op_test passes at 8, 11 and 16 bits (the 16 bit run takes about 450 s) and above 16 it skips. Two more width bugs fell out on the way: the divmod divisor sweep used 1000 and 2047 unconditionally (they wrap at 8 bits), and the undigits garbage guard OR'ed in bits above the cell, which at 8 bits turned '0'+digit into a value over 255. test_divmod_signed also divided by the recovered divisor without re-checking it, and at 8 bits the boundary value 1024 wraps to 0 -- that was a hard crash (divide by zero), not a failure. CMakeLists.txt now refuses -DR8FORGE_CELL_SIZE outside 1..32 at configure time; the range used to be a comment, so an out of range width was discovered as a compiler error in whichever file shifted by it first. geometry.hh and SPEC section 13 record that 32 is the ceiling because every VM stores a cell in uint32_t -- going further means widening all five VMs, the assembler's immediate type and ROT-8-viz's rot8_data. Also recorded there: the %synth cache is keyed by the truth table, not the width, so a 32 bit build hits the committed entries (0.4 s for the flagship tape of 227075 characters). A full cold rebuild takes ~500 s on a 44 thread machine, 479 s of which is the single 6 parameter full adder table.
20 lines
1.1 KiB
C++
20 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
|
|
// Machine geometry the tools use unless something says otherwise: how wide a
|
|
// cell is in bits, and how many cells the tape holds. The instruction set does
|
|
// not fix either (ROR just rotates inside a cell and the tape is a ring), so
|
|
// these are the only places the old 8 bit / 256 cell assumptions live.
|
|
inline constexpr size_t kDefaultCellSize = R8FORGE_CELL_SIZE; // build option: -DR8FORGE_CELL_SIZE=<1..32>
|
|
inline constexpr size_t kDefaultMemoryCells = 259;
|
|
// The VMs store a cell in uint32_t, so 32 bits is the ceiling -- and `1u << 32`
|
|
// would be undefined, hence the special case instead of a plain shift. CMake
|
|
// refuses anything outside 1..32 at configure time, and the exhaustive byte
|
|
// level test prints "skipped" instead of running above 16 bits (its sweeps are
|
|
// 2^W rows). Going past 32 would mean widening the cell in all five VMs *and*
|
|
// in ROT-8-viz's rot8_data -- SPEC §13 has the checklist.
|
|
inline constexpr uint32_t kDefaultCellMask =
|
|
kDefaultCellSize >= 32 ? 0xFFFFFFFFu : (1u << kDefaultCellSize) - 1u;
|