-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from bcarlet/hanoi
Add Hanoi benchmark
- Loading branch information
Showing
4 changed files
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Tower of Hanoi puzzle. | ||
# | ||
# Input: Number of disks. | ||
# Output: Each move in order, one on each line, where a move `src dst` indicates | ||
# that the top disk from rod `src` should be moved to rod `dst`. | ||
|
||
@hanoi (disks: int, src: int, dst: int, spare: int) { | ||
zero: int = const 0; | ||
pos: bool = gt disks zero; | ||
br pos .then .else; | ||
.then: | ||
one: int = const 1; | ||
above: int = sub disks one; | ||
call @hanoi above src spare dst; | ||
print src dst; | ||
call @hanoi above spare dst src; | ||
.else: | ||
ret; | ||
} | ||
|
||
# ARGS: 3 | ||
@main (disks: int) { | ||
src: int = const 0; | ||
dst: int = const 2; | ||
spare: int = const 1; | ||
call @hanoi disks src dst spare; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
0 2 | ||
0 1 | ||
2 1 | ||
0 2 | ||
1 0 | ||
1 2 | ||
0 2 |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
total_dyn_inst: 99 |
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