<?xml version="1.0" ?><?xml-stylesheet type="text/xsl" encoding="UTF-8" href="iform.xsl" version="1.0"?><!DOCTYPE instructionsection  PUBLIC '-//ARM//DTD instructionsection //EN'  'iform-p.dtd'><!-- Copyright (c) 2010-2026 Arm Limited or its affiliates. All rights reserved. --><!-- This document is Non-Confidential. This document may only be used and distributed in accordance with the terms of the agreement entered into by Arm and the party that Arm delivered this document to. --><instructionsection id="SWPT" title="SWPT, SWPTA, SWPTAL, SWPTL -- A64" type="instruction">
  <docvars>
    <docvar key="instr-class" value="general"/>
    <docvar key="isa" value="A64"/>
  </docvars>
  <heading>SWPT, SWPTA, SWPTAL, SWPTL</heading>
  <desc>
    <brief>
      <para>Swap unprivileged</para>
    </brief>
    <authored>
      <para>This instruction atomically loads a 32-bit word or
64-bit doubleword from a memory location,
and stores the value held in a register back to the same memory location.
The value initially loaded from memory is returned in the destination register.</para>
      <list type="unordered">
        <listitem>
          <content>If the destination register is not one of <value>WZR</value> or
        <value>XZR</value>, <instruction>SWPTA</instruction> and <instruction>SWPTAL</instruction> load from memory with acquire semantics.</content>
        </listitem>
        <listitem>
          <content>
            <instruction>SWPTL</instruction> and <instruction>SWPTAL</instruction> store to memory with release semantics.</content>
        </listitem>
        <listitem>
          <content>
            <instruction>SWPT</instruction> has neither acquire nor release semantics.</content>
        </listitem>
      </list>
      <para>For more information about memory ordering semantics, see <xref linkend="ARMARM_BEIHCHEF">Load-Acquire, Store-Release</xref>.</para>
      <para>For information about addressing modes, see
<xref linkend="ARMARM_CHDIIIBB">Load/Store addressing modes</xref>.</para>
      <para>Explicit Memory  effects produced by the instruction behave as if the instruction was
  executed at EL0 if the <xref linkend="ARMARM_Effective_value">Effective value</xref> of
  PSTATE.UAO is 0 and either:</para>
      <list type="unordered">
        <listitem>
          <content>The instruction is executed at EL1.</content>
        </listitem>
        <listitem>
          <content>The instruction is executed at EL2 when the <xref linkend="ARMARM_Effective_value">Effective value</xref>
  of <register_link id="AArch64-hcr_el2.xml" state="AArch64">HCR_EL2()</register_link>.{E2H, TGE} is '11'.</content>
        </listitem>
      </list>
      <para>Otherwise, the Explicit Memory  effects operate with the restrictions determined by
  the Exception level at which the instruction is executed.</para>
    </authored>
  </desc>
  <alias_list howmany="0"/>
  <classes>
    <iclass name="Integer" oneof="1" id="iclass_integer" no_encodings="8" isa="A64">
      <docvars>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
      </docvars>
      <iclassintro count="8"/>
      <arch_variants>
        <arch_variant feature="FEAT_LSUI" name="v9Ap6"/>
      </arch_variants>
      <regdiagram form="32" psname="A64.ldst.memop_unpriv.SWPT_32_memop_unpriv" tworows="1">
        <box hibit="31" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="30" width="1" name="sz" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="29" width="6" settings="6">
          <c>0</c>
          <c>1</c>
          <c>1</c>
          <c>0</c>
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="22" width="1" name="R" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="21" width="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="20" width="5" name="Rs" usename="1">
          <c colspan="5"/>
        </box>
        <box hibit="15" name="o3" usename="1" settings="1" psbits="x">
          <c>1</c>
        </box>
        <box hibit="14" width="3" name="opc" usename="1" settings="3" psbits="xxx">
          <c>0</c>
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="11" width="2" settings="2">
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="9" width="5" name="Rn" usename="1">
          <c colspan="5"/>
        </box>
        <box hibit="4" width="5" name="Rt" usename="1">
          <c colspan="5"/>
        </box>
      </regdiagram>
      <encoding name="SWPT_32_memop_unpriv" oneofinclass="8" oneof="8" label="32-bit SWPT" bitdiffs="sz == 0 &amp;&amp; A == 0 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPT-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="SWPT"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>SWPT  </text><a hover="Is the 32-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="WsOrWZR__2">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPTA_32_memop_unpriv" oneofinclass="8" oneof="8" label="32-bit SWPTA" bitdiffs="sz == 0 &amp;&amp; A == 1 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPTA-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="SWPTA"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>SWPTA  </text><a hover="Is the 32-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="WsOrWZR__2">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPTAL_32_memop_unpriv" oneofinclass="8" oneof="8" label="32-bit SWPTAL" bitdiffs="sz == 0 &amp;&amp; A == 1 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPTAL-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="SWPTAL"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>SWPTAL  </text><a hover="Is the 32-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="WsOrWZR__2">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPTL_32_memop_unpriv" oneofinclass="8" oneof="8" label="32-bit SWPTL" bitdiffs="sz == 0 &amp;&amp; A == 0 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPTL-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="SWPTL"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>SWPTL  </text><a hover="Is the 32-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="WsOrWZR__2">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPT_64_memop_unpriv" oneofinclass="8" oneof="8" label="64-bit SWPT" bitdiffs="sz == 1 &amp;&amp; A == 0 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPT-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="SWPT"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>SWPT  </text><a hover="Is the 64-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="XsOrXZR">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPTA_64_memop_unpriv" oneofinclass="8" oneof="8" label="64-bit SWPTA" bitdiffs="sz == 1 &amp;&amp; A == 1 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPTA-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="SWPTA"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>SWPTA  </text><a hover="Is the 64-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="XsOrXZR">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPTAL_64_memop_unpriv" oneofinclass="8" oneof="8" label="64-bit SWPTAL" bitdiffs="sz == 1 &amp;&amp; A == 1 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPTAL-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="SWPTAL"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>SWPTAL  </text><a hover="Is the 64-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="XsOrXZR">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="SWPTL_64_memop_unpriv" oneofinclass="8" oneof="8" label="64-bit SWPTL" bitdiffs="sz == 1 &amp;&amp; A == 0 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="SWPTL-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="SWPTL"/>
        </docvars>
        <box hibit="30" width="1" name="sz">
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>SWPTL  </text><a hover="Is the 64-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field." link="XsOrXZR">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.memop_unpriv.SWPT_32_memop_unpriv" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !IsFeatureImplemented(FEAT_LSUI) then <a link="func_EndOfDecode_1" file="shared_pseudocode.xml">EndOfDecode</a>(<a link="enum_Decode_UNDEF" file="shared_pseudocode.xml">Decode_UNDEF</a>); end;

let s : integer{} = UInt(Rs);
let t : integer{} = UInt(Rt);
let n : integer{} = UInt(Rn);

let datasize : integer{} = 32 &lt;&lt; UInt(sz);
let regsize : integer{} = if datasize == 64 then 64 else 32;
let acquire : boolean = A == '1' &amp;&amp; Rt != '11111';
let release : boolean = R == '1';
let tagchecked : boolean = n != 31;</pstext></ps>
      </ps_section>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="SWPT_32_memop_unpriv, SWPTA_32_memop_unpriv, SWPTAL_32_memop_unpriv, SWPTL_32_memop_unpriv" symboldefcount="1">
      <symbol link="WsOrWZR__2">&lt;Ws&gt;</symbol>
      <account encodedin="Rs">
        <intro>
          <para>Is the 32-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="SWPT_32_memop_unpriv, SWPTA_32_memop_unpriv, SWPTAL_32_memop_unpriv, SWPTL_32_memop_unpriv" symboldefcount="1">
      <symbol link="WtOrWZR__2">&lt;Wt&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="SWPT_32_memop_unpriv, SWPTA_32_memop_unpriv, SWPTAL_32_memop_unpriv, SWPTL_32_memop_unpriv, SWPT_64_memop_unpriv, SWPTA_64_memop_unpriv, SWPTAL_64_memop_unpriv, SWPTL_64_memop_unpriv" symboldefcount="1">
      <symbol link="XnSP_option">&lt;Xn|SP&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="SWPT_64_memop_unpriv, SWPTA_64_memop_unpriv, SWPTAL_64_memop_unpriv, SWPTL_64_memop_unpriv" symboldefcount="1">
      <symbol link="XsOrXZR">&lt;Xs&gt;</symbol>
      <account encodedin="Rs">
        <intro>
          <para>Is the 64-bit name of the general-purpose register to be stored, encoded in the &quot;Rs&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="SWPT_64_memop_unpriv, SWPTA_64_memop_unpriv, SWPTAL_64_memop_unpriv, SWPTL_64_memop_unpriv" symboldefcount="1">
      <symbol link="XtOrXZR__8">&lt;Xt&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <ps_section howmany="1">
    <ps name="A64.ldst.memop_unpriv.SWPT_32_memop_unpriv" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute">var address : bits(64);
var data : bits(datasize);
var store_value : bits(datasize);

let privileged : boolean = <a link="func_AArch64_IsUnprivAccessPriv_0" file="shared_pseudocode.xml">AArch64_IsUnprivAccessPriv</a>();
let accdesc : <a link="type_AccessDescriptor" file="shared_pseudocode.xml">AccessDescriptor</a> = <a link="func_CreateAccDescAtomicOp_7" file="shared_pseudocode.xml">CreateAccDescAtomicOp</a>(<a link="enum_MemAtomicOp_SWP" file="shared_pseudocode.xml">MemAtomicOp_SWP</a>, acquire, release,
                                                       tagchecked, privileged, t, s);

if n == 31 then
    <a link="func_CheckSPAlignment_0" file="shared_pseudocode.xml">CheckSPAlignment</a>();
    address = <a link="accessor_SP_1" file="shared_pseudocode.xml">SP</a>{64}();
else
    address = <a link="accessor_X_2" file="shared_pseudocode.xml">X</a>{64}(n);
end;

store_value = <a link="accessor_X_2" file="shared_pseudocode.xml">X</a>{datasize}(s);

let comparevalue : bits(datasize) = ARBITRARY : bits(datasize); // Irrelevant when not executing CAS
data = <a link="func_MemAtomic_5" file="shared_pseudocode.xml">MemAtomic</a>{datasize}(address, comparevalue, store_value, accdesc);

<a link="accessor_X_2" file="shared_pseudocode.xml">X</a>{regsize}(t) = ZeroExtend{regsize}(data);</pstext></ps>
  </ps_section>
  <timestamp>2026-03-26 20:27:25</timestamp>
  <commit_id>2026-03_rel</commit_id>
</instructionsection>