From: Chris Lattner Date: Thu, 18 Oct 2001 21:55:07 +0000 (+0000) Subject: Check in new testcase based on .c file. Adapted to run with lli X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b7e711838f8d6445f1ad7fa032515ad472060c84;p=oota-llvm.git Check in new testcase based on .c file. Adapted to run with lli git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@908 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/ackermann.c b/test/ackermann.c new file mode 100644 index 00000000000..5e1bd489441 --- /dev/null +++ b/test/ackermann.c @@ -0,0 +1,23 @@ +/* -*- mode: c -*- + * $Id$ + * http://www.bagley.org/~doug/shootout/ + */ + +int printf(const char *, int, int); +int atoi(const char *); + +int +Ack(int M, int N) { + if (M == 0) return( N + 1 ); + if (N == 0) return( Ack(M - 1, 1) ); + return( Ack(M - 1, Ack(M, (N - 1))) ); +} + +int +main(int argc, char *argv[]) { + int n = ((argc == 2) ? atoi(argv[1]) : 5); + + printf("Ack(3,%d): %d\n", n, Ack(3, n)); + return(0); +} + diff --git a/test/ackermann.ll b/test/ackermann.ll new file mode 100644 index 00000000000..508b5861d99 --- /dev/null +++ b/test/ackermann.ll @@ -0,0 +1,92 @@ +%__intern_LC0 = global [sbyte] c"Ack(3, \00" +%__intern_LC1 = global [sbyte] c") = \00" +%__intern_LC2 = global [sbyte] c"\0A\00" ; <[15 x sbyte] *> [#uses=1] +implementation + +declare void "__main"() + +declare void "printVal"([sbyte] *) +declare void "printVal"(int) + +declare int "atoi"(sbyte *) + +int "main"(int %argc, sbyte * * %argv) +begin +bb1: ;[#uses=1] + call void () * %__main( ) + %cond1002 = setne int %argc, 2 ; [#uses=1] + br bool %cond1002, label %bb4, label %bb2 + +bb2: ;[#uses=2] + %cast1010 = cast ulong 8 to sbyte * * ; [#uses=1] + %reg1003 = add sbyte * * %argv, %cast1010 ; [#uses=1] + %reg110 = load sbyte * * %reg1003 ; [#uses=1] + %reg109 = call int (sbyte *) * %atoi( sbyte * %reg110 ) ; [#uses=1] + br label %bb4 + +bb4: ;[#uses=2] + %reg132 = phi int [ %reg109, %bb2 ], [ 5, %bb1 ] ; [#uses=4] + %cond1004 = setne ulong 3, 0 ; [#uses=1] + br bool %cond1004, label %bb6, label %bb5 + +bb5: ;[#uses=2] + %reg115 = add int %reg132, 1 ; [#uses=1] + br label %bb9 + +bb6: ;[#uses=1] + %cond1005 = setne int %reg132, 0 ; [#uses=1] + br bool %cond1005, label %bb8, label %bb7 + +bb7: ;[#uses=2] + %cast1006 = cast ulong 1 to int ; [#uses=1] + %cast1007 = cast ulong 2 to int ; [#uses=1] + %reg119 = call int (int, int) * %Ack( int %cast1007, int %cast1006 ) ; [#uses=1] + br label %bb9 + +bb8: ;[#uses=2] + %reg121 = add int %reg132, -1 ; [#uses=1] + %cast1008 = cast ulong 3 to int ; [#uses=1] + %reg122 = call int (int, int) * %Ack( int %cast1008, int %reg121 ) ; [#uses=1] + %cast1009 = cast ulong 2 to int ; [#uses=1] + %reg124 = call int (int, int) * %Ack( int %cast1009, int %reg122 ) ; [#uses=1] + br label %bb9 + +bb9: ;[#uses=3] + %reg135 = phi int [ %reg124, %bb8 ], [ %reg119, %bb7 ], [ %reg115, %bb5 ] ; [#uses=1] + call void %printVal([sbyte] *%__intern_LC0) + call void %printVal(int %reg132) + call void %printVal([sbyte] *%__intern_LC1) + call void %printVal(int %reg135) + call void %printVal([sbyte] *%__intern_LC2) + ret int 0 +end + +int "Ack"(int %M, int %N) +begin +bb1: ;[#uses=2] + br label %bb2 + +bb2: ;[#uses=3] + %reg121 = phi int [ %reg117, %bb6 ], [ 1, %bb5 ], [ %N, %bb1 ] ; [#uses=3] + %reg122 = phi int [ %reg115, %bb6 ], [ %reg123, %bb5 ], [ %M, %bb1 ] ; [#uses=4] + %cond1000 = setne int %reg122, 0 ; [#uses=1] + br bool %cond1000, label %bb4, label %bb3 + +bb3: ;[#uses=1] + %reg109 = add int %reg121, 1 ; [#uses=1] + ret int %reg109 + +bb4: ;[#uses=1] + %cond1001 = setne int %reg121, 0 ; [#uses=1] + br bool %cond1001, label %bb6, label %bb5 + +bb5: ;[#uses=3] + %reg123 = add int %reg122, -1 ; [#uses=1] + br label %bb2 + +bb6: ;[#uses=3] + %reg115 = add int %reg122, -1 ; [#uses=1] + %reg116 = add int %reg121, -1 ; [#uses=1] + %reg117 = call int (int, int) * %Ack( int %reg122, int %reg116 ) ; [#uses=1] + br label %bb2 +end