Skip to content

Commit

Permalink
Remove dependence of C softfloat code on Sail model.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Timmmm committed Nov 7, 2023
1 parent 69af65c commit abf0427
Show file tree
Hide file tree
Showing 3 changed files with 430 additions and 555 deletions.
Loading

0 comments on commit abf0427

Please sign in to comment.