(no commit message)
[libreriscv.git] / openpower / sv / cr_ops.mdwn
1 # Data-dependent fail-first on CR operations
2
3 Data-dependent SVP64 Vectorised Operations involving the creation or
4 modification of a CR require an extra two bits, which are not available
5 in the compact space of the `MODE` Field. With the concept of element
6 width overrides being meaningless for CR Fields it is possible to use the
7 `ELWIDTH` field for extra fields.
8
9 Condition Register based operations such as `mfcr` and `crand` can thus
10 be made more flexible. However the rules that apply in this section
11 also apply to future CR-based instructions. Note that these rules and
12 the alternative mapping **only** applies to instructions that **only**
13 reference a CR Field or CR bit as the sole exclusive result. This section
14 **does not** apply to instructions which primarily produce arithmetic
15 results that also produce a CR Field (such as when Rc=1).
16
17 SVP64 RM `MODE` (includes `ELWIDTH` bits) for CR-based operations:
18
19 | 4 | 5 | 19-20 | 21 | 22 23 | description |
20 | - | - | ----- | --- |---------|----------------- |
21 |dz |VLi| 01 | inv | CR-bit | normal mode |
22 |sz |VLi| 01 | inv | dz Rc1 | VLSET mode |
23 | / | / | 00 | 0 | dz sz | normal mode |
24 | / | / | 00 | 1 | 0 RG | scalar reduce mode (mapreduce), SUBVL=1 |
25 | / | / | 00 | 1 | 1 CRM | parallel reduce mode (mapreduce), SUBVL=1 |
26 | / | / | 00 | 1 | SVM RG | subvector reduce mode, SUBVL>1 |
27 | / | / | 10 | / | / / | RESERVED |
28 |dz | / | 11 | inv | CR-bit | Rc=1: pred-result CR sel |
29 |sz | / | 11 | inv | dz RC1 | Rc=0: pred-result z/nonz |
30
31 Fields:
32
33 There are two primary different types of CR operations:
34
35 * Those which have a 3-bit operand field (referring to a CR Field)
36 * Those which have a 5-bit operand (referring to a bit within the
37 whole 32-bit CR)
38
39 Examining these two as has already been done it is observed that the
40 difference may be considered to be that the 5-bit variant provides
41 additional information about which CR Field bit (EQ, GE, LT, SO) is to
42 be operated on by the instruction.
43
44 Thus, logically, we may set the following rule:
45
46 * When a 5-bit CR Result field is used in an instruction, the
47 `inv, VLi and RC1` variant of Data-Dependent Fail-First
48 must be used. i.e. the bit of the CR field to be tested is
49 the one that has just been modified by the operation.
50 * When a 3-bit CR Result field is used the `inv CRbit` variant
51 must be used in order to select which CR Field bit shall
52 be tested (EQ, LE, GE, SO)
53
54 The reason why the 3-bit CR variant needs the additional CR-bit
55 field should be obvious from the fact that the 3-bit CR Field
56 from the base Power ISA v3.0B operation clearly does not contain
57 and is missing the two CR Field Selector bits. Thus, these two
58 bits (to select EQ, LE, GE or SO) must be provided in another
59 way.
60
61 Examples of the former type:
62
63 * crand, cror, crnor. These all are 5-bit (BA, BB, BT). The bit
64 to be tested against `inv` is the one selected by `BT`
65 * mcrf. This has only 3-bit (BF, BFA). In order to select the
66 bit to be tested, the alternative FFirst encoding must be used.
67
68 This limits sv.mcrf in that it may not use the `VLi` (VL inclusive)
69 Mode. This is unfortunste but unavoidable due to encoding pressure
70 on SVP64.
71