2003-09-29 21:21:59 +00:00
|
|
|
; RUN: llvm-as < %s | opt -f -lowerrefs -o %t1.bc
|
2002-08-03 13:16:47 +00:00
|
|
|
;
|
2002-03-24 03:17:16 +00:00
|
|
|
%Flat_struct = type { sbyte, float }
|
|
|
|
%Flat_t = type { sbyte, float }
|
|
|
|
%Mixed_struct = type { int, [10 x double], [10 x [10 x double]], [10 x { sbyte, float }] }
|
|
|
|
%Mixed_t = type { int, [10 x double], [10 x [10 x double]], [10 x { sbyte, float }] }
|
|
|
|
|
|
|
|
%trstr = internal constant [34 x sbyte] c"ENTERING METHOD: int () * %%ain\0A\00"
|
|
|
|
|
|
|
|
declare int "printf"(sbyte *, ...)
|
|
|
|
|
2002-10-15 21:14:24 +00:00
|
|
|
declare int "ArrayRef"([100 x int] * %Array, long %I, long %J)
|
2002-03-24 03:17:16 +00:00
|
|
|
|
|
|
|
implementation
|
|
|
|
|
2002-05-02 20:19:11 +00:00
|
|
|
int "test"([20 x [10 x [5 x int]]] * %A)
|
|
|
|
begin
|
2002-10-15 21:14:24 +00:00
|
|
|
%idx = getelementptr [20 x [10 x [5 x int]]] * %A, long 1, long 2, long 3, long 4
|
2002-08-22 16:39:05 +00:00
|
|
|
%i = load int* %idx
|
2002-08-03 13:16:47 +00:00
|
|
|
|
|
|
|
;; same as above but via a GEP
|
2002-10-15 21:14:24 +00:00
|
|
|
%iptr = getelementptr [20 x [10 x [5 x int]]] * %A, long 1, long 2, long 3, long 4
|
2002-08-03 13:16:47 +00:00
|
|
|
%ii= load int* %iptr
|
|
|
|
|
|
|
|
;; EXPECTED RESULT: decomposed indices for above LOAD or GEP
|
|
|
|
;; %ptr1 = getelementptr [20 x [10 x [5 x int]]] * %A, uint 1
|
|
|
|
;; %ptr2 = getelementptr [20 x [10 x [5 x int]]] * %ptr1, uint 0, uint 2
|
|
|
|
;; %ptr3 = getelementptr [10 x [5 x int]] * %ptr2, uint 0, uint 3
|
|
|
|
;; %iii = load [5 x int] * %ptr3, uint 0, uint 4
|
|
|
|
|
2002-05-02 20:19:11 +00:00
|
|
|
ret int %i
|
|
|
|
end
|
|
|
|
|
2002-03-24 03:17:16 +00:00
|
|
|
void "InitializeMixed"(%Mixed_struct * %M, int %base)
|
|
|
|
begin
|
|
|
|
bb0: ;[#uses=2]
|
|
|
|
%reg112 = add int %base, 1 ; <int> [#uses=1]
|
2002-10-15 21:14:24 +00:00
|
|
|
%reg164-idxcast = cast int %reg112 to long ; <uint> [#uses=1]
|
2002-08-03 13:16:47 +00:00
|
|
|
|
|
|
|
;; Store to a structure field
|
2002-10-15 21:14:24 +00:00
|
|
|
%idx1 = getelementptr %Mixed_struct * %M, long 0, ubyte 3, long %reg164-idxcast, ubyte 0
|
2002-08-22 16:39:05 +00:00
|
|
|
store sbyte 81, sbyte* %idx1
|
2002-03-24 03:17:16 +00:00
|
|
|
|
2002-08-03 13:16:47 +00:00
|
|
|
;; EXPECTED RESULT: decomposed indices for above STORE
|
|
|
|
;; %ptr1 = getelementptr %Mixed_struct * %M, uint 0, ubyte 3
|
|
|
|
;; %ptr2 = getelementptr [10 x { sbyte, float }]* %ptr1, uint 0, uint %reg164-idxcast
|
|
|
|
;; store sbyte 81, {sbyte,float}* %ptr2, uint 0, ubyte 0
|
|
|
|
|
|
|
|
;; Store to an array field within a structure
|
2002-10-15 21:14:24 +00:00
|
|
|
%idx2 = getelementptr %Mixed_struct * %M, long 0, ubyte 1, long %reg164-idxcast
|
2002-08-22 16:39:05 +00:00
|
|
|
store double 2.17, double* %idx2
|
2002-08-03 13:16:47 +00:00
|
|
|
|
|
|
|
;; EXPECTED RESULT: decomposed indices for above STORE
|
|
|
|
;; %ptr1 = getelementptr %Mixed_struct * %M, uint 0, ubyte 1
|
|
|
|
;; store double 2.17, [10 x double]* %ptr1, uint 0, uint %reg164-idxcast
|
|
|
|
|
2002-03-24 03:17:16 +00:00
|
|
|
ret void
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
int "main"()
|
|
|
|
begin
|
|
|
|
bb0: ;[#uses=1]
|
|
|
|
%Array = alloca [100 x [100 x int]]
|
2002-10-15 21:14:24 +00:00
|
|
|
%ArraySlice = getelementptr [100 x [100 x int]]* %Array, long 0, long 0
|
|
|
|
%trstrP = getelementptr [34 x sbyte] * %trstr, long 0, long 0
|
2002-03-24 03:17:16 +00:00
|
|
|
|
|
|
|
%trace = call int (sbyte *, ...) * %printf( sbyte * %trstrP )
|
|
|
|
|
2002-10-15 21:14:24 +00:00
|
|
|
%eltVal = call int %ArrayRef([100 x int]* %ArraySlice, long 8, long 12)
|
2002-08-03 13:16:47 +00:00
|
|
|
ret int %eltVal
|
2002-03-24 03:17:16 +00:00
|
|
|
|
2002-08-03 13:16:47 +00:00
|
|
|
;; ret int 0
|
2002-03-24 03:17:16 +00:00
|
|
|
end
|
|
|
|
|
2002-10-15 21:14:24 +00:00
|
|
|
int "ArrayRef"([100 x int] * %Array, long %I, long %J)
|
2002-03-24 03:17:16 +00:00
|
|
|
begin
|
|
|
|
bb0: ;[#uses=3]
|
2002-10-15 21:14:24 +00:00
|
|
|
%idx = getelementptr [100 x int]* %Array, long %I, long %J ; <int> [#uses=1]
|
2002-08-22 16:39:05 +00:00
|
|
|
%reg121 = load int* %idx
|
2002-10-15 21:14:24 +00:00
|
|
|
ret int %reg121
|
2002-03-24 03:17:16 +00:00
|
|
|
end
|
2002-08-03 13:16:47 +00:00
|
|
|
|
2002-10-15 21:14:24 +00:00
|
|
|
sbyte "PtrRef"(sbyte** %argv, long %I, long %J)
|
2002-08-03 13:16:47 +00:00
|
|
|
begin
|
|
|
|
bb0: ;[#uses=3]
|
2003-08-18 22:34:14 +00:00
|
|
|
%idx = getelementptr sbyte** %argv, long %I
|
|
|
|
%reg222 = load sbyte** %idx
|
|
|
|
%tmp = load sbyte* %reg222
|
|
|
|
ret sbyte %tmp
|
2002-08-03 13:16:47 +00:00
|
|
|
end
|