Add directed fp unit tests, and fix bugs found#1811
Add directed fp unit tests, and fix bugs found#1811dhower-qc wants to merge 2 commits intoriscv:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1811 +/- ##
==========================================
- Coverage 72.24% 72.23% -0.02%
==========================================
Files 52 52
Lines 27671 27671
Branches 6009 6009
==========================================
- Hits 19992 19988 -4
- Misses 7679 7683 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a directed floating-point stimulus corpus plus a new C++/SoftFloat comparison test to validate generated fp.idl helpers, and applies several fixes to fp.idl and C++ support code uncovered by those tests.
Changes:
- Add an FPgen-style Ruby generator scaffold and check in an expanded directed f32 JSONL vector corpus.
- Add a new
test_softfloat_fpCatch2 test (built + runnable via new rake tasks) that compares generated hart FP ops vs Berkeley SoftFloat. - Fix multiple floating-point corner cases in
spec/std/isa/isa/fp.idl(sNaN NV flag setting, sqrt exponent handling, recip approximation changes) and fix 3-valued logic operators inSatisfiedResult.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/scripts/fpgen_generate.rb | Adds a Ruby utility to emit directed f32 vectors and optional Z3 “all-types” vectors. |
| tests/data/fp/directed/f32_fpgen_expanded.jsonl | Adds checked-in directed f32 vector corpus used by the new C++ test. |
| tests/data/fp/directed/REUSE.toml | Declares licensing metadata for generated test corpus files in this directory. |
| spec/std/isa/isa/fp.idl | Fixes FP semantics (sNaN NV flagging, sqrt/div corner cases, recip helper, exp width changes). |
| backends/cpp_hart_gen/templates/db_data.hxx.erb | Fixes SatisfiedResult && / ` |
| backends/cpp_hart_gen/tasks.rake | Adds rake tasks to build/run the new SoftFloat FP tests. |
| backends/cpp_hart_gen/cpp/test/test_softfloat_fp.cpp | New Catch2 test comparing hart FP ops vs Berkeley SoftFloat on directed vectors. |
| backends/cpp_hart_gen/CMakeLists.txt | Adds build dependencies for nlohmann-json and Berkeley SoftFloat; wires up test_softfloat_fp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ExternalProject_Add(berkeley_softfloat | ||
| GIT_REPOSITORY https://github.com/ucb-bar/berkeley-softfloat-3.git | ||
| GIT_TAG a0c6494cdc11865811dec815d5c0049fba9d82a8 | ||
| UPDATE_DISCONNECTED TRUE | ||
| CONFIGURE_COMMAND "" | ||
| BUILD_COMMAND make -C <SOURCE_DIR>/build/Linux-x86_64-GCC | ||
| INSTALL_COMMAND "" | ||
| ) | ||
|
|
||
| ExternalProject_Get_Property(berkeley_softfloat SOURCE_DIR) | ||
| file(MAKE_DIRECTORY "${SOURCE_DIR}/source/include") # Prevent CMake error before it is cloned | ||
|
|
||
| add_library(libsoftfloat_static STATIC IMPORTED) | ||
| set_target_properties(libsoftfloat_static PROPERTIES | ||
| IMPORTED_LOCATION "${SOURCE_DIR}/build/Linux-x86_64-GCC/softfloat.a" | ||
| INTERFACE_INCLUDE_DIRECTORIES "${SOURCE_DIR}/source/include" | ||
| ) |
There was a problem hiding this comment.
Good point — fixing this now. I'll replace the two hard-coded Linux-x86_64-GCC strings with a SOFTFLOAT_BUILD_SPEC cache variable that is auto-derived from CMake's host/toolchain introspection variables (CMAKE_HOST_SYSTEM_NAME, CMAKE_HOST_SYSTEM_PROCESSOR, CMAKE_C_COMPILER_ID). The default value on Linux/x86_64/GCC will remain identical to what is there today, so there is no behaviour change for the current CI environment. Users on other hosts (e.g. macOS/ARM64/Clang) will get the correct spec automatically, and anyone on an unusual toolchain can still pass -DSOFTFLOAT_BUILD_SPEC=<value> to override. I'll push the change shortly.
No description provided.