libqbe/test/loop.ssa

25 lines
357 B
Text
Raw Normal View History

2015-07-03 15:11:36 -04:00
# simple looping program
# sums all integers from 100 to 0
2016-03-28 10:30:55 -04:00
export
2015-09-18 12:27:50 -04:00
function $test() {
2015-09-14 18:06:29 -04:00
@start
2015-07-03 15:11:36 -04:00
2015-09-14 18:06:29 -04:00
@loop
%s =w phi @start 0, @loop %s1
%n =w phi @start 100, @loop %n1
2015-08-01 18:17:06 -04:00
%s1 =w add %s, %n
2016-03-16 10:41:01 -04:00
%n1 =w sub %n, 1
jnz %n1, @loop, @end
2015-07-03 15:11:36 -04:00
2015-09-14 18:06:29 -04:00
@end
storew %s1, $a
2015-07-03 15:11:36 -04:00
ret
}
# >>> driver
# extern void test(void);
# int a;
# int main() { test(); return !(a == 5050); }
# <<<