Skip to content

Add directed fp unit tests, and fix bugs found#1811

Open
dhower-qc wants to merge 2 commits intoriscv:mainfrom
dhower-qc:fp-test
Open

Add directed fp unit tests, and fix bugs found#1811
dhower-qc wants to merge 2 commits intoriscv:mainfrom
dhower-qc:fp-test

Conversation

@dhower-qc
Copy link
Copy Markdown
Collaborator

No description provided.

@dhower-qc dhower-qc requested a review from ThinkOpenly as a code owner April 29, 2026 15:07
Copilot AI review requested due to automatic review settings April 29, 2026 15:07
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.23%. Comparing base (a1225d7) to head (209afcd).
⚠️ Report is 9 commits behind head on main.

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     
Flag Coverage Δ
idlc 76.18% <ø> (ø)
udb 66.23% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_fp Catch2 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 in SatisfiedResult.

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.

Comment thread spec/std/isa/isa/fp.idl
Comment thread spec/std/isa/isa/fp.idl
Comment on lines +111 to +127
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"
)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants