Skip to content

Commit

Permalink
accept insta tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ghaith committed Jan 17, 2025
1 parent 71b249e commit 16481a9
Show file tree
Hide file tree
Showing 26 changed files with 156 additions and 513 deletions.
2 changes: 1 addition & 1 deletion src/codegen/tests/debug_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn switch_case_debug_info() {
x2 : INT;
x3 : INT;
END_VAR
WHILE TRUE DO
x1 := x1 + 1;
Expand Down

This file was deleted.

53 changes: 22 additions & 31 deletions src/codegen/tests/initialization_test/complex_initializers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,8 +790,6 @@ fn stateful_pous_methods_and_structs_get_init_functions() {
%foo = type {}
%cl = type {}
%myStruct = type {}
%foo.m = type {}
%cl.m = type {}
@prog_instance = global %prog zeroinitializer
@__foo__init = unnamed_addr constant %foo zeroinitializer
Expand All @@ -808,7 +806,7 @@ fn stateful_pous_methods_and_structs_get_init_functions() {
ret void
}
define void @foo.m(%foo* %0, %foo.m* %1) {
define void @foo.m(%foo* %0) {
entry:
ret void
}
Expand All @@ -818,7 +816,7 @@ fn stateful_pous_methods_and_structs_get_init_functions() {
ret void
}
define void @cl.m(%cl* %0, %cl.m* %1) {
define void @cl.m(%cl* %0) {
entry:
ret void
}
Expand Down Expand Up @@ -1641,7 +1639,6 @@ fn initializing_method_variables_with_refs() {
source_filename = "<internal>"
%foo = type {}
%foo.bar = type { i32, i32* }
@__foo__init = unnamed_addr constant %foo zeroinitializer
Expand All @@ -1650,10 +1647,10 @@ fn initializing_method_variables_with_refs() {
ret void
}
define void @foo.bar(%foo* %0, %foo.bar* %1) {
define void @foo.bar(%foo* %0) {
entry:
%x = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 0
%px = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 1
%x = alloca i32, align 4
%px = alloca i32*, align 8
store i32 10, i32* %x, align 4
store i32* %x, i32** %px, align 8
store i32* %x, i32** %px, align 8
Expand Down Expand Up @@ -1707,7 +1704,6 @@ fn initializing_method_variables_with_refs_referencing_parent_pou_variable() {
source_filename = "<internal>"
%foo = type { i32 }
%foo.bar = type { i32* }
@__foo__init = unnamed_addr constant %foo { i32 5 }
Expand All @@ -1717,10 +1713,10 @@ fn initializing_method_variables_with_refs_referencing_parent_pou_variable() {
ret void
}
define void @foo.bar(%foo* %0, %foo.bar* %1) {
define void @foo.bar(%foo* %0) {
entry:
%x = getelementptr inbounds %foo, %foo* %0, i32 0, i32 0
%px = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 0
%px = alloca i32*, align 8
store i32* %x, i32** %px, align 8
store i32* %x, i32** %px, align 8
ret void
Expand Down Expand Up @@ -1773,7 +1769,6 @@ fn initializing_method_variables_with_refs_referencing_global_variable() {
source_filename = "<internal>"
%foo = type {}
%foo.bar = type { i32* }
@x = global i32 0
@__foo__init = unnamed_addr constant %foo zeroinitializer
Expand All @@ -1783,9 +1778,9 @@ fn initializing_method_variables_with_refs_referencing_global_variable() {
ret void
}
define void @foo.bar(%foo* %0, %foo.bar* %1) {
define void @foo.bar(%foo* %0) {
entry:
%px = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 0
%px = alloca i32*, align 8
store i32* @x, i32** %px, align 8
store i32* @x, i32** %px, align 8
ret void
Expand Down Expand Up @@ -1839,7 +1834,6 @@ fn initializing_method_variables_with_refs_shadowing() {
source_filename = "<internal>"
%foo = type {}
%foo.bar = type { i32, i32* }
@x = global i32 0
@__foo__init = unnamed_addr constant %foo zeroinitializer
Expand All @@ -1849,10 +1843,10 @@ fn initializing_method_variables_with_refs_shadowing() {
ret void
}
define void @foo.bar(%foo* %0, %foo.bar* %1) {
define void @foo.bar(%foo* %0) {
entry:
%x = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 0
%px = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 1
%x = alloca i32, align 4
%px = alloca i32*, align 8
store i32 0, i32* %x, align 4
store i32* %x, i32** %px, align 8
store i32* %x, i32** %px, align 8
Expand Down Expand Up @@ -1903,7 +1897,6 @@ fn initializing_method_variables_with_alias() {
source_filename = "<internal>"
%foo = type {}
%foo.bar = type { i32, i32* }
@__foo__init = unnamed_addr constant %foo zeroinitializer
Expand All @@ -1912,10 +1905,10 @@ fn initializing_method_variables_with_alias() {
ret void
}
define void @foo.bar(%foo* %0, %foo.bar* %1) {
define void @foo.bar(%foo* %0) {
entry:
%x = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 0
%px = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 1
%x = alloca i32, align 4
%px = alloca i32*, align 8
store i32 0, i32* %x, align 4
store i32* null, i32** %px, align 8
store i32* %x, i32** %px, align 8
Expand Down Expand Up @@ -1966,7 +1959,6 @@ fn initializing_method_variables_with_reference_to() {
source_filename = "<internal>"
%foo = type {}
%foo.bar = type { i32, i32* }
@__foo__init = unnamed_addr constant %foo zeroinitializer
Expand All @@ -1975,10 +1967,10 @@ fn initializing_method_variables_with_reference_to() {
ret void
}
define void @foo.bar(%foo* %0, %foo.bar* %1) {
define void @foo.bar(%foo* %0) {
entry:
%x = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 0
%px = getelementptr inbounds %foo.bar, %foo.bar* %1, i32 0, i32 1
%x = alloca i32, align 4
%px = alloca i32*, align 8
store i32 0, i32* %x, align 4
store i32* null, i32** %px, align 8
store i32* %x, i32** %px, align 8
Expand Down Expand Up @@ -2037,7 +2029,6 @@ fn methods_call_init_functions_for_their_members() {
%foo = type { i32, i32* }
%bar = type {}
%bar.baz = type { %foo }
@__foo__init = unnamed_addr constant %foo zeroinitializer
@__bar__init = unnamed_addr constant %bar zeroinitializer
Expand All @@ -2054,11 +2045,11 @@ fn methods_call_init_functions_for_their_members() {
ret void
}
define void @bar.baz(%bar* %0, %bar.baz* %1) {
define void @bar.baz(%bar* %0) {
entry:
%fb = getelementptr inbounds %bar.baz, %bar.baz* %1, i32 0, i32 0
%2 = bitcast %foo* %fb to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %2, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false)
%fb = alloca %foo, align 8
%1 = bitcast %foo* %fb to i8*
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 bitcast (%foo* @__foo__init to i8*), i64 ptrtoint (%foo* getelementptr (%foo, %foo* null, i32 1) to i64), i1 false)
call void @__init_foo(%foo* %fb)
ret void
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
---
source: src/codegen/tests/code_gen_tests.rs
expression: result
snapshot_kind: text
---
; ModuleID = '<internal>'
source_filename = "<internal>"

%MyClass = type { i16, i16 }
%MyClass.testMethod = type { i16, i16 }

@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer

Expand All @@ -18,12 +16,13 @@ entry:
ret void
}

define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) {
define void @MyClass.testMethod(%MyClass* %0, i16 %1) {
entry:
%x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0
%y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1
%myMethodArg = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 0
%myMethodLocalVar = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 1
%myMethodArg = alloca i16, align 2
store i16 %1, i16* %myMethodArg, align 2
%myMethodLocalVar = alloca i16, align 2
store i16 0, i16* %myMethodLocalVar, align 2
%load_myMethodArg = load i16, i16* %myMethodArg, align 2
store i16 %load_myMethodArg, i16* %x, align 2
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
source: src/codegen/tests/code_gen_tests.rs
expression: result
snapshot_kind: text
---
; ModuleID = '<internal>'
source_filename = "<internal>"

%MyClass = type { i16, i16 }
%prg = type { %MyClass, i16 }
%MyClass.testMethod = type { i16, i16 }

@__MyClass__init = unnamed_addr constant %MyClass zeroinitializer
@prg_instance = global %prg zeroinitializer
Expand All @@ -20,12 +18,13 @@ entry:
ret void
}

define void @MyClass.testMethod(%MyClass* %0, %MyClass.testMethod* %1) {
define void @MyClass.testMethod(%MyClass* %0, i16 %1) {
entry:
%x = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 0
%y = getelementptr inbounds %MyClass, %MyClass* %0, i32 0, i32 1
%myMethodArg = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 0
%myMethodLocalVar = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %1, i32 0, i32 1
%myMethodArg = alloca i16, align 2
store i16 %1, i16* %myMethodArg, align 2
%myMethodLocalVar = alloca i16, align 2
store i16 0, i16* %myMethodLocalVar, align 2
%load_myMethodArg = load i16, i16* %myMethodArg, align 2
store i16 %load_myMethodArg, i16* %x, align 2
Expand All @@ -46,16 +45,10 @@ entry:
%x1 = getelementptr inbounds %MyClass, %MyClass* %cl, i32 0, i32 0
%load_x = load i16, i16* %x1, align 2
store i16 %load_x, i16* %x, align 2
%MyClass.testMethod_instance = alloca %MyClass.testMethod, align 8
%1 = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %MyClass.testMethod_instance, i32 0, i32 0
%load_x2 = load i16, i16* %x, align 2
store i16 %load_x2, i16* %1, align 2
call void @MyClass.testMethod(%MyClass* %cl, %MyClass.testMethod* %MyClass.testMethod_instance)
%MyClass.testMethod_instance3 = alloca %MyClass.testMethod, align 8
%2 = getelementptr inbounds %MyClass.testMethod, %MyClass.testMethod* %MyClass.testMethod_instance3, i32 0, i32 0
%load_x4 = load i16, i16* %x, align 2
store i16 %load_x4, i16* %2, align 2
call void @MyClass.testMethod(%MyClass* %cl, %MyClass.testMethod* %MyClass.testMethod_instance3)
call void @MyClass.testMethod(%MyClass* %cl, i16 %load_x2)
%load_x3 = load i16, i16* %x, align 2
call void @MyClass.testMethod(%MyClass* %cl, i16 %load_x3)
ret void
}
; ModuleID = '__initializers'
Expand Down
Loading

0 comments on commit 16481a9

Please sign in to comment.