Start working on L2
This changes the compilation process to keep track of register types, which
we'll need to distinguish between local/permanent variables. It also makes
things a bit more obvious/safe when compiling argument registers because they're
tagged explicitly.
This also changes up the actual running of the code by actually using
CALL/PROCEED, though it's not fully fleshed out yet.
author |
Steve Losh <steve@stevelosh.com> |
date |
Wed, 13 Apr 2016 17:38:57 +0000 |
parents |
51022d18e98f |
children |
(none) |
(in-package #:bones.wam)
;;; This file contains some basic helpers for working with opcodes themselves.
;;; For the actual implementation of the instructions, see instructions.lisp.
(defun* instruction-size ((opcode opcode))
(:returns (integer 0 3))
"Return the size of an instruction for the given opcode.
The size includes one word for the opcode itself and one for each argument.
"
(eswitch (opcode)
(+opcode-get-structure+ 3)
(+opcode-unify-variable+ 2)
(+opcode-unify-value+ 2)
(+opcode-get-variable+ 3)
(+opcode-get-value+ 3)
(+opcode-put-structure+ 3)
(+opcode-set-variable+ 2)
(+opcode-set-value+ 2)
(+opcode-put-variable+ 3)
(+opcode-put-value+ 3)
(+opcode-call+ 2)
(+opcode-proceed+ 1)))
(defun* opcode-name ((opcode opcode))
(:returns string)
(eswitch (opcode)
(+opcode-get-structure+ "GET-STRUCTURE")
(+opcode-unify-variable+ "UNIFY-VARIABLE")
(+opcode-unify-value+ "UNIFY-VALUE")
(+opcode-get-variable+ "GET-VARIABLE")
(+opcode-get-value+ "GET-VALUE")
(+opcode-put-structure+ "PUT-STRUCTURE")
(+opcode-set-variable+ "SET-VARIABLE")
(+opcode-set-value+ "SET-VALUE")
(+opcode-put-variable+ "PUT-VARIABLE")
(+opcode-put-value+ "PUT-VALUE")
(+opcode-call+ "CALL")
(+opcode-proceed+ "PROCEED")))
(defun* opcode-short-name ((opcode opcode))
(:returns string)
(eswitch (opcode)
(+opcode-get-structure+ "GETS")
(+opcode-unify-variable+ "UVAR")
(+opcode-unify-value+ "UVLU")
(+opcode-get-variable+ "GVAR")
(+opcode-get-value+ "GVLU")
(+opcode-put-structure+ "PUTS")
(+opcode-set-variable+ "SVAR")
(+opcode-set-value+ "SVLU")
(+opcode-put-variable+ "PVAR")
(+opcode-put-value+ "PVLU")
(+opcode-call+ "CALL")
(+opcode-proceed+ "PROC")))