Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: merged file and group ir snapshots #131

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
source: crates/mun_codegen/src/test.rs
expression: "fn add(a:int, b:int):int {\n a+b\n}\n\nfn subtract(a:int, b:int):int {\n a-b\n}\n\nfn multiply(a:int, b:int):int {\n a*b\n}"
expression: "fn add(a:int, b:int)->int {\n a+b\n}\n\nfn subtract(a:int, b:int)->int {\n a-b\n}\n\nfn multiply(a:int, b:int)->int {\n a*b\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

Expand All @@ -23,3 +24,8 @@ body:
ret i64 %mul
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
source: crates/mun_codegen/src/test.rs
expression: "fn main(a:int):int {\n if a > 4 {\n return a;\n }\n a - 1\n}"
expression: "fn main(a:int)->int {\n if a > 4 {\n return a;\n }\n a - 1\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

Expand All @@ -18,3 +19,8 @@ if_merge: ; preds = %body
ret i64 %sub
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
source: crates/mun_codegen/src/test.rs
expression: "fn equals(a:int, b:int):bool { a == b }\nfn not_equals(a:int, b:int):bool { a != b }\nfn less(a:int, b:int):bool { a < b }\nfn less_equal(a:int, b:int):bool { a <= b }\nfn greater(a:int, b:int):bool { a > b }\nfn greater_equal(a:int, b:int):bool { a >= b }\nfn equalsf(a:float, b:float):bool { a == b }\nfn not_equalsf(a:float, b:float):bool { a != b }\nfn lessf(a:float, b:float):bool { a < b }\nfn less_equalf(a:float, b:float):bool { a <= b }\nfn greaterf(a:float, b:float):bool { a > b }\nfn greater_equalf(a:float, b:float):bool { a >= b }"
expression: "fn equals(a:int, b:int)->bool { a == b }\nfn not_equals(a:int, b:int)->bool { a != b }\nfn less(a:int, b:int)->bool { a < b }\nfn less_equal(a:int, b:int)->bool { a <= b }\nfn greater(a:int, b:int)->bool { a > b }\nfn greater_equal(a:int, b:int)->bool { a >= b }\nfn equalsf(a:float, b:float)->bool { a == b }\nfn not_equalsf(a:float, b:float)->bool { a != b }\nfn lessf(a:float, b:float)->bool { a < b }\nfn less_equalf(a:float, b:float)->bool { a <= b }\nfn greaterf(a:float, b:float)->bool { a > b }\nfn greater_equalf(a:float, b:float)->bool { a >= b }"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

Expand Down Expand Up @@ -77,3 +78,8 @@ body:
ret i1 %greatereq
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

This file was deleted.

34 changes: 34 additions & 0 deletions crates/mun_codegen/src/snapshots/test__extern_fn.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
source: crates/mun_codegen/src/test.rs
expression: "extern fn add(a:int, b:int) -> int;\nfn main() {\n add(3,4);\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

%DispatchTable = type { i64 (i64, i64)* }
%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 }

@dispatchTable = external global %DispatchTable
@global_type_table = external global [1 x %struct.MunTypeInfo addrspace(4)*]

define void @main() {
body:
%add_ptr = load i64 (i64, i64)*, i64 (i64, i64)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0)
%add = call i64 %add_ptr(i64 3, i64 4)
ret void
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 }
%DispatchTable = type { i64 (i64, i64)* }

@"type_info::<core::i64>::name" = private unnamed_addr constant [10 x i8] c"core::i64\00"
@"type_info::<core::i64>" = private unnamed_addr constant %struct.MunTypeInfo { [16 x i8] c"G\13;t\97j8\18\D7M\83`\1D\C8\19%", [10 x i8]* @"type_info::<core::i64>::name", i32 64, i8 8, i8 0 }
@global_type_table = global [1 x %struct.MunTypeInfo addrspace(4)*] [%struct.MunTypeInfo addrspace(4)* @"type_info::<core::i64>"]
@dispatchTable = global %DispatchTable zeroinitializer

20 changes: 0 additions & 20 deletions crates/mun_codegen/src/snapshots/test__extern_fn_file_ir.snap

This file was deleted.

15 changes: 0 additions & 15 deletions crates/mun_codegen/src/snapshots/test__extern_fn_group_ir.snap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
source: crates/mun_codegen/src/test.rs
expression: "fn fibonacci(n:int):int {\n if n <= 1 {\n n\n } else {\n fibonacci(n-1) + fibonacci(n-2)\n }\n}"
expression: "fn fibonacci(n:int)->int {\n if n <= 1 {\n n\n } else {\n fibonacci(n-1) + fibonacci(n-2)\n }\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

Expand Down Expand Up @@ -29,3 +30,14 @@ if_merge: ; preds = %body, %else
ret i64 %iftmp
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

%DispatchTable = type { i64 (i64)* }

@dispatchTable = global %DispatchTable { i64 (i64)* @fibonacci }

declare i64 @fibonacci(i64)

13 changes: 0 additions & 13 deletions crates/mun_codegen/src/snapshots/test__fibonacci_group_ir.snap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
source: crates/mun_codegen/src/test.rs
expression: "fn fibonacci(n:int):int {\n let a = 0;\n let b = 1;\n let i = 1;\n loop {\n if i > n {\n return a\n }\n let sum = a + b;\n a = b;\n b = sum;\n i += 1;\n }\n}"
expression: "fn fibonacci(n:int)->int {\n let a = 0;\n let b = 1;\n let i = 1;\n loop {\n if i > n {\n return a\n }\n let sum = a + b;\n a = b;\n b = sum;\n i += 1;\n }\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

Expand All @@ -25,3 +26,8 @@ if_merge: ; preds = %loop
br label %loop
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
---
source: crates/mun_codegen/src/test.rs
expression: "struct(gc) Foo { a: int };\n\nfn main(c:int):int {\n let b = Foo { a: c + 5 }\n b.a\n}"
expression: "struct(gc) Foo { a: int };\n\nfn main(c:int)->int {\n let b = Foo { a: c + 5 }\n b.a\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)* }
%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 }
%Foo = type { i64 }

@allocatorHandle = external global i8*
@dispatchTable = external global %DispatchTable
@global_type_table = external global [5 x %struct.MunTypeInfo addrspace(4)*]

define i64 @main(i64) {
body:
%b = alloca %Foo* addrspace(4)*
%c = alloca i64
store i64 %0, i64* %c
%c1 = load i64, i64* %c
%add = add i64 %c1, 5
%init = insertvalue %Foo undef, i64 %add, 0
%new_ptr = load i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i8* addrspace(4)* (i8 addrspace(4)*, i8*)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 0)
%Foo_ptr = load %struct.MunTypeInfo addrspace(4)*, %struct.MunTypeInfo addrspace(4)** getelementptr inbounds ([5 x %struct.MunTypeInfo addrspace(4)*], [5 x %struct.MunTypeInfo addrspace(4)*]* @global_type_table, i32 0, i32 0)
%type_info_ptr_to_i8_ptr = bitcast %struct.MunTypeInfo addrspace(4)* %Foo_ptr to i8 addrspace(4)*
%allocator_handle = load i8*, i8** @allocatorHandle
%new = call i8* addrspace(4)* %new_ptr(i8 addrspace(4)* %type_info_ptr_to_i8_ptr, i8* %allocator_handle)
%Foo_ptr_ptr = bitcast i8* addrspace(4)* %new to %Foo* addrspace(4)*
%Foo_mem_ptr = load %Foo*, %Foo* addrspace(4)* %Foo_ptr_ptr
store %Foo %init, %Foo* %Foo_mem_ptr
store %Foo* addrspace(4)* %Foo_ptr_ptr, %Foo* addrspace(4)** %b
%mem_ptr = load %Foo* addrspace(4)*, %Foo* addrspace(4)** %b
%deref = load %Foo*, %Foo* addrspace(4)* %mem_ptr
%Foo.a = getelementptr inbounds %Foo, %Foo* %deref, i32 0, i32 0
%a = load i64, i64* %Foo.a
ret i64 %a
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

Expand Down
39 changes: 0 additions & 39 deletions crates/mun_codegen/src/snapshots/test__field_crash_file_ir.snap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
---
source: crates/mun_codegen/src/test.rs
expression: "struct(value) Bar(float, Foo);\nstruct(value) Foo { a: int };\n\nfn bar_0(bar: Bar): float {\n bar.0\n}\n\nfn bar_1(bar: Bar): Foo {\n bar.1\n}\n\nfn bar_1_a(bar: Bar): int {\n bar.1.a\n}\n\nfn foo_a(foo: Foo): int {\n foo.a\n}\n\nfn bar_1_foo_a(bar: Bar): int {\n foo_a(bar_1(bar))\n}\n\nfn main(): int {\n let a: Foo = Foo { a: 5 };\n let b: Bar = Bar(1.23, a);\n let aa_lhs = a.a + 2;\n let aa_rhs = 2 + a.a;\n aa_lhs + aa_rhs\n}"
expression: "struct(value) Bar(float, Foo);\nstruct(value) Foo { a: int };\n\nfn bar_0(bar: Bar) -> float {\n bar.0\n}\n\nfn bar_1(bar: Bar) -> Foo {\n bar.1\n}\n\nfn bar_1_a(bar: Bar) -> int {\n bar.1.a\n}\n\nfn foo_a(foo: Foo) -> int {\n foo.a\n}\n\nfn bar_1_foo_a(bar: Bar) -> int {\n foo_a(bar_1(bar))\n}\n\nfn main() -> int {\n let a: Foo = Foo { a: 5 };\n let b: Bar = Bar(1.23, a);\n let aa_lhs = a.a + 2;\n let aa_rhs = 2 + a.a;\n aa_lhs + aa_rhs\n}"
---
; == FILE IR =====================================
; ModuleID = 'main.mun'
source_filename = "main.mun"

%DispatchTable = type { i8* addrspace(4)* (i8 addrspace(4)*, i8*)*, i64 (%Foo)*, %Foo (%Bar)* }
%Foo = type { i64 }
%Bar = type { double, %Foo }
%struct.MunTypeInfo = type { [16 x i8], i8 addrspace(4)*, i32, i8, i8 }

@allocatorHandle = external global i8*
@dispatchTable = external global %DispatchTable
@global_type_table = external global [7 x %struct.MunTypeInfo addrspace(4)*]

define double @bar_0(%Bar) {
body:
%.fca.0.extract = extractvalue %Bar %0, 0
ret double %.fca.0.extract
}

define %Foo @bar_1(%Bar) {
body:
%.fca.1.0.extract = extractvalue %Bar %0, 1, 0
%"1.fca.0.insert" = insertvalue %Foo undef, i64 %.fca.1.0.extract, 0
ret %Foo %"1.fca.0.insert"
}

define i64 @bar_1_a(%Bar) {
body:
%.fca.1.0.extract = extractvalue %Bar %0, 1, 0
ret i64 %.fca.1.0.extract
}

define i64 @foo_a(%Foo) {
body:
%.fca.0.extract = extractvalue %Foo %0, 0
ret i64 %.fca.0.extract
}

define i64 @bar_1_foo_a(%Bar) {
body:
%.fca.0.extract = extractvalue %Bar %0, 0
%.fca.1.0.extract = extractvalue %Bar %0, 1, 0
%bar_1_ptr = load %Foo (%Bar)*, %Foo (%Bar)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 2)
%bar_1 = call %Foo %bar_1_ptr(%Bar %0)
%foo_a_ptr = load i64 (%Foo)*, i64 (%Foo)** getelementptr inbounds (%DispatchTable, %DispatchTable* @dispatchTable, i32 0, i32 1)
%foo_a = call i64 %foo_a_ptr(%Foo %bar_1)
ret i64 %foo_a
}

define i64 @main() {
body:
ret i64 14
}


; == GROUP IR ====================================
; ModuleID = 'group_name'
source_filename = "group_name"

Expand Down
Loading