X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/1d8cc67a3f4ded443f5efc673a616883cbae9c50..9ec578d9fe450b7e7f9030dc9d930185593aa991:/src/codegen-proto.lisp diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index 4b38521..b8206fa 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -62,10 +62,10 @@ This is automatically reset to zero before the output functions are invoked to write a file. This way, we can ensure that the same output - file is always produced from the same input." - ;; FIXME: this is currently a lie. Need some protocol to ensure that this - ;; happens. -) + file is always produced from the same input.") + +(define-clear-the-decks reset-codegen-index + (setf *temporary-index* 0)) ;; Important temporary names. @@ -86,9 +86,9 @@ "A base class for instructions. An `instruction' is anything which might be useful to string into a code - generator. Both statements and expressions map can be represented by - trees of instructions. The `definst' macro is a convenient way of - defining new instructions. + generator. Both statements and expressions can be represented by trees of + instructions. The `definst' macro is a convenient way of defining new + instructions. The only important protocol for instructions is output, which is achieved by calling `print-object' with `*print-escape*' nil. @@ -108,9 +108,14 @@ This isn't intended to be a particularly rigorous definition. Its purpose is to allow code generators to make decisions about inlining or calling code fairly simply.") - (:method (inst) + (:method ((inst t)) + (declare (ignore inst)) + 1) + (:method ((inst null)) (declare (ignore inst)) - 1)) + 1) + (:method ((inst list)) + (reduce #'+ inst :key #'inst-metric))) ;; Instruction definition. @@ -316,7 +321,7 @@ "Evaluate BODY with VAR bound to a temporary variable name. During BODY, VAR will be marked in-use; when BODY ends, VAR will be marked - available for re-use." + available for re-use." `(let ((,var (temporary-var ,codegen ,type))) (unwind-protect (progn ,@body)