Chris Lattner | 91e1596 | 2001-07-08 23:23:30 +0000 | [diff] [blame^] | 1 | %struct = type { int , {float, {ubyte } } , ulong } |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 2 | |
| 3 | implementation |
| 4 | |
| 5 | int "test function"(int %i0, int %j0) |
| 6 | begin |
| 7 | %array0 = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array0 |
| 8 | %size = add uint 2, 2 ; yields {uint}:size = uint %4 |
| 9 | %array1 = malloc [ubyte], uint 4 ; yields {[ubyte]*}:array1 |
| 10 | %array2 = malloc [ubyte], uint %size ; yields {[ubyte]*}:array2 |
| 11 | free [4x ubyte]* %array0 |
| 12 | free [ubyte]* %array1 |
| 13 | free [ubyte]* %array2 |
| 14 | |
| 15 | |
| 16 | alloca [ubyte], uint 5 |
| 17 | %ptr = alloca int ; yields {int*}:ptr |
Chris Lattner | 91e1596 | 2001-07-08 23:23:30 +0000 | [diff] [blame^] | 18 | store int 3, int* %ptr ; yields {void} |
| 19 | %val = load int* %ptr ; yields {int}:val = int %3 |
| 20 | |
| 21 | %sptr = alloca %struct ; yields {%struct*}:sptr |
| 22 | %ubsptr = getelementptr %struct * %sptr, ubyte 1, ubyte 1 ; yields {{ubyte}*}:ubsptr |
| 23 | store ubyte 4, {ubyte} * %ubsptr, ubyte 0 |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 24 | |
| 25 | ret int 3 |
| 26 | end |
| 27 | |