Skip to content

Commit d2cf938

Browse files
Add synopsis and description for Zacas (Atomic CAS) extension (#516) (#518)
* Add synopses and descriptions for Zacas instructions * Add synopses and descriptions for Zacas instructions * Add synopses and descriptions for Zacas instruction * Add synopses and descriptions for Zacas instructions. * Add synopses and descriptions for Zacas instructions --------- Co-authored-by: Derek Hower <134728312+dhower-qc@users.noreply.github.com>
1 parent d0f01f8 commit d2cf938

File tree

3 files changed

+144
-18
lines changed

3 files changed

+144
-18
lines changed

arch/inst/Zacas/amocas.d.yaml

Lines changed: 70 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,82 @@
1+
---
12
# yaml-language-server: $schema=../../../schemas/inst_schema.json
23

34
$schema: "inst_schema.json#"
45
kind: instruction
56
name: amocas.d
6-
long_name: No synopsis available.
7+
long_name: Atomic Compare-and-Swap Doubleword
78
description: |
8-
No description available.
9+
For RV32, AMOCAS.D atomically loads 64-bits of a data value from address in
10+
rs1, compares the loaded value to a 64-bit value held in a register pair
11+
consisting of rd and rd+1, and if the comparison is bitwise equal, then
12+
stores the 64-bit value held in the register pair rs2 and rs2+1 to the
13+
original address in rs1. The value loaded from memory is placed into the
14+
register pair rd and rd+1. The instruction requires the first register in
15+
the pair to be even numbered; encodings with odd-numbered registers
16+
specified in rs2 and rd are reserved. When the first register of a source
17+
register pair is x0, then both halves of the pair read as zero. When the
18+
first register of a destination register pair is x0, then the entire
19+
register result is discarded and neither destination register is written.
20+
21+
For RV64, AMOCAS.D atomically loads 64-bits of a data value from address in
22+
rs1, compares the loaded value to a 64-bit value held in rd, and if the
23+
comparison is bitwise equal, then stores the 64-bit value held in rs2 to the
24+
original address in rs1. The value loaded from memory is placed into
25+
register rd.
26+
27+
Just as for AMOs in the A extension, AMOCAS.D requires that the address held
28+
in rs1 be naturally aligned to the size of the operand (i.e., eight-byte
29+
aligned for doublewords). And the same exception options apply if the
30+
address is not naturally aligned.
31+
32+
Just as for AMOs in the A extension, the AMOCAS.D optionally provides release
33+
consistency semantics, using the aq and rl bits, to help implement
34+
multiprocessor synchronization. The memory operation performed by an
35+
AMOCAS.D, when successful, has acquire semantics if aq bit is 1 and has
36+
release semantics if rl bit is 1. The memory operation performed by an
37+
AMOCAS.W/D/Q, when not successful, has acquire semantics if aq bit is 1 but
38+
does not have release semantics, regardless of rl.
39+
40+
A FENCE instruction may be used to order the memory read access and, if
41+
produced, the memory write access by an AMOCAS.D instruction.
42+
43+
[Note] An unsuccessful AMOCAS.D may either not perform a memory write or may
44+
write back the old value loaded from memory. The memory write, if produced,
45+
does not have release semantics, regardless of rl.
46+
47+
An AMOCAS.D instruction always requires write permissions.
48+
949
definedBy: Zacas
1050
assembly: xd, xs1, xs2, aq, rl
1151
encoding:
12-
match: 00101------------011-----0101111
13-
variables:
14-
- name: aq
15-
location: 26-26
16-
- name: rl
17-
location: 25-25
18-
- name: rs2
19-
location: 24-20
20-
- name: rs1
21-
location: 19-15
22-
- name: rd
23-
location: 11-7
52+
RV32:
53+
match: 00101------------011-----0101111
54+
variables:
55+
- name: aq
56+
location: 26-26
57+
- name: rl
58+
location: 25-25
59+
- name: rs2
60+
location: 24-20
61+
not: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
62+
- name: rs1
63+
location: 19-15
64+
- name: rd
65+
location: 11-7
66+
not: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
67+
RV64:
68+
match: 00101------------011-----0101111
69+
variables:
70+
- name: aq
71+
location: 26-26
72+
- name: rl
73+
location: 25-25
74+
- name: rs2
75+
location: 24-20
76+
- name: rs1
77+
location: 19-15
78+
- name: rd
79+
location: 11-7
2480
access:
2581
s: always
2682
u: always

arch/inst/Zacas/amocas.q.yaml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
1+
---
12
# yaml-language-server: $schema=../../../schemas/inst_schema.json
23

34
$schema: "inst_schema.json#"
45
kind: instruction
56
name: amocas.q
6-
long_name: No synopsis available.
7+
long_name: Atomic Compare-and-Swap Quadword
78
description: |
8-
No description available.
9+
For RV64, AMOCAS.Q atomically loads 128-bits of a data value from address
10+
in rs1, compares the loaded value to a 128-bit value held in a register
11+
pair consisting of rd and rd+1, and if the comparison is bitwise equal,
12+
then stores the 128-bit value held in the register pair rs2 and rs2+1 to
13+
the original address in rs1. The value loaded from memory is placed into
14+
the register pair rd and rd+1. The instruction requires the first register
15+
in the pair to be even numbered; encodings with odd-numbered registers
16+
specified in rs2 and rd are reserved. When the first register of a source
17+
register pair is x0, then both halves of the pair read as zero. When the
18+
first register of a destination register pair is x0, then the entire
19+
register result is discarded and neither destination register is written.
20+
21+
Just as for AMOs in the A extension, AMOCAS.Q requires that the address held
22+
in rs1 be naturally aligned to the size of the operand (i.e., sixteen-byte
23+
aligned for quadwords). And the same exception options apply if the
24+
address is not naturally aligned.
25+
26+
Just as for AMOs in the A extension, the AMOCAS.Q optionally provides release
27+
consistency semantics, using the aq and rl bits, to help implement
28+
multiprocessor synchronization. The memory operation performed by an
29+
AMOCAS.Q, when successful, has acquire semantics if aq bit is 1 and has
30+
release semantics if rl bit is 1. The memory operation performed by an
31+
AMOCAS.W/D/Q, when not successful, has acquire semantics if aq bit is 1 but
32+
does not have release semantics, regardless of rl.
33+
34+
A FENCE instruction may be used to order the memory read access and, if
35+
produced, the memory write access by an AMOCAS.Q instruction.
36+
37+
[Note] An unsuccessful AMOCAS.Q may either not perform a memory write or
38+
may write back the old value loaded from memory. The memory write, if
39+
produced, does not have release semantics, regardless of rl.
40+
41+
An AMOCAS.Q instruction always requires write permissions.
42+
943
definedBy: Zacas
1044
base: 64
1145
assembly: xd, xs1, xs2, aq, rl
@@ -18,10 +52,12 @@ encoding:
1852
location: 25-25
1953
- name: rs2
2054
location: 24-20
55+
not: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
2156
- name: rs1
2257
location: 19-15
2358
- name: rd
2459
location: 11-7
60+
not: [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]
2561
access:
2662
s: always
2763
u: always

arch/inst/Zacas/amocas.w.yaml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
1+
---
12
# yaml-language-server: $schema=../../../schemas/inst_schema.json
23

34
$schema: "inst_schema.json#"
45
kind: instruction
56
name: amocas.w
6-
long_name: No synopsis available.
7+
long_name: Atomic Compare-and-Swap Word
78
description: |
8-
No description available.
9+
For RV32, AMOCAS.W atomically loads a 32-bit data value from address in rs1,
10+
compares the loaded value to the 32-bit value held in rd, and if the
11+
comparison is bitwise equal, then stores the 32-bit value held in rs2 to the
12+
original address in rs1. The value loaded from memory is placed into
13+
register rd.
14+
15+
For RV64, AMOCAS.W atomically loads a 32-bit data value from address in rs1,
16+
compares the loaded value to the lower 32 bits of the value held in rd, and
17+
if the comparison is bitwise equal, then stores the lower 32 bits of the
18+
value held in rs2 to the original address in rs1. The 32-bit value loaded
19+
from memory is sign-extended and is placed into register rd.
20+
21+
Just as for AMOs in the A extension, AMOCAS.W requires that the address held
22+
in rs1 be naturally aligned to the size of the operand (i.e., four-byte
23+
aligned for words). And the same exception options apply if the address is
24+
not naturally aligned.
25+
26+
Just as for AMOs in the A extension, the AMOCAS.W optionally provides release
27+
consistency semantics, using the aq and rl bits, to help implement
28+
multiprocessor synchronization. The memory operation performed by an
29+
AMOCAS.W, when successful, has acquire semantics if aq bit is 1 and has
30+
release semantics if rl bit is 1. The memory operation performed by an
31+
AMOCAS.W/D/Q, when not successful, has acquire semantics if aq bit is 1 but
32+
does not have release semantics, regardless of rl.
33+
34+
A FENCE instruction may be used to order the memory read access and, if
35+
produced, the memory write access by an AMOCAS.W instruction.
36+
37+
[Note] An unsuccessful AMOCAS.W may either not perform a memory write or may
38+
write back the old value loaded from memory. The memory write, if produced,
39+
does not have release semantics, regardless of rl.
40+
41+
An AMOCAS.W instruction always requires write permissions.
42+
943
definedBy: Zacas
1044
assembly: xd, xs1, xs2, aq, rl
1145
encoding:

0 commit comments

Comments
 (0)