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

Added join-let and join-apply; bugfixes #13

Merged
merged 2 commits into from
Jan 8, 2025
Merged

Conversation

AdUhTkJm
Copy link

@AdUhTkJm AdUhTkJm commented Jan 8, 2025

Join-let and join-apply refers to this control flow:

fn f() {
  for {
    if a > 0 {
      return 2;
    }
  }
}

For a statement let x = f(), the frontend will rewrite it into something like:

join-let ret = fn () { return 2; }
let x = for {
  if a > 0 {
    join-apply ret()
  }
}

The semantics is that join-apply behaves exact the same as br in WASM; in other words, it's similar to break in a loop, but it can carry a value.

Bugfixes:

  • a ^ b used to get compiled into and %1, a, b. Now it produces xor correctly.
  • unsigned conversion (from u32 to u64/i64) now works. Bits 32-63 can be any value for an u32, so we must erase them.

@mengzhuo mengzhuo merged commit 9aebecb into plctlab:main Jan 8, 2025
2 checks 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.

2 participants