From 2500cebfd060a786287210198861aa4a590fb9c1 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Wed, 19 Aug 2009 04:20:29 +0000 Subject: [PATCH] * ifield.scm (ifld-encode-mode): Add FIXME. * opcodes.scm ( 'gen-insert): Handle encode parameters with modes. ( 'gen-extract): Similarly. * read.scm (parse-error): Handle #f for context-location. * utils-cgen.scm (unspecified-location): Fix building of single-location. --- ChangeLog | 15 ++++++++++++--- ifield.scm | 2 ++ opcodes.scm | 16 ++++++++++++---- read.scm | 2 +- utils-cgen.scm | 7 +++++-- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2bd845..3dd5345 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,11 +1,20 @@ 2009-08-18 Doug Evans + * ifield.scm (ifld-encode-mode): Add FIXME. + * opcodes.scm ( 'gen-insert): Handle encode parameters with + modes. + ( 'gen-extract): Similarly. + + * read.scm (parse-error): Handle #f for context-location. + * utils-cgen.scm (unspecified-location): Fix building of + single-location. + * doc/rtl.texi: Document how to write hex and boolean values. - * gas-test.scm (, test-data): Handle () values. - (, test-data): Convert symbols to strings before passing + * gas-test.scm ( test-data): Handle () values. + ( test-data): Convert symbols to strings before passing to string-append. - (, test-data): Enumerate all cases. Emit correctly sized + ( test-data): Enumerate all cases. Emit correctly sized result for scalars. * operand.scm (hw-index-scalar): Set `name'. diff --git a/ifield.scm b/ifield.scm index 16616c1..d8dd0c5 100644 --- a/ifield.scm +++ b/ifield.scm @@ -82,6 +82,8 @@ (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)) ) diff --git a/opcodes.scm b/opcodes.scm index cb2c28b..5ed8891 100644 --- a/opcodes.scm +++ b/opcodes.scm @@ -111,9 +111,13 @@ "") (if encode (string-append " value = " + ;; NOTE: ENCODE is either, e.g., + ;; ((value pc) (sra DI value 1)) + ;; or + ;; ((( value) ( pc)) (sra DI value 1)) (let ((expr (cadr encode)) - (value (caar encode)) - (pc (cadar encode))) + (value (if (symbol? (caar encode)) (caar encode) (cadr (caar encode)))) + (pc (if (symbol? (cadar encode)) (cadar encode) (cadr (cadar encode))))) (rtl-c DFLT expr (list (list value (obj:name (ifld-encode-mode self)) "value") (list pc 'IAI "pc")))) @@ -190,9 +194,13 @@ ");\n" (if decode (string-append " value = " + ;; NOTE: DECODE is either, e.g., + ;; ((value pc) (sll DI value 1)) + ;; or + ;; ((( value) ( pc)) (sll DI value 1)) (let ((expr (cadr decode)) - (value (caar decode)) - (pc (cadar decode))) + (value (if (symbol? (caar decode)) (caar decode) (cadr (caar decode)))) + (pc (if (symbol? (cadar decode)) (cadar decode) (cadr (cadar decode))))) (rtl-c DFLT expr (list (list value (obj:name (ifld-decode-mode self)) "value") (list pc 'IAI "pc")))) diff --git a/read.scm b/read.scm index 1eca982..b66a1a6 100644 --- a/read.scm +++ b/read.scm @@ -313,7 +313,7 @@ (define (parse-error context message expr . maybe-help-text) (if (not context) (set! context (make (current-reader-location) #f))) - (let* ((loc (context-location context)) + (let* ((loc (or (context-location context) (unspecified-location))) (top-sloc (location-top loc)) (prefix (context-prefix context))) (error diff --git a/utils-cgen.scm b/utils-cgen.scm index 2ee2a50..662b7a4 100644 --- a/utils-cgen.scm +++ b/utils-cgen.scm @@ -85,6 +85,7 @@ ;;; A single source location. ;;; This is recorded as a vector for simplicity. ;;; END? is true if the location marks the end of the expression. +;;; NOTE: LINE and COLUMN are origin-0 (the first line is line 0). (define (make-single-location file line column end?) (vector file line column end?) @@ -171,10 +172,12 @@ ) ;;; Return an unspecified . -;;; This is for use in debugging utilities. +;;; This is mainly for use in debugging utilities. +;;; Ideally for .cpu-file related stuff we always have a location, +;;; but that's not always true. (define (unspecified-location) - (make (list (cons "unspecified" 1))) + (make (list (make-single-location "unspecified" 0 0 #f))) ) ;;; Return a object for the current input port. -- 2.43.5