Skip to content

Commit

Permalink
[TESTS] adding more ir tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0a3 committed Sep 12, 2024
1 parent 57d34dc commit e2e95ce
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/IR/assign/assign0.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# RUN:
cargo run -p ylc -- -in=%s -o=out.o
gcc out.o -o a.exe
./a.exe
# IN:
define u32 @main() {
entry:
%1 = u32 5
ret u32 %1
}

# EXIT_CODE=5
13 changes: 13 additions & 0 deletions tests/IR/assign/assign1.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# RUN:
cargo run -p ylc -- -in=%s -o=out.o
gcc out.o -o a.exe
./a.exe
# IN:
define u32 @main() {
entry:
%1 = u32 68
%2 = u32 %1
ret u32 %1
}

# EXIT_CODE=68
31 changes: 31 additions & 0 deletions tests/IR/call/call1.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# RUN:
cargo run -p ylc -- -in=%s -o=out.o
gcc out.o -o a.exe
./a.exe
# IN:

define u32 @func(u32 %0, u32 %1) {
entry:
%2 = add u32 %0, %1
%3 = sub u32 %2, 5
br cond %3 isnt0, is0

isnt0:
ret u32 4

is0:
ret u32 0
}
define u32 @main() {
entry:
%1 = u32 9
%2 = u32 21

%3 = call u32 func u32 %1 u32 %2

%4 = add u32 %3, 6

ret u32 %4
}

# EXIT_CODE=10
11 changes: 11 additions & 0 deletions tests/IR/ret/ret0.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RUN:
cargo run -p ylc -- -in=%s -o=out.o
gcc out.o -o a.exe
./a.exe
# IN:
define u32 @main() {
entry:
ret u32 3
}

# EXIT_CODE=3
11 changes: 11 additions & 0 deletions tests/IR/ret/ret1.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# RUN:
cargo run -p ylc -- -in=%s -o=out.o
gcc out.o -o a.exe
./a.exe
# IN:
define u32 @main(u32 %0) {
entry:
ret u32 %0
}

# EXIT_CODE=1

0 comments on commit e2e95ce

Please sign in to comment.