diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-27 15:00:45 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2016-03-27 15:00:45 -0400 |
commit | 36635660b40573f6a0c19d50dfdd9277589030de (patch) | |
tree | a1b4463f7260462c314bd8d7cb35b3d199143f33 /test/sum.ssa | |
parent | aad52241c88ad5327a8488c66dc906c8393c9c92 (diff) | |
download | roux-36635660b40573f6a0c19d50dfdd9277589030de.tar.gz |
extract tests out of src
Diffstat (limited to 'test/sum.ssa')
-rw-r--r-- | test/sum.ssa | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/sum.ssa b/test/sum.ssa new file mode 100644 index 0000000..266054e --- /dev/null +++ b/test/sum.ssa @@ -0,0 +1,31 @@ +# Simple test for addressing modes. + +function w $sum(l %arr, w %num) { +@start +@loop + %n1 =w phi @start %num, @loop1 %n2 + %s0 =w phi @start 0, @loop1 %s1 + %n2 =w sub %n1, 1 + %c =w cslew %n1, 0 + jnz %c, @end, @loop1 +@loop1 + %idx0 =l extsw %n2 + %idx1 =l mul 4, %idx0 + %idx2 =l add %idx1, %arr + %w =w loadw %idx2 + %s1 =w add %w, %s0 + jmp @loop +@end + ret %s0 +} + +# >>> driver +# extern int sum(int *, int); +# int arr[] = { 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21 }; +# #define N sizeof arr / sizeof arr[0] +# int main() { +# int i, s; +# for (s=i=0; i<N; i++) s+=arr[i]; +# return !(sum(arr, N) == s); +# } +# <<< |