vslv

Vector Shift Left Variable

vslv VRT,VRA,VRB

Shifts the contents of vector elements left by a variable amount.

Details

The vslv instruction shifts each byte element in VSR[VRA+32] left by a variable amount specified in the corresponding byte element of VSR[VRB+32]. The result is stored in VSR[VRT+32].

Pseudocode Operation

if MSR.VEC=0 then
    Vector_Unavailable_Interrupt()
else
    vsrc.byte[0:15] ← VSR[VRA+32]
    vsrc.byte[16] ← 0x00
    do i = 0 to 15
        shVSR[VRB+32].byte[i].bit[5:7]
        VSR[VRT+32].byte[i] ← src.byte[i:i+1].bit[sh:sh+7]
    end

Programming Note

The vslv instruction is used to perform variable left shifts on each byte of a vector register. Ensure that the shift amounts in VSR[VRB+32] are within the valid range (0-7) to avoid unexpected results. This instruction operates at user privilege level and will raise an exception if the Vector Facility is not enabled.

Example

vslv v1, v2, v3

Encoding

Binary Layout
4
0
VRT
6
VRA
11
VRB
16
1860
21
 
Format VX-form
Opcode 0x10000744
Extension VMX (AltiVec)

Operands

  • VRT
    Target Vector Register
  • VRA
    Source Vector Register
  • VRB
    Shift Amount Vector Register