blob: fca4532fae130f32c45af36f79dd0d71d3f86a47 [file] [log] [blame]
Chris Lattnerf20469c2001-07-08 23:23:30 +00001%struct = type { int , {float, {ubyte } } , ulong }
Chris Lattnereb81d532001-12-14 16:46:53 +00002%complexty = type {int, {[4 x sbyte *], float}, double}
Chris Lattner2f7c9632001-06-06 20:29:01 +00003
4implementation
5
Chris Lattner792dc992001-11-26 17:02:56 +00006int "main"()
7begin
Chris Lattner8ec8b252002-10-06 22:43:49 +00008 call int %testfunction(long 0, long 1)
Chris Lattner792dc992001-11-26 17:02:56 +00009 ret int 0
10end
11
Chris Lattner8ec8b252002-10-06 22:43:49 +000012int "testfunction"(long %i0, long %j0)
Chris Lattner2f7c9632001-06-06 20:29:01 +000013begin
14 %array0 = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array0
15 %size = add uint 2, 2 ; yields {uint}:size = uint %4
Chris Lattnereb81d532001-12-14 16:46:53 +000016 %array1 = malloc ubyte, uint 4 ; yields {ubyte*}:array1
17 %array2 = malloc ubyte, uint %size ; yields {ubyte*}:array2
Chris Lattner792dc992001-11-26 17:02:56 +000018
Chris Lattner8ec8b252002-10-06 22:43:49 +000019 %idx = getelementptr [4 x ubyte]* %array0, long 0, long 2
Chris Lattner33a01ef2002-08-22 16:04:03 +000020 store ubyte 123, ubyte* %idx
Chris Lattner2f7c9632001-06-06 20:29:01 +000021 free [4x ubyte]* %array0
Chris Lattnereb81d532001-12-14 16:46:53 +000022 free ubyte* %array1
23 free ubyte* %array2
Chris Lattner2f7c9632001-06-06 20:29:01 +000024
25
Chris Lattner792dc992001-11-26 17:02:56 +000026 %aa = alloca %complexty, uint 5
Chris Lattner8ec8b252002-10-06 22:43:49 +000027 %idx2 = getelementptr %complexty* %aa, long %i0, ubyte 1, ubyte 0, long %j0
Chris Lattner33a01ef2002-08-22 16:04:03 +000028 store sbyte *null, sbyte** %idx2
Chris Lattner792dc992001-11-26 17:02:56 +000029
Chris Lattner2f7c9632001-06-06 20:29:01 +000030 %ptr = alloca int ; yields {int*}:ptr
Chris Lattnerf20469c2001-07-08 23:23:30 +000031 store int 3, int* %ptr ; yields {void}
32 %val = load int* %ptr ; yields {int}:val = int %3
33
34 %sptr = alloca %struct ; yields {%struct*}:sptr
Chris Lattner8ec8b252002-10-06 22:43:49 +000035 %ubsptr = getelementptr %struct * %sptr, long 0, ubyte 1, ubyte 1 ; yields {{ubyte}*}:ubsptr
36 %idx3 = getelementptr {ubyte} * %ubsptr, long 0, ubyte 0
Chris Lattner33a01ef2002-08-22 16:04:03 +000037 store ubyte 4, ubyte* %idx3
Chris Lattner2f7c9632001-06-06 20:29:01 +000038
39 ret int 3
40end
41