September 14, 2004
AltiVec from Lisp

Did you know you can write AltiVec (AKA Velocity Engine, kind of like MMX or SSE2 but for G4 and G5 processors) code from within OpenMCL?

(defppclapfunction load-array ((n arg_z))
  (check-nargs 1)
  (with-altivec-registers (vr1 vr2 vr3 vr27) ; Clobbers imm0
    (li imm0 arch::misc-data-offset)
    (lvx vr1 arg_z imm0) ; load MSQ
    (lvsl vr27 arg_z imm0) ; set the permute vector
    (addi imm0 imm0 16) ; address of LSQ
    (lvx vr2 arg_z imm0) ; load LSQ
    (vperm vr3 vr1 vr2 vr27) ; aligned result appears in VR3
    (dbg t)) ; Look at result in some debugger

I wish there were some cool examples.

Posted by jjwiseman at September 14, 2004 06:26 PM
Post a comment

Email Address:


Unless you answer this question, your comment will be classified as spam and will not be posted.
(I'll give you a hint: the answer is “lisp”.)


Remember info?