Lower fp32 to soft-float calls on RV32 - #149
Draft
Zaneham wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. The pass works, the runtime lowers, and float kernels still do not
compile end to end because of #148.
The Tensix baby cores are RV32IM with no F extension, so float has to become
calls into
runtime/soft_fp.c. That file has been sitting in the treehost-tested and never actually wired to anything, and
rv_iselsaid as much:So this is the wiring.
bir_softfprewritesBIR_FADDand friends intoBIR_CALLto thelibgcc-named entry points. Every op it handles is a one-for-one rewrite in
place, so nothing renumbers. It runs after cfold, so constant float folds away
rather than turning into a call nobody needed. FCMP is deliberately absent: it
needs a call plus a compare against zero, which is an insertion rather than a
rewrite, and it refuses in isel until that lands.
The driver appends
runtime/soft_fp.cto the translation unit when the kernelmentions float, so
BIR_CALLcan resolve a callee by index intofuncs[].Gated on float use, or every integer kernel pays the text budget for arithmetic
it never does.
Three things were wrong in the runtime and none of them had ever been noticed,
because nothing had compiled it as device code:
#ifndef __device__erased the qualifier on every build. It is a keywordand never a macro, so the condition is always true. The whole runtime was
being compiled as host code and skipped by lowering.
too.
memcpyis not a device builtin, so the float/int punning now uses__float_as_intand__int_as_float, which Booth already had.What is left is #148.
sfp_unpacked_thas a_pad[]member, and indexing anarray member of a struct produces a GEP with a non-pointer result type. That is
a general frontend bug with a seven-line repro, nothing to do with soft-float,
and it blocks this the moment the runtime actually runs.
Suite is green at 358. I have deliberately not included two speculative fixes
to
bir_lowerthat looked right and changed the output by nothing, since anunverified edit to lowering is worse than no edit.