<?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-2025 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="STGP" title="STGP -- A64" type="instruction">
  <docvars>
    <docvar key="atomic-ops" value="STGP-pair-64"/>
    <docvar key="instr-class" value="general"/>
    <docvar key="isa" value="A64"/>
    <docvar key="mnemonic" value="STGP"/>
    <docvar key="offset-type" value="off7s_s"/>
    <docvar key="reg-type" value="pair-64"/>
  </docvars>
  <heading>STGP</heading>
  <desc>
    <brief>
      <para>Store Allocation Tag and pair of registers</para>
    </brief>
    <authored>
      <para>This instruction stores an Allocation Tag and two
64-bit doublewords to memory, from two registers. The address used for the
store is calculated from the base register and an immediate signed offset
scaled by the Tag Granule. The Allocation Tag is calculated from the Logical
Address Tag in the base register.</para>
      <para>This instruction generates an Unchecked access.</para>
    </authored>
  </desc>
  <alias_list howmany="0"/>
  <classes>
    <classesintro count="3">
      <txt>It has encodings from 3 classes:</txt>
      <a href="#iclass_post_index">Post-index</a>
      <txt>, </txt>
      <a href="#iclass_pre_index">Pre-index</a>
      <txt> and </txt>
      <a href="#iclass_signed_offset">Signed offset</a>
    </classesintro>
    <iclass name="Post-index" oneof="3" id="iclass_post_index" no_encodings="1" isa="A64">
      <docvars>
        <docvar key="address-form" value="post-indexed"/>
        <docvar key="address-form-reg-type" value="post-indexed-pair-64"/>
        <docvar key="atomic-ops" value="STGP-pair-64"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="STGP"/>
        <docvar key="offset-type" value="off7s_s"/>
        <docvar key="reg-type" value="pair-64"/>
      </docvars>
      <iclassintro count="1"/>
      <arch_variants>
        <arch_variant feature="FEAT_MTE" name="v8Ap5"/>
      </arch_variants>
      <regdiagram form="32" psname="A64.ldst.ldstpair_post.STGP_64_ldstpair_post" tworows="1">
        <box hibit="31" width="2" name="opc" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="29" width="2" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="27" width="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="26" name="VR" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="25" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="24" width="2" settings="2">
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="22" name="L" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="21" width="7" name="simm7" usename="1">
          <c colspan="7"/>
        </box>
        <box hibit="14" width="5" name="Rt2" usename="1">
          <c colspan="5"/>
        </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="STGP_64_ldstpair_post" oneofinclass="1" oneof="3" label="">
        <docvars>
          <docvar key="address-form" value="post-indexed"/>
          <docvar key="address-form-reg-type" value="post-indexed-pair-64"/>
          <docvar key="atomic-ops" value="STGP-pair-64"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off7s_s"/>
          <docvar key="reg-type" value="pair-64"/>
          <docvar key="mnemonic" value="STGP"/>
        </docvars>
        <asmtemplate><text>STGP  </text><a hover="Is the 64-bit name of the first general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="Xt1OrXZR">&lt;Xt1&gt;</a><text>, </text><a hover="Is the 64-bit name of the second general-purpose register to be transferred, encoded in the &quot;Rt2&quot; field." link="Xt2OrXZR">&lt;Xt2&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><a hover="For the &quot;Post-index&quot; and &quot;Pre-index&quot; variants: is the signed immediate offset, a multiple of 16 in the range -1024 to 1008, encoded in the &quot;simm7&quot; field." link="imm__13">&lt;imm&gt;</a></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.ldstpair_post.STGP_64_ldstpair_post" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !IsFeatureImplemented(FEAT_MTE) then EndOfDecode(Decode_UNDEF); end;
let t : integer{} = UInt(Rt);
let t2 : integer{} = UInt(Rt2);
let n : integer{} = UInt(Rn);
let offset : bits(64) = LSL(SignExtend{64}(simm7), LOG2_TAG_GRANULE);
let writeback : boolean = TRUE;
let postindex : boolean = TRUE;</pstext></ps>
      </ps_section>
    </iclass>
    <iclass name="Pre-index" oneof="3" id="iclass_pre_index" no_encodings="1" isa="A64">
      <docvars>
        <docvar key="address-form" value="pre-indexed"/>
        <docvar key="address-form-reg-type" value="pre-indexed-pair-64"/>
        <docvar key="atomic-ops" value="STGP-pair-64"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="STGP"/>
        <docvar key="offset-type" value="off7s_s"/>
        <docvar key="reg-type" value="pair-64"/>
      </docvars>
      <iclassintro count="1"/>
      <arch_variants>
        <arch_variant feature="FEAT_MTE" name="v8Ap5"/>
      </arch_variants>
      <regdiagram form="32" psname="A64.ldst.ldstpair_pre.STGP_64_ldstpair_pre" tworows="1">
        <box hibit="31" width="2" name="opc" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="29" width="2" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="27" width="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="26" name="VR" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="25" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="24" width="2" settings="2">
          <c>1</c>
          <c>1</c>
        </box>
        <box hibit="22" name="L" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="21" width="7" name="simm7" usename="1">
          <c colspan="7"/>
        </box>
        <box hibit="14" width="5" name="Rt2" usename="1">
          <c colspan="5"/>
        </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="STGP_64_ldstpair_pre" oneofinclass="1" oneof="3" label="">
        <docvars>
          <docvar key="address-form" value="pre-indexed"/>
          <docvar key="address-form-reg-type" value="pre-indexed-pair-64"/>
          <docvar key="atomic-ops" value="STGP-pair-64"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off7s_s"/>
          <docvar key="reg-type" value="pair-64"/>
          <docvar key="mnemonic" value="STGP"/>
        </docvars>
        <asmtemplate><text>STGP  </text><a hover="Is the 64-bit name of the first general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="Xt1OrXZR">&lt;Xt1&gt;</a><text>, </text><a hover="Is the 64-bit name of the second general-purpose register to be transferred, encoded in the &quot;Rt2&quot; field." link="Xt2OrXZR">&lt;Xt2&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><a hover="For the &quot;Post-index&quot; and &quot;Pre-index&quot; variants: is the signed immediate offset, a multiple of 16 in the range -1024 to 1008, encoded in the &quot;simm7&quot; field." link="imm__13">&lt;imm&gt;</a><text>]!</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.ldstpair_pre.STGP_64_ldstpair_pre" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !IsFeatureImplemented(FEAT_MTE) then EndOfDecode(Decode_UNDEF); end;
let t : integer{} = UInt(Rt);
let t2 : integer{} = UInt(Rt2);
let n : integer{} = UInt(Rn);
let offset : bits(64) = LSL(SignExtend{64}(simm7), LOG2_TAG_GRANULE);
let writeback : boolean = TRUE;
let postindex : boolean = FALSE;</pstext></ps>
      </ps_section>
    </iclass>
    <iclass name="Signed offset" oneof="3" id="iclass_signed_offset" no_encodings="1" isa="A64">
      <docvars>
        <docvar key="address-form" value="signed-scaled-offset"/>
        <docvar key="address-form-reg-type" value="signed-scaled-offset-pair-64"/>
        <docvar key="atomic-ops" value="STGP-pair-64"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="STGP"/>
        <docvar key="offset-type" value="off7s_s"/>
        <docvar key="reg-type" value="pair-64"/>
      </docvars>
      <iclassintro count="1"/>
      <arch_variants>
        <arch_variant feature="FEAT_MTE" name="v8Ap5"/>
      </arch_variants>
      <regdiagram form="32" psname="A64.ldst.ldstpair_off.STGP_64_ldstpair_off" tworows="1">
        <box hibit="31" width="2" name="opc" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="29" width="2" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="27" width="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="26" name="VR" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="25" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="24" width="2" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="22" name="L" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="21" width="7" name="simm7" usename="1">
          <c colspan="7"/>
        </box>
        <box hibit="14" width="5" name="Rt2" usename="1">
          <c colspan="5"/>
        </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="STGP_64_ldstpair_off" oneofinclass="1" oneof="3" label="">
        <docvars>
          <docvar key="address-form" value="signed-scaled-offset"/>
          <docvar key="address-form-reg-type" value="signed-scaled-offset-pair-64"/>
          <docvar key="atomic-ops" value="STGP-pair-64"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off7s_s"/>
          <docvar key="reg-type" value="pair-64"/>
          <docvar key="mnemonic" value="STGP"/>
        </docvars>
        <asmtemplate><text>STGP  </text><a hover="Is the 64-bit name of the first general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="Xt1OrXZR">&lt;Xt1&gt;</a><text>, </text><a hover="Is the 64-bit name of the second general-purpose register to be transferred, encoded in the &quot;Rt2&quot; field." link="Xt2OrXZR">&lt;Xt2&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><a hover="For the &quot;Signed offset&quot; variant: is the optional signed immediate offset, a multiple of 16 in the range -1024 to 1008, defaulting to 0 and encoded in the &quot;simm7&quot; field." link="imm__8">&lt;imm&gt;</a><text>}]</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.ldstpair_off.STGP_64_ldstpair_off" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !IsFeatureImplemented(FEAT_MTE) then EndOfDecode(Decode_UNDEF); end;
let t : integer{} = UInt(Rt);
let t2 : integer{} = UInt(Rt2);
let n : integer{} = UInt(Rn);
let offset : bits(64) = LSL(SignExtend{64}(simm7), LOG2_TAG_GRANULE);
let writeback : boolean = FALSE;
let postindex : boolean = FALSE;</pstext></ps>
      </ps_section>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="STGP_64_ldstpair_post, STGP_64_ldstpair_pre, STGP_64_ldstpair_off" symboldefcount="1">
      <symbol link="Xt1OrXZR">&lt;Xt1&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 64-bit name of the first general-purpose register to be transferred, encoded in the "Rt" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="STGP_64_ldstpair_post, STGP_64_ldstpair_pre, STGP_64_ldstpair_off" symboldefcount="1">
      <symbol link="Xt2OrXZR">&lt;Xt2&gt;</symbol>
      <account encodedin="Rt2">
        <intro>
          <para>Is the 64-bit name of the second general-purpose register to be transferred, encoded in the "Rt2" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="STGP_64_ldstpair_post, STGP_64_ldstpair_pre, STGP_64_ldstpair_off" 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 "Rn" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="STGP_64_ldstpair_post, STGP_64_ldstpair_pre" symboldefcount="1">
      <symbol link="imm__13">&lt;imm&gt;</symbol>
      <account encodedin="simm7">
        <intro>
          <para>For the "Post-index" and "Pre-index" variants: is the signed immediate offset, a multiple of 16 in the range -1024 to 1008, encoded in the "simm7" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="STGP_64_ldstpair_off" symboldefcount="2">
      <symbol link="imm__8">&lt;imm&gt;</symbol>
      <account encodedin="simm7">
        <intro>
          <para>For the "Signed offset" variant: is the optional signed immediate offset, a multiple of 16 in the range -1024 to 1008, defaulting to 0 and encoded in the "simm7" field.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <ps_section howmany="1">
    <ps name="A64.ldst.ldstpair_post.STGP_64_ldstpair_post" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute">var address : bits(64);

if n == 31 then
    CheckSPAlignment();
    address = SP{64}();
else
    address = X{64}(n);
end;

let stzgm : boolean = FALSE;
let ispair : boolean = TRUE;
let accdesc : AccessDescriptor = CreateAccDescLDGSTG(MemOp_STORE, stzgm, ispair, t, t2);

if !postindex then
    address = AddressAdd(address, offset, accdesc);
end;

if !IsAlignedSize(address, TAG_GRANULE) then
    let fault : FaultRecord = AlignmentFault(accdesc, address);
    AArch64_Abort(fault);
end;

let data : bits(128) = (if BigEndian(accdesc.acctype) then X{64}(t) ::X{64}(t2)
                                                      else X{64}(t2)::X{64}(t));
Mem{128}(address, accdesc) = data;

AArch64_MemTag(address, accdesc) = AArch64_AllocationTagFromAddress(address);

if writeback then
    if postindex then
        address = AddressAdd(address, offset, accdesc);
    end;

    if n == 31 then
        SP{64}() = address;
    else
        X{64}(n) = address;
    end;
end;</pstext></ps>
  </ps_section>
  <timestamp>2026-03-12 12:23:09</timestamp>
  <commit_id>2025-09_rel_asl1</commit_id>
</instructionsection>
