Commit ffae614a authored by Kunshan Wang's avatar Kunshan Wang

Unify struct/array/vector constant representations.

parent 3bfcda85
......@@ -1682,8 +1682,8 @@ inclusively, where n is the length of *T1*, then it has undefined behaviour.
.const @S6 <@float> = 9.7f
.const @S7 <@float> = 9.3f
.const @V0 <@4xfloat> = VEC { @S0 @S1 @S2 @S3 } // { 3.1f 4.1f 5.9f 2.6f }
.const @V1 <@4xfloat> = VEC { @S4 @S5 @S6 @S7 } // { 5.3f 5.8f 9.7f 9.3f }
.const @V0 <@4xfloat> = { @S0 @S1 @S2 @S3 } // { 3.1f 4.1f 5.9f 2.6f }
.const @V1 <@4xfloat> = { @S4 @S5 @S6 @S7 } // { 5.3f 5.8f 9.7f 9.3f }
.const @I32_2 <@i32> = 2
.const @I32_3 <@i32> = 3
......@@ -1692,12 +1692,12 @@ inclusively, where n is the length of *T1*, then it has undefined behaviour.
.const @I32_6 <@i32> = 6
.const @I32_7 <@i32> = 7
.const @M0 <@4xi32> = VEC { @I32_1 @I32_0 @I32_2 @I32_1 }
.const @M0 <@4xi32> = { @I32_1 @I32_0 @I32_2 @I32_1 }
.typedef @8xi32 = vector <@i32 8>
.typedef @8xfloat = vector <@float 8>
.const @M1 <@8xi32> = VEC { @I32_7 @I32_5 @I32_6 @I32_4 @I32_2 @I32_1 @I32_3 @I32_0 }
.const @M1 <@8xi32> = { @I32_7 @I32_5 @I32_6 @I32_4 @I32_2 @I32_1 @I32_3 @I32_0 }
%a = EXTRACTELEMENT <@4xfloat @i64> @V0 @I64_2 // 5.9f
%b = INSERTELEMENT <@4xfloat @i64> @V0 @I64_3 @S7 // { 3.1f 4.1f 5.9f 9.3f }
......
......@@ -176,21 +176,21 @@ A double constant constructor has the following form:
NOTE: this is equivalent to a double literal in the text form.
Struct Constant Constructor
~~~~~~~~~~~~~~~~~~~~~~~~~~~
List Constant Constructor
~~~~~~~~~~~~~~~~~~~~~~~~~
A struct constant constructor has the following form:
A list constant constructor has the following form:
+------+---------+
| opct | idList |
+======+=========+
| 0x04 | fields |
| 0x04 | elems |
+------+---------+
``fields`` is a list of IDs, each of which refers to another constant which is
the value of the corresponding field of the struct.
``elems`` is a list of IDs, each of which refers to another constant which is
the value of the corresponding field of the struct or element of array/vector.
NOTE: this is equivalent to the struct literal ``{fields}`` in the text
NOTE: this is equivalent to the struct literal ``{elems}`` in the text
form.
NULL Constant Constructor
......
......@@ -351,25 +351,22 @@ A **constant constructor** can be the following:
the same bit-wise representation as the 32-bit or 64-bit integer of
``intlit``, respectively.
- A **struct constructor** creates a struct constant. It is:
- A **list constructor** creates a struct/array/vector constant. It is:
+ an opening brace ``{``, followed by
+ a sequence of global names of other global variables separated by spaces,
and
+ a closing brace ``}``.
The sequence of names must have the same number of names as the number of
fields/elements as the type requires.
A constant must not be recursive.
- A **null constructor** create a null value of *general reference types* except
``weakref`` (defined in `<type-system>`__). It is written as the **null
literal**: ``NULL``.
- A **vector constructor** create a vector constant. It is:
+ the literal ``VEC`` followed by an open brace ``{``, followed by
+ a sequence of global names of other constants separated by spaces, and
+ a closing brace ``}``.
..
NOTE: The client must ensure the number (integer or floating point) can be
......@@ -453,7 +450,7 @@ A **constant constructor** can be the following:
.const @null_sr <@sref> = NULL
.typedef @4xfloat = vector <@float 4>
.const @vec1 <@4xfloat> = VEC { @float1 @float2 @float3 @float4 }
.const @vec1 <@4xfloat> = { @float1 @float2 @float3 @float4 }
// global cells and functions are global variables, too, and they are constants
.global @g1 <@i64>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment