Skip to content
Open
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
198de5b
fix builtins
abroooo Sep 12, 2025
0577ac7
Merge branch 'master' into abroooo/fix_support_named_arguments_for_bu…
abroooo Sep 16, 2025
a7874bf
fix tests
abroooo Sep 22, 2025
1d63f42
add codegen tests
abroooo Sep 22, 2025
b409966
add correctness tests
abroooo Sep 22, 2025
3325e39
improve lit test
abroooo Sep 22, 2025
454f9b5
add more tests
abroooo Sep 22, 2025
ed037f4
cleanup
abroooo Sep 22, 2025
3548826
fix and cleanup
abroooo Sep 22, 2025
f3582c3
Merge branch 'master' into abroooo/fix_support_named_arguments_for_bu…
abroooo Sep 23, 2025
f8e2987
refactor
abroooo Sep 23, 2025
bfc95e2
more refactor
abroooo Sep 23, 2025
9263a52
support div and sub
abroooo Sep 23, 2025
e6886eb
more tests
abroooo Sep 23, 2025
b96b01a
even more refactor
abroooo Sep 23, 2025
b686636
add tests for sub/div
abroooo Sep 23, 2025
3ce4de5
another refactor
abroooo Sep 23, 2025
a045647
add lit test for sub/div
abroooo Sep 23, 2025
3cac9f6
add missing snapshots
abroooo Sep 24, 2025
c8777f3
add/modify comments
abroooo Sep 24, 2025
18053d8
implement feedback
abroooo Sep 24, 2025
a0acc53
seperate tests for named and positional arguments into two lit tests
abroooo Sep 25, 2025
d073131
add positional test for missing builtins
abroooo Sep 25, 2025
12263a1
remove correctness tests for named builtins as we have lit tests for it
abroooo Sep 25, 2025
5d6f513
delete dangling snapshots
abroooo Sep 30, 2025
0180846
delete more dangling snapshots 😲
abroooo Sep 30, 2025
ba92b85
Merge branch 'master' into abroooo/fix_support_named_arguments_for_bu…
abroooo Oct 6, 2025
76db03e
refactor
abroooo Oct 7, 2025
463d17c
cleanup
abroooo Oct 7, 2025
19f6b47
style
abroooo Oct 7, 2025
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
320 changes: 190 additions & 130 deletions src/builtins.rs

Large diffs are not rendered by default.

578 changes: 571 additions & 7 deletions src/codegen/tests/expression_tests.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: src/codegen/tests/expression_tests.rs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have some dangling snapshots here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch! will remove them

expression: res
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

define i32 @main() {
entry:
%main = alloca i32, align 4
%x = alloca i32, align 4
%y = alloca i32, align 4
store i32 20, i32* %x, align 4
store i32 4, i32* %y, align 4
store i32 0, i32* %main, align 4
%load_x = load i32, i32* %x, align 4
%load_y = load i32, i32* %y, align 4
%tmpVar = sdiv i32 %load_x, %load_y
%main_ret = load i32, i32* %main, align 4
ret i32 %main_ret
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
source: src/codegen/tests/expression_tests.rs
expression: result
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

%main = type { [2 x i32], i32 }
%__foo_vla = type { i32*, [2 x i32] }

@main_instance = global %main zeroinitializer
@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer

define void @main(%main* %0) {
entry:
%a = getelementptr inbounds %main, %main* %0, i32 0, i32 0
%b = getelementptr inbounds %main, %main* %0, i32 0, i32 1
%auto_deref = load [2 x i32], [2 x i32]* %a, align 4
%outer_arr_gep = getelementptr inbounds [2 x i32], [2 x i32]* %a, i32 0, i32 0
%vla_struct = alloca %__foo_vla, align 8
%vla_array_gep = getelementptr inbounds %__foo_vla, %__foo_vla* %vla_struct, i32 0, i32 0
%vla_dimensions_gep = getelementptr inbounds %__foo_vla, %__foo_vla* %vla_struct, i32 0, i32 1
store [2 x i32] [i32 0, i32 1], [2 x i32]* %vla_dimensions_gep, align 4
store i32* %outer_arr_gep, i32** %vla_array_gep, align 8
%1 = load %__foo_vla, %__foo_vla* %vla_struct, align 8
%vla_struct_ptr = alloca %__foo_vla, align 8
store %__foo_vla %1, %__foo_vla* %vla_struct_ptr, align 8
%call = call i32 @foo(%__foo_vla* %vla_struct_ptr)
store i32 %call, i32* %b, align 4
ret void
}

define i32 @foo(%__foo_vla* %0) {
entry:
%foo = alloca i32, align 4
%vla = alloca %__foo_vla*, align 8
store %__foo_vla* %0, %__foo_vla** %vla, align 8
store i32 0, i32* %foo, align 4
%deref = load %__foo_vla*, %__foo_vla** %vla, align 8
%dim = getelementptr inbounds %__foo_vla, %__foo_vla* %deref, i32 0, i32 1
%1 = getelementptr inbounds [2 x i32], [2 x i32]* %dim, i32 0, i32 0
%2 = load i32, i32* %1, align 4
store i32 %2, i32* %foo, align 4
%foo_ret = load i32, i32* %foo, align 4
ret i32 %foo_ret
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
source: src/codegen/tests/expression_tests.rs
expression: result
snapshot_kind: text
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

%main = type { i32*, i32 }
%main = type { i32, i32 }

@main_instance = global %main zeroinitializer

define void @main(%main* %0) {
entry:
%a = getelementptr inbounds %main, %main* %0, i32 0, i32 0
%b = getelementptr inbounds %main, %main* %0, i32 0, i32 1
store i32* %b, i32** %a, align 8
%load_b = load i32, i32* %b, align 4
store i32 %load_b, i32* %a, align 4
ret void
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
source: src/codegen/tests/expression_tests.rs
expression: result
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

%main = type { i32, i32, i32 }

@main_instance = global %main zeroinitializer

define void @main(%main* %0) {
entry:
%a = getelementptr inbounds %main, %main* %0, i32 0, i32 0
%b = getelementptr inbounds %main, %main* %0, i32 0, i32 1
%c = getelementptr inbounds %main, %main* %0, i32 0, i32 2
%load_b = load i32, i32* %b, align 4
%load_c = load i32, i32* %c, align 4
%1 = select i1 true, i32 %load_c, i32 %load_b
store i32 %1, i32* %a, align 4
ret void
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
---
source: src/codegen/tests/expression_tests.rs
expression: result
snapshot_kind: text
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

%main = type { i32*, i32 }
%main = type { i32, i64 }

@main_instance = global %main zeroinitializer

define void @main(%main* %0) {
entry:
%a = getelementptr inbounds %main, %main* %0, i32 0, i32 0
%b = getelementptr inbounds %main, %main* %0, i32 0, i32 1
store i32* %b, i32** %a, align 8
store i32 ptrtoint (i64* getelementptr (i64, i64* null, i32 1) to i32), i32* %a, align 4
ret void
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
source: src/codegen/tests/expression_tests.rs
expression: result
snapshot_kind: text
---
; ModuleID = '<internal>'
source_filename = "<internal>"
Expand Down Expand Up @@ -45,6 +44,11 @@ entry:
%1 = getelementptr inbounds [2 x i32], [2 x i32]* %dim, i32 0, i32 7
%2 = load i32, i32* %1, align 4
store i32 %2, i32* %foo, align 4
%deref1 = load %__foo_vla*, %__foo_vla** %vla, align 8
%dim2 = getelementptr inbounds %__foo_vla, %__foo_vla* %deref1, i32 0, i32 1
%3 = getelementptr inbounds [2 x i32], [2 x i32]* %dim2, i32 0, i32 7
%4 = load i32, i32* %3, align 4
store i32 %4, i32* %foo, align 4
%foo_ret = load i32, i32* %foo, align 4
ret i32 %foo_ret
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
source: src/codegen/tests/expression_tests.rs
expression: result
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

%main = type { [2 x i32], i32 }
%__foo_vla = type { i32*, [2 x i32] }

@main_instance = global %main zeroinitializer
@____foo_vla__init = unnamed_addr constant %__foo_vla zeroinitializer

define void @main(%main* %0) {
entry:
%a = getelementptr inbounds %main, %main* %0, i32 0, i32 0
%b = getelementptr inbounds %main, %main* %0, i32 0, i32 1
%auto_deref = load [2 x i32], [2 x i32]* %a, align 4
%outer_arr_gep = getelementptr inbounds [2 x i32], [2 x i32]* %a, i32 0, i32 0
%vla_struct = alloca %__foo_vla, align 8
%vla_array_gep = getelementptr inbounds %__foo_vla, %__foo_vla* %vla_struct, i32 0, i32 0
%vla_dimensions_gep = getelementptr inbounds %__foo_vla, %__foo_vla* %vla_struct, i32 0, i32 1
store [2 x i32] [i32 0, i32 1], [2 x i32]* %vla_dimensions_gep, align 4
store i32* %outer_arr_gep, i32** %vla_array_gep, align 8
%1 = load %__foo_vla, %__foo_vla* %vla_struct, align 8
%vla_struct_ptr = alloca %__foo_vla, align 8
store %__foo_vla %1, %__foo_vla* %vla_struct_ptr, align 8
%call = call i32 @foo(%__foo_vla* %vla_struct_ptr)
store i32 %call, i32* %b, align 4
ret void
}

define i32 @foo(%__foo_vla* %0) {
entry:
%foo = alloca i32, align 4
%vla = alloca %__foo_vla*, align 8
store %__foo_vla* %0, %__foo_vla** %vla, align 8
store i32 0, i32* %foo, align 4
%deref = load %__foo_vla*, %__foo_vla** %vla, align 8
%dim = getelementptr inbounds %__foo_vla, %__foo_vla* %deref, i32 0, i32 1
%1 = getelementptr inbounds [2 x i32], [2 x i32]* %dim, i32 0, i32 1
%2 = load i32, i32* %1, align 4
store i32 %2, i32* %foo, align 4
%foo_ret = load i32, i32* %foo, align 4
ret i32 %foo_ret
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
source: src/codegen/tests/expression_tests.rs
expression: res
---
; ModuleID = '<internal>'
source_filename = "<internal>"
target datalayout = "[filtered]"
target triple = "[filtered]"

define i32 @main() {
entry:
%main = alloca i32, align 4
%x = alloca i32, align 4
%y = alloca i32, align 4
store i32 20, i32* %x, align 4
store i32 4, i32* %y, align 4
store i32 0, i32* %main, align 4
%load_x = load i32, i32* %x, align 4
%load_y = load i32, i32* %y, align 4
%tmpVar = sub i32 %load_x, %load_y
%main_ret = load i32, i32* %main, align 4
ret i32 %main_ret
}
3 changes: 2 additions & 1 deletion src/validation/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,8 @@ fn validate_type_nature<T: AnnotationMap>(
if let DataTypeInformation::Generic { generic_symbol, nature, .. } = type_hint.get_type_information()
{
// we might be validating an identifier of a formal parameter assignment (FOO(x := 0))
if let AstStatement::Identifier(_) = statement.get_stmt() {
// This includes both Identifier and ReferenceExpr nodes for named arguments
if let AstStatement::Identifier(_) | AstStatement::ReferenceExpr(_) = statement.get_stmt() {
return;
}
validator.push_diagnostic(
Expand Down
Loading