All five R8Forge machines stored a cell in uint16_t, so anything above 16 bits
was silently truncated even though geometry.hh (and the viz) allow 1..32; and
`(1 << cell_size) - 1` for _CELL_MAX was undefined at 32.
* cells and out/input buffers are uint32_t in derive, tape_run, byte_op_test,
examples_test and synth_test (r8veritas*.hh keep their uint16_t search
state -- that is node ids, unrelated)
* kDefaultCellMask and the injected _CELL_MAX special-case 32 instead of
shifting by 32
* width is now a build option: -DR8FORGE_CELL_SIZE=<1..32> (CMake cache var,
added as a compile definition), so a whole toolchain of another width is one
configure away; build*/ is ignored so those trees do not leak into git
Verified: 11 bits unchanged (tape 64513, byte_op ok); a 16 bit build passes
synth_test 8/8 and byte_op_test (65536 exhaustive pairs); a 32 bit build passes
synth_test, verify_clb_bit_add_nc and assembles full_add to the same 95 chars.
Exhaustive 32 bit is 2^64 pairs -- that stays sampled, not verified.
SPEC 13 checklist now says five VMs / uint32_t / the 32 bit mask case.
56 lines
2.2 KiB
CMake
56 lines
2.2 KiB
CMake
cmake_minimum_required(VERSION 3.10)
|
|
project(R8Forge)
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
include_directories(include)
|
|
|
|
# The width of a cell. 11 is the project default; the tests and the VMs follow
|
|
# it, so `-DR8FORGE_CELL_SIZE=16` builds an entirely 16 bit toolchain.
|
|
set(R8FORGE_CELL_SIZE 11 CACHE STRING "bits per cell (1..32)")
|
|
add_compile_definitions(R8FORGE_CELL_SIZE=${R8FORGE_CELL_SIZE})
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
add_library(r8forge_core src/r8asm.cc src/synth.cc)
|
|
target_link_libraries(r8forge_core PUBLIC Threads::Threads)
|
|
|
|
# 别再 set(CMAKE_CXX_FLAGS ...) 了:那会把默认 flag 整个换掉,MSVC 下丢 /EHsc、
|
|
# 还会把 -O3 塞进 Debug 和 /RTC1 打架。Release 配置本来就带 -O3 / /O2 和 NDEBUG。
|
|
if(NOT MSVC)
|
|
add_compile_options($<$<CONFIG:Release>:-march=native>)
|
|
endif()
|
|
|
|
add_executable(r8forge tests/asm_test.cc)
|
|
target_link_libraries(r8forge r8forge_core)
|
|
|
|
add_executable(r8forge_synth_test tests/synth_test.cc)
|
|
target_link_libraries(r8forge_synth_test r8forge_core)
|
|
|
|
add_executable(r8forge_derive src/derive.cc)
|
|
target_link_libraries(r8forge_derive r8forge_core)
|
|
|
|
# A second, independent ROT-8 interpreter: runs a .rot8 file with no assembler
|
|
# and no macros involved, so its verdict can be checked against r8forge_derive.
|
|
add_executable(r8forge_tape_run tests/tape_run.cc)
|
|
|
|
# Runs the byte level library macros (raw_add / raw_and / raw_or / raw_xor /
|
|
# raw_inc) over every input combination.
|
|
add_executable(r8forge_byte_op_test tests/byte_op_test.cc)
|
|
target_link_libraries(r8forge_byte_op_test r8forge_core)
|
|
|
|
# Checks that every %macro in asm/ carries a doc comment in the house format.
|
|
add_executable(r8forge_macro_docs_test tests/macro_docs_test.cc)
|
|
|
|
# Runs every examples/*.r8asm as a stand alone program and compares its OUT
|
|
# stream with the `; out ...` line in the file header.
|
|
add_executable(r8forge_examples_test tests/examples_test.cc)
|
|
target_link_libraries(r8forge_examples_test r8forge_core)
|
|
|
|
add_executable(r8forge_cost_par tests/cost_par.cc)
|
|
target_link_libraries(r8forge_cost_par r8forge_core)
|
|
|
|
add_executable(r8forge_cost_search tests/cost_search.cc)
|
|
target_link_libraries(r8forge_cost_search r8forge_core)
|