From b3318992a2c8713e3aab26facb24a0233f2bbce4 Mon Sep 17 00:00:00 2001 From: devans Date: Thu, 28 Jan 2010 05:29:04 +0000 Subject: [PATCH] * mach.scm: Follow commenting convention. --- cgen/ChangeLog | 1 + cgen/mach.scm | 762 ++++++++++++++++++++++++++++----------------------------- 2 files changed, 382 insertions(+), 381 deletions(-) diff --git a/cgen/ChangeLog b/cgen/ChangeLog index ee9e7c439d..94e070f92b 100644 --- a/cgen/ChangeLog +++ b/cgen/ChangeLog @@ -1,6 +1,7 @@ 2010-01-27 Doug Evans * read.scm: Follow commenting convention. + * mach.scm: Follow commenting convention. * pmacros.scm: Follow commenting convention. Replace change to $pmacro to %pmacro. $pmacro is confusing with $ in assembler syntax. diff --git a/cgen/mach.scm b/cgen/mach.scm index cd4dec51fb..f54e90f8d2 100644 --- a/cgen/mach.scm +++ b/cgen/mach.scm @@ -1,17 +1,17 @@ -; CPU architecture description. -; Copyright (C) 2000, 2003, 2009 Red Hat, Inc. -; This file is part of CGEN. -; See file COPYING.CGEN for details. +;; CPU architecture description. +;; Copyright (C) 2000, 2003, 2009 Red Hat, Inc. +;; This file is part of CGEN. +;; See file COPYING.CGEN for details. -; Top level class that records everything about a cpu. -; FIXME: Rename this to something else and rename to -; for consistency with other classes (define-foo -> object). +;; Top level class that records everything about a cpu. +;; FIXME: Rename this to something else and rename to +;; for consistency with other classes (define-foo -> object). (define (class-make ' nil '( - ; An object of type . + ;; An object of type . data ;; ??? All should really be assumed to be a black-box table. @@ -31,30 +31,30 @@ (minsn-table . ()) (subr-list . ()) - (insn-extract . #f) ; FIXME: wip (and move elsewhere) - (insn-execute . #f) ; FIXME: wip (and move elsewhere) + (insn-extract . #f) ;; FIXME: wip (and move elsewhere) + (insn-execute . #f) ;; FIXME: wip (and move elsewhere) - ; standard values derived from the input data + ;; standard values derived from the input data derived - ; #t if multi-insns have been instantiated + ;; #t if multi-insns have been instantiated (multi-insns-instantiated? . #f) - ; #t if instructions have been analyzed + ;; #t if instructions have been analyzed (insns-analyzed? . #f) - ; #t if semantics were included in the analysis + ;; #t if semantics were included in the analysis (semantics-analyzed? . #f) - ; #t if alias insns were included in the analysis + ;; #t if alias insns were included in the analysis (aliases-analyzed? . #f) - ; ordinal of next object that needs one + ;; ordinal of next object that needs one (next-ordinal . 0) ) nil) ) -; Accessors. -; Each getter is arch-foo. -; Each setter is arch-set-foo!. +;; Accessors. +;; Each getter is arch-foo. +;; Each setter is arch-set-foo!. (define-getters arch (data @@ -82,8 +82,8 @@ ) ) -; For elements recorded as a table, return a sorted list. -; ??? All elements should really be assumed to be a black-box table. +;; For elements recorded as a table, return a sorted list. +;; ??? All elements should really be assumed to be a black-box table. (define (arch-ifld-list arch) (/ident-object-table->list (arch-ifld-table arch)) @@ -199,35 +199,35 @@ (hashq-ref iot key) ) -; Class for recording things specified in `define-arch'. -; This simplifies define-arch as the global arch object CURRENT-ARCH -; must exist before loading the .cpu file. +;; Class for recording things specified in `define-arch'. +;; This simplifies define-arch as the global arch object CURRENT-ARCH +;; must exist before loading the .cpu file. (define (class-make ' '() '( - ; Default alignment of memory operations. - ; One of aligned, unaligned, forced. + ;; Default alignment of memory operations. + ;; One of aligned, unaligned, forced. default-alignment - ; Orientation of insn bit numbering (#f->msb=0, #t->lsb=0). + ;; Orientation of insn bit numbering (#f->msb=0, #t->lsb=0). insn-lsb0? - ; List of all machs. - ; Each element is pair of (mach-name . sanitize-key) - ; where sanitize-key is #f if there is none. - ; blah blah blah ... ooohhh, evil sanitize key, blah blah blah + ;; List of all machs. + ;; Each element is pair of (mach-name . sanitize-key) + ;; where sanitize-key is #f if there is none. + ;; blah blah blah ... ooohhh, evil sanitize key, blah blah blah machs - ; List of all isas (instruction set architecture). - ; Each element is a pair of (isa-name . sanitize-key) - ; where sanitize-key is #f if there is none. - ; There is usually just one. ARM has two (arm, thumb). - ; blah blah blah ... ooohhh, evil sanitize key, blah blah blah + ;; List of all isas (instruction set architecture). + ;; Each element is a pair of (isa-name . sanitize-key) + ;; where sanitize-key is #f if there is none. + ;; There is usually just one. ARM has two (arm, thumb). + ;; blah blah blah ... ooohhh, evil sanitize key, blah blah blah isas - ; ??? Defaults for other things should be here. + ;; ??? Defaults for other things should be here. ) nil) ) @@ -236,10 +236,10 @@ (default-alignment insn-lsb0? machs isas) ) -; Add, list, lookup accessors for . -; -; For the lookup routines, the result is the object or #f if not found. -; For some, if X is already an object, return that. +;; Add, list, lookup accessors for . +;; +;; For the lookup routines, the result is the object or #f if not found. +;; For some, if X is already an object, return that. (define (current-arch-name) (obj:name (arch-data CURRENT-ARCH))) @@ -261,24 +261,24 @@ (map car (adata-isas (arch-data CURRENT-ARCH))) ) -; Attributes. -; Recorded as a pair of lists. -; The car is a list of objects. -; The cdr is an associative list of (name . ) elements, for lookup. -; Could use a hash table except that there currently aren't that many. +;; Attributes. +;; Recorded as a pair of lists. +;; The car is a list of objects. +;; The cdr is an associative list of (name . ) elements, for lookup. +;; Could use a hash table except that there currently aren't that many. (define (current-attr-list) (car (arch-attr-list CURRENT-ARCH))) (define (current-attr-add! a) - ; NOTE: While putting this test in define-attr feels better, having it here - ; is more robust, internal calls get checked too. Thus it's here. - ; Ditto for all the other such tests in this file. + ;; NOTE: While putting this test in define-attr feels better, having it here + ;; is more robust, internal calls get checked too. Thus it's here. + ;; Ditto for all the other such tests in this file. (if (current-attr-lookup (obj:name a)) (parse-error (make-current-context "define-attr") "attribute already defined" (obj:name a))) (let ((adata (arch-attr-list CURRENT-ARCH))) - ; Build list in normal order so we don't have to reverse it at the end - ; (since our format is non-trivial). + ;; Build list in normal order so we don't have to reverse it at the end + ;; (since our format is non-trivial). (if (null? (car adata)) (arch-set-attr-list! CURRENT-ARCH (cons (cons a nil) @@ -293,7 +293,7 @@ (assq-ref (cdr (arch-attr-list CURRENT-ARCH)) attr-name) ) -; Enums. +;; Enums. (define (current-enum-list) (arch-enum-list CURRENT-ARCH)) @@ -309,7 +309,7 @@ (object-assq enum-name (current-enum-list)) ) -; Keywords. +;; Keywords. (define (current-kw-list) (arch-kw-list CURRENT-ARCH)) @@ -325,7 +325,7 @@ (object-assq kw-name (current-kw-list)) ) -; Instruction sets. +;; Instruction sets. (define (current-isa-list) (arch-isa-list CURRENT-ARCH)) @@ -355,7 +355,7 @@ obj-list)) ) -; Cpu families. +;; Cpu families. (define (current-cpu-list) (arch-cpu-list CURRENT-ARCH)) @@ -371,7 +371,7 @@ (object-assq cpu-name (current-cpu-list)) ) -; Machines. +;; Machines. (define (current-mach-list) (arch-mach-list CURRENT-ARCH)) @@ -387,7 +387,7 @@ (object-assq mach-name (current-mach-list)) ) -; Models. +;; Models. (define (current-model-list) (arch-model-list CURRENT-ARCH)) @@ -420,8 +420,8 @@ (define (current-hw-lookup hw) (if (object? hw) hw - ; This doesn't use object-assq on purpose. Hardware objects handle - ; get-name specially. + ;; This doesn't use object-assq on purpose. Hardware objects handle + ;; get-name specially. (find-first (lambda (hw-obj) (eq? (send hw-obj 'get-name) hw)) (current-hw-list))) ) @@ -470,15 +470,15 @@ #f))) ) -; Return a boolean indicating if F is currently defined. -; This is slightly complicated because multiple isas can have different -; ifields with the same name. +;; Return a boolean indicating if F is currently defined. +;; This is slightly complicated because multiple isas can have different +;; ifields with the same name. (define (/ifld-already-defined? f) (let ((iflds (/ident-object-table-lookup (car (arch-ifld-table CURRENT-ARCH)) (obj:name f)))) - ; We've got all the ifields with the same name, - ; now see if any have the same ISA as F. + ;; We've got all the ifields with the same name, + ;; now see if any have the same ISA as F. (if iflds (let ((result #f) (f-isas (obj-isa-list f))) @@ -529,15 +529,15 @@ #f)) ) -; Return a boolean indicating if OP is currently defined. -; This is slightly complicated because multiple isas can have different -; operands with the same name. +;; Return a boolean indicating if OP is currently defined. +;; This is slightly complicated because multiple isas can have different +;; operands with the same name. (define (/op-already-defined? op) (let ((ops (/ident-object-table-lookup (car (arch-op-table CURRENT-ARCH)) (obj:name op)))) - ; We've got all the operands with the same name, - ; now see if any have the same ISA as OP. + ;; We've got all the operands with the same name, + ;; now see if any have the same ISA as OP. (if ops (let ((result #f) (op-isas (obj-isa-list op))) @@ -549,12 +549,12 @@ #f)) ) -; Instruction field formats. +;; Instruction field formats. (define (current-ifmt-list) (arch-ifmt-list CURRENT-ARCH)) -; Semantic formats (akin to ifmt's, except includes semantics to distinguish -; insns). +;; Semantic formats (akin to ifmt's, except includes semantics to distinguish +;; insns). (define (current-sfmt-list) (arch-sfmt-list CURRENT-ARCH)) @@ -594,15 +594,15 @@ #f)) ) -; Return a boolean indicating if INSN is currently defined. -; This is slightly complicated because multiple isas can have different -; insns with the same name. +;; Return a boolean indicating if INSN is currently defined. +;; This is slightly complicated because multiple isas can have different +;; insns with the same name. (define (/insn-already-defined? insn) (let ((insns (/ident-object-table-lookup (car (arch-insn-table CURRENT-ARCH)) (obj:name insn)))) - ; We've got all the insns with the same name, - ; now see if any have the same ISA as INSN. + ;; We've got all the insns with the same name, + ;; now see if any have the same ISA as INSN. (if insns (let ((result #f) (insn-isas (obj-isa-list insn))) @@ -650,15 +650,15 @@ #f)) ) -; Return a boolean indicating if MINSN is currently defined. -; This is slightly complicated because multiple isas can have different -; macro-insns with the same name. +;; Return a boolean indicating if MINSN is currently defined. +;; This is slightly complicated because multiple isas can have different +;; macro-insns with the same name. (define (/minsn-already-defined? m) (let ((minsns (/ident-object-table-lookup (car (arch-minsn-table CURRENT-ARCH)) (obj:name m)))) - ; We've got all the macro-insns with the same name, - ; now see if any have the same ISA as M. + ;; We've got all the macro-insns with the same name, + ;; now see if any have the same ISA as M. (if minsns (let ((result #f) (m-isas (obj-isa-list m))) @@ -670,7 +670,7 @@ #f)) ) -; rtx subroutines. +;; rtx subroutines. (define (current-subr-list) (map cdr (arch-subr-list CURRENT-ARCH))) @@ -687,9 +687,9 @@ (assq-ref (arch-subr-list CURRENT-ARCH) name) ) -; Arch parsing support. +;; Arch parsing support. -; Parse an alignment spec. +;; Parse an alignment spec. (define (/arch-parse-alignment context alignment) (if (memq alignment '(aligned unaligned forced)) @@ -697,16 +697,16 @@ (parse-error context "invalid alignment" alignment)) ) -; Parse an arch mach spec. -; The value is a list of mach names or (mach-name sanitize-key) elements. -; The result is a list of (mach-name . sanitize-key) elements. +;; Parse an arch mach spec. +;; The value is a list of mach names or (mach-name sanitize-key) elements. +;; The result is a list of (mach-name . sanitize-key) elements. (define (/arch-parse-machs context machs) (for-each (lambda (m) (if (or (symbol? m) (and (list? m) (= (length m) 2) (symbol? (car m)) (symbol? (cadr m)))) - #t ; ok + #t ;; ok (parse-error context "bad arch mach spec" m))) machs) (map (lambda (m) @@ -716,16 +716,16 @@ machs) ) -; Parse an arch isa spec. -; The value is a list of isa names or (isa-name sanitize-key) elements. -; The result is a list of (isa-name . sanitize-key) elements. +;; Parse an arch isa spec. +;; The value is a list of isa names or (isa-name sanitize-key) elements. +;; The result is a list of (isa-name . sanitize-key) elements. (define (/arch-parse-isas context isas) (for-each (lambda (m) (if (or (symbol? m) (and (list? m) (= (length m) 2) (symbol? (car m)) (symbol? (cadr m)))) - #t ; ok + #t ;; ok (parse-error context "bad arch isa spec" m))) isas) (map (lambda (m) @@ -735,10 +735,10 @@ isas) ) -; Parse an architecture description -; This is the main routine for building an arch object from a cpu -; description in the .cpu file. -; All arguments are in raw (non-evaluated) form. +;; Parse an architecture description +;; This is the main routine for building an arch object from a cpu +;; description in the .cpu file. +;; All arguments are in raw (non-evaluated) form. (define (/arch-parse context name comment attrs default-alignment insn-lsb0? @@ -754,15 +754,15 @@ (/arch-parse-isas context isas)) ) -; Read an architecture description. -; This is the main routine for analyzing an arch description in the .cpu file. -; ARG-LIST is an associative list of field name and field value. -; parse-arch is invoked to create the `arch' object. +;; Read an architecture description. +;; This is the main routine for analyzing an arch description in the .cpu file. +;; ARG-LIST is an associative list of field name and field value. +;; parse-arch is invoked to create the `arch' object. (define /arch-read (lambda arg-list (let ((context "arch-read") - ; object members and default values + ;; object members and default values (name "unknown") (comment "") (attrs nil) @@ -771,7 +771,7 @@ (machs #f) (isas #f) ) - ; Loop over each element in ARG-LIST, recording what's found. + ;; Loop over each element in ARG-LIST, recording what's found. (let loop ((arg-list arg-list)) (if (null? arg-list) nil @@ -787,19 +787,19 @@ ((isas) (set! isas (cdr arg))) (else (parse-error context "invalid arch arg" arg))) (loop (cdr arg-list))))) - ; Ensure required fields are present. + ;; Ensure required fields are present. (if (not machs) (parse-error context "missing machs spec")) (if (not isas) (parse-error context "missing isas spec")) - ; Now that we've identified the elements, build the object. + ;; Now that we've identified the elements, build the object. (/arch-parse context name comment attrs default-alignment insn-lsb0? machs isas) ) ) ) -; Define an arch object, name/value pair list version. +;; Define an arch object, name/value pair list version. (define define-arch (lambda arg-list @@ -809,16 +809,16 @@ (keep-mach-validate!) (def-isa-attr! (adata-isas a)) (keep-isa-validate!) - ; Install the builtin objects now that we have an arch, and now that - ; attributes MACH and ISA exist. + ;; Install the builtin objects now that we have an arch, and now that + ;; attributes MACH and ISA exist. (reader-install-builtin!) a)) ) -; Mach/isa processing. +;; Mach/isa processing. -; Create the MACH attribute. -; MACHS is the canonicalized machs spec to define-arch: (name . sanitize-key). +;; Create the MACH attribute. +;; MACHS is the canonicalized machs spec to define-arch: (name . sanitize-key). (define (def-mach-attr! machs) (let ((mach-enums (append @@ -839,23 +839,23 @@ *UNSPECIFIED* ) -; Return #t if MACH is supported by OBJ. -; This is done by looking for the MACH attribute in OBJ. -; By definition, objects that support the default (base) mach support -; all machs. +;; Return #t if MACH is supported by OBJ. +;; This is done by looking for the MACH attribute in OBJ. +;; By definition, objects that support the default (base) mach support +;; all machs. (define (mach-supports? mach obj) (let ((machs (obj-attr-value obj 'MACH)) (name (obj:name mach))) (or (memq name machs) (memq 'base machs))) - ;(let ((deflt (attr-lookup-default 'MACH obj))) - ; (any-true? (map (lambda (m) (memq m deflt)) machs))))) + ;;(let ((deflt (attr-lookup-default 'MACH obj))) + ;; (any-true? (map (lambda (m) (memq m deflt)) machs))))) ) -; Create the ISA attribute. -; ISAS is the canonicalized isas spec to define-arch: (name . sanitize-key). -; ISAS is a list of isa names. +;; Create the ISA attribute. +;; ISAS is the canonicalized isas spec to define-arch: (name . sanitize-key). +;; ISAS is a list of isa names. (define (def-isa-attr! isas) (let ((isa-enums (append @@ -869,8 +869,8 @@ '((max))))) (define-attr '(type bitset) '(name ISA) '(comment "instruction set selection") - ; If there's only one isa, don't (yet) pollute the tables with a value - ; for it. + ;; If there's only one isa, don't (yet) pollute the tables with a value + ;; for it. (if (= (length isas) 1) '(for) '(for ifield operand insn hardware)) @@ -881,33 +881,33 @@ *UNSPECIFIED* ) -; Return the bitset attr value for all isas. +;; Return the bitset attr value for all isas. (define (all-isas-attr-value) (current-arch-isa-name-list) ) -; Return an ISA attribute of all isas. -; This is useful for things like f-nil which exist across all isas. +;; Return an ISA attribute of all isas. +;; This is useful for things like f-nil which exist across all isas. (define (all-isas-attr) (bitset-attr-make 'ISA (all-isas-attr-value)) ) -; Return list of ISA names specified by attribute object ATLIST. +;; Return list of ISA names specified by attribute object ATLIST. (define (attr-isa-list atlist) (atlist-attr-value atlist 'ISA #f) ) -; Return list of ISA names specified by OBJ. +;; Return list of ISA names specified by OBJ. (define (obj-isa-list obj) (obj-attr-value obj 'ISA) ) -; Return #t if ISA is supported by OBJ. -; This is done by looking for the ISA attribute in OBJ. +;; Return #t if ISA is supported by OBJ. +;; This is done by looking for the ISA attribute in OBJ. (define (isa-supports? isa obj) (let ((isas (obj-isa-list obj)) @@ -915,132 +915,132 @@ (->bool (memq name isas))) ) -; The fetch/decode/execute process. -; "extract" is a fancy word for fetch/decode. -; FIXME: wip, not currently used. -; FIXME: move to inside define-isa, and maybe elsewhere. -; +;; The fetch/decode/execute process. +;; "extract" is a fancy word for fetch/decode. +;; FIXME: wip, not currently used. +;; FIXME: move to inside define-isa, and maybe elsewhere. +;; ;(defmacro -; define-extract (code) -; ;(arch-set-insn-extract! CURRENT-ARCH code) -; *UNSPECIFIED* +;; define-extract (code) +;; ;;(arch-set-insn-extract! CURRENT-ARCH code) +;; *UNSPECIFIED* ;) -; +;; ;(defmacro -; define-execute (code) -; ;(arch-set-insn-execute! CURRENT-ARCH code) -; *UNSPECIFIED* -;) +;; define-execute (code) +;; ;;(arch-set-insn-execute! CURRENT-ARCH code) +;; *UNSPECIFIED* +;;) -; ISA specification. -; Each architecture is generally one isa, but in the case of ARM (and a few -; others) there is more than one. -; -; ??? "ISA" has a very well defined meaning, and our usage of it one might -; want to quibble over. A better name would be welcome. - -; Associated with an instruction set is its framing. -; This refers to how instructions are laid out at the liw level (where several -; insns are framed together and executed sequentially or in parallel). -; ??? If one defines the term "format" as being how an individual instruction -; is laid out then formatting can be thought of as being different from -; framing. However, it's possible for a particular ISA to intertwine the two. -; Thus this will need to evolve. -; ??? Not used yet, wip. - -(define