Binary Operations
@@ -1044,8 +1016,8 @@ Memory is allocated, a pointer is returned. 'alloca'd memory is automa
Syntax:
<result> = load <ty>* <pointer> ; yields {ty}:result
- <result> = load <ty>* <arrayptr>, uint <idx> ; yields {ty}:result
- <result> = load <ty>* <structptr>{, <idx>}* ; yields field type
+ <result> = load <ty>* <arrayptr>{, uint <idx>}+ ; yields {ty}:result
+ <result> = load <ty>* <structptr>{, ubyte <idx>}+ ; yields field type
Overview:
@@ -1055,8 +1027,11 @@ The 'load' instruction is used to read from memory.
There are three forms of the 'load' instruction: one for reading from a general pointer, one for reading from a pointer to an array, and one for reading from a pointer to a structure.
-In the first form, '<ty>' may be any pointer type. If it is a pointer to an array, the first (zeroth) element is read from). In the second form, '<ty>' must be a pointer to an array. No bounds checking is performed on array reads. In the third form, the pointer must point to a (possibly nested) structure. There shall be one ubyte argument for each level of dereferencing involved.
+In the first form, '<ty>' must be a pointer to a simple type (a primitive type or another pointer).
+In the second form, '<ty>' must be a pointer to an array, and a list of one or more indices is provided as indexes into the (possibly multidimensional) array. No bounds checking is performed on array reads.
+
+In the third form, the pointer must point to a (possibly nested) structure. There shall be one ubyte argument for each level of dereferencing involved.
Semantics:
...
@@ -1064,12 +1039,11 @@ In the first form, '<ty>' may be any pointer type. If it is a po
Examples:
%ptr = alloca int ; yields {int*}:ptr
- store int* %ptr, int 3 ; yields {void}
+ store int 3, int* %ptr ; yields {void}
%val = load int* %ptr ; yields {int}:val = int 3
%array = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array
- store [4 x ubyte]* %array,
- uint 4, ubyte 124
+ store ubyte 124, [4 x ubyte]* %array, uint 4
%val = load [4 x ubyte]* %array, uint 4 ; yields {ubyte}:val = ubyte 124
%val = load {{int, float}}* %stptr, 0, 1 ; yields {float}:val
@@ -1082,49 +1056,49 @@ In the first form, '<ty>' may be any pointer type. If it is a po
Syntax:
- store <ty>* <pointer>, <ty> <value> ; yields {void}
- store <ty>* <arrayptr>, uint <idx>, <ty> <value> ; yields {void}
+ store <ty> <value>, <ty>* <pointer> ; yields {void}
+ store <ty> <value>, <ty>* <arrayptr>{, uint <idx>}+ ; yields {void}
+ store <ty> <value>, <ty>* <structptr>{, ubyte <idx>}+ ; yields {void}e
Overview:
The 'store' instruction is used to write to memory.
-
Arguments:
-There are two forms of the 'store' instruction: one for writing through a general pointer, and one for writing through a pointer to an array.
-
-In the first form, '<ty>' may be any pointer type. If it is a pointer to an array, the first (zeroth) element is writen to). In the second form, '<ty>' must be a pointer to an array. No bounds checking is performed on array writes.
+There are three forms of the 'store' instruction: one for writing through a general pointer, one for writing through a pointer to a (possibly multidimensional) array, and one for writing to an element of a (potentially nested) structure.
+The semantics of this instruction closely match that of the load instruction, except that memory is written to, not read from.
Semantics:
...
Example:
- %ptr = alloca int ; yields {int*}:ptr
- store int* %ptr, int 3 ; yields {void}
- %val = load int* %ptr ; yields {int}:val = int 3
+ %ptr = alloca int ; yields {int*}:ptr
+ store int 3, int* %ptr ; yields {void}
+ %val = load int* %ptr ; yields {int}:val = int 3
- %array = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array
- store [4 x ubyte]* %array,
- uint 4, ubyte 124
- %val = load [4 x ubyte]* %array, uint 4 ; yields {ubyte}:val = ubyte 124
+ %array = malloc [4 x ubyte] ; yields {[4 x ubyte]*}:array
+ store ubyte 124, [4 x ubyte]* %array, uint 4
+ %val = load [4 x ubyte]* %array, uint 4 ; yields {ubyte}:val = ubyte 124
+ %val = load {{int, float}}* %stptr, 0, 1 ; yields {float}:val
-