-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
irgen: Add binary expression test cases.
- Loading branch information
Showing
3 changed files
with
198 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
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,71 @@ | ||
int f() { | ||
int a; | ||
int b; | ||
return a + b; | ||
} | ||
|
||
int g() { | ||
int a; | ||
int b; | ||
return a - b; | ||
} | ||
|
||
int h() { | ||
int a; | ||
int b; | ||
return a * b; | ||
} | ||
|
||
int i() { | ||
int a; | ||
int b; | ||
return a / b; | ||
} | ||
|
||
int j() { | ||
int a; | ||
int b; | ||
return a < b; | ||
} | ||
|
||
int k() { | ||
int a; | ||
int b; | ||
return a > b; | ||
} | ||
|
||
int l() { | ||
int a; | ||
int b; | ||
return a <= b; | ||
} | ||
|
||
int m() { | ||
int a; | ||
int b; | ||
return a >= b; | ||
} | ||
|
||
int n() { | ||
int a; | ||
int b; | ||
return a != b; | ||
} | ||
|
||
int o() { | ||
int a; | ||
int b; | ||
return a == b; | ||
} | ||
|
||
int p() { | ||
int a; | ||
int b; | ||
return a && b; | ||
} | ||
|
||
int q() { | ||
int a; | ||
int b; | ||
return a = b; | ||
} |
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,120 @@ | ||
define i32 @f() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = add i32 %1, %2 | ||
ret i32 %3 | ||
} | ||
define i32 @g() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = sub i32 %1, %2 | ||
ret i32 %3 | ||
} | ||
define i32 @h() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = mul i32 %1, %2 | ||
ret i32 %3 | ||
} | ||
define i32 @i() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = sdiv i32 %1, %2 | ||
ret i32 %3 | ||
} | ||
define i32 @j() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = icmp slt i32 %1, %2 | ||
%4 = zext i1 %3 to i32 | ||
ret i32 %4 | ||
} | ||
define i32 @k() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = icmp sgt i32 %1, %2 | ||
%4 = zext i1 %3 to i32 | ||
ret i32 %4 | ||
} | ||
define i32 @l() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = icmp sle i32 %1, %2 | ||
%4 = zext i1 %3 to i32 | ||
ret i32 %4 | ||
} | ||
define i32 @m() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = icmp sge i32 %1, %2 | ||
%4 = zext i1 %3 to i32 | ||
ret i32 %4 | ||
} | ||
define i32 @n() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = icmp ne i32 %1, %2 | ||
%4 = zext i1 %3 to i32 | ||
ret i32 %4 | ||
} | ||
define i32 @o() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = load i32, i32* %b | ||
%3 = icmp eq i32 %1, %2 | ||
%4 = zext i1 %3 to i32 | ||
ret i32 %4 | ||
} | ||
define i32 @p() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %a | ||
%2 = icmp ne i32 %1, 0 | ||
br i1 %2, label %3, label %6 | ||
3: | ||
%4 = load i32, i32* %b | ||
%5 = icmp ne i32 %4, 0 | ||
br label %6 | ||
6: | ||
%7 = phi i1 [ false, %0 ], [ %5, %3 ] | ||
%8 = zext i1 %7 to i32 | ||
ret i32 %8 | ||
} | ||
define i32 @q() { | ||
0: | ||
%a = alloca i32 | ||
%b = alloca i32 | ||
%1 = load i32, i32* %b | ||
store i32 %1, i32* %a | ||
ret i32 %1 | ||
} |