From ffjeld at common-lisp.net Thu Sep 2 09:01:22 2004 From: ffjeld at common-lisp.net (Frode Vatvedt Fjeld) Date: Thu, 02 Sep 2004 11:01:22 +0200 Subject: [movitz-cvs] CVS update: ia-x86/codec.lisp Message-ID: Update of /project/movitz/cvsroot/ia-x86 In directory common-lisp.net:/tmp/cvs-serv12156 Modified Files: codec.lisp Log Message: Added a protocol for adding "extra" prefixes (such as NOPs) to instructions as they are inserted in a code-stream. This is needed for Movitz to be able to align call instructions such that return-addresses are distinguisable from immediate values, which is required by stack discipline. Date: Thu Sep 2 11:01:20 2004 Author: ffjeld Index: ia-x86/codec.lisp diff -u ia-x86/codec.lisp:1.5 ia-x86/codec.lisp:1.6 --- ia-x86/codec.lisp:1.5 Tue Feb 10 01:03:14 2004 +++ ia-x86/codec.lisp Thu Sep 2 11:01:19 2004 @@ -1,15 +1,15 @@ ;;;;------------------------------------------------------------------ ;;;; -;;;; Copyright (C) 20012000, 2002, 2004, +;;;; Copyright (C) 2000, 2001, 2002, 2004, ;;;; Department of Computer Science, University of Tromso, Norway ;;;; ;;;; Filename: codec.lisp -;;;; Description: +;;;; Description: Encoding and decoding of instructions to/from binary. ;;;; Author: Frode Vatvedt Fjeld ;;;; Created at: Thu May 4 15:16:45 2000 ;;;; Distribution: See the accompanying file COPYING. ;;;; -;;;; $Id: codec.lisp,v 1.5 2004/02/10 00:03:14 ffjeld Exp $ +;;;; $Id: codec.lisp,v 1.6 2004/09/02 09:01:19 ffjeld Exp $ ;;;; ;;;;------------------------------------------------------------------ @@ -428,9 +428,11 @@ -(defun template-instr-and-prefix-length (template instr) +(defun template-instr-and-prefix-length (template instr env) (+ (template-instr-numo template) - (length (calculate-prefixes instr template)))) + (length (calculate-prefixes instr template)) + (length (compute-instruction-extra-prefixes instr template env)))) + ;;; ---------------------------------------------------------------- ;;; Instruction decode @@ -454,8 +456,8 @@ (defun make-decode-instruction (datum prefixes template) (instruction-decode (make-instance (template-instr-classname template) - 'datum datum - 'prefixes (set-difference prefixes + :datum datum + :prefixes (set-difference prefixes (template-req-prefixes template))) template)) @@ -473,18 +475,22 @@ (set-difference (instruction-prefixes instr) (template-not-prefixes template))))) -(defun prefix-encode (prefix-list cdatum) +(defun prefix-encode (cdatum prefix-list &optional extra-prefixes) "Given an instruction encoded into by