Skip to content

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 requested review from mktnk3 and myreen May 25, 2023 10:19
@IlmariReissumies IlmariReissumies merged commit 57e23a9 into master Jun 2, 2023
@xrchz xrchz deleted the pancake_divmul branch February 22, 2025 13:36
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.

1 participant