-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pretyping: accept words as array index
A int-of-word cast is silently introduced where needed (cherry picked from commit f943682)
- Loading branch information
Showing
4 changed files
with
103 additions
and
3 deletions.
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
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,48 @@ | ||
inline fn array_init () -> stack u32[5] { | ||
stack u32[5] a; | ||
reg u32 t; | ||
inline int i; | ||
for i = 0 to 5 { | ||
t = i; a[i] = t; | ||
} | ||
return a; | ||
} | ||
|
||
export | ||
fn test_u16 () -> reg u32 { | ||
stack u32[5] a; | ||
reg ptr u32[5] pa; | ||
a = array_init(); | ||
pa = a; | ||
reg u32 i; | ||
i = 0; | ||
|
||
reg u32 t; | ||
t = 3; | ||
pa[i] = t; | ||
reg u32 r; | ||
r = (32u) pa[u16 i]; | ||
|
||
return r; | ||
} | ||
|
||
fn test_u32 () -> reg u32 { | ||
stack u32[5] a; | ||
reg ptr u32[5] pa; | ||
a = array_init(); | ||
pa = a; | ||
|
||
reg u32 r; | ||
r = 0; | ||
|
||
reg u32 i; | ||
i = 0; | ||
reg u32 t; | ||
while (i < 5) { | ||
t = pa[i]; | ||
r = r + t; | ||
i += 1; | ||
} | ||
|
||
return r; | ||
} |
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,41 @@ | ||
inline fn array_init () -> stack u32[5] { | ||
stack u32[5] a; | ||
inline int i; | ||
for i = 0 to 5 { | ||
a[i] = i; | ||
} | ||
return a; | ||
} | ||
|
||
export | ||
fn test_u16 () -> reg u16 { | ||
stack u32[5] a; | ||
a = array_init(); | ||
|
||
reg u64 i; | ||
i = 0; | ||
a[i] = 3; | ||
reg u16 r; | ||
r = a[u16 i]; | ||
|
||
return r; | ||
} | ||
|
||
fn test_u32 () -> reg u32 { | ||
stack u32[5] a; | ||
a = array_init(); | ||
|
||
reg u32 r; | ||
r = 0; | ||
|
||
reg u64 i; | ||
i = 0; | ||
reg u32 t; | ||
while (i < 5) { | ||
t = a[i]; | ||
r = r + t; | ||
i += 1; | ||
} | ||
|
||
return r; | ||
} |