;
; An insn format field is a list of ifields that make up the instruction.
; All bits must be specified, including reserved bits
-; [at present no checking is made of this, but the rule still holds].
+; [at present little checking is made of this, but the rule still holds].
;
; A normal entry begins with `+' and then consist of the following:
; - operand name
(not (ifld-beyond-base? f)))
(ifields-simple-ifields parsed-ifld-list)))
(base-iflds-length (apply + (map ifld-length base-iflds))))
+
;; FIXME: We don't use parse-error here because some existing ports
;; have problems, and I don't have time to fix them right now.
(cond ((< base-iflds-length base-len)
(pretty-print-iflds parsed-ifld-list)
"\nprovided spec")
ifld-list)))
+
+ ;; Detect duplicate ifields.
+ (if (!= (length base-iflds)
+ (length (obj-list-nub base-iflds)))
+ (parse-error-continuable context
+ "duplicate ifields present"
+ ifld-list))
)
))
":")))
)
-;;; Subroutine of parse-error, parse-warning to simplify them.
-;;; Flag an error or a warning.
-;;; EMITTER is a function of one argument, the message to print.
+;; Subroutine of parse-error, parse-warning to simplify them.
+;; Flag an error or a warning.
+;; EMITTER is a function of one argument, the message to print.
(define (/parse-diagnostic emitter context message expr maybe-help-text)
(if (not context)
""))))
)
-;;; Signal a parse error while reading a .cpu file.
-;;; If CONTEXT is #f, use a default context of the current reader location
-;;; and an empty prefix.
-;;; If MAYBE-HELP-TEXT is specified, elide the last trailing \n.
-;;; Multiple lines of help text need embedded newlines, and should be no longer
-;;; than 79 characters.
+;; Signal a parse error while reading a .cpu file.
+;; Processing stops immediately.
+;; If CONTEXT is #f, use a default context of the current reader location
+;; and an empty prefix.
+;; If MAYBE-HELP-TEXT is specified, elide the last trailing \n.
+;; Multiple lines of help text need embedded newlines, and should be no longer
+;; than 79 characters.
(define (parse-error context errmsg expr . maybe-help-text)
(/parse-diagnostic error
(if (null? maybe-help-text) "" (car maybe-help-text)))
)
-;;; Signal a parse warning while reading a .cpu file.
-;;; If CONTEXT is #f, use a default context of the current reader location
-;;; and an empty prefix.
-;;; If MAYBE-HELP-TEXT is specified, elide the last trailing \n.
-;;; Multiple lines of help text need embedded newlines, and should be no longer
-;;; than 79 characters.
+;; Same as parse-error, but continue processing.
+
+(define (parse-error-continuable context errmsg expr . maybe-help-text)
+ (set! /continuable-error-found? #t)
+ (/parse-diagnostic (lambda (text) (message "Error: " text "\n"))
+ context
+ errmsg
+ expr
+ (if (null? maybe-help-text) #f (car maybe-help-text)))
+)
+
+;; Signal a parse warning while reading a .cpu file.
+;; If CONTEXT is #f, use a default context of the current reader location
+;; and an empty prefix.
+;; If MAYBE-HELP-TEXT is specified, elide the last trailing \n.
+;; Multiple lines of help text need embedded newlines, and should be no longer
+;; than 79 characters.
(define (parse-warning context errmsg expr . maybe-help-text)
(/parse-diagnostic (lambda (text) (message "Warning: " text "\n"))
\f
; .cpu file loader support
+;; #t if an error was found (but processing continued)
+(define /continuable-error-found? #f)
+
;; Initialize a new <reader> object.
;; This doesn't add cgen-specific commands, leaving each element (ifield,
;; hardware, etc.) to add their own.
(set! /CGEN-RTL-VERSION /default-rtl-version)
+ (set! /continuable-error-found? #f)
+
(reader-add-command! 'define-rtl-version
"Specify the RTL version being used.\n"
nil '(major minor) /cmd-define-rtl-version)
*UNSPECIFIED*
)
+;; Called at the end of .cpu file loading.
+
+(define (/finish-reader! file)
+ (if /continuable-error-found?
+ (error (string-append "Error loading " file)))
+ *UNSPECIFIED*
+)
+
; Prepare to parse a .cpu file.
; This initializes the application independent tables.
; KEEP-MACH specifies what machs to keep.
(logit 1 "diags: " diagnostic-options "\n")
(set! arch-path (dirname file))
(reader-read-file! file)
- (logit 2 "Processing cpu description " file " ...\n")
(/finish-parse-cpu!)
+ (/finish-reader! file)
+ (logit 1 "Processing cpu description " file " ...\n")
(app-finisher!)
(/global-error-checks)
(analyzer!)