Orc Opcodes: Orc Reference Manual

## Orc Opcodes Orc Opcodes — Description of Opcodes |

## Orc Opcodes

Opcodes only work with variables of a particular size. In the table below, destination and source indicate the size of the destination and source operands, in bytes. In general, opcodes have a suffix indicating the sizes, "b" for 1-byte operations, "w" for 2-byte operations, and "l" for 4-byte operations. If the source and destination have different sizes, the source size suffix is listed first, then the destination suffix. For example, converting a 1-byte variable to 2-byte can be performed using the "convsbw" opcode.

Signed, unsigned, and saturating operations are indicated by the letters "s", "u", and "s". If signed or unsigned is not indicated, it generally means that the signedness is not relevant to the definition of the opcode, and that the operation on signed or unsigned values will give the same result.

The "select" opcodes divide the bits in the source value into two halves. For "select0", the half that is first in memory order is selected, and the latter half for "select1". In other words, "convwb" is the same as "select0wb" on little-endian systems, and "select1wb" on big-endian systems.

The "merge" opcodes take two values and put them together in memory order.

Accumulating opcodes require an accumulator variable as the destination. Accumulating opcodes start with "acc". These opcodes sum the source values over the entire array, and can be read from the OrcExecutor structure after an execution of an Orc program.

Shift opcodes only work with constants or parameters as the second source value.

For more precise understanding of operations, it is recommended to compile a program for the C target and examine the resulting C source code.

Table 1. Table of Opcodes

opcode | destination size | source 1 size | source 2 size | description | pseudo code
--- | --- | --- | --- | --- | ---
absb | 1 | 1 |  | absolute value | (a < 0) ? -a : a
addb | 1 | 1 | 1 | add | a + b
addssb | 1 | 1 | 1 | add with signed saturate | clamp(a + b)
addusb | 1 | 1 | 1 | add with unsigned saturate | clamp(a + b)
andb | 1 | 1 | 1 | bitwise AND | a & b
andnb | 1 | 1 | 1 | bitwise AND NOT | a & (~b)
avgsb | 1 | 1 | 1 | signed average | (a + b + 1)>>1
avgub | 1 | 1 | 1 | unsigned average | (a + b + 1)>>1
cmpeqb | 1 | 1 | 1 | compare equal | (a == b) ? (~0) : 0
cmpgtsb | 1 | 1 | 1 | compare greater than | (a > b) ? (~0) : 0
copyb | 1 | 1 |  | copy | a
loadb | 1 | 1 |  | load from memory | array[i]
loadoffb | 1 | 1 | 4S | load from memory with offset | array[i+offset]
loadupdb | 1 | 1 |  | load upsampled duplicate | array[i>>1]
loadupib | 1 | 1 |  | load upsampled interpolate | (array[i>>1] + array[(i+1)>>1] + 1)>>1
loadpb | 1 | 1 |  | load parameter or constant | scalar
ldresnearb | 1 | 1 | 4S | load, nearest neighbor resampled | array[(b+c*i)>>8]
ldresnearl | 4 | 4 | 4S | load, nearest neighbor resampled | array[(b+c*i)>>8]
ldreslinb | 1 | 1 | 4S | load, bilinear resampled | special
ldreslinl | 4 | 4 | 4S | load, bilinear resampled | special
maxsb | 1 | 1 | 1 | signed maximum | (a > b) ? a : b
maxub | 1 | 1 | 1 | unsigned maximum | (a > b) ? a : b
minsb | 1 | 1 | 1 | signed minimum | (a < b) ? a : b
minub | 1 | 1 | 1 | unsigned minimum | (a < b) ? a : b
mullb | 1 | 1 | 1 | low bits of multiply | a * b
mulhsb | 1 | 1 | 1 | high bits of signed multiply | (a * b) >> 8
mulhub | 1 | 1 | 1 | high bits of unsigned multiply | (a * b) >> 8
orb | 1 | 1 | 1 | bitwise or | a | b
shlb | 1 | 1 | 1S | shift left | a << b
shrsb | 1 | 1 | 1S | signed shift right | a >> b
shrub | 1 | 1 | 1S | unsigned shift right | a >> b
signb | 1 | 1 |  | sign | sign(a)
storeb | 1 | 1 |  | store to memory | special
subb | 1 | 1 | 1 | subtract | a - b
subssb | 1 | 1 | 1 | subtract with signed saturate | clamp(a - b)
subusb | 1 | 1 | 1 | subtract with unsigned saturate | clamp(a - b)
xorb | 1 | 1 | 1 | bitwise XOR | a ^ b
absw | 2 | 2 |  | absolute value | (a < 0) ? -a : a
addw | 2 | 2 | 2 | add | a + b
addssw | 2 | 2 | 2 | add with signed saturate | clamp(a + b)
addusw | 2 | 2 | 2 | add with unsigned saturate | clamp(a + b)
andw | 2 | 2 | 2 | bitwise AND | a & b
andnw | 2 | 2 | 2 | bitwise AND NOT | a & (~b)
avgsw | 2 | 2 | 2 | signed average | (a + b + 1)>>1
avguw | 2 | 2 | 2 | unsigned average | (a + b + 1)>>1
cmpeqw | 2 | 2 | 2 | compare equal | (a == b) ? (~0) : 0
cmpgtsw | 2 | 2 | 2 | compare greater than | (a > b) ? (~0) : 0
copyw | 2 | 2 |  | copy | a
div255w | 2 | 2 |  | divide by 255 | a/255
divluw | 2 | 2 | 2 | saturated unsigned divide 16-bit by 8-bit | clamp(a/(b & 255),0,255)
loadw | 2 | 2 |  | load from memory | array[i]
loadoffw | 2 | 2 | 4S | load from memory with offset | array[i+offset]
loadpw | 2 | 2 |  | load parameter or constant | scalar
maxsw | 2 | 2 | 2 | signed maximum | (a > b) ? a : b
maxuw | 2 | 2 | 2 | unsigned maximum | (a > b) ? a : b
minsw | 2 | 2 | 2 | signed minimum | (a < b) ? a : b
minuw | 2 | 2 | 2 | unsigned minimum | (a < b) ? a : b
mullw | 2 | 2 | 2 | low bits of multiply | a * b
mulhsw | 2 | 2 | 2 | high bits of signed multiply | (a * b) >> 8
mulhuw | 2 | 2 | 2 | high bits of unsigned multiply | (a * b) >> 8
orw | 2 | 2 | 2 | bitwise or | a | b
shlw | 2 | 2 | 2S | shift left | a << b
shrsw | 2 | 2 | 2S | signed shift right | a >> b
shruw | 2 | 2 | 2S | unsigned shift right | a >> b
signw | 2 | 2 |  | sign | sign(a)
storew | 2 | 2 |  | store to memory | special
subw | 2 | 2 | 2 | subtract | a - b
subssw | 2 | 2 | 2 | subtract with signed saturate | clamp(a - b)
subusw | 2 | 2 | 2 | subtract with unsigned saturate | clamp(a - b)
xorw | 2 | 2 | 2 | bitwise XOR | a ^ b
absl | 4 | 4 |  | absolute value | (a < 0) ? -a : a
addl | 4 | 4 | 4 | add | a + b
addssl | 4 | 4 | 4 | add with signed saturate | clamp(a + b)
addusl | 4 | 4 | 4 | add with unsigned saturate | clamp(a + b)
andl | 4 | 4 | 4 | bitwise AND | a & b
andnl | 4 | 4 | 4 | bitwise AND NOT | a & (~b)
avgsl | 4 | 4 | 4 | signed average | (a + b + 1)>>1
avgul | 4 | 4 | 4 | unsigned average | (a + b + 1)>>1
cmpeql | 4 | 4 | 4 | compare equal | (a == b) ? (~0) : 0
cmpgtsl | 4 | 4 | 4 | compare greater than | (a > b) ? (~0) : 0
copyl | 4 | 4 |  | copy | a
loadl | 4 | 4 |  | load from memory | array[i]
loadoffl | 4 | 4 | 4S | load from memory with offset | array[i+offset]
loadpl | 4 | 4 |  | load parameter or constant | scalar
maxsl | 4 | 4 | 4 | signed maximum | (a > b) ? a : b
maxul | 4 | 4 | 4 | unsigned maximum | (a > b) ? a : b
minsl | 4 | 4 | 4 | signed minimum | (a < b) ? a : b
minul | 4 | 4 | 4 | unsigned minimum | (a < b) ? a : b
mulll | 4 | 4 | 4 | low bits of multiply | a * b
mulhsl | 4 | 4 | 4 | high bits of signed multiply | (a * b) >> 16
mulhul | 4 | 4 | 4 | high bits of unsigned multiply | (a * b) >> 16
orl | 4 | 4 | 4 | bitwise or | a | b
shll | 4 | 4 | 4S | shift left | a << b
shrsl | 4 | 4 | 4S | signed shift right | a >> b
shrul | 4 | 4 | 4S | unsigned shift right | a >> b
signl | 4 | 4 |  | sign | sign(a)
storel | 4 | 4 |  | store to memory | special
subl | 4 | 4 | 4 | subtract | a - b
subssl | 4 | 4 | 4 | subtract with signed saturate | clamp(a - b)
subusl | 4 | 4 | 4 | subtract with unsigned saturate | clamp(a - b)
xorl | 4 | 4 | 4 | bitwise XOR | a ^ b
loadq | 8 | 8 |  | load from memory | array[i]
loadpq | 8 | 8 |  | load parameter or constant | scalar
storeq | 8 | 8 |  | store to memory | special
splatw3q | 8 | 8 |  | duplicates high 16-bits to lower 48 bits | special
copyq | 8 | 8 |  |  |
cmpeqq | 8 | 8 | 8 |  |
cmpgtsq | 8 | 8 | 8 |  |
andq | 8 | 8 | 8 |  |
andnq | 8 | 8 | 8 |  |
orq | 8 | 8 | 8 |  |
xorq | 8 | 8 | 8 |  |
addq | 8 | 8 | 8 |  |
subq | 8 | 8 | 8 |  |
shlq | 8 | 8 | 8S |  |
shrsq | 8 | 8 | 8S |  |
shruq | 8 | 8 | 8S |  |
convsbw | 2 | 1 |  | convert signed | a
convubw | 2 | 1 |  | convert unsigned | a
splatbw | 2 | 1 |  | duplicates 8 bits to both halfs of 16 bits | special
splatbl | 4 | 1 |  | duplicates 8 bits to all parts of 32 bits | special
convswl | 4 | 2 |  | convert signed | a
convuwl | 4 | 2 |  | convert unsigned | a
convslq | 8 | 4 |  | signed convert | a
convulq | 8 | 4 |  | unsigned convert | a
convwb | 1 | 2 |  | convert | a
convhwb | 1 | 2 |  | shift and convert | a>>8
convssswb | 1 | 2 |  | convert signed to signed with saturation | clamp(a)
convsuswb | 1 | 2 |  | convert signed to unsigned with saturation | clamp(a)
convusswb | 1 | 2 |  | convert unsigned to signed with saturation | clamp(a)
convuuswb | 1 | 2 |  | convert unsigned to unsigned with saturation | clamp(a)
convlw | 2 | 4 |  | convert | a
convhlw | 2 | 4 |  | shift and convert | a>>16
convssslw | 2 | 4 |  | convert signed to signed with saturation | clamp(a)
convsuslw | 2 | 4 |  | convert signed to unsigned with saturation | clamp(a)
convusslw | 2 | 4 |  | convert unsigned to signed with saturation | clamp(a)
convuuslw | 2 | 4 |  | convert unsigned to unsigned with saturation | clamp(a)
convql | 4 | 8 |  | convert | a
convsssql | 4 | 8 |  | convert signed to signed with saturation | clamp(a)
convsusql | 4 | 8 |  | convert signed to unsigned with saturation | clamp(a)
convussql | 4 | 8 |  | convert unsigned to signed with saturation | clamp(a)
convuusql | 4 | 8 |  | convert unsigned to unsigned with saturation | clamp(a)
mulsbw | 2 | 1 | 1 | multiply signed | a * b
mulubw | 2 | 1 | 1 | multiply unsigned | a * b
mulswl | 4 | 2 | 2 | multiply signed | a * b
muluwl | 4 | 2 | 2 | multiply unsigned | a * b
mulslq | 8 | 4 | 4 |  |
mululq | 8 | 4 | 4 |  |
accw | 2 | 2 |  | accumulate | += a
accl | 4 | 4 |  | accumulate | += a
accsadubl | 4 | 1 | 1 | accumulate absolute difference | += abs(a - b)
swapw | 2 | 2 |  | endianness swap | special
swapl | 4 | 4 |  | endianness swap | special
swapwl | 4 | 4 |  |  |
swapq | 8 | 8 |  |  |
swaplq | 8 | 8 |  |  |
select0wb | 1 | 2 |  | select first half | special
select1wb | 1 | 2 |  | select second half | special
select0lw | 2 | 4 |  | select first half | special
select1lw | 2 | 4 |  | select second half | special
select0ql | 4 | 8 |  |  |
select1ql | 4 | 8 |  |  |
mergelq | 8 | 4 | 4 |  |
mergewl | 4 | 2 | 2 | merge halves | special
mergebw | 2 | 1 | 1 | merge halves | special
splitql | 4 | 8 |  |  |
splitlw | 2 | 4 |  | split first/second words | special
splitwb | 1 | 2 |  | split first/second bytes | special
addf | 4 | 4 | 4 | add | a + b
subf | 4 | 4 | 4 | subtract | a - b
mulf | 4 | 4 | 4 | multiply | a * b
divf | 4 | 4 | 4 | divide | a / b
sqrtf | 4 | 4 |  | square root | sqrt(a)
maxf | 4 | 4 | 4 | maximum | max(a,b)
minf | 4 | 4 | 4 | minimum | min(a,b)
cmpeqf | 4 | 4 | 4 | compare equal | (a == b) ? (~0) : 0
cmpltf | 4 | 4 | 4 | compare less than | (a == b) ? (~0) : 0
cmplef | 4 | 4 | 4 | compare less than or equal | (a == b) ? (~0) : 0
convfl | 4 | 4 |  | convert float point to integer | a
convlf | 4 | 4 |  | convert integer to floating point | a
addd | 8 | 8 | 8 |  |
subd | 8 | 8 | 8 |  |
muld | 8 | 8 | 8 |  |
divd | 8 | 8 | 8 |  |
sqrtd | 8 | 8 |  |  |
maxd | 8 | 8 | 8 |  |
mind | 8 | 8 | 8 |  |
cmpeqd | 8 | 8 | 8 |  |
cmpltd | 8 | 8 | 8 |  |
cmpled | 8 | 8 | 8 |  |
convdl | 4 | 8 |  |  |
convld | 8 | 4 |  |  |
convfd | 8 | 4 |  |  |
convdf | 4 | 8 |  |  |

In the pseudo code of the above table, abs() indicates absolute value, clamp() indicates that any values outside the destination range are set to the nearest value in the destination range, and sign() evaluates to -1 for values less than 0, 1 for values greater than 0, and 0 for 0.

## Rule Coverage

The values for shift operations are not correct in this table.

Table 2. Table of Opcode Rule Coverage

opcode name | sse | mmx | altivec | arm | neon | c64x-c
--- | --- | --- | --- | --- | --- | ---
absb | yes | yes | yes | no | yes | no
addb | yes | yes | yes | no | yes | no
addssb | yes | yes | yes | no | yes | no
addusb | yes | yes | yes | no | yes | no
andb | yes | yes | yes | yes | yes | no
andnb | yes | yes | yes | yes | yes | no
avgsb | yes | yes | yes | yes | yes | no
avgub | yes | yes | yes | yes | yes | no
cmpeqb | yes | yes | yes | yes | yes | no
cmpgtsb | yes | yes | yes | yes | yes | no
copyb | yes | yes | yes | yes | yes | no
loadb | yes | yes | yes | yes | yes | no
loadoffb | yes | yes | no | no | yes | no
loadupdb | yes | yes | no | no | no | no
loadupib | yes | yes | no | no | no | no
loadpb | yes | yes | yes | yes | yes | no
ldresnearb | no | no | no | no | no | no
ldresnearl | yes | yes | no | no | no | no
ldreslinb | no | no | no | no | no | no
ldreslinl | yes | yes | no | no | no | no
maxsb | yes | yes | yes | no | yes | no
maxub | yes | yes | yes | no | yes | no
minsb | yes | yes | yes | no | yes | no
minub | yes | yes | yes | no | yes | no
mullb | yes | yes | yes | no | yes | no
mulhsb | yes | yes | yes | no | yes | no
mulhub | yes | yes | yes | no | yes | no
orb | yes | yes | yes | yes | yes | no
shlb | yes | yes | yes | yes | yes | no
shrsb | yes | yes | yes | no | yes | no
shrub | yes | yes | yes | no | yes | no
signb | yes | yes | yes | no | yes | no
storeb | yes | yes | yes | yes | yes | no
subb | yes | yes | yes | no | yes | no
subssb | yes | yes | yes | no | yes | no
subusb | yes | yes | yes | no | yes | no
xorb | yes | yes | yes | yes | yes | no
absw | yes | yes | yes | no | yes | no
addw | yes | yes | yes | no | yes | no
addssw | yes | yes | yes | no | yes | no
addusw | yes | yes | yes | no | yes | no
andw | yes | yes | yes | yes | yes | no
andnw | yes | yes | yes | yes | yes | no
avgsw | yes | yes | yes | no | yes | no
avguw | yes | yes | yes | yes | yes | no
cmpeqw | yes | yes | yes | yes | yes | no
cmpgtsw | yes | yes | yes | yes | yes | no
copyw | yes | yes | yes | yes | yes | no
div255w | yes | yes | yes | no | yes | no
divluw | yes | yes | no | no | no | no
loadw | yes | yes | yes | yes | yes | no
loadoffw | yes | yes | no | no | yes | no
loadpw | yes | yes | yes | yes | yes | no
maxsw | yes | yes | yes | no | yes | no
maxuw | yes | yes | yes | no | yes | no
minsw | yes | yes | yes | no | yes | no
minuw | yes | yes | yes | no | yes | no
mullw | yes | yes | yes | yes | yes | no
mulhsw | yes | yes | yes | yes | yes | no
mulhuw | yes | yes | yes | no | yes | no
orw | yes | yes | yes | yes | yes | no
shlw | yes | yes | yes | yes | yes | no
shrsw | yes | yes | yes | no | yes | no
shruw | yes | yes | yes | yes | yes | no
signw | yes | yes | yes | no | yes | no
storew | yes | yes | yes | yes | yes | no
subw | yes | yes | yes | no | yes | no
subssw | yes | yes | yes | no | yes | no
subusw | yes | yes | yes | no | yes | no
xorw | yes | yes | yes | yes | yes | no
absl | yes | yes | yes | no | yes | no
addl | yes | yes | yes | yes | yes | no
addssl | yes | yes | yes | yes | yes | no
addusl | yes | yes | yes | yes | yes | no
andl | yes | yes | yes | yes | yes | no
andnl | yes | yes | yes | yes | yes | no
avgsl | yes | yes | yes | no | yes | no
avgul | yes | yes | yes | no | yes | no
cmpeql | yes | yes | yes | yes | yes | no
cmpgtsl | yes | yes | yes | yes | yes | no
copyl | yes | yes | yes | yes | yes | no
loadl | yes | yes | yes | yes | yes | no
loadoffl | yes | yes | no | no | yes | no
loadpl | yes | yes | yes | yes | yes | no
maxsl | yes | yes | yes | yes | yes | no
maxul | yes | yes | yes | yes | yes | no
minsl | yes | yes | yes | yes | yes | no
minul | yes | yes | yes | yes | yes | no
mulll | yes | no | no | yes | yes | no
mulhsl | yes | no | no | yes | yes | no
mulhul | yes | no | no | no | yes | no
orl | yes | yes | yes | yes | yes | no
shll | yes | yes | yes | yes | yes | no
shrsl | yes | yes | yes | yes | yes | no
shrul | yes | yes | yes | yes | yes | no
signl | yes | yes | yes | no | yes | no
storel | yes | yes | yes | yes | yes | no
subl | yes | yes | yes | yes | yes | no
subssl | yes | yes | yes | no | yes | no
subusl | yes | yes | yes | yes | yes | no
xorl | yes | yes | yes | yes | yes | no
loadq | yes | yes | yes | no | yes | no
loadpq | yes | yes | no | no | no | no
storeq | yes | yes | yes | no | yes | no
splatw3q | yes | yes | yes | no | yes | no
copyq | yes | yes | no | no | yes | no
cmpeqq | no | no | no | no | no | no
cmpgtsq | no | no | no | no | no | no
andq | yes | yes | no | no | yes | no
andnq | yes | yes | no | no | yes | no
orq | yes | yes | no | no | yes | no
xorq | yes | yes | no | no | yes | no
addq | yes | no | no | no | yes | no
subq | yes | no | no | no | yes | no
shlq | yes | yes | no | no | no | no
shrsq | yes | yes | no | no | no | no
shruq | yes | yes | no | no | no | no
convsbw | yes | yes | yes | yes | yes | no
convubw | yes | yes | yes | no | yes | no
splatbw | yes | yes | yes | no | yes | no
splatbl | yes | yes | yes | no | yes | no
convswl | yes | yes | yes | no | yes | no
convuwl | yes | yes | yes | no | yes | no
convslq | yes | yes | yes | no | yes | no
convulq | yes | yes | yes | no | yes | no
convwb | yes | yes | yes | yes | yes | no
convhwb | yes | yes | yes | no | yes | no
convssswb | yes | yes | yes | no | yes | no
convsuswb | yes | yes | yes | no | yes | no
convusswb | no | no | no | no | no | no
convuuswb | yes | yes | yes | no | yes | no
convlw | yes | yes | yes | yes | yes | no
convhlw | yes | yes | yes | no | yes | no
convssslw | yes | yes | yes | no | yes | no
convsuslw | no | no | yes | no | yes | no
convusslw | no | no | no | no | no | no
convuuslw | no | no | yes | no | yes | no
convql | yes | yes | yes | no | yes | no
convsssql | no | no | no | no | yes | no
convsusql | no | no | no | no | yes | no
convussql | no | no | no | no | no | no
convuusql | no | no | no | no | yes | no
mulsbw | yes | yes | yes | yes | yes | no
mulubw | yes | yes | yes | no | yes | no
mulswl | yes | yes | yes | no | yes | no
muluwl | yes | yes | yes | no | yes | no
mulslq | no | no | no | no | no | no
mululq | yes | no | no | no | no | no
accw | yes | yes | no | no | yes | no
accl | yes | yes | yes | no | yes | no
accsadubl | yes | yes | no | no | yes | no
swapw | yes | yes | yes | no | yes | no
swapl | yes | yes | yes | no | yes | no
swapwl | yes | yes | no | no | yes | no
swapq | yes | yes | no | no | yes | no
swaplq | yes | yes | no | no | yes | no
select0wb | yes | yes | yes | yes | yes | no
select1wb | yes | yes | yes | yes | yes | no
select0lw | yes | yes | yes | yes | yes | no
select1lw | yes | yes | yes | yes | yes | no
select0ql | yes | yes | no | no | yes | no
select1ql | yes | yes | no | no | no | no
mergelq | yes | yes | no | no | yes | no
mergewl | yes | yes | yes | yes | yes | no
mergebw | yes | yes | yes | no | yes | no
splitql | yes | yes | no | no | yes | no
splitlw | yes | yes | yes | no | yes | no
splitwb | yes | yes | yes | no | yes | no
addf | yes | no | yes | no | yes | no
subf | yes | no | yes | no | yes | no
mulf | yes | no | yes | no | yes | no
divf | yes | no | no | no | yes | no
sqrtf | yes | no | no | no | yes | no
maxf | yes | no | yes | no | yes | no
minf | yes | no | yes | no | yes | no
cmpeqf | yes | no | yes | no | yes | no
cmpltf | yes | no | yes | no | no | no
cmplef | yes | no | yes | no | no | no
convfl | yes | no | yes | no | yes | no
convlf | yes | no | yes | no | yes | no
addd | yes | no | no | no | yes | no
subd | yes | no | no | no | yes | no
muld | yes | no | no | no | yes | no
divd | yes | no | no | no | yes | no
sqrtd | yes | no | no | no | no | no
maxd | yes | no | no | no | no | no
mind | yes | no | no | no | no | no
cmpeqd | yes | no | no | no | no | no
cmpltd | yes | no | no | no | no | no
cmpled | yes | no | no | no | no | no
convdl | yes | no | no | no | no | no
convld | yes | no | no | no | no | no
convfd | yes | no | no | no | no | no
convdf | yes | no | no | no | no | no