@@ -107,7 +107,7 @@ the `lr` and `sc` instructions.
107107
108108|`atomic_<op>(memory_order_acq_rel)` |`amo<op>.{w\|d}.aqrl` |4
109109
110- |`atomic_<op>(memory_order_seq_cst)` |`amo<op>.{w\|d}.aqrl` |4
110+ |`atomic_<op>(memory_order_seq_cst)` |`amo<op>.{w\|d}.aqrl` |4, 5
111111
112112|===
113113
@@ -148,6 +148,11 @@ mappings with code generated by a compiler using those older mappings.
148148
1491494) Currently only directly possible for 32- and 64-bit operands.
150150
151+ 5) atomic_compare_exchange operations with a memory_order_seq_cst failure
152+ ordering are considered to have a note 3 annotation.
153+ To remove the note 3 annotation the amocas operation must be prepended with a
154+ leading fence (`fence rw,rw; amocas.{w\|d}.aqrl`).
155+
151156== Ztso atomics mappings
152157
153158This specifies additional mappings of C and {Cpp} atomic operations to RISC-V
@@ -157,7 +162,8 @@ For each construct, we provide a mapping that assumes only the A and Ztso
157162extension.
158163
159164All mappings interoperate correctly with the RVWMO mappings, and with the
160- original "Table A.6" mappings.
165+ original "Table A.6" mappings, _except_ that mappings marked with note 3 do not
166+ interoperate with the original "Table A.6" mappings.
161167
162168We present the mappings as a table in 3 sections, as above.
163169
@@ -167,32 +173,32 @@ We present the mappings as a table in 3 sections, as above.
167173|===
168174|C/{Cpp} Construct |Ztso Mapping |Notes
169175
170- |`atomic_load(memory_order_acquire)` |`l{b\|h\|w\|d}` | 5
176+ |`atomic_load(memory_order_acquire)` |`l{b\|h\|w\|d}` | 6
171177
172- |`atomic_load(memory_order_seq_cst)` |`fence rw,rw; l{b\|h\|w\|d}` | 5
178+ |`atomic_load(memory_order_seq_cst)` |`fence rw,rw; l{b\|h\|w\|d}` | 6
173179
174- |`atomic_store(memory_order_release)` |`s{b\|h\|w\|d}` | 5
180+ |`atomic_store(memory_order_release)` |`s{b\|h\|w\|d}` | 6
175181
176- |`atomic_store(memory_order_seq_cst)` |`s{b\|h\|w\|d}; fence rw, rw` | 5
182+ |`atomic_store(memory_order_seq_cst)` |`s{b\|h\|w\|d}; fence rw, rw` | 6
177183
178- |`atomic_thread_fence(memory_order_acquire)` |`nop` | 5
184+ |`atomic_thread_fence(memory_order_acquire)` |`nop` | 6
179185
180- |`atomic_thread_fence(memory_order_release)` |`nop` | 5
186+ |`atomic_thread_fence(memory_order_release)` |`nop` | 6
181187
182- |`atomic_thread_fence(memory_order_acq_rel)` |`nop` | 5
188+ |`atomic_thread_fence(memory_order_acq_rel)` |`nop` | 6
183189|===
184190
185191[cols="<20,<20,<4",options="header",]
186192|===
187193|C/{Cpp} Construct |Ztso AMO Mapping |Notes
188194
189- |`atomic_<op>(memory_order_acquire)` |`amo<op>.{w\|d}` |4, 5
195+ |`atomic_<op>(memory_order_acquire)` |`amo<op>.{w\|d}` |4, 6
190196
191- |`atomic_<op>(memory_order_release)` |`amo<op>.{w\|d}` |4, 5
197+ |`atomic_<op>(memory_order_release)` |`amo<op>.{w\|d}` |4, 6
192198
193- |`atomic_<op>(memory_order_acq_rel)` |`amo<op>.{w\|d}` |4, 5
199+ |`atomic_<op>(memory_order_acq_rel)` |`amo<op>.{w\|d}` |4, 6
194200
195- |`atomic_<op>(memory_order_seq_cst)` |`amo<op>.{w\|d}` |4, 5
201+ |`atomic_<op>(memory_order_seq_cst)` |`amo<op>.{w\|d}` |4, 5, 6
196202
197203|===
198204
@@ -201,21 +207,30 @@ We present the mappings as a table in 3 sections, as above.
201207|C/{Cpp} Construct |Ztso LR/SC Mapping |Notes
202208
203209|`atomic_<op>(memory_order_acquire)`
204- |`loop:lr.{w\|d}; <op>; sc.{w\|d}; bnez loop` |4, 5
210+ |`loop:lr.{w\|d}; <op>; sc.{w\|d}; bnez loop` |4, 6
205211
206212|`atomic_<op>(memory_order_release)`
207- |`loop:lr.{w\|d}; <op>; sc.{w\|d}; bnez loop` |4, 5
213+ |`loop:lr.{w\|d}; <op>; sc.{w\|d}; bnez loop` |4, 6
208214
209215|`atomic_<op>(memory_order_acq_rel)`
210- |`loop:lr.{w\|d}; <op>; sc.{w\|d}; bnez loop` |4, 5
216+ |`loop:lr.{w\|d}; <op>; sc.{w\|d}; bnez loop` |4, 6
211217
212218|===
213219
214220=== Meaning of notes in table
215221
222+ 3) Incompatible with the original "Table A.6" mapping. Do not combine these
223+ mappings with code generated by a compiler using those older mappings.
224+ (This was mostly used by the initial LLVM implementations for RISC-V.)
225+
2162264) Currently only directly possible for 32- and 64-bit operands.
217227
218- 5) Requires the Ztso extension.
228+ 5) atomic_compare_exchange operations with a memory_order_seq_cst failure
229+ ordering are considered to have a note 3 annotation.
230+ To remove the note 3 annotation the amocas operation must be prepended with a
231+ leading fence (`fence rw,rw; amocas.{w\|d}`).
232+
233+ 6) Requires the Ztso extension.
219234
220235== Other conventions
221236
0 commit comments