-
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.
Changes to display in required format
- Loading branch information
1 parent
f467ea4
commit e83df43
Showing
6 changed files
with
252 additions
and
40 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
Empty file.
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,30 @@ | ||
extern input:(int,&int) -> int | ||
|
||
g1:int | ||
g2:&int | ||
|
||
fn main() -> int { | ||
let i:int, j:int, x:int, y:int, z:int, tmp:int, a:&int | ||
|
||
entry: | ||
x = $call_ext input(tmp,a) | ||
y = $copy 0 | ||
z = $copy 1 | ||
i = $copy 0 | ||
j = $copy 1 | ||
$jump loop_hdr | ||
|
||
loop_hdr: | ||
tmp = $cmp lt i x | ||
$branch tmp loop_body exit | ||
|
||
loop_body: | ||
y = $arith add y 2 | ||
z = $arith mul z j | ||
i = $arith add i 1 | ||
j = $arith add j 2 | ||
$jump loop_hdr | ||
|
||
exit: | ||
$ret y | ||
} |
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 @@ | ||
{"structs":{},"globals":[{"name":"g1","typ":"Int","scope":null},{"name":"g2","typ":{"Pointer":"Int"},"scope":null}],"functions":{"main":{"id":"main","ret_ty":"Int","params":[],"locals":[{"name":"a","typ":{"Pointer":"Int"},"scope":"main"},{"name":"i","typ":"Int","scope":"main"},{"name":"j","typ":"Int","scope":"main"},{"name":"tmp","typ":"Int","scope":"main"},{"name":"x","typ":"Int","scope":"main"},{"name":"y","typ":"Int","scope":"main"},{"name":"z","typ":"Int","scope":"main"}],"body":{"entry":{"id":"entry","insts":[{"CallExt":{"lhs":{"name":"x","typ":"Int","scope":"main"},"ext_callee":"input","args":[{"Var":{"name":"tmp","typ":"Int","scope":"main"}},{"Var":{"name":"a","typ":{"Pointer":"Int"},"scope":"main"}}]}},{"Copy":{"lhs":{"name":"y","typ":"Int","scope":"main"},"op":{"CInt":0}}},{"Copy":{"lhs":{"name":"z","typ":"Int","scope":"main"},"op":{"CInt":1}}},{"Copy":{"lhs":{"name":"i","typ":"Int","scope":"main"},"op":{"CInt":0}}},{"Copy":{"lhs":{"name":"j","typ":"Int","scope":"main"},"op":{"CInt":1}}}],"term":{"Jump":"loop_hdr"}},"exit":{"id":"exit","insts":[],"term":{"Ret":{"Var":{"name":"y","typ":"Int","scope":"main"}}}},"loop_body":{"id":"loop_body","insts":[{"Arith":{"lhs":{"name":"y","typ":"Int","scope":"main"},"aop":"Add","op1":{"Var":{"name":"y","typ":"Int","scope":"main"}},"op2":{"CInt":2}}},{"Arith":{"lhs":{"name":"z","typ":"Int","scope":"main"},"aop":"Multiply","op1":{"Var":{"name":"z","typ":"Int","scope":"main"}},"op2":{"Var":{"name":"j","typ":"Int","scope":"main"}}}},{"Arith":{"lhs":{"name":"i","typ":"Int","scope":"main"},"aop":"Add","op1":{"Var":{"name":"i","typ":"Int","scope":"main"}},"op2":{"CInt":1}}},{"Arith":{"lhs":{"name":"j","typ":"Int","scope":"main"},"aop":"Add","op1":{"Var":{"name":"j","typ":"Int","scope":"main"}},"op2":{"CInt":2}}}],"term":{"Jump":"loop_hdr"}},"loop_hdr":{"id":"loop_hdr","insts":[{"Cmp":{"lhs":{"name":"tmp","typ":"Int","scope":"main"},"rop":"Less","op1":{"Var":{"name":"i","typ":"Int","scope":"main"}},"op2":{"Var":{"name":"x","typ":"Int","scope":"main"}}}}],"term":{"Branch":{"cond":{"Var":{"name":"tmp","typ":"Int","scope":"main"}},"tt":"loop_body","ff":"exit"}}}}}},"externs":{"input":{"Function":{"ret_ty":"Int","param_ty":["Int",{"Pointer":"Int"}]}}}} |
Oops, something went wrong.