Skip to content

Instantly share code, notes, and snippets.

@auroranockert
Created April 9, 2012 18:34
Show Gist options
  • Save auroranockert/2345303 to your computer and use it in GitHub Desktop.
Save auroranockert/2345303 to your computer and use it in GitHub Desktop.
Hydrazine ISA
Hydrazine ISA
Hydrazine is a register-less, three-operand virtual machine for browsers.
All instructions are available in SIMD widths of 1, 2, 4, 8, 16 and 32.
Operands are passed as a typed array view and an index into that array, all operands need to be of the same type (unless noted) and need to have natural alignment (but needs at most 16 byte alignment, since that is what AVX needs).
Immediates are converted to the type of the other operands.
Datatypes
Int{8,16,32,64}
Uint{8,16,32,64}
Float{32,64,(128)}
(Complex{32,64,(128)})
Arithmetic (All types)
add, sub, (addsub, subadd)
mul, (mul.low, mul.high)
div
sqrt
max, min
add.us, sub.us, mul.us, (div.us, fmadd.us, fmsub.us) [Unsigned Saturation]
add.ss, sub.ss, mul.ss, (div.ss, fmadd.ss, fmsub.ss) [Signed Saturation]
madd, msub, nmadd, nmsub
fmadd, fmsub, fnmadd, fnmsub, (fmaddsub, fmsubadd, fnmaddsub, fnmsubadd)
Bit (All types)
and
nand
or
xor
not
sll, srl [Logical Shifts]
sla, sra [Arithmetic Shifts]
rotl, rotr [Rotations]
popcount, clz, clo [Bitcounts]
byteswap
Comparison (Real types) [Returns an immediate value]
all.le, all.lt, all.gt, all.ge
all.eq. all.neq
all.ordered, all.unordered
any.le, any.lt, any.gt, any.ge
any.eq. any.neq
any.ordered, any.unordered
Load/Store/Convert (All types)
gather (r, ri, a, ai, b, bi) [b is always Uint32, r[ri + i] = a[ai + i + b[bi + i]]]
convert [r, ri, a, ai, have relaxed type requirements, r[ri + i] = cast(a[ai + i])]
broadcast (r, ri, imm) [r[ri + i] = imm]
shuffle (r, ri, a, ai, imm0 - immn) [r[ri + i] = a[ai + imm[i]]]
align (r, ri, a, ai, b, bi, imm) [r[ri + i] = (a[ai + i] << n * sizeof(a) + b[bi + i]) >> imm]
And possibly some immediate versions of that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment