[ Home ]
SBCL Internals

The pages on this CLiki-driven site can be edited by anybody at any time. No warranty of any kind can therefore be made; any implied warranties of merchantability or fitness for a particular purpose are expressly disclaimed
[ Home ] [ Recent Changes ] [ About CLiki ] [ Text Formatting ]

VOP stands for Virtual Operation, and is the basic unit of currency in the Compiler Backend. VOPs usually expand into assembly instructions. For details see Adding VOPs.

VOP selection is mostly explained in VOP Selection, at least as far as relevance of :ARG-TYPES and :RESULT-TYPES go.

The :POLICY section of the VOP relates to the current optimisation policy for the call. There are two parameters: safety (:FAST and :SMALL vs :FAST-SAFE and :SAFE) and speed vs code size. :FAST-SAFE VOP performs all checks, except for argument types; :SAFE checks arguments too. :SAFE VOPs seem to be supposed to be smaller than :FAST-SAFE one, though it may be untrue.

VOPs may be called directly by name. In source code use SB-SYS:%PRIMITIVE? special operator; this may be useful for temporary kludges when VOPs aren't being called though they should be. It's also the mechanism used by things like /SHOW0?, which after vigorous macroexpansion turns into (%primitive print ...). In an IR2-CONVERT optimizer use VOP/VOP* macros.

VOPs translating for various numeric operations assume that if there is a Constant? argument, it is the second argument. This is guaranteed by the IR1 transformation phase for the functions defined in the ANSI specification.

Smaller sleeker VOPs can be written for the cases where one or more arguments are compile-time constants. Put the parameter name in :info instead of :args, but give it an :arg-types entry as usual. Viz:

(defknown pop-words (index) (values) (call))
(define-vop (pop-words)
    (:translate pop-words)
  (:args)
  (:arg-types (:constant (unsigned-byte 29)))
  (:info number)
  (:policy :fast-safe)
  (:generator 2
    (inst add esp-tn (fixnumize number))))

When writing VOPs you may find the following functions useful (list taken from CMUCL docs)

#lisp wisdom

12:01 < nikodemus> when do vops get selected based on their names, and when 
                   based on their translations?
12:03 < Krystof> nikodemus: they get selected on their names only when called 
                 by %primitive

Or in other words, they never get selected by name, but you can ask for a particular VOP by name if you need it.


Pages in this topic: Guard   RANDOM-MT19937  


Also linked from: Abbreviations   BACKEND-FEATUREP   Compiler   Darwin   HPPA   index   IR2   move-function   Peephole Optimizer   PENTIUM-STYLE-FYL2XP1   Registers   SPARC   stack allocation   TN   Virtual Operation  

CLiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively