ISARef Multi-ISA & Silicon Reference
45,419 ISA items · 105,907 timings · 913 microarchs · 15,555 chips · 105 sources
Arch:
Tier:

AMX SETCLR

T3 apple-silicon matrix insn
Apple AMX: setclr
SourceApple AMX Matrix Coprocessor Specification (corsix/amx) (apple_corsix_amx)
Reliability TierT3 — Hardware-Verified
ISA / Silicon ScopeApple Silicon M1–M4 (AMX)
Apple M1 / M2 / M3 / M4 (A13+)
License & VersionMIT
main
Upstreamhttps://github.com/corsix/amx
Privilegeuser
Note: Undocumented Apple matrix coprocessor specification verified on M1–M4 hardware.

Summary

Before any other AMX instructions can be used, set must be issued. At some point later, clr must be issued. The pair of instructions are _not_ re-entrant: set will raise an invalid instruction exception if AMX is already enabled for the issuing thread. The implied ABI for public functions is therefore: AMX will be disabled on entry, and if enabled within the function, must be disabled again before returning.

Syntax / Encoding

AMX setclr Xn (0x002010e0 | Rn)

Binary Encodings (1)

WidthFormatBit PatternMask / Match
32A64.AMX000000000010000000010000111xxxxx0xffffffe0 / 0x002010e0

Operands

NameDescription
Xn64-bit packed operand descriptor (0 bitfields)

Reference Notes

## Quick summary

|Instruction|General theme|Notes|
|---|---|---|
|`set`|Setup AMX state|Raises invalid instruction exception if already setup. All registers set to zero.|
|`clr`|Clear AMX state|All registers set to uninitialised, no longer need saving/restoring on context switch.|

## Instruction encoding

|Bit|Width|Meaning|Notes|
|---:|---:|---|---|
|10|22|[A64 reserved instruction](aarch64.md)|Must be `0x201000 >> 10`|
|5|5|Instruction|Must be `17`|
|0|5|5-bit immediate|`0` for `set`<br/>`1` for `clr`|

## Description

Before any other AMX instructions can be used, `set` must be issued. At some point later, `clr` must be issued. The pair of instructions are _not_ re-entrant: `set` will raise an invalid instruction exception if AMX is already enabled for the issuing thread. The implied ABI for public functions is therefore: AMX will be disabled on entry, and if enabled within the function, must be disabled again before returning.

As a side-effect of `set`, all X and Y and Z registers are set to zero. If the goal is merely setting Z to zero, then various computational instructions can be used instead, for example [`fma16`](fma.md) with bits 27=1, 28=1, 29=1, 62=1. Alternatively, some computational instructions that accumulate onto Z can be configured to read Z as zero (bit 27 to [`fma16`](fma.md) / [`fma32`](fma.md) / [`fma64`](fma.md) / [`fms16`](fms.md) / [`fms32`](fms.md) / [`fms64`](fms.md) / [`mac16`](mac16.md)).

## Emulation code

Do not require emulation