<?xml version="1.0" encoding="utf-8"?>
<?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-2022 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="addsvl_r_ri" title="ADDSVL" type="instruction">
  <docvars>
    <docvar key="instr-class" value="mortlach" />
    <docvar key="isa" value="A64" />
    <docvar key="mnemonic" value="ADDSVL" />
  </docvars>
  <heading>ADDSVL</heading>
  <desc>
    <brief>Add multiple of Streaming SVE vector register size to scalar register</brief>
    <description>
      <para>Add the Streaming SVE vector register size in bytes multiplied by an immediate in the range -32 to 31 to the 64-bit source general-purpose register or current stack pointer, and place the result in the 64-bit destination general-purpose register or current stack pointer.</para>
      <para>This instruction does not require the PE to be in Streaming SVE mode.</para>
    </description>
    <status>Amber</status>
    <predicated>False</predicated>
    <uses_dit condition="FEAT_SVE2 is implemented or FEAT_SME is implemented">True</uses_dit>
  </desc>
  <alias_list howmany="0"></alias_list>
  <classes>
    <iclass name="SME" oneof="1" id="iclass_mortlach" no_encodings="1" isa="A64">
      <docvars>
        <docvar key="instr-class" value="mortlach" />
        <docvar key="isa" value="A64" />
        <docvar key="mnemonic" value="ADDSVL" />
      </docvars>
      <iclassintro count="1"></iclassintro>
      <arch_variants>
        <arch_variant name="FEAT_SME" feature="FEAT_SME" />
      </arch_variants>
      <regdiagram form="32" psname="ADDSVL-R.RI-_">
        <box hibit="31" width="9" settings="9">
          <c>0</c>
          <c>0</c>
          <c>0</c>
          <c>0</c>
          <c>0</c>
          <c>1</c>
          <c>0</c>
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="22" name="op" settings="1">
          <c>0</c>
        </box>
        <box hibit="21" settings="1">
          <c>1</c>
        </box>
        <box hibit="20" width="5" name="Rn" usename="1">
          <c colspan="5"></c>
        </box>
        <box hibit="15" width="5" settings="5">
          <c>0</c>
          <c>1</c>
          <c>0</c>
          <c>1</c>
          <c>1</c>
        </box>
        <box hibit="10" width="6" name="imm6" usename="1">
          <c colspan="6"></c>
        </box>
        <box hibit="4" width="5" name="Rd" usename="1">
          <c colspan="5"></c>
        </box>
      </regdiagram>
      <encoding name="addsvl_r_ri_" oneofinclass="1" oneof="1" label="">
        <docvars>
          <docvar key="instr-class" value="mortlach" />
          <docvar key="isa" value="A64" />
          <docvar key="mnemonic" value="ADDSVL" />
        </docvars>
        <asmtemplate><text>ADDSVL  </text><a link="sa_xd_sp" hover="64-bit destination general-purpose register or SP (field &quot;Rd&quot;)">&lt;Xd|SP&gt;</a><text>, </text><a link="sa_xn_sp" hover="64-bit source general-purpose register or SP (field &quot;Rn&quot;)">&lt;Xn|SP&gt;</a><text>, #</text><a link="sa_imm" hover="Signed immediate operand [-32-31] (field &quot;imm6&quot;)">&lt;imm&gt;</a></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="ADDSVL-R.RI-_" mylink="ADDSVL-R.RI-_" enclabels="" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !<a link="impl-aarch64.HaveSME.0" file="shared_pseudocode.xml" hover="function: boolean HaveSME()">HaveSME</a>() then UNDEFINED;
integer n = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Rn);
integer d = <a link="impl-shared.UInt.1" file="shared_pseudocode.xml" hover="function: integer UInt(bits(N) x)">UInt</a>(Rd);
integer imm = <a link="impl-shared.SInt.1" file="shared_pseudocode.xml" hover="function: integer SInt(bits(N) x)">SInt</a>(imm6);</pstext>
        </ps>
      </ps_section>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="addsvl_r_ri_" symboldefcount="1">
      <symbol link="sa_xd_sp">&lt;Xd|SP&gt;</symbol>
      <account encodedin="Rd">
        <intro>
          <para>Is the 64-bit name of the destination general-purpose register or stack pointer, encoded in the "Rd" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="addsvl_r_ri_" symboldefcount="1">
      <symbol link="sa_xn_sp">&lt;Xn|SP&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the 64-bit name of the source general-purpose register or stack pointer, encoded in the "Rn" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="addsvl_r_ri_" symboldefcount="1">
      <symbol link="sa_imm">&lt;imm&gt;</symbol>
      <account encodedin="imm6">
        <intro>
          <para>Is the signed immediate operand, in the range -32 to 31, encoded in the "imm6" field.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <ps_section howmany="1">
    <ps name="ADDSVL-R.RI-_" mylink="execute" enclabels="" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute"><a link="impl-aarch64.CheckSMEEnabled.0" file="shared_pseudocode.xml" hover="function: CheckSMEEnabled()">CheckSMEEnabled</a>();
constant integer SVL = <a link="impl-aarch64.CurrentSVL.read.none" file="shared_pseudocode.xml" hover="accessor: integer CurrentSVL">CurrentSVL</a>;
integer len = imm * (SVL DIV 8);
bits(64) operand1 = if n == 31 then <a link="impl-aarch64.SP.read.0" file="shared_pseudocode.xml" hover="accessor: bits(64) SP[]">SP</a>[] else <a link="impl-aarch64.X.read.2" file="shared_pseudocode.xml" hover="accessor: bits(width) X[integer n, integer width]">X</a>[n, 64];
bits(64) result = operand1 + len;

if d == 31 then
    <a link="impl-aarch64.SP.write.0" file="shared_pseudocode.xml" hover="accessor: SP[] = bits(64) value">SP</a>[] = result;
else
    <a link="impl-aarch64.X.write.2" file="shared_pseudocode.xml" hover="accessor: X[integer n, integer width] = bits(width) value">X</a>[d, 64] = result;</pstext>
    </ps>
  </ps_section>
</instructionsection>
