(no commit message)
[libreriscv.git] / simple_v_extension / vector_ops.mdwn
index 4873de0e161fb9eec5e4a11a8f5c29a2a028a09c..5294cbdb5012e5dfde9f2c84ae89f871553beb50 100644 (file)
@@ -1,7 +1,11 @@
-[[!tag standards]]
+[[!tag oldstandards]]
+
+**OBSOLETE**, see [[openpower/sv/3d_vector_ops]]
 
 # Vector Operations Extension to SV
 
+This extension defines vector operations that would otherwise take several cycles to complete in software. With 3D priorities being to compute as many pixels per clock as possible, the normal RISC rules (reduce opcode count and make heavy use of macro op fusion) do not necessarily apply. 
+
 This extension is usually dependent on SV SUBVL being implemented. When SUBVL is set to define the length of a subvector the operations in this extension interpret the elements as a single vector.
 
 Normally in SV all operations are scalar and independent, and the operations on them may inherently be independently parallelised, with the result being a vector of length exactly equal to the input vectors.
@@ -23,11 +27,16 @@ Examples which can require SUBVL include cross product and may in future involve
 * CORDIC.cir.vec vd, vs, beta
 * CORDIC.hyp.vec vd, vs, beta
 
+
+| Instr | result | src1 | src2 | SUBVL | VL | Notes |
+| ------------------ | ------ | ---- | ---- | ----- | -- | ------ |
+| CORDIC.x.t vd, vs1, rs2 | vec2 | vec2 | scal | 2 | any | src2 ignores SUBVL |
+
 SUBVL must be set to 2 and applies to vd and vs. SUBVL is *ignored* on beta.  vd and vs must be marked as vectors.
 
 VL may be applied.  beta as a scalar is ok (applies across all vectors vd and vs). Predication is also ok (single predication) sourced from vd. Use of swizzle is also ok.
 
-Non vector args vd, vs, or SUBVL != 2 are reserved encodings.
+Non vector args vd, vs are reserved encodings.
 
 CORDIC is an extremely general-purpose algorithm useful for a huge number
 of diverse purposes.  In its full form it does however require quite a
@@ -50,11 +59,17 @@ Links:
 
 ## Vector cross product
 
-SUBVL=3, all regs. VL nonzero produces multiple vd results.
-
 * VCROSS vd, vs1, vs1
 
-Result is the cross product of x and y, i.e., the resulting components are, in order:
+Result is the cross product of x and y.
+
+SUBVL must be set to 3, and all regs must be vectors. VL nonzero produces multiple results in vd.
+
+| Instr | result | src1 | src2 | SUBVL | VL |
+| ------------------ | ------ | ---- | ---- | ----- | -- |
+| VCROSS vd, vs1, vs2 | vec3 | vec3 | vec3 | 3 | any |
+
+The resulting components are, in order:
 
     x[1] * y[2] - y[1] * x[2]
     x[2] * y[0] - y[2] * x[0]
@@ -75,23 +90,31 @@ Pseudocode:
 
 Assembler:
 
-    fpermute,2130 F4, F1
-    fpermute,1320 F5, F1
-    fpermute,2130 F6, F2
-    fpermute,1320 F7, F2
+    fswizzlei,2130 F4, F1
+    fswizzlei,1320 F5, F1
+    fswizzlei,2130 F6, F2
+    fswizzlei,1320 F7, F2
     fmul F8, F5, F6
     fmulsub F3, F4, F7, F8
 
 ## Vector dot product
 
-* SUBVL ignored on rd.  SUBVL=2,3,4 vs1,vs2, if all vectors, multiple results generated. If rd scalar, only first (unpredicated) SUBVector is used.
-* rd=scalar, SUBVL=1 and vs1, vs2=vec will produce one scalar result. Predication allowed on src vectors.
-
 * VDOT rd, vs1, vs2
 
 Computes the dot product of two vectors. Internal accuracy must be
 greater than the input vectors and the result.
 
+There are two possible argument options:
+
+* SUBVL=2,3,4 vs1 and vs2 set as vectors,  multiple results are generated. When VL is set, only the first (unpredicated) SUBVector is used to create a result, if rd is scalar (standard behaviour for single predication). Otherwise, if rd is a vector, multiple scalar results are calculated (i.e. SUBVL is always ignored for rd). Swizzling may be applied.
+* When rd=scalar, SUBVL=1 and vs1=vec, vs2=vec, one scalar result is generated from the entire src vectors.  Predication is allowed on the src vectors.
+
+
+| Instr | result | src1 | src2 | SUBVL | VL |
+| ------------------ | ------ | ---- | ---- | ----- | -- |
+| VDOT rd, vs1, vs2 | scal | vec  | vec | 2-4 | any |
+| VDOT rd, vs1, vs2 | scal | vec  | vec | 1 | any |
+
 Pseudocode in python:
 
     from operator import mul
@@ -143,7 +166,11 @@ other and returns length:
 
 ## Vector LERP
 
-* VLERP rd, vs1, rs2 # SUBVL=2: vs1.v0 vs1.v1
+* VLERP vd, vs1, rs2 # SUBVL=2: vs1.v0 vs1.v1
+
+| Instr | result | src1 | src2 | SUBVL | VL |
+| ------------------ | ------ | ---- | ---- | ----- | -- |
+| VLERP vd, vs1, rs2 | vec2 | vec2 | scal | 2 | any |
 
 Known as **fmix** in GLSL.