forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provision IR for future storage API. (FuelLabs#866)
* Introduce storage operations to IR. - 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. * Use the new `get_ptr` and `ptr_cast` instructions in IRgen. - `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`.
- Loading branch information
Showing
37 changed files
with
620 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
script { | ||
fn main() -> bool { | ||
local ptr bool a | ||
local mut ptr bool a | ||
|
||
entry: | ||
v0 = const bool true | ||
store v0, ptr bool a | ||
v0 = get_ptr mut ptr bool a | ||
v1 = const bool true | ||
store v1, ptr v0 | ||
br while | ||
|
||
while: | ||
v1 = load ptr bool a | ||
cbr v1, while_body, end_while | ||
v2 = get_ptr mut ptr bool a | ||
v3 = load ptr v2 | ||
cbr v3, while_body, end_while | ||
|
||
while_body: | ||
v2 = load ptr bool a | ||
cbr v2, block0, block1 | ||
v4 = get_ptr mut ptr bool a | ||
v5 = load ptr v4 | ||
cbr v5, block0, block1 | ||
|
||
block0: | ||
v3 = phi(while_body: v2) | ||
v4 = const bool false | ||
v6 = phi(while_body: v5) | ||
v7 = const bool false | ||
br block1 | ||
|
||
block1: | ||
v5 = phi(while_body: v2, block0: v4) | ||
store v5, ptr bool a | ||
v8 = phi(while_body: v5, block0: v7) | ||
v9 = get_ptr mut ptr bool a | ||
store v8, ptr v9 | ||
br while | ||
|
||
end_while: | ||
v6 = load ptr bool a | ||
ret bool v6 | ||
v10 = get_ptr mut ptr bool a | ||
v11 = load ptr v10 | ||
ret bool v11 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.