From c8feb547abe0357e2a79cab782ca6e095c4d96b1 Mon Sep 17 00:00:00 2001 From: devans Date: Thu, 15 Oct 2009 05:51:08 +0000 Subject: [PATCH] * ifield.scm (, value): Provide default initial value. (ifield-encode-mode): Delete (ifield-decode-mode): Delete duplicate definition. (, 'make!): Initialize members encode, decode. --- cgen/ChangeLog | 7 +++++++ cgen/ifield.scm | 43 ++++++++++++++----------------------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/cgen/ChangeLog b/cgen/ChangeLog index a47880b45f..ac963d764c 100644 --- a/cgen/ChangeLog +++ b/cgen/ChangeLog @@ -1,3 +1,10 @@ +2009-10-14 Doug Evans + + * ifield.scm (, value): Provide default initial value. + (ifield-encode-mode): Delete + (ifield-decode-mode): Delete duplicate definition. + (, 'make!): Initialize members encode, decode. + 2009-10-05 Dave Korn * sim-model.scm (@cpu@_prepare_run): Use @prefix@, not @cpu@, diff --git a/cgen/ifield.scm b/cgen/ifield.scm index cc744348f1..3b17ceaad4 100644 --- a/cgen/ifield.scm +++ b/cgen/ifield.scm @@ -51,9 +51,9 @@ ; here and partially in the operand. encode decode - ; Value of field, if there is one. + ; Value of field, if there is one, or #f. ; Possible types are: integer, , ??? - value + (value . #f) ) nil) ) @@ -78,23 +78,19 @@ (define (ifld-word-offset f) (bitrange-word-offset (/ifld-bitrange f))) (define (ifld-word-length f) (bitrange-word-length (/ifld-bitrange f))) -; Return the mode of the value passed to the encode rtl. -; This is the mode of the result of the decode rtl. +; Return the mode of the decoded value of F. +; ??? This is made easy because we require the decode expression to have +; an explicit mode. -(define (ifld-encode-mode f) - (if (ifld-decode f) - ; cadr/cadr gets WI in ((value pc) (sra WI ...)) - ; FIXME: That's wrong for a fully canonical expression like - ; ((value pc) (sra () WI ...)). - (mode:lookup (cadr (cadr (ifld-decode f)))) - (ifld-mode f)) +(define (ifld-decode-mode f) + (assert (elm-bound? f 'decode)) + (let ((d (ifld-decode f))) + (if d + ;; FIXME: Does this work with canonicalized rtl? + (mode:lookup (cadr (cadr d))) + (ifld-mode f))) ) -; Return the mode of the value passed to the decode rtl. -; This is the mode of the field. - -(define (ifld-decode-mode f) (ifld-mode f)) - ; Return start of ifield. (method-make! @@ -1059,6 +1055,8 @@ Define an instruction multi-field, all arguments specified. (elm-set! self 'attrs attrs) (elm-set! self 'mode UINT) (elm-set! self 'bitrange (make 0 0 0 0 #f)) + (elm-set! self 'encode #f) + (elm-set! self 'decode #f) (elm-set! self 'owner owner) (elm-set! self 'subfields subfields) self) @@ -1161,19 +1159,6 @@ Define an instruction multi-field, all arguments specified. (> (ifld-word-offset f) 0) ) -; Return the mode of the decoded value of F. -; ??? This is made easy because we require the decode expression to have -; an explicit mode. - -(define (ifld-decode-mode f) - (if (not (elm-bound? f 'decode)) - (ifld-mode f) - (let ((d (ifld-decode f))) - (if d - (mode:lookup (cadr (cadr d))) - (ifld-mode f)))) -) - ; Return object to use to hold value of F. ; i.e. one of h-uint, h-sint. ; NB: Should be defined in terms of `hardware-for-mode'. -- 2.11.0