1 # Scalar OpenPOWER Audio and Video Opcodes
3 the fundamental principle of SV is a hardware for-loop. therefore the first (and in nearly 100% of cases only) place to put Vector operations is first and foremost in the *scalar* ISA. However only by analysing those scalar opcodes *in* a SV Vectorisation context does it become clear why they are needed and how they may be designed.
5 This page therefore has acompanying discussion at <https://bugs.libre-soc.org/show_bug.cgi?id=230> for evolution of suitable opcodes.
9 The fundamental principle for these instructions is:
11 * identify the scalar primitive
12 * assume that longer runs of scalars will have Simple-V vectorisatin applied
13 * assume that "swizzle" may be applied at the (vec2 - SUBVL=2) Vector level
15 Thus for example, where OpenPOWER VSX has vpkswss, this would be achieved in SV with simply:
17 * addition of a scalar ext/clamp instruction
18 * 1st op, swizzle-selection vec2 "select X only" from source to dest:
19 dest.X = extclamp(src.X)
20 * 2nd op, swizzle-select vec2 "select Y only" from source to dest
21 dest.Y = extclamp(src.Y)
23 Macro-op fusion may be used to detect that these two interleave cleanly.
33 vpkpx is a 32-bit to 16-bit 8888 into 1555 conversion
37 a single 32-bit to 16-bit operation should suffice, fitting cleanly into one single scalar op:
40 dest[1 : 5] = src[8 :12]
41 dest[6 :10] = src[16:20]
42 dest[11:15] = src[24:28]
46 signed and unsigned, these are N-to-M (N=64/32/16, M=32/16/8) chop/clamp/sign/zero-extend operations
50 these are 16-bit to 32-bit 1555 to 8888 conversion
54 signed and unsigned, 8/16/32: these are all of the form:
56 result = truncate((a + b + 1) >> 1))
60 unsigned 8/16/32: these are all of the form:
62 result = (src1 > src2) ? truncate(src1-src2) :
65 ### vmaxs* / vmaxu* (and min)
67 signed and unsigned, 8/16/32: these are all of the form:
69 result = (src1 > src2) ? src1 : src2 # max
70 result = (src1 < src2) ? src1 : src2 # min