feat(arch): add the {1toN} broadcast to the packed amd64 memory sources

Assisted-by: GLM 5.3 Flash
This commit is contained in:
petrbalvin committed 2026-10-07 02:06:11 +02:00
1 parent 9c1392dfc3
commit ccb155437e
4 files changed
+218 -32

No files matched your search

+20
View File
@@ -170,6 +170,11 @@ type ExtOperand struct {
// operand (the encoder may derive the sh bit from the value).
Shift int
HasShift bool
// Broadcast spells the {1toN} broadcast on an amd64 memory operand: the
// base-relative location holds one element the hardware splats across
// every lane of the destination, which the encoder lays down as EVEX.b.
// Only the memory positions of the entries that carry Bcast accept it.
Broadcast bool
}
// ExtVector builds a scalable vector operand, ADD Z1.S style.
@@ -200,6 +205,14 @@ func ExtMemory(base int, disp int64) ExtOperand {
return ExtOperand{Kind: ExtMem, Reg: base, Imm: disp}
}
// ExtBroadcast builds the {1toN} broadcast spelling of a base-relative memory
// operand, the amd64 packed forms' m16bcst shape: the base is a 64-bit general
// register number, 0..15, the displacement keeps the plain ModR/M semantics,
// and the encoder sets EVEX.b so the single element splats across the lanes.
func ExtBroadcast(base int, disp int64) ExtOperand {
return ExtOperand{Kind: ExtMem, Reg: base, Imm: disp, Broadcast: true}
}
// ExtField is one named field of the 32-bit encoding word: a bit offset from
// the least significant end and the field's width.
type ExtField struct {
@@ -467,6 +480,13 @@ type ExtInstr struct {
// of their own, ExtFormAmdMemVec and ExtFormAmdVecMem, and need no
// flag. The arm64 entries all carry the zero value.
Mem int
// Bcast records that the entry's memory position takes the {1toN}
// broadcast beside the plain vector source, the SDM's m16bcst and
// m32bcst spellings: one element the hardware splats across the lanes,
// encoded as EVEX.b. The packed arithmetic carries it; the scalar
// forms and the full-width sources do not. The arm64 entries all
// carry the zero value.
Bcast bool
}
// Encode assembles the operands into the 4 little-endian bytes of the