(no commit message)
[libreriscv.git] / ztrans_proposal.mdwn
1 # Ztrans - transcendental operations
2
3 See:
4
5 * <http://bugs.libre-riscv.org/show_bug.cgi?id=127>
6 * <https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.ExtendedInstructionSet.100.html>
7
8 Extension subsets:
9
10 * **Ztrans**: standard transcendentals (best suited to 3D)
11 * **ZtransExt**: extra functions (useful, not generally needed for 3D)
12 * **ZtransAdv**: much more complex to implement in hardware
13
14 [[!toc levels=2]]
15
16 # List of 2-arg opcodes
17
18 [[!table data="""
19 opcode | Description | pseudo-code | Extension |
20 FATAN2 | atan2 arc tangent | rd = atan2(rs2, rs1) | Ztrans |
21 FATAN2PI | atan arc tangent / pi | rd = atan2(rs2, rs1) / pi | ZtransExt |
22 FPOW | x power of y | rd = pow(rs1, rs2) | ZtransAdv |
23 FROOT | x power 1/y | rd = pow(rs1, 1/rs2) | ZtransAdv |
24 """]]
25
26 # List of 1-arg opcodes
27
28 [[!table data="""
29 opcode | Description | pseudo-code | Extension |
30 FCBRT | Cube Root | rd = pow(rs1, 3) | Ztrans |
31 FEXP2 | power-of-2 | rd = pow(2, rs1) | Ztrans |
32 FLOG2 | log2 | rd = log2(rs1) | Ztrans |
33 FEXPM1 | exponent minus 1 | rd = pow(e, rs1) - 1.0 | Ztrans |
34 FLOG1P | log plus 1 | rd = log(e, 1 + rs1) | Ztrans |
35 FEXP | exponent | rd = pow(e, rs1) | ZtransExt |
36 FLOG | natural log (base e) | rd = log(e, rs1) | ZtransExt |
37 FEXP10 | power-of-10 | rd = pow(10, rs1) | ZtransExt |
38 FLOG10 | log base 10 | rd = log10(rs1) | ZtransExt |
39 FSIN | sin (radians) | | Ztrans |
40 FCOS | cos (radians) | | Ztrans |
41 FTAN | tan (radians) | | Ztrans |
42 FASIN | arcsin (radians) | rd = asin(rs1) | Ztrans |
43 FACOS | arccos (radians) | rd = acos(rs1) | Ztrans |
44 FATAN | arctan (radians) | rd = atan(rs1) | Ztrans |
45 FSINPI | sin times pi | rd = sin(pi * rs1) | ZtransExt |
46 FCOSPI | cos times pi | rd = cos(pi * rs1) | ZtransExt |
47 FTANPI | tan times pi | rd = tan(pi * rs1) | ZtransExt |
48 FSINH | hyperbolic sin (radians) | | ZtransExt |
49 FCOSH | hyperbolic cos (radians) | | ZtransExt |
50 FTANH | hyperbolic tan (radians) | | ZtransExt |
51 FASINH | inverse hyperbolic sin | | ZtransExt |
52 FACOSH | inverse hyperbolic cos | | ZtransExt |
53 FATANH | inverse hyperbolic tan | | ZtransExt |
54 """]]
55
56 # Pseudo-code ops
57
58 * FRCP rd, rs1 - pseudo-code alias for rd = 1.0 / rs1
59 * FATAN - pseudo-code alias for rd = atan2(rs1, 1.0) - FATAN2
60 * FATANPI - pseudo alias for rd = atan2pi(rs1, 1.0) - FATAN2PI
61 * FSINCOS - fused macro-op between FSIN and FCOS (issued in that order).
62 * FSINCOSPI - fused macro-op between FSINPI and FCOSPI (issued in that order).
63