llvm.org GIT mirror llvm / 7209bff
- Cleaned up all of the test/Feature tests to not use uint's with getelementptr instructions and not to add pointers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4049 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 18 years ago
7 changed file(s) with 38 addition(s) and 36 deletion(s). Raw diff Collapse all Expand all
2424 ;;---------------------------------------------------
2525
2626 %array = constant [2 x int] [ int 12, int 52 ]
27 %arrayPtr = global int* getelementptr ([2 x int]* %array, uint 0, uint 0) ;; int* &%array[0][0]
28 %arrayPtr5 = global int* getelementptr (int** %arrayPtr, uint 0, uint 5) ;; int* &%arrayPtr[5]
27 %arrayPtr = global int* getelementptr ([2 x int]* %array, long 0, long 0) ;; int* &%array[0][0]
28 %arrayPtr5 = global int* getelementptr (int** %arrayPtr, long 0, long 5) ;; int* &%arrayPtr[5]
2929
3030 %somestr = constant [11x sbyte] c"hello world"
31 %char5 = global sbyte* getelementptr([11x sbyte]* %somestr, uint 0, uint 5)
31 %char5 = global sbyte* getelementptr([11x sbyte]* %somestr, long 0, long 5)
3232
3333 ;; cast of getelementptr
34 %char8a = global int* cast (sbyte* getelementptr([11x sbyte]* %somestr, uint 0, uint 8) to int*)
34 %char8a = global int* cast (sbyte* getelementptr([11x sbyte]* %somestr, long 0, long 8) to int*)
3535
3636 ;; getelementptr containing casts
37 %char8b = global sbyte* getelementptr([11x sbyte]* %somestr, uint cast (ubyte 0 to uint), uint cast (sbyte 8 to uint))
37 %char8b = global sbyte* getelementptr([11x sbyte]* %somestr, long cast (ubyte 0 to long), long cast (sbyte 8 to long))
3838
3939 ;;-------------------------------------------------------
4040 ;; TODO: Test constant getelementpr expressions for structures
5353 %S3 = global %SAType* %S3c ;; Ref. to constant S3
5454
5555 ;; Pointer to float (**%S1).1.0
56 %S1fld1a = global float* getelementptr (%SType** %S1, uint 0, uint 0, ubyte 1, ubyte 0)
56 %S1fld1a = global float* getelementptr (%SType** %S1, long 0, long 0, ubyte 1, ubyte 0)
5757 ;; Another ptr to the same!
58 %S1fld1b = global float* getelementptr (%SType*** %S1ptr, uint 0, uint 0, uint 0, ubyte 1, ubyte 0)
58 %S1fld1b = global float* getelementptr (%SType*** %S1ptr, long 0, long 0, long 0, ubyte 1, ubyte 0)
5959
6060 %S1fld1bptr = global float** %S1fld1b ;; Ref. to previous pointer
6161
6262 ;; Pointer to ubyte (**%S2).1.1.0
63 %S2fld3 = global ubyte* getelementptr (%SType** %S2, uint 0, uint 0, ubyte 1, ubyte 1, ubyte 0)
63 %S2fld3 = global ubyte* getelementptr (%SType** %S2, long 0, long 0, ubyte 1, ubyte 1, ubyte 0)
6464
6565 ;; Pointer to float (**%S2).1.0[0]
66 %S3fld3 = global float* getelementptr (%SAType** %S3, uint 0, uint 0, ubyte 1, ubyte 0, uint 0)
66 %S3fld3 = global float* getelementptr (%SAType** %S3, long 0, long 0, ubyte 1, ubyte 0, long 0)
6767
6868 ;;---------------------------------------------------------
6969 ;; TODO: Test constant expressions for unary and binary operators
7676
7777 %t4 = global int** cast (uint** %t3 to int**)
7878
79 %char8a = global int* cast (sbyte* getelementptr([11x sbyte]* %somestr, uint 0, uint 8) to int*)
79 %char8a = global int* cast (sbyte* getelementptr([11x sbyte]* %somestr, long 0, long 8) to int*)
8080
81 %S3fld3 = global float* getelementptr (%SAType** %S3, uint 0, uint 0, ubyte 1, ubyte 0, uint 0)
81 %S3fld3 = global float* getelementptr (%SAType** %S3, long 0, long 0, ubyte 1, ubyte 0, long 0)
8282
8383
8484 ;;---------------------------------------------------
2222 ;;---------------------------------------------------
2323
2424 ;; return value must be a pointer to the element
25 ;%geperr1 = global sbyte getelementptr([11x sbyte]* %somestr, uint 0, uint 8)
25 ;%geperr1 = global sbyte getelementptr([11x sbyte]* %somestr, long 0, long 8)
2626
2727 ;; index types must be valid for pointer type
2828 ;%geperr2 = global sbyte* getelementptr([11x sbyte]* %somestr, ubyte 0)
29 ;%geperr3 = global sbyte* getelementptr([11x sbyte]* %somestr, uint 0, uint 0, uint 3)
29 ;%geperr3 = global sbyte* getelementptr([11x sbyte]* %somestr, long 0, long 0, long 3)
3030
3131 ;; element accessed by index list must match return type
3232 ;%geperr4 = global sbyte* getelementptr([11x sbyte]* %somestr)
33 ;%geperr5 = global sbyte* getelementptr([11x sbyte]* %somestr, uint 0)
34 ;%geperr6 = global int* getelementptr([11x sbyte]* %somestr, uint 0, uint 0)
33 ;%geperr5 = global sbyte* getelementptr([11x sbyte]* %somestr, long 0)
34 ;%geperr6 = global int* getelementptr([11x sbyte]* %somestr, long 0, long 0)
3535
3636 ;; Cannot use cast expression in pointer field of getelementptr
3737 ;; (unlike the index fields, where it is legal)
38 ;%geperr7 = constant int* getelementptr (int* cast long 0, uint 27)
38 ;%geperr7 = constant int* getelementptr (int* cast long 0, long 27)
3939
4040
66 %thisfuncty = type int (int) *
77 implementation
88
9 declare void %F(%thisfuncty, %thisfuncty, %thisfuncty)
10
911 ; This function always returns zero
10 int "zarro"(int %Func)
12 int %zarro(int %Func)
1113 begin
1214 Startup:
1315 add int 0, 10
1416 ret int 0
1517 end
1618
17 int "test"(int)
19 int %test(int)
1820 begin
19 add %thisfuncty %zarro, %test
20 add %thisfuncty %test, %foozball
21 call void %F(%thisfuncty %zarro, %thisfuncty %test, %thisfuncty %foozball)
2122 ret int 0
2223 end
2324
24 int "foozball"(int)
25 int %foozball(int)
2526 begin
2627 ret int 0
2728 end
6262 %cast1006 = cast %list** %reg119 to sbyte** ;;
6363 %reg111 = call sbyte* %malloc(uint 16) ;;
6464 store sbyte* %reg111, sbyte** %cast1006 ;;
65 %cast1007 = cast ulong 8 to sbyte* ;;
66 %reg1002 = add sbyte* %reg111, %cast1007 ;;
65 %reg111 = cast sbyte* %reg111 to ulong
66 %reg1002 = add ulong %reg111, 8
67 %reg1002 = cast ulong %reg1002 to sbyte* ;;
6768 %cast1008 = cast sbyte* %reg1002 to int* ;;
6869 store int %Data, int* %cast1008 ;;
6970 %cast1003 = cast ulong 0 to ulong* ;;
8788 ret %list* null
8889
8990 bb4:
90 %idx = getelementptr %list* %reg115, uint 0, ubyte 1 ;;
91 %idx = getelementptr %list* %reg115, long 0, ubyte 1 ;;
9192 %reg111 = load int* %idx
9293 %cond1013 = setne int %reg111, %Data ;;
9394 br bool %cond1013, label %bb6, label %bb5
9697 ret %list* %reg115
9798
9899 bb6:
99 %idx2 = getelementptr %list* %reg115, uint 0, ubyte 0 ;;<%list*>
100 %idx2 = getelementptr %list* %reg115, long 0, ubyte 0 ;;<%list*>
100101 %reg116 = load %list** %idx2
101102 br label %bb2
102103 end
1010 %val = load int* %ptr ; yields {int}:val = int %3
1111
1212 %sptr = alloca %struct ; yields {%struct*}:sptr
13 %nsptr = getelementptr %struct * %sptr, uint 0, ubyte 1 ; yields {inners*}:nsptr
14 %ubsptr = getelementptr %inners * %nsptr, uint 0, ubyte 1 ; yields {{ubyte}*}:ubsptr
15 %idx = getelementptr {ubyte} * %ubsptr, uint 0, ubyte 0
13 %nsptr = getelementptr %struct * %sptr, long 0, ubyte 1 ; yields {inners*}:nsptr
14 %ubsptr = getelementptr %inners * %nsptr, long 0, ubyte 1 ; yields {{ubyte}*}:ubsptr
15 %idx = getelementptr {ubyte} * %ubsptr, long 0, ubyte 0
1616 store ubyte 4, ubyte* %idx
1717
18 %fptr = getelementptr %struct * %sptr, uint 0, ubyte 1, ubyte 0 ; yields {float*}:fptr
18 %fptr = getelementptr %struct * %sptr, long 0, ubyte 1, ubyte 0 ; yields {float*}:fptr
1919 store float 4.0, float * %fptr
2020
2121 ret int 3
1010
1111 sbyte* %otherfunc(int, double)
1212 begin
13 %somestr = getelementptr [11x sbyte]* %somestr, uint 0, uint 0
13 %somestr = getelementptr [11x sbyte]* %somestr, long 0, long 0
1414 ret sbyte* %somestr
1515 end
1616
44
55 int "main"()
66 begin
7 call int %testfunction(uint 0, uint 1)
7 call int %testfunction(long 0, long 1)
88 ret int 0
99 end
1010
11 int "testfunction"(uint %i0, uint %j0)
11 int "testfunction"(long %i0, long %j0)
1212 begin
1313 %array0 = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array0
1414 %size = add uint 2, 2 ; yields {uint}:size = uint %4
1515 %array1 = malloc ubyte, uint 4 ; yields {ubyte*}:array1
1616 %array2 = malloc ubyte, uint %size ; yields {ubyte*}:array2
1717
18 %idx = getelementptr [4 x ubyte]* %array0, uint 0, uint 2
18 %idx = getelementptr [4 x ubyte]* %array0, long 0, long 2
1919 store ubyte 123, ubyte* %idx
2020 free [4x ubyte]* %array0
2121 free ubyte* %array1
2323
2424
2525 %aa = alloca %complexty, uint 5
26 %idx2 = getelementptr %complexty* %aa, uint %i0, ubyte 1, ubyte 0, uint %j0
26 %idx2 = getelementptr %complexty* %aa, long %i0, ubyte 1, ubyte 0, long %j0
2727 store sbyte *null, sbyte** %idx2
2828
2929 %ptr = alloca int ; yields {int*}:ptr
3131 %val = load int* %ptr ; yields {int}:val = int %3
3232
3333 %sptr = alloca %struct ; yields {%struct*}:sptr
34 %ubsptr = getelementptr %struct * %sptr, uint 0, ubyte 1, ubyte 1 ; yields {{ubyte}*}:ubsptr
35 %idx3 = getelementptr {ubyte} * %ubsptr, uint 0, ubyte 0
34 %ubsptr = getelementptr %struct * %sptr, long 0, ubyte 1, ubyte 1 ; yields {{ubyte}*}:ubsptr
35 %idx3 = getelementptr {ubyte} * %ubsptr, long 0, ubyte 0
3636 store ubyte 4, ubyte* %idx3
3737
3838 ret int 3