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

Provision IR for future storage API. #866

Merged
merged 2 commits into from
Mar 4, 2022
Merged

Conversation

otrho
Copy link
Contributor

@otrho otrho commented Mar 3, 2022

This adds the ability implement the storage instructions via IR. They're not exercised at all yet, other than a little IR test, but not all the way to ASM. Once #646 is done we can do it then.

Closes #856. Will probably conflict with #857.

- Switch `load` and `store` instructions to use a Value for the source
  or destination.
  - Instead of accessing a Pointer directly the use of a `get_ptr`
    instruction is now mandated.
  - Introduct a `ptr_cast` operation which casts the type of a pointer
    and may also be passed to `load` and `store`.
- Add `state_load` and `state_store` which take a `b256` key and read or
  write either `u64` or `b256` values from or to memory.
- Change the serialised syntax a little bit, update the tests.
- `load` and `store` must now take a value as the address arg.
- Add stubs to ASMgen for the yet to be utilised `ptr_cast`,
  `state_load` and `state_store` IR operations.
- Update the tests for the new `load` and `store`.
@otrho otrho added enhancement New feature or request compiler General compiler. Should eventually become more specific as the issue is triaged compiler: ir IRgen and sway-ir including optimization passes labels Mar 3, 2022
@otrho otrho self-assigned this Mar 3, 2022
@emilyaherbert
Copy link
Contributor

Should we wait for #646 to go in so that we can test these changes all the way through ASM?

@otrho
Copy link
Contributor Author

otrho commented Mar 4, 2022

I would really rather not, as these changes (2 days of work) will obviously get stale. @sezna What's the status of #646?

@sezna
Copy link
Contributor

sezna commented Mar 4, 2022

#646 is two things back in my queue right now, I say we take this first and follow up with a smaller PR hooking the front end up to it.

Copy link
Contributor

@sezna sezna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@otrho otrho merged commit 142156f into master Mar 4, 2022
@otrho otrho deleted the otrho/856_ir_casts_and_storage branch March 4, 2022 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: ir IRgen and sway-ir including optimization passes compiler General compiler. Should eventually become more specific as the issue is triaged enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add casting instructions to IR.
3 participants