Skip to content

Commit

Permalink
hw(3): Add nested_structs
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzikai committed Nov 3, 2021
1 parent e0d449c commit cae626c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ setup.log

# Local OPAM switch
_opam/

# macOS
.DS_Store
*.icloud
1 change: 1 addition & 0 deletions 03/sharedtests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ open Assert
let shared_suite : suite =
[ Test ("dbernhard", Gradedtests.executed Dbernhard.dbernhard_tests)
; Test ("nicdard", Nicdard.executed Nicdard.nicdard_tests)
; Test ("zikai", Gradedtests.executed Zikai.zikai_tests)
]
7 changes: 7 additions & 0 deletions 03/zikai.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let prefix = "./compiler-design-eth-tests/03/zikai/"

let zikai_tests = [
prefix ^ "nested_structs.ll", 16L
; prefix ^ "nested_structs2.ll", 8L
; prefix ^ "nested_structs3.ll", 127L
]
11 changes: 11 additions & 0 deletions 03/zikai/nested_structs.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

%struct.ST = type { i64, i64, %struct.RT }
%struct.RT = type { i64, [2 x [4 x i64]], i64 }

@s = global [2 x %struct.ST] [%struct.ST { i64 42, i64 -42, %struct.RT { i64 24, [2 x [4 x i64]] [[4 x i64] [i64 1, i64 2, i64 3, i64 4], [4 x i64] [i64 5, i64 6, i64 7, i64 8]], i64 127 } }, %struct.ST { i64 24, i64 -24, %struct.RT { i64 42, [2 x [4 x i64]] [[4 x i64] [i64 9, i64 10, i64 11, i64 12], [4 x i64] [i64 13, i64 14, i64 15, i64 16]], i64 -127 } }]

define i64 @main(i64 %argc, i8** %arcv) {
%1 = getelementptr [2 x %struct.ST], [2 x %struct.ST]* @s, i64 0, i64 1, i32 2, i32 1, i64 1, i64 3
%2 = load i64, i64* %1
ret i64 %2
}
11 changes: 11 additions & 0 deletions 03/zikai/nested_structs2.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

%struct.ST = type { i64, i64, %struct.RT }
%struct.RT = type { i64, [2 x [4 x i64]], i64 }

@s = global [2 x %struct.ST] [%struct.ST { i64 42, i64 -42, %struct.RT { i64 24, [2 x [4 x i64]] [[4 x i64] [i64 1, i64 2, i64 3, i64 4], [4 x i64] [i64 5, i64 6, i64 7, i64 8]], i64 127 } }, %struct.ST { i64 24, i64 -24, %struct.RT { i64 42, [2 x [4 x i64]] [[4 x i64] [i64 9, i64 10, i64 11, i64 12], [4 x i64] [i64 13, i64 14, i64 15, i64 16]], i64 -127 } }]

define i64 @main(i64 %argc, i8** %arcv) {
%1 = getelementptr [2 x %struct.ST], [2 x %struct.ST]* @s, i64 0, i64 0, i32 2, i32 1, i64 1, i64 3
%2 = load i64, i64* %1
ret i64 %2
}
11 changes: 11 additions & 0 deletions 03/zikai/nested_structs3.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

%struct.ST = type { i64, i64, %struct.RT }
%struct.RT = type { i64, [2 x [4 x i64]], i64 }

@s = global [2 x %struct.ST] [%struct.ST { i64 42, i64 -42, %struct.RT { i64 24, [2 x [4 x i64]] [[4 x i64] [i64 1, i64 2, i64 3, i64 4], [4 x i64] [i64 5, i64 6, i64 7, i64 8]], i64 127 } }, %struct.ST { i64 24, i64 -24, %struct.RT { i64 42, [2 x [4 x i64]] [[4 x i64] [i64 9, i64 10, i64 11, i64 12], [4 x i64] [i64 13, i64 14, i64 15, i64 16]], i64 127 } }]

define i64 @main(i64 %argc, i8** %arcv) {
%1 = getelementptr [2 x %struct.ST], [2 x %struct.ST]* @s, i64 0, i64 1, i32 2, i32 2
%2 = load i64, i64* %1
ret i64 %2
}

0 comments on commit cae626c

Please sign in to comment.