0.6.11.10:
[sbcl.git] / src / compiler / vop.lisp
index 7fc2f6c..d847d4a 100644 (file)
 (deftype local-tn-vector () `(simple-vector ,local-tn-limit))
 (deftype local-tn-bit-vector () `(simple-bit-vector ,local-tn-limit))
 
-;;; Type of an SC number.
+;;; type of an SC number
 (deftype sc-number () `(integer 0 (,sc-number-limit)))
 
-;;; Types for vectors indexed by SC numbers.
+;;; types for vectors indexed by SC numbers
 (deftype sc-vector () `(simple-vector ,sc-number-limit))
 (deftype sc-bit-vector () `(simple-bit-vector ,sc-number-limit))
 
-;;; The different policies we can use to determine the coding strategy.
-(deftype policies ()
+;;; the different policies we can use to determine the coding strategy
+(deftype ltn-policy ()
   '(member :safe :small :fast :fast-safe))
 \f
 ;;;; PRIMITIVE-TYPEs
 
-;;; The primitive type is used to represent the aspects of type
+;;; A PRIMITIVE-TYPE is used to represent the aspects of type
 ;;; interesting to the VM. Selection of IR2 translation templates is
 ;;; done on the basis of the primitive types of the operands, and the
 ;;; primitive type of a value is used to constrain the possible
 ;;; representations of that value.
-(defstruct primitive-type
+(defstruct (primitive-type (:copier nil))
   ;; the name of this PRIMITIVE-TYPE
   (name nil :type symbol)
   ;; a list of the SC numbers for all the SCs that a TN of this type
 ;;; and after IR2 conversion. It is stored in the BLOCK-INFO slot for
 ;;; the associated block.
 (defstruct (ir2-block (:include block-annotation)
-                     (:constructor make-ir2-block (block)))
+                     (:constructor make-ir2-block (block))
+                     (:copier nil))
   ;; the IR2-Block's number, which differs from Block's Block-Number
   ;; if any blocks are split. This is assigned by lifetime analysis.
   (number nil :type (or index null))
   (local-tn-count :test (not (zerop local-tn-count)))
   (%label :test %label))
 
-;;; An IR2-Continuation structure is used to annotate continuations
+;;; An IR2-CONTINUATION structure is used to annotate continuations
 ;;; that are used as a function result continuation or that receive MVs.
 (defstruct (ir2-continuation
-           (:constructor make-ir2-continuation (primitive-type)))
+           (:constructor make-ir2-continuation (primitive-type))
+           (:copier nil))
   ;; If this is :DELAYED, then this is a single value continuation for
   ;; which the evaluation of the use is to be postponed until the
   ;; evaluation of destination. This can be done for ref nodes or
   primitive-type
   locs)
 
-;;; The IR2-Component serves mostly to accumulate non-code information
+;;; An IR2-COMPONENT serves mostly to accumulate non-code information
 ;;; about the component being compiled.
-(defstruct ir2-component
+(defstruct (ir2-component (:copier nil))
   ;; the counter used to allocate global TN numbers
   (global-tn-counter 0 :type index)
   ;; NORMAL-TNS is the head of the list of all the normal TNs that
 ;;; structures are somtimes created before they are initialized, since
 ;;; IR2 conversion may need to compile a forward reference. In this
 ;;; case the slots aren't actually initialized until entry analysis runs.
-(defstruct entry-info
+(defstruct (entry-info (:copier nil))
   ;; true if this function has a non-null closure environment
   (closure-p nil :type boolean)
   ;; a label pointing to the entry vector for this function, or NIL
 
 ;;; An IR2-ENVIRONMENT is used to annotate non-LET lambdas with their
 ;;; passing locations. It is stored in the Environment-Info.
-(defstruct ir2-environment
+(defstruct (ir2-environment (:copier nil))
   ;; the TNs that hold the passed environment within the function.
   ;; This is an alist translating from the NLX-Info or lambda-var to
   ;; the TN that holds the corresponding value within this function.
 ;;; A RETURN-INFO is used by GTN to represent the return strategy and
 ;;; locations for all the functions in a given TAIL-SET. It is stored
 ;;; in the TAIL-SET-INFO.
-(defstruct return-info
+(defstruct (return-info (:copier nil))
   ;; The return convention used:
   ;; -- If :UNKNOWN, we use the standard return convention.
   ;; -- If :FIXED, we use the known-values convention.
   types
   locations)
 
-(defstruct ir2-nlx-info
+(defstruct (ir2-nlx-info (:copier nil))
   ;; If the kind is :ENTRY (a lexical exit), then in the home
   ;; environment, this holds a VALUE-CELL object containing the unwind
   ;; block pointer. In the other cases nobody directly references the
   home
   save-sp
   dynamic-state)
-
-;;; FIXME: Delete? (was commented out in CMU CL)
-#|
-;;; The Loop structure holds information about a loop.
-(defstruct (cloop (:conc-name loop-)
-                 (:predicate loop-p)
-                 (:constructor make-loop)
-                 (:copier copy-loop))
-  ;; The kind of loop that this is. These values are legal:
-  ;;
-  ;;    :Outer
-  ;;   This is the outermost loop structure, and represents all the
-  ;;   code in a component.
-  ;;
-  ;;    :Natural
-  ;;   A normal loop with only one entry.
-  ;;
-  ;;    :Strange
-  ;;   A segment of a "strange loop" in a non-reducible flow graph.
-  (kind (required-argument) :type (member :outer :natural :strange))
-  ;; The first and last blocks in the loop. There may be more than one tail,
-  ;; since there may be multiple back branches to the same head.
-  (head nil :type (or cblock null))
-  (tail nil :type list)
-  ;; A list of all the blocks in this loop or its inferiors that have a
-  ;; successor outside of the loop.
-  (exits nil :type list)
-  ;; The loop that this loop is nested within. This is null in the outermost
-  ;; loop structure.
-  (superior nil :type (or cloop null))
-  ;; A list of the loops nested directly within this one.
-  (inferiors nil :type list)
-  ;; The head of the list of blocks directly within this loop. We must recurse
-  ;; on Inferiors to find all the blocks.
-  (blocks nil :type (or null cblock)))
-(defprinter (loop)
-  kind
-  head
-  tail
-  exits)
-|#
 \f
 ;;;; VOPs and templates
 
 ;;; A VOP is a Virtual Operation. It represents an operation and the
 ;;; operands to the operation.
-(defstruct (vop (:constructor make-vop (block node info args results)))
+(defstruct (vop (:constructor make-vop (block node info args results))
+               (:copier nil))
   ;; VOP-Info structure containing static info about the operation.
   (info nil :type (or vop-info null))
   ;; The IR2-Block this VOP is in.
 ;;; A TN-REF object contains information about a particular reference
 ;;; to a TN. The information in TN-REFs largely determines how TNs are
 ;;; packed.
-(defstruct (tn-ref (:constructor make-tn-ref (tn write-p)))
+(defstruct (tn-ref (:constructor make-tn-ref (tn write-p))
+                  (:copier nil))
   ;; the TN referenced
   (tn (required-argument) :type tn)
   ;; Is this is a write reference? (as opposed to a read reference)
 ;;; a known function.
 (def!struct (template (:constructor nil)
                      #-sb-xc-host (:pure t))
-  ;; The symbol name of this VOP. This is used when printing the VOP
+  ;; the symbol name of this VOP. This is used when printing the VOP
   ;; and is also used to provide a handle for definition and
   ;; translation.
   (name nil :type symbol)
-  ;; A Function-Type describing the arg/result type restrictions. We
-  ;; compute this from the Primitive-Type restrictions to make life
-  ;; easier for IR1 phases that need to anticipate LTN's template
-  ;; selection.
+  ;; the arg/result type restrictions. We compute this from the
+  ;; PRIMITIVE-TYPE restrictions to make life easier for IR1 phases
+  ;; that need to anticipate LTN's template selection.
   (type (required-argument) :type function-type)
-  ;; Lists of restrictions on the argument and result types. A
+  ;; lists of restrictions on the argument and result types. A
   ;; restriction may take several forms:
   ;; -- The restriction * is no restriction at all.
   ;; -- A restriction (:OR <primitive-type>*) means that the operand 
   ;;    the type tested by the predicate, used when we want to represent
   ;;    the type constraint as a Lisp function type.
   ;;
-  ;; If Result-Types is :Conditional, then this is an IF-xxx style
+  ;; If RESULT-TYPES is :CONDITIONAL, then this is an IF-FOO style
   ;; conditional that yeilds its result as a control transfer. The
   ;; emit function takes two info arguments: the target label and a
   ;; boolean flag indicating whether to negate the sense of the test.
   (arg-types nil :type list)
   (result-types nil :type (or list (member :conditional)))
-  ;; The primitive type restriction applied to each extra argument or
+  ;; the primitive type restriction applied to each extra argument or
   ;; result following the fixed operands. If NIL, no extra
   ;; args/results are allowed. Otherwise, either * or a (:OR ...) list
   ;; as described for the {ARG,RESULT}-TYPES.
   ;; conditionally compile for different target hardware
   ;; configuarations (e.g. FP hardware.)
   (guard nil :type (or function null))
-  ;; The policy under which this template is the best translation.
+  ;; the policy under which this template is the best translation.
   ;; Note that LTN might use this template under other policies if it
-  ;; can't figure our anything better to do.
-  (policy (required-argument) :type policies)
-  ;; The base cost for this template, given optimistic assumptions
+  ;; can't figure out anything better to do.
+  (ltn-policy (required-argument) :type ltn-policy)
+  ;; the base cost for this template, given optimistic assumptions
   ;; such as no operand loading, etc.
   (cost (required-argument) :type index)
-  ;; If true, then a short noun-like phrase describing what this VOP
-  ;; "does", i.e. the implementation strategy. This is for use in
-  ;; efficiency notes.
+  ;; If true, then this is a short noun-like phrase describing what
+  ;; this VOP "does", i.e. the implementation strategy. This is for
+  ;; use in efficiency notes.
   (note nil :type (or string null))
   ;; The number of trailing arguments to VOP or %PRIMITIVE that we
   ;; bundle into a list and pass into the emit function. This provides
   ;; a way to pass uninterpreted stuff directly to the code generator.
   (info-arg-count 0 :type index)
-  ;; A function that emits the VOPs for this template. Arguments:
+  ;; a function that emits the VOPs for this template. Arguments:
   ;;  1] Node for source context.
   ;;  2] IR2-Block that we place the VOP in.
   ;;  3] This structure.
   result-types
   (more-args-type :test more-args-type :prin1 more-args-type)
   (more-results-type :test more-results-type :prin1 more-results-type)
-  policy
+  ltn-policy
   cost
   (note :test note)
   (info-arg-count :test (not (zerop info-arg-count))))
 (def!struct (vop-info
             (:include template)
             (:make-load-form-fun ignore-it))
-  ;; Side-effects of this VOP and side-effects that affect the value
-  ;; of this VOP.
+  ;; side-effects of this VOP and side-effects that affect the value
+  ;; of this VOP
   (effects (required-argument) :type attributes)
   (affected (required-argument) :type attributes)
   ;; If true, causes special casing of TNs live after this VOP that
   ;; -- If :Compute-Only, just compute the save set, don't do any saving.
   ;;    This is used to get the live variables for debug info.
   (save-p nil :type (member t nil :force-to-stack :compute-only))
-  ;; Info for automatic emission of move-arg VOPs by representation
+  ;; info for automatic emission of move-arg VOPs by representation
   ;; selection. If NIL, then do nothing special. If non-null, then
   ;; there must be a more arg. Each more arg is moved to its passing
   ;; location using the appropriate representation-specific
   ;; :KNOWN-RETURN
   ;;     If needed, the old NFP is computed using COMPUTE-OLD-NFP.
   (move-args nil :type (member nil :full-call :local-call :known-return))
-  ;; A list of sc-vectors representing the loading costs of each fixed
-  ;; argument and result.
+  ;; a list of sc-vectors representing the loading costs of each fixed
+  ;; argument and result
   (arg-costs nil :type list)
   (result-costs nil :type list)
-  ;; If true, sc-vectors representing the loading costs for any more
-  ;; args and results.
+  ;; if true, SC-VECTORs representing the loading costs for any more
+  ;; args and results
   (more-arg-costs nil :type (or sc-vector null))
   (more-result-costs nil :type (or sc-vector null))
-  ;; Lists of sc-vectors mapping each SC to the SCs that we can load
+  ;; lists of SC-VECTORs mapping each SC to the SCs that we can load
   ;; into. If a SC is directly acceptable to the VOP, then the entry
   ;; is T. Otherwise, it is a list of the SC numbers of all the SCs
   ;; that we can load into. This list will be empty if there is no
   ;; operand SC restriction.
   (arg-load-scs nil :type list)
   (result-load-scs nil :type list)
-  ;; If true, a function that is called with the VOP to do operand
+  ;; if true, a function that is called with the VOP to do operand
   ;; targeting. This is done by modifiying the TN-Ref-Target slots in
   ;; the TN-Refs so that they point to other TN-Refs in the same VOP.
   (target-function nil :type (or null function))
-  ;; A function that emits assembly code for a use of this VOP when it
+  ;; a function that emits assembly code for a use of this VOP when it
   ;; is called with the VOP structure. Null if this VOP has no
   ;; specified generator (i.e. it exists only to be inherited by other
   ;; VOPs.)
   (generator-function nil :type (or function null))
-  ;; A list of things that are used to parameterize an inherited
+  ;; a list of things that are used to parameterize an inherited
   ;; generator. This allows the same generator function to be used for
   ;; a group of VOPs with similar implementations.
   (variant nil :type list)
-  ;; The number of arguments and results. Each regular arg/result
+  ;; the number of arguments and results. Each regular arg/result
   ;; counts as one, and all the more args/results together count as 1.
   (num-args 0 :type index)
   (num-results 0 :type index)
-  ;; Vector of the temporaries the vop needs. See emit-generic-vop in
-  ;; vmdef for information on how the temps are encoded.
-  ;;
-  ;; (The SB-XC-HOST conditionalization on the type is there because
-  ;; it's difficult to dump specialized arrays portably, so on the
-  ;; cross-compilation host we punt by using unspecialized arrays
-  ;; instead.)
+  ;; a vector of the temporaries the vop needs. See EMIT-GENERIC-VOP
+  ;; in vmdef for information on how the temps are encoded.
   (temps nil :type (or null (specializable-vector (unsigned-byte 16))))
-  ;; The order all the refs for this vop should be put in. Each
+  ;; the order all the refs for this vop should be put in. Each
   ;; operand is assigned a number in the following ordering: args,
   ;; more-args, results, more-results, temps This vector represents
   ;; the order the operands should be put into in the next-ref link.
-  ;;
-  ;; (The SB-XC-HOST conditionalization on the type is there because
-  ;; it's difficult to dump specialized arrays portably, so on the
-  ;; cross-compilation host we punt by using unspecialized arrays
-  ;; instead.)
   (ref-ordering nil :type (or null (specializable-vector (unsigned-byte 8))))
-  ;; Array of the various targets that should be done. Each element
+  ;; a vector of the various targets that should be done. Each element
   ;; encodes the source ref (shifted 8) and the dest ref index.
   (targets nil :type (or null (specializable-vector (unsigned-byte 16)))))
 \f
 
 ;;; the SC structure holds the storage base that storage is allocated
 ;;; in and information used to select locations within the SB.
-(defstruct sc
+(defstruct (sc (:copier nil))
   ;; Name, for printing and reference.
   (name nil :type symbol)
   ;; The number used to index SC cost vectors.
 
 (defstruct (tn (:include sset-element)
               (:constructor make-random-tn)
-              (:constructor make-tn (number kind primitive-type sc)))
+              (:constructor make-tn (number kind primitive-type sc))
+              (:copier nil))
   ;; The kind of TN this is:
   ;;
   ;;   :NORMAL
 ;;; lifetime analysis to represent the set of TNs live at the start of
 ;;; the IR2 block.
 (defstruct (global-conflicts
-           (:constructor make-global-conflicts (kind tn block number)))
+           (:constructor make-global-conflicts (kind tn block number))
+           (:copier nil))
   ;; The IR2-Block that this structure represents the conflicts for.
   (block (required-argument) :type ir2-block)
   ;; Thread running through all the Global-Conflict for Block. This