<?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="TBL_advsimd" title="TBL -- A64" type="instruction">
  <docvars>
    <docvar key="instr-class" value="advsimd"/>
    <docvar key="isa" value="A64"/>
    <docvar key="mnemonic" value="TBL"/>
  </docvars>
  <heading>TBL</heading>
  <desc>
    <brief>
      <para>Table vector lookup</para>
    </brief>
    <authored>
      <para>This instruction reads each value from the vector elements in the index source SIMD&amp;FP register,
uses each result as an index to perform a lookup in a table of bytes that
is described by one to four source table SIMD&amp;FP registers,
places the lookup result in a vector, and writes
the vector to the destination SIMD&amp;FP register.
If an index is out of range for the table, the result for that lookup is 0.
If more than one source register is used to describe the table,
the first source register describes the lowest bytes of the table.</para>
      <para>Depending on the settings in the <register_link id="AArch64-cpacr_el1.xml" state="AArch64">CPACR_EL1</register_link>,
  <register_link id="AArch64-cptr_el2.xml" state="AArch64">CPTR_EL2</register_link>, and <register_link id="AArch64-cptr_el3.xml" state="AArch64">CPTR_EL3</register_link> registers,
  and the current Security state and Exception level,
  an attempt to execute the instruction might be trapped.</para>
    </authored>
  </desc>
  <operationalnotes>
    <operationalnote>
      <operationalnote_content>
        <para>This instruction is a data-independent-time instruction as described in <xref linkend="ARMARM_BEICCDDAB3">About PSTATE.DIT</xref>.</para>
      </operationalnote_content>
    </operationalnote>
  </operationalnotes>
  <alias_list howmany="0"/>
  <classes>
    <iclass name="Advanced SIMD" oneof="1" id="iclass_advanced_simd" no_encodings="4" isa="A64">
      <docvars>
        <docvar key="instr-class" value="advsimd"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="TBL"/>
      </docvars>
      <iclassintro count="4"/>
      <arch_variants>
        <arch_variant feature="FEAT_AdvSIMD" name="v8Ap0"/>
      </arch_variants>
      <regdiagram form="32" psname="A64.simd_dp.asimdtbl.TBL_asimdtbl_L1_1" tworows="1">
        <box hibit="31" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="30" width="1" name="Q" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="29" width="6" settings="6">
          <c>0</c>
          <c>0</c>
          <c>1</c>
          <c>1</c>
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="23" width="2" name="op2" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="21" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="20" width="5" name="Rm" usename="1">
          <c colspan="5"/>
        </box>
        <box hibit="15" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="14" width="2" name="len" usename="1">
          <c colspan="2"/>
        </box>
        <box hibit="12" name="op" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="11" width="2" settings="2">
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="9" width="5" name="Rn" usename="1">
          <c colspan="5"/>
        </box>
        <box hibit="4" width="5" name="Rd" usename="1">
          <c colspan="5"/>
        </box>
      </regdiagram>
      <encoding name="TBL_asimdtbl_L1_1" oneofinclass="4" oneof="4" label="Single register table" bitdiffs="len == 00">
        <docvars>
          <docvar key="instr-class" value="advsimd"/>
          <docvar key="isa" value="A64"/>
          <docvar key="no-reg-for-table" value="tbl1"/>
          <docvar key="mnemonic" value="TBL"/>
        </docvars>
        <box hibit="14" width="2" name="len">
          <c>0</c>
          <c>0</c>
        </box>
        <asmtemplate><text>TBL  </text><a hover="Is the name of the SIMD&amp;FP destination register, encoded in the &quot;Rd&quot; field." link="Vd">&lt;Vd&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a><text>, { </text><a hover="For the &quot;Single register table&quot; variant: is the name of the SIMD&amp;FP table register, encoded in the &quot;Rn&quot; field." link="Vn__3">&lt;Vn&gt;</a><text>.16B }, </text><a hover="Is the name of the SIMD&amp;FP index register, encoded in the &quot;Rm&quot; field." link="Vm__3">&lt;Vm&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a></asmtemplate>
      </encoding>
      <encoding name="TBL_asimdtbl_L2_2" oneofinclass="4" oneof="4" label="Two register table" bitdiffs="len == 01">
        <docvars>
          <docvar key="instr-class" value="advsimd"/>
          <docvar key="isa" value="A64"/>
          <docvar key="no-reg-for-table" value="tbl2"/>
          <docvar key="mnemonic" value="TBL"/>
        </docvars>
        <box hibit="14" width="2" name="len">
          <c>0</c>
          <c>1</c>
        </box>
        <asmtemplate><text>TBL  </text><a hover="Is the name of the SIMD&amp;FP destination register, encoded in the &quot;Rd&quot; field." link="Vd">&lt;Vd&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a><text>, { </text><a hover="For the &quot;Four register table&quot;, &quot;Three register table&quot;, and &quot;Two register table&quot; variants: is the name of the first SIMD&amp;FP table register, encoded in the &quot;Rn&quot; field." link="Vn__4">&lt;Vn&gt;</a><text>.16B, </text><a hover="Is the name of the second SIMD&amp;FP table register, encoded as &quot;Rn&quot; plus 1 modulo 32." link="VnPlus1">&lt;Vn+1&gt;</a><text>.16B }, </text><a hover="Is the name of the SIMD&amp;FP index register, encoded in the &quot;Rm&quot; field." link="Vm__3">&lt;Vm&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a></asmtemplate>
      </encoding>
      <encoding name="TBL_asimdtbl_L3_3" oneofinclass="4" oneof="4" label="Three register table" bitdiffs="len == 10">
        <docvars>
          <docvar key="instr-class" value="advsimd"/>
          <docvar key="isa" value="A64"/>
          <docvar key="no-reg-for-table" value="tbl3"/>
          <docvar key="mnemonic" value="TBL"/>
        </docvars>
        <box hibit="14" width="2" name="len">
          <c>1</c>
          <c>0</c>
        </box>
        <asmtemplate><text>TBL  </text><a hover="Is the name of the SIMD&amp;FP destination register, encoded in the &quot;Rd&quot; field." link="Vd">&lt;Vd&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a><text>, { </text><a hover="For the &quot;Four register table&quot;, &quot;Three register table&quot;, and &quot;Two register table&quot; variants: is the name of the first SIMD&amp;FP table register, encoded in the &quot;Rn&quot; field." link="Vn__4">&lt;Vn&gt;</a><text>.16B, </text><a hover="Is the name of the second SIMD&amp;FP table register, encoded as &quot;Rn&quot; plus 1 modulo 32." link="VnPlus1">&lt;Vn+1&gt;</a><text>.16B, </text><a hover="Is the name of the third SIMD&amp;FP table register, encoded as &quot;Rn&quot; plus 2 modulo 32." link="VnPlus2">&lt;Vn+2&gt;</a><text>.16B }, </text><a hover="Is the name of the SIMD&amp;FP index register, encoded in the &quot;Rm&quot; field." link="Vm__3">&lt;Vm&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a></asmtemplate>
      </encoding>
      <encoding name="TBL_asimdtbl_L4_4" oneofinclass="4" oneof="4" label="Four register table" bitdiffs="len == 11">
        <docvars>
          <docvar key="instr-class" value="advsimd"/>
          <docvar key="isa" value="A64"/>
          <docvar key="no-reg-for-table" value="tbl4"/>
          <docvar key="mnemonic" value="TBL"/>
        </docvars>
        <box hibit="14" width="2" name="len">
          <c>1</c>
          <c>1</c>
        </box>
        <asmtemplate><text>TBL  </text><a hover="Is the name of the SIMD&amp;FP destination register, encoded in the &quot;Rd&quot; field." link="Vd">&lt;Vd&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a><text>, { </text><a hover="For the &quot;Four register table&quot;, &quot;Three register table&quot;, and &quot;Two register table&quot; variants: is the name of the first SIMD&amp;FP table register, encoded in the &quot;Rn&quot; field." link="Vn__4">&lt;Vn&gt;</a><text>.16B, </text><a hover="Is the name of the second SIMD&amp;FP table register, encoded as &quot;Rn&quot; plus 1 modulo 32." link="VnPlus1">&lt;Vn+1&gt;</a><text>.16B, </text><a hover="Is the name of the third SIMD&amp;FP table register, encoded as &quot;Rn&quot; plus 2 modulo 32." link="VnPlus2">&lt;Vn+2&gt;</a><text>.16B, </text><a hover="Is the name of the fourth SIMD&amp;FP table register, encoded as &quot;Rn&quot; plus 3 modulo 32." link="VnPlus3">&lt;Vn+3&gt;</a><text>.16B }, </text><a hover="Is the name of the SIMD&amp;FP index register, encoded in the &quot;Rm&quot; field." link="Vm__3">&lt;Vm&gt;</a><text>.</text><a hover="Is an arrangement specifier, " link="Ta_option__2">&lt;Ta&gt;</a></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.simd_dp.asimdtbl.TBL_asimdtbl_L1_1" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !IsFeatureImplemented(FEAT_AdvSIMD) then EndOfDecode(Decode_UNDEF); end;
let d : integer = UInt(Rd);
let n : integer = UInt(Rn);
let m : integer = UInt(Rm);

let datasize : integer{} = 64 &lt;&lt; UInt(Q);
let elements : integer = datasize DIV 8;
let regs : integer{} = UInt(len) + 1;
let is_tbl : boolean = (op == '0');</pstext></ps>
      </ps_section>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="TBL_asimdtbl_L1_1, TBL_asimdtbl_L2_2, TBL_asimdtbl_L3_3, TBL_asimdtbl_L4_4" symboldefcount="1">
      <symbol link="Vd">&lt;Vd&gt;</symbol>
      <account encodedin="Rd">
        <intro>
          <para>Is the name of the SIMD&amp;FP destination register, encoded in the "Rd" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L1_1, TBL_asimdtbl_L2_2, TBL_asimdtbl_L3_3, TBL_asimdtbl_L4_4" symboldefcount="1">
      <symbol link="Ta_option__2">&lt;Ta&gt;</symbol>
      <definition encodedin="Q">
        <intro>Is an arrangement specifier, </intro>
        <table class="valuetable">
          <tgroup cols="2">
            <thead>
              <row>
                <entry class="bitfield">Q</entry>
                <entry class="symbol">&lt;Ta&gt;</entry>
              </row>
            </thead>
            <tbody>
              <row>
                <entry class="bitfield">0</entry>
                <entry class="symbol">8B</entry>
              </row>
              <row>
                <entry class="bitfield">1</entry>
                <entry class="symbol">16B</entry>
              </row>
            </tbody>
          </tgroup>
        </table>
      </definition>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L1_1" symboldefcount="1">
      <symbol link="Vn__3">&lt;Vn&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>For the "Single register table" variant: is the name of the SIMD&amp;FP table register, encoded in the "Rn" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L2_2, TBL_asimdtbl_L3_3, TBL_asimdtbl_L4_4" symboldefcount="2">
      <symbol link="Vn__4">&lt;Vn&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>For the "Four register table", "Three register table", and "Two register table" variants: is the name of the first SIMD&amp;FP table register, encoded in the "Rn" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L1_1, TBL_asimdtbl_L2_2, TBL_asimdtbl_L3_3, TBL_asimdtbl_L4_4" symboldefcount="1">
      <symbol link="Vm__3">&lt;Vm&gt;</symbol>
      <account encodedin="Rm">
        <intro>
          <para>Is the name of the SIMD&amp;FP index register, encoded in the "Rm" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L2_2, TBL_asimdtbl_L3_3, TBL_asimdtbl_L4_4" symboldefcount="1">
      <symbol link="VnPlus1">&lt;Vn+1&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the name of the second SIMD&amp;FP table register, encoded as "Rn" plus 1 modulo 32.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L3_3, TBL_asimdtbl_L4_4" symboldefcount="1">
      <symbol link="VnPlus2">&lt;Vn+2&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the name of the third SIMD&amp;FP table register, encoded as "Rn" plus 2 modulo 32.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="TBL_asimdtbl_L4_4" symboldefcount="1">
      <symbol link="VnPlus3">&lt;Vn+3&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the name of the fourth SIMD&amp;FP table register, encoded as "Rn" plus 3 modulo 32.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <ps_section howmany="1">
    <ps name="A64.simd_dp.asimdtbl.TBL_asimdtbl_L1_1" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute">AArch64_CheckFPAdvSIMDEnabled();
let indices : bits(datasize) = V{}(m);
var table : bits(128*regs) = Zeros{};
var result : bits(datasize);
var index : integer;

// Create table from registers
for i = 0 to regs - 1 do
    table[i*:128] = V{128}((n+i) MOD 32);
end;

result = if is_tbl then Zeros{datasize} else V{datasize}(d);
for i = 0 to elements - 1 do
    index = UInt(indices[i*:8]);
    if index &lt; 16 * regs then
        result[i*:8] = table[index*:8];
    end;
end;

V{datasize}(d) = result;</pstext></ps>
  </ps_section>
  <timestamp>2026-03-12 12:23:09</timestamp>
  <commit_id>2025-09_rel_asl1</commit_id>
</instructionsection>
