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
Add multiplication to Pancake #956
Merged
Merged
Conversation
This file contains 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
These aren't in the concrete syntax, so map them to 1 and 0 C-style Addresses (the easy part of) issue #939
Adds binary division and multiplication to Pancake, and pushes it down to loopLang. Next step: worry about how to push it to word. While at it, I've modernised a couple of proofs to get rid of TRY-style, and other needless detours. This is a start on issue #936
I forgot all about division by 0 on the first draft. In this new approach, we'll do the heavy lifting in crep_to_loop, which is convenient since there's already a pass there for converting expressions to statement sequences with intermediate variables.
For divisionless platforms
The previous definition was too restrictive to accommodate the looping and branching needed to implement software multiplication.
I think doing division properly requires exposing more operators in asmScript, so that it can be consistently signed or unsigned across platforms. I'm fine with using software division for oddball targets, but for ARMv8 and x86 I'd really like to target a division instruction.
inst_ok_less requires that some of the registers used with the LongMul instruction are distinct, depending on platform. Because parts of the Pancake compiler populate omitted arguments with defaults, this property is not guaranteed to hold unless the source program has no such arity mismatches. This assumption is propagated all the way to the top. This is not really a limitation: offending programs are impossible to even write in concrete syntax.
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.
Also fixes a parser bug related to nested infix operators, and adds boolean literal parsing. This addresses half of issue #936.
Division would be nice, but I would like it to (a) target hardware division instructions on non-oddball platforms, and (b) give it consistent semantics across platforms. This is currently not possible because the way
asm
is set up, some platforms expose only signed division, and others only unsigned division. In a hypothetical future whereasm
has been extended accordingly, most of the work necessary to add division to thepan_to_word
part of the compiler can be fished out of the commit history of this PR.