-
Notifications
You must be signed in to change notification settings - Fork 64
feat: support named arguments for builtins #1529
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
Open
abroooo
wants to merge
30
commits into
master
Choose a base branch
from
abroooo/fix_support_named_arguments_for_builtins
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
198de5b
fix builtins
abroooo 0577ac7
Merge branch 'master' into abroooo/fix_support_named_arguments_for_bu…
abroooo a7874bf
fix tests
abroooo 1d63f42
add codegen tests
abroooo b409966
add correctness tests
abroooo 3325e39
improve lit test
abroooo 454f9b5
add more tests
abroooo ed037f4
cleanup
abroooo 3548826
fix and cleanup
abroooo f3582c3
Merge branch 'master' into abroooo/fix_support_named_arguments_for_bu…
abroooo f8e2987
refactor
abroooo bfc95e2
more refactor
abroooo 9263a52
support div and sub
abroooo e6886eb
more tests
abroooo b96b01a
even more refactor
abroooo b686636
add tests for sub/div
abroooo 3ce4de5
another refactor
abroooo a045647
add lit test for sub/div
abroooo 3cac9f6
add missing snapshots
abroooo c8777f3
add/modify comments
abroooo 18053d8
implement feedback
abroooo a0acc53
seperate tests for named and positional arguments into two lit tests
abroooo d073131
add positional test for missing builtins
abroooo 12263a1
remove correctness tests for named builtins as we have lit tests for it
abroooo 5d6f513
delete dangling snapshots
abroooo 0180846
delete more dangling snapshots 😲
abroooo ba92b85
Merge branch 'master' into abroooo/fix_support_named_arguments_for_bu…
abroooo 76db03e
refactor
abroooo 463d17c
cleanup
abroooo 19f6b47
style
abroooo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
.../snapshots/rusty__codegen__tests__expression_tests__builtin_div_with_named_arguments.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = sdiv i32 %load_x, %load_y | ||
%main_ret = load i32, i32* %main, align 4 | ||
ret i32 %main_ret | ||
} |
48 changes: 48 additions & 0 deletions
48
...gen__tests__expression_tests__builtin_function_call_lower_bound_with_named_arguments.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
6 changes: 3 additions & 3 deletions
6
...ion_tests__builtin_function_call_adr.snap → ...nction_call_move_with_named_argument.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
24 changes: 24 additions & 0 deletions
24
...sty__codegen__tests__expression_tests__builtin_function_call_sel_with_named_argument.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
5 changes: 2 additions & 3 deletions
5
...ion_tests__builtin_function_call_ref.snap → ...tion_call_sizeof_with_named_argument.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...egen__tests__expression_tests__builtin_function_call_upper_bound_with_named_argument.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
23 changes: 23 additions & 0 deletions
23
.../snapshots/rusty__codegen__tests__expression_tests__builtin_sub_with_named_arguments.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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