Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dependence of C softfloat code on Sail model. #340

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Timmmm
Copy link
Collaborator

@Timmmm Timmmm commented Nov 7, 2023

The flags and result for a softfloat operation are currently pushed to the Sail code from C like this:

// C
zfloat_result = res.v;
zfloat_fflags = (mach_bits)softfloat_exceptionFlags

// Sail
register float_result : bits(64)
register float_fflags : bits(64)

This changes it to pull the flags from the Sail side with a callback:

// C
mach_bits softfloat_float_flags(unit u)
{
  return (mach_bits)softfloat_exceptionFlags;
}

// Sail
val extern_float_flags = {c: "softfloat_float_flags", ocaml: "Softfloat.float_flags", lem: "softfloat_float_flags"} : (unit) -> bits_LU

The float_result is changed to just be the return value of all of the functions.

The benefits are:

  1. It uses the official FFI system instead of hackily reaching into the generated C code.
  2. It removes the two-way dependence between the C softfloat code and the Sail model. The C softfloat code no longer has any references to the Sail model.

Tested with run_fp_tests.sh - all 82 tests pass.

The flags and result for a softfloat operation are currently pushed to the Sail code from C like this:

    // C
    zfloat_result = res.v;
    zfloat_fflags = (mach_bits)softfloat_exceptionFlags

    // Sail
    register float_result : bits(64)
    register float_fflags : bits(64)

This changes it to pull the flags from the Sail side with a callback:

    // C
    mach_bits softfloat_float_flags(unit u)
    {
      return (mach_bits)softfloat_exceptionFlags;
    }
    // Sail
    val extern_float_flags = {c: "softfloat_float_flags", ocaml: "Softfloat.float_flags", lem: "softfloat_float_flags"} : (unit) -> bits_LU

The `float_result` is changed to just be the return value of all of the functions.

The benefits are:

1. It uses the official FFI system instead of hackily reaching into the generated C code.
2. It removes the two-way dependence between the C softfloat code and the Sail model. The C softfloat code no longer has any references to the Sail model.

Tested with `run_fp_tests.sh` - all 82 tests pass.
Copy link

github-actions bot commented Nov 7, 2023

Unit Test Results

712 tests  ±0   396 ✔️  - 316   0s ⏱️ ±0s
    6 suites ±0       0 💤 ±    0 
    1 files   ±0   316 +316 

For more details on these failures, see this check.

Results for commit abf0427. ± Comparison against base commit 69af65c.

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.

1 participant