-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work on #14, can now return small (<= 4 bytes) structs from functions
- Loading branch information
1 parent
518fc16
commit 57fd952
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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,10 @@ | ||
struct MyStruct | ||
{ | ||
int a; | ||
}; | ||
|
||
struct MyStruct get_small_struct() | ||
{ | ||
struct MyStruct a = { 33 }; | ||
return a; | ||
} |
This file contains 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,32 @@ | ||
<Test> | ||
<Flags>--emit-ir-post=cconv -c</Flags> | ||
|
||
<TestFlags> | ||
<TestFlag name="regex" value="false"></TestFlag> | ||
</TestFlags> | ||
|
||
<ExpectedOutput> | ||
MyStruct = struct { i32 } | ||
|
||
@ci0:ptr = global i32 0:i32 | ||
@ci1:ptr = global i32 33:i32 | ||
|
||
function get_small_struct(): void { | ||
.0: | ||
stack_alloc [MyStruct x 1], %0:ptr | ||
stack_alloc [MyStruct x 1], %1:ptr | ||
ptrtoint [ptr -> i32], %1:ptr, %2:i32 | ||
load @ci0:ptr, %3:i32 | ||
iadd %2:i32, %3:i32, %4:i32 | ||
inttoptr [i32 -> ptr], %4:i32, %5:ptr | ||
load @ci1:ptr, %6:i32 | ||
store %6:i32, %5:ptr | ||
load %1:ptr, %7:MyStruct | ||
store %7:MyStruct, %0:ptr | ||
br .1 | ||
.1: | ||
load %0:ptr, r0:i32 | ||
ret | ||
} | ||
</ExpectedOutput> | ||
</Test> |