-
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 remote-tracking branch 'upstream/main'
- Loading branch information
Showing
23 changed files
with
1,370 additions
and
1 deletion.
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,47 @@ | ||
# ARGS: 23 | ||
@main(n: float) { | ||
v0: float = id n; | ||
c: float = call @probability v0; | ||
c: float = id c; | ||
v1: float = id c; | ||
print v1; | ||
v2: int = const 0; | ||
} | ||
@probability(n: float): float { | ||
v0: float = const 1; | ||
prob: float = id v0; | ||
v2: float = const 1; | ||
i: float = id v2; | ||
.for.cond.1: | ||
v3: float = id i; | ||
v4: float = id n; | ||
v5: bool = flt v3 v4; | ||
br v5 .for.body.1 .for.end.1; | ||
.for.body.1: | ||
v6: float = const 365; | ||
v7: float = id i; | ||
v8: float = fsub v6 v7; | ||
log: float = id v8; | ||
v9: float = id log; | ||
v10: float = const 365; | ||
v11: float = fdiv v9 v10; | ||
logUpdated: float = id v11; | ||
v12: float = id prob; | ||
v13: float = id logUpdated; | ||
v14: float = fmul v12 v13; | ||
prob: float = id v14; | ||
v15: float = id i; | ||
v16: float = const 1; | ||
v17: float = fadd v15 v16; | ||
i: float = id v17; | ||
jmp .for.cond.1; | ||
.for.end.1: | ||
v18: float = const 1; | ||
v19: float = id prob; | ||
v20: float = const 100; | ||
v21: float = fmul v19 v20; | ||
v22: float = const 100; | ||
v23: float = fdiv v21 v22; | ||
v24: float = fsub v18 v23; | ||
ret v24; | ||
} |
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 @@ | ||
0.50729723432398566 |
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: 484 |
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,16 @@ | ||
# ARGS: 12 4 5 13 | ||
@main (width1:int, height1:int, width2:int, height2:int){ | ||
output: bool = call @fitsInside width1 height1 width2 height2; | ||
print output; | ||
} | ||
|
||
@fitsInside(w1: int, h1: int, w2: int, h2: int) : bool { | ||
width_check: bool = le w1 w2; | ||
height_check: bool = le h1 h2; | ||
first_check: bool = and width_check height_check; | ||
widthheight_check: bool = le w1 h2; | ||
heightwidth_check: bool = le h1 w2; | ||
second_check: bool = and widthheight_check heightwidth_check; | ||
ret_val: bool = or first_check second_check; | ||
ret ret_val; | ||
} |
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 @@ | ||
true |
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: 10 |
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,34 @@ | ||
#ARGS: 64 24 | ||
@main(x: int, y: int) { | ||
greater: int = id y; | ||
v4: bool = gt x y; | ||
br v4 .then.1 .else.1; | ||
.then.1: | ||
greater: int = id x; | ||
jmp .endif.1; | ||
.else.1: | ||
.endif.1: | ||
.foreverloop: | ||
modX : int = call @getMod greater x; | ||
modY : int = call @getMod greater y; | ||
zero: int = const 0; | ||
xZero : bool = eq modX zero; | ||
yZero : bool = eq modY zero; | ||
bothZero : bool = and xZero yZero; | ||
br bothZero .then.2 .else.2; | ||
.then.2: | ||
print greater; | ||
jmp .loopend; | ||
.else.2: | ||
one: int = const 1; | ||
greater:int = add greater one; | ||
jmp .foreverloop; | ||
.loopend: | ||
} | ||
|
||
@getMod(val: int, mod: int): int{ | ||
divisor: int = div val mod; | ||
multiple: int = mul divisor mod; | ||
rem: int = sub val multiple; | ||
ret rem; | ||
} |
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 @@ | ||
192 |
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: 2326 |
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,38 @@ | ||
# compute the sum of [1, n] by both loop and formula | ||
# and compare them to see if the result is the same | ||
|
||
# ARGS: 1000 | ||
@main(n: int) { | ||
first: int = call @sum_by_loop n; | ||
second: int = call @sum_by_formula n; | ||
isSame: bool = eq first second; | ||
print first; | ||
print second; | ||
print isSame; | ||
} | ||
|
||
@sum_by_loop(n: int): int { | ||
one: int = const 1; | ||
sum: int = const 0; | ||
i: int = const 1; | ||
|
||
.for_start: | ||
con: bool = le i n; | ||
br con .for .end; | ||
.for: | ||
sum: int = add sum i; | ||
i: int = add i one; | ||
jmp .for_start; | ||
.end: | ||
ret sum; | ||
} | ||
|
||
# sum = (1 + n) * n / 2 | ||
@sum_by_formula(n: int): int { | ||
one: int = const 1; | ||
two: int = const 2; | ||
n_1: int = add one n; | ||
multi: int = mul n_1 n; | ||
sum: int = div multi two; | ||
ret sum; | ||
} |
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,3 @@ | ||
500500 | ||
500500 | ||
true |
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: 5018 |
Oops, something went wrong.