-
Notifications
You must be signed in to change notification settings - Fork 2
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
Improve Partial Evaluation of Floating Point Conversion Operations #46
Comments
Hm yes, coincidentally (again!) I have also been looking at these instructions. I don't think we can safely eliminate the FPCR reads in general. Are you asking for the types to be replaced with concrete bitvectors of the same size? This could be possible. In my project, I took the different approach of updating the grammar to support this syntax. This is a bit nicer, I think, as the type constructor is useful to track down the enum's meaning, especially when its values are replaced by bits. You can find the g4 file here, if you would like to try this. The grammar is not too nice to work with and I will fix this in the not-too-far future. |
Types replaced with concrete bitvectors of the same size would be ideal - I can look up (and have already done so) what the type actually is in ASLi, but having to manually handle every type declaration like that is not really ideal at all. I'm not asking for FPCR reads to removed, just for them to be cleaned up. I've already actually rewritten the grammar here to support these elements, as well as more extensively cleaning it up and fixing a number of errors in it. You may find that helpful. This is enough to parse cntlm. Here's a pseudocode simplification of the fcvt example:
Most of these temporary variables are redundant - Exp4__5 and Exp5__4 don't really serve any purpose and you even could propagate Exp10__6 into the final assignment. FPDecodeRounding8__7 is just a conversion from bitvector to enum, with an impossible to reach exception in that conversion. The biggest issue for BASIL is FPDecodeRounding8__7 not being a bitvector - this more difficult to work around and will require special treatment. Everything else can be managed (and mostly is at present, though I haven't yet added a way to handle the floating point functions but it is not difficult to do so - they can just be uninterpreted functions for now). I guess the issue with just treating it as a bitvector of size 2 is that there are two other FPRounding modes which are not represented in FPCR and only ever used explicitly? All the issues with FPRounding could probably be avoided if the FPConvert that only takes two parameters wasn't inlined? That version just calls the three-parameter version, taking the FPRounding value from FPCR's RMode field, but if we could abstract away that version too that would be simplest. |
It is simplest at present if BASIL can deal with everything in terms of bitvectors. An alternate version of ASLp that keeps the original typing of everything as much as possible may have some real advantages (with that following through to a significantly overhauled BASIL) and could be worthy of investigation, but that would need to be an explicit design choice, not just having one or two stray non-bitvectors here and there. |
This should be partially addressed by #48, but the question of floating point function primitives remains open.
Note the conversion of |
Thanks, that seems like a significant improvement. That should solve all the existing issues. |
The fcvt and ucvtf instructions are good now, but scvtf now has exposed integers in some cases which is not really ideal.
I understand it is just creating the temporary variable Cse0__5 to hold the integer because it is used multiple times, but is it possible to disable the creation of those temporary variables for cvt_bits_uint.0 operations? |
The instructions
fcvt
,ucvtf
, andscvtf
are all floating point conversion instructions, and the currently produced semantics are not ideal for BASIL, containing a number of unusual constructs compared to most of the output. These instructions appear in cntlm.Here are the gtirb-semantics output for them, since that's what I have on hand.
The call to the fixed point functions are not really an issue - we can just treat those as uninterpreted functions for the time being. The register declaration, variable declaration of type
FPRounding
(an enum in ASLi) and conversion from the FPCR bytes to the enum value are the real issue.The text was updated successfully, but these errors were encountered: