llvm.org GIT mirror llvm / 6a8f91e
New testcase to deal with lists git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@503 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 19 years ago
1 changed file(s) with 102 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; This file contains the output from the following compiled C code:
1 ; typedef struct list {
2 ; struct list *Next;
3 ; int Data;
4 ; } list;
5 ;
6 ; // Iterative insert fn
7 ; void InsertIntoListTail(list **L, int Data) {
8 ; while (*L)
9 ; L = &(*L)->Next;
10 ; *L = (list*)malloc(sizeof(list));
11 ; (*L)->Data = Data;
12 ; (*L)->Next = 0;
13 ; }
14 ;
15 ; // Recursive list search fn
16 ; list *FindData(list *L, int Data) {
17 ; if (L == 0) return 0;
18 ; if (L->Data == Data) return L;
19 ; return FindData(L->Next, Data);
20 ; }
21 ;
22 ; void DoListStuff() {
23 ; list *MyList = 0;
24 ; InsertIntoListTail(&MyList, 100);
25 ; InsertIntoListTail(&MyList, 12);
26 ; InsertIntoListTail(&MyList, 42);
27 ; InsertIntoListTail(&MyList, 1123);
28 ; InsertIntoListTail(&MyList, 1213);
29 ;
30 ; if (FindData(MyList, 75)) foundIt();
31 ; if (FindData(MyList, 42)) foundIt();
32 ; if (FindData(MyList, 700)) foundIt();
33 ; }
34
35 %list = type { %list*, int }
36
37 declare sbyte *"malloc"(uint)
38
39 ;;**********************
40 implementation
41 ;;**********************
42
43 void "InsertIntoListTail"(%list** %L, int %Data)
44 begin
45 bb1:
46 %reg116 = load %list** %L ;;<%list*>
47 %cast1004 = cast ulong 0 to %list* ;;<%list*>
48 %cond1000 = seteq %list* %reg116, %cast1004 ;;
49 br bool %cond1000, label %bb3, label %bb2
50
51 bb2:
52 %reg117 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ;;<%list**>
53 %cast1010 = cast %list** %reg117 to %list*** ;;<%list***>
54 %reg118 = load %list*** %cast1010 ;;<%list**>
55 %reg109 = load %list** %reg118 ;;<%list*>
56 %cast1005 = cast ulong 0 to %list* ;;<%list*>
57 %cond1001 = setne %list* %reg109, %cast1005 ;;
58 br bool %cond1001, label %bb2, label %bb3
59
60 bb3:
61 %reg119 = phi %list** [ %reg118, %bb2 ], [ %L, %bb1 ] ;;<%list**>
62 %cast1006 = cast %list** %reg119 to sbyte** ;;
63 %reg111 = call sbyte* %malloc(uint 16) ;;
64 store sbyte* %reg111, sbyte** %cast1006 ;;
65 %cast1007 = cast ulong 8 to sbyte* ;;
66 %reg1002 = add sbyte* %reg111, %cast1007 ;;
67 %cast1008 = cast sbyte* %reg1002 to int* ;;
68 store int %Data, int* %cast1008 ;;
69 %cast1003 = cast ulong 0 to ulong* ;;
70 %cast1009 = cast sbyte* %reg111 to ulong** ;;
71 store ulong* %cast1003, ulong** %cast1009 ;;
72 ret void
73 end
74
75 %list* "FindData"(%list* %L, int %Data)
76 begin
77 bb1:
78 br label %bb2
79
80 bb2:
81 %reg115 = phi %list* [ %reg116, %bb6 ], [ %L, %bb1 ] ;;<%list*>
82 %cast1014 = cast ulong 0 to %list* ;;<%list*>
83 %cond1011 = setne %list* %reg115, %cast1014 ;;
84 br bool %cond1011, label %bb4, label %bb3
85
86 bb3:
87 %cast1015 = cast ulong 0 to %list* ;;<%list*>
88 ret %list* %cast1015
89
90 bb4:
91 %reg111 = load %list* %reg115, ubyte 1 ;;
92 %cond1013 = setne int %reg111, %Data ;;
93 br bool %cond1013, label %bb6, label %bb5
94
95 bb5:
96 ret %list* %reg115
97
98 bb6:
99 %reg116 = load %list* %reg115, ubyte 0 ;;<%list*>
100 br label %bb2
101 end