Skip to content

Add a Go backend#638

Merged
JasonGross merged 2 commits into
mit-plv:masterfrom
JasonGross:go
Feb 10, 2020
Merged

Add a Go backend#638
JasonGross merged 2 commits into
mit-plv:masterfrom
JasonGross:go

Conversation

@JasonGross

@JasonGross JasonGross commented Jan 9, 2020

Copy link
Copy Markdown
Collaborator

Requested by @FiloSottile

The code does not fully work yet. Still remaining (at least):

  • Dealing with the "declared and not used" errors from cases where one return value of bits.Mul64 is unused (the other is used), etc. (@FiloSottile thoughts?)
  • Figuring out what's up with Invalid identifier in arithmetic expression Z.zselect (shows up in to_bytes for unsaturated solinas, and a bunch of other places as well). I'll dig into this when I get a chance.
  • Figuring out what's up with remaining Z.combine_at_bitwidth in 32-bit outputs (maybe not necessary if Go only cares about cases when we have 64 bit integers available?) (@FiloSottile can we use uint64 on 32-bit platforms?)

@FiloSottile

Copy link
Copy Markdown

Awesome!

  • Dealing with the "declared and not used" errors from cases where one return value of bits.Mul64 is unused (the other is used), etc. (@FiloSottile thoughts?)

If you know already that you won't use that value, just call it _ and it will get ignored. Otherwise you have to explicitly ignore it by doing something like _ = a.

  • Figuring out what's up with remaining Z.combine_at_bitwidth in 32-bit outputs (maybe not necessary if Go only cares about cases when we have 64 bit integers available?) (@FiloSottile can we use uint64 on 32-bit platforms?)

We can use uint64 on 32-bit platforms, but it might not have acceptable performance?

@JasonGross

Copy link
Copy Markdown
Collaborator Author

If you know already that you won't use that value, just call it _ and it will get ignored. Otherwise you have to explicitly ignore it by doing something like _ = a.

This is pretty tricky for us. I could make it happen, but it'd probably take a week or two of my working on it full time. Within each function, though, we don't reuse variable names. Could you get a post-processing phase to do this?

We can use uint64 on 32-bit platforms, but it might not have acceptable performance?

Nah, should be fine, we'd only use it to get 32x32 -> 32x32 multiplication, and also for 32-bit add-with-carry.

@FiloSottile

Copy link
Copy Markdown

If you know already that you won't use that value, just call it _ and it will get ignored. Otherwise you have to explicitly ignore it by doing something like _ = a.

This is pretty tricky for us. I could make it happen, but it'd probably take a week or two of my working on it full time. Within each function, though, we don't reuse variable names. Could you get a post-processing phase to do this?

Yeah, sounds like it will be easier to do in post-processing.

@JasonGross
JasonGross force-pushed the go branch 13 times, most recently from e4fe573 to 72e4e7d Compare February 8, 2020 05:46
@JasonGross

Copy link
Copy Markdown
Collaborator Author

@FiloSottile Success! All of the Go files now build!

@JasonGross
JasonGross force-pushed the go branch 4 times, most recently from 766e8a4 to f3641a3 Compare February 8, 2020 05:57
@JasonGross

Copy link
Copy Markdown
Collaborator Author

Btw, I added in a post-processing phase that replaces unused identifiers with _, so you don't have to. (There aren't any proofs about this pass, just like there aren't any proofs about any of the stringification bits.)

@JasonGross
JasonGross force-pushed the go branch 2 times, most recently from bcb702c to 7b9c560 Compare February 8, 2020 20:52
This is one way of dealing with mit-plv#655 (changing from 17 limbs to 18
limbs).
@JasonGross
JasonGross force-pushed the go branch 2 times, most recently from 9239872 to 48ab2d6 Compare February 8, 2020 23:04
@JasonGross

Copy link
Copy Markdown
Collaborator Author

I am going to merge this. @FiloSottile feel free to open an issue if you want changes to this, or want this published as a Go package like the Rust code is, or whatever.

@JasonGross
JasonGross merged commit 7b82258 into mit-plv:master Feb 10, 2020
@JasonGross
JasonGross deleted the go branch February 10, 2020 18:23
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