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

Add multiplication to Pancake #956

Merged
merged 23 commits into from Jun 2, 2023
Merged

Add multiplication to Pancake #956

merged 23 commits into from Jun 2, 2023

Conversation

IlmariReissumies
Copy link
Member

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 where asm has been extended accordingly, most of the work necessary to add division to the pan_to_word part of the compiler can be fished out of the commit history of this PR.

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.
@IlmariReissumies IlmariReissumies merged commit 57e23a9 into master Jun 2, 2023
1 check passed
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.

None yet

1 participant