Operands and parameters
SrcL- Reg5 atomic address source
SrcR- Reg5 doubleword replacement source
RegDst- Reg5 old-value destination
aq- acquire ordering bit
rl- release ordering bit
far- flat-address routing hint
SWAPD atomically replaces one doubleword and publishes the prior value.
PTO-SCALAR-SWAPDswapd [SrcL], SrcR, ->Rdswapd.aq [SrcL], SrcR, ->Rdswapd.rl [SrcL], SrcR, ->Rdswapd.f [SrcL], SrcR, ->Rdswapd.aqrl [SrcL], SrcR, ->Rdswapd.aqf [SrcL], SrcR, ->Rdswapd.rlf [SrcL], SrcR, ->Rdswapd.aqrlf [SrcL], SrcR, ->Rd| Field | Bits | Signedness | Architectural role | Encoded zero |
|---|---|---|---|---|
RegDst | 5 | encoding-defined | Reg5 old-value destination | Encoded zero discards the prior value. |
SrcL | 5 | encoding-defined | Reg5 atomic address source | Encoded zero reads the architectural zero register as the address. |
SrcR | 5 | encoding-defined | Reg5 doubleword replacement source | Encoded zero supplies numeric zero as the replacement. |
aq | 1 | encoding-defined | acquire ordering bit | Encoded zero disables acquire ordering. |
far | 1 | encoding-defined | flat-address routing hint | Encoded zero selects the default flat-address route. |
rl | 1 | encoding-defined | release ordering bit | Encoded zero disables release ordering. |
Loading WaveDrom diagram… The encoding table and WaveJSON remain available below.
| Decoded item | Bit range | Value |
|---|---|---|
| Constant | 31:28 | 4'b0011 |
| far | 27 | variable |
| aq | 26 | variable |
| rl | 25 | variable |
| SrcR | 24:20 | variable |
| SrcL | 19:15 | variable |
| Constant | 14:12 | 3'b110 |
| RegDst | 11:7 | variable |
| Constant | 6:0 | 7'b0001011 |
{
"reg": [
{
"bits": 7,
"name": "7'b0001011"
},
{
"bits": 5,
"name": "RegDst"
},
{
"bits": 3,
"name": "3'b110"
},
{
"bits": 5,
"name": "SrcL"
},
{
"bits": 5,
"name": "SrcR"
},
{
"bits": 1,
"name": "rl"
},
{
"bits": 1,
"name": "aq"
},
{
"bits": 1,
"name": "far"
},
{
"bits": 4,
"name": "4'b0011"
}
],
"config": {
"bits": 32,
"fontsize": 13,
"hspace": 900,
"lanes": 1,
"offset": 0
}
}swapd<.{aq, rl, f, aqrl, aqf, rlf, aqrlf}> [SrcL], SrcR, {->t, ->u, ->Rd}
SrcLSrcRRegDstaqrlfarThis Operation comes directly from the instruction owner; the page does not rewrite its behavior.
readonly func InstructionContractOperation_SWAPD() => ScalarOperationbegin return ScalarOperation_SWAPD;end;readonly func InstructionContractHandler_SWAPD() => ScalarSemanticHandlerbegin return ScalarHandler_AtomicReadModifyWrite;end;
pure func InstructionContractAtomicOperation_SWAPD() => AtomicOperationbegin return Atomic_SWAP;end;
pure func InstructionContractAtomicSizeBytes_SWAPD() => integer {1,2,4,8}begin return 8;end;
pure func InstructionContractZeroExtendsOldValue_SWAPD() => booleanbegin return FALSE;end;
pure func InstructionContractSignExtendsOldValue_SWAPD() => booleanbegin return FALSE;end;// PTO-INSTRUCTION: {"assembly":["swapd [SrcL], SrcR, ->Rd","swapd.aq [SrcL], SrcR, ->Rd","swapd.rl [SrcL], SrcR, ->Rd","swapd.f [SrcL], SrcR, ->Rd","swapd.aqrl [SrcL], SrcR, ->Rd","swapd.aqf [SrcL], SrcR, ->Rd","swapd.rlf [SrcL], SrcR, ->Rd","swapd.aqrlf [SrcL], SrcR, ->Rd"],"block":[],"catalog_indices":[452],"catalog_records":[{"asm":"swapd<.{aq, rl, f, aqrl, aqf, rlf, aqrlf}> [SrcL], SrcR, {->t, ->u, ->Rd}","constraints":[],"encoding":[{"index":0,"mask":"0xf000707f","match":"0x3000600b","width_bits":32}],"encoding_kind":"L32","fields":[{"name":"RegDst","pieces":[{"instruction_lsb":7,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"SrcL","pieces":[{"instruction_lsb":15,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"SrcR","pieces":[{"instruction_lsb":20,"value_lsb":0,"width":5}],"signedness":"encoding-defined","width":5},{"name":"aq","pieces":[{"instruction_lsb":26,"value_lsb":0,"width":1}],"signedness":"encoding-defined","width":1},{"name":"far","pieces":[{"instruction_lsb":27,"value_lsb":0,"width":1}],"signedness":"encoding-defined","width":1},{"name":"rl","pieces":[{"instruction_lsb":25,"value_lsb":0,"width":1}],"signedness":"encoding-defined","width":1}],"form_id":"swapd_32_cd31ccde2303","length_bits":32,"mnemonic":"SWAPD","semantic_family":"AMO","semantic_group":"AMO","semantic_handler":"AtomicReadModifyWrite","semantic_summary":"SWAPD atomically replaces one doubleword and publishes the prior value.","status":"accepted"}],"classification":["amo"],"contract":{"block_composition":["none"],"canonical_assembly":["swapd [SrcL], SrcR, ->Rd","swapd.aq [SrcL], SrcR, ->Rd","swapd.rl [SrcL], SrcR, ->Rd","swapd.f [SrcL], SrcR, ->Rd","swapd.aqrl [SrcL], SrcR, ->Rd","swapd.aqf [SrcL], SrcR, ->Rd","swapd.rlf [SrcL], SrcR, ->Rd","swapd.aqrlf [SrcL], SrcR, ->Rd"],"defaults":["SrcL, SrcR, and RegDst are required Reg5 fields. Encoded source zero reads the architectural zero register; encoded destination zero discards the old value.","aq=0 and rl=0 select relaxed ordering. aq=1 selects acquire, rl=1 selects release, and aq=1 with rl=1 selects acquire-release.","far=0 selects the default flat-address route. far=1 is a profile routing hint; the reference profile preserves the same architectural address and atomic result."],"encoding_class":"standalone-encoded","examples":["swapd [a0], a1, ->a2","swapd.aqrl [t#1], u#1, ->u","swapd.f [sp], zero, ->t"],"exceptions":["The effective address must be aligned to 8 bytes. Alignment, read translation/permission, write translation/permission, and translated-address equality are checked before effects.","On a fault, no destination, memory write, event, reservation update, or TPC advance occurs. Trap entry saves the original TPC and recovery restores it for full reissue.","An undecodable fixed-bit pattern raises Fault_IllegalInstruction before effects. All explicit field values are assigned."],"field_contracts":{},"field_zero_meanings":{"RegDst":"Encoded zero discards the prior value.","SrcL":"Encoded zero reads the architectural zero register as the address.","SrcR":"Encoded zero supplies numeric zero as the replacement.","aq":"Encoded zero disables acquire ordering.","far":"Encoded zero selects the default flat-address route.","rl":"Encoded zero disables release ordering."},"legality":["All 32 SrcL and SrcR Reg5 encodings are assigned: 0..23 select absolute GPRs, 24..27 select T#1..T#4, and 28..31 select U#1..U#4.","All 32 RegDst encodings are assigned. Code 0 and codes 24..29 discard, code 30 pushes U, code 31 pushes T, and codes 1..23 write the named absolute GPR.","All aq, rl, and far combinations are assigned.","The effective address must be aligned to 8 bytes."],"memory_effects":["After aligned read and write preflight identify the same translated location, atomically read one 8-byte doubleword, store SrcR truncated to 8 bytes, and emit one ordered atomic event.","A successful overlapping write invalidates the local 64-byte-line reservation; a nonoverlapping write preserves it.","The 64-bit old value is published unchanged."],"operands":[{"field":"SrcL","role":"Reg5 atomic address source"},{"field":"SrcR","role":"Reg5 doubleword replacement source"},{"field":"RegDst","role":"Reg5 old-value destination"},{"field":"aq","role":"acquire ordering bit"},{"field":"rl","role":"release ordering bit"},{"field":"far","role":"flat-address routing hint"}],"ordering":["aq=0,rl=0 records relaxed ordering; aq=1,rl=0 acquire; aq=0,rl=1 release; aq=1,rl=1 acquire-release.","far changes only the route hint in the reference profile."],"standalone_opcode":true,"state_effects":["Snapshot SrcL and SrcR before any memory or destination effect.","Publish the prior value only after successful atomic commit.","The 64-bit old value is published unchanged.","Successful execution advances TPC by four bytes. A fault saves and later restores the original TPC for full reissue."]},"depends_on":["PTO-BLOCK-MODEL-SCHEMA-PROFILE-ENCODING"],"id":"PTO-SCALAR-SWAPD","mnemonic":"SWAPD","summary":"SWAPD atomically replaces one doubleword and publishes the prior value.","surface":"scalar"}// PTO-REVIEW: {"review_method":"formal-definition-read","outcome":"FORMAL-COMPLETE","reviewed_fields":["assembly","encoding","defaults","operation","state","memory","ordering","faults","reserved"]}// NDF-BEGIN: PTO-SWAPD-ADR-CONTRACT-001// ndf: kind=contract level=L1 layer=scalar status=accepted// Decisions: ADR-0030.// SWAPD MUST preflight its complete mnemonic-owned atomic access before// memory, reservation, event, or destination effects and MUST commit the// selected width, ordering, memory update, event, and result atomically.// NDF-END: PTO-SWAPD-ADR-CONTRACT-001// DOC-BEGIN: decodereadonly func InstructionContractOperation_SWAPD() => ScalarOperationbegin return ScalarOperation_SWAPD;end;// DOC-END: decode// DOC-BEGIN: operationreadonly func InstructionContractHandler_SWAPD() => ScalarSemanticHandlerbegin return ScalarHandler_AtomicReadModifyWrite;end;
pure func InstructionContractAtomicOperation_SWAPD() => AtomicOperationbegin return Atomic_SWAP;end;
pure func InstructionContractAtomicSizeBytes_SWAPD() => integer {1,2,4,8}begin return 8;end;
pure func InstructionContractZeroExtendsOldValue_SWAPD() => booleanbegin return FALSE;end;
pure func InstructionContractSignExtendsOldValue_SWAPD() => booleanbegin return FALSE;end;// DOC-END: operation
SWAPD atomically replaces one doubleword with SrcR and publishes the prior 64-bit value.
The ASL DOC contract selects ScalarHandler_AtomicReadModifyWrite with an access width of 8 bytes.
The read and write probes must resolve to the same translated location before the atomic exchange can commit.
SrcL carries the Reg5 atomic address source; SrcR carries the Reg5 doubleword replacement source; RegDst carries the Reg5 old-value destination; aq carries the acquire ordering bit; rl carries the release ordering bit; far carries the flat-address routing hint.
aq and rl select relaxed, acquire, release, or acquire-release ordering; far is a profile routing hint and does not change the architectural result in the reference profile.
On success, one atomic event records the exchange and the old value is published only after the memory update commits.
A completed write invalidates an overlapping local 64-byte-line reservation, preserves a nonoverlapping reservation, and advances TPC by 4 bytes.
The effective address must be aligned to 8 bytes. Alignment, translation, and permission checks precede architectural effects.
A failing preflight publishes no destination, memory event, reservation update, or retirement effect; the saved original TPC supports full reissue.
This example only shows one accepted spelling; the generated contract below remains authoritative.
For a first reading, use swapd [SrcL], SrcR, ->Rd and then vary only the ordering or route modifiers described above.
Bodies come from owning ASL. Dragging or buttons change only this page-session view order.
Decisions: ADR-0030. SWAPD MUST preflight its complete mnemonic-owned atomic access before memory, reservation, event, or destination effects and MUST commit the selected width, ordering, memory update, event, and result atomically.
PTO-SWAPD-ADR-CONTRACT-001asl/scalar/amo/SWAPD.aslc9d7ad4c27f25b3894245e412dd943d9c6e97d64aec2abb479c29e903ce6ce0c5ac71f7f59245befa190ece818db9339ef53599b5c5e2edd4ad623e8793d0ecf13 matching entries
PTO-AVS-SCALAR-SWAPD-ALIASES-001tests/asl/scalar/amo/SWAPD/scalar-bound-swapd-aliases-001.asl8c617fb503e67b90106bfff41a2300472ea03348340fbf876b23c62cd6366d0ePTO-AVS-SCALAR-SWAPD-DECODE-001tests/asl/scalar/amo/SWAPD/scalar-decode-swapd-canonical-001.asl6278b81d0cd72e651d67e565d48ee05512d07176a5b2737b6559cabbfacdb253PTO-AVS-SCALAR-SWAPD-PRECISE-001tests/asl/scalar/amo/SWAPD/scalar-fault-swapd-precise-001.asl2ca39491bfd0b5f4ebcdadbac6f7be5c579c3ff0e42d12b1786a2e2f17a51b9fPTO-AVS-SCALAR-SWAPD-RESULT-001tests/asl/scalar/amo/SWAPD/scalar-exec-swapd-result-001.asl25fc29438f2cf5541f4143f7656e459818d6749c5f9967e131975947bace3b61PTO-EVIDENCE-RELEASE-TRACEABILITYPTO-EVIDENCE-RELEASE-TRACEABILITYspec/evidence/release-traceability-readiness.jsonc7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3ePTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREspec/evidence/instruction-contract-closure.json3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106aPTO-EVIDENCE-ARCHITECTURE-READINESSPTO-EVIDENCE-ARCHITECTURE-READINESSspec/evidence/architecture-readiness.json4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004PTO-EVIDENCE-RELEASE-GATE-READINESSPTO-EVIDENCE-RELEASE-GATE-READINESSspec/evidence/release-gate-readiness.jsona0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0PTO-EVIDENCE-RELEASE-MANIFESTPTO-EVIDENCE-RELEASE-MANIFESTspec/release-manifest.json1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8Loading ADR-0020…
ADR-0020docs/status/decisions/0020-production-memory-events-and-atomic-corners.md215b18f05d0b53120949373fce6a5ce22f7ab534fb22df24743a9b2b4beb2decLoading ADR-0030…
ADR-0030docs/status/decisions/0030-scalar-amo-totality-and-reservation.md110bd32b3004a8383913ac6053cc7d0a1d0b8e03e3ef7c47d83292c94a6a17ebLoading ADR-0059…
ADR-0059docs/status/decisions/0059-mnemonic-field-encoding-closure.mdf18d13f735cfaf9f2803c754c5818f4af33d1cc42c489f0d9ce060b07bb3a196Loading ADR-0084…
ADR-0084docs/status/decisions/0084-scalar-system-and-queue-operations.mde068992fa81e2c4ac46e492391a2f784141d68e041bf0b9e0586c37217d1e08c{
"classification": [
"amo"
],
"documentation": "docs/scalar/amo/SWAPD.md",
"id": "PTO-SCALAR-SWAPD",
"instruction_contract": {
"artifact": "spec/evidence/instruction-contract-closure.json",
"mnemonic": "SWAPD",
"ndf_clause": "PTO-INST-SCALAR-SWAPD"
},
"mnemonic": "SWAPD",
"readiness_subjects": [
"ADR-0020",
"ADR-0030",
"ADR-0059",
"ADR-0084"
],
"semantic_tests": [
"PTO-AVS-SCALAR-SWAPD-ALIASES-001",
"PTO-AVS-SCALAR-SWAPD-PRECISE-001",
"PTO-AVS-SCALAR-SWAPD-RESULT-001"
],
"source": "asl/scalar/amo/SWAPD.asl",
"surface": "scalar",
"tests": [
"PTO-AVS-SCALAR-SWAPD-ALIASES-001",
"PTO-AVS-SCALAR-SWAPD-DECODE-001",
"PTO-AVS-SCALAR-SWAPD-PRECISE-001",
"PTO-AVS-SCALAR-SWAPD-RESULT-001"
]
}0.58.5 · Release candidate7dc8b7e5b121d2b2499a2273bebff29e2cd86812c9d7ad4c27f25b3894245e412dd943d9c6e97d64aec2abb479c29e903ce6ce0cb6abd2e27fd5e58b2a294b39488c7401ca3a73ecf81df63cfe6a21d4d98c4d41asl/scalar/amo/SWAPD.aslasl/scalar/amo/SWAPD.aslasl/scalar/amo/SWAPD.asl