OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [iformat.scm] - Rev 7

Go to most recent revision | Compare with Previous | Blame | View Log

; Instruction formats.
; Copyright (C) 2000, 2009 Red Hat, Inc.
; This file is part of CGEN.
; See file COPYING.CGEN for details.
; Instruction formats are computed after the .cpu file has been read in.
; ??? May also wish to allow programmer to specify formats, but not sure this
; will complicate things more than it simplifies them, so it's defered.
;
; Two kinds of formats are defined here: iformat and sformat.
; (pronounced "I-format" and "S-format")
;
; Iformats are the instruction format as specified by the instructions' fields,
; and are the machine computed version of the generally known notion of an
; "instruction format".  No semantic information is attributed to iformats.
;
; Sformats are the same as iformats except that semantics are used to
; distinguish them.  For example, if an operand is refered to in one mode by
; one instruction and in a different mode by another instruction, then these
; two insns would have different sformats but the same iformat.  Sformats
; are used in simulator extraction code to collapse the number of cases that
; must be handled.  They can also be used to collapse the number of cases
; in the modeling code.
;
; The "base length" is the length of the insn that is initially fetched for
; decoding purposes.
; Formats are fixed in length.  For variable instruction length architectures
; there are separate formats for each insn's possible length.
; From <ident>:
; - NAME is derived from number, but we might have user
;   specified formats someday [though I wouldn't add them
;   without a clear need].
; - COMMENT is the assembler syntax of an example insn that
;   uses the format.
; Index into the iformat table.
; Sort key, used to determine insns with identical formats.
; List of <ifield> objects.
; min (insn-length, base-insn-size)
; total length of insns with this format
; mask of base part
; An example insn that uses the format.
; Accessor fns.
; Traverse the ifield list to collect all base (non-derived) ifields used in it.
; Return enum cgen_fmt_type value for FMT.
; ??? Not currently used.
"@CPU@_"; Given FLD-LIST, compute the length of the insn in bits.
; This is done by adding up all the field sizes.
; All bits must be represent exactly once.
; Given FLD-LIST, compute the base length in bits.
;
; For variable length instruction sets, or with cpus with multiple
; instruction sets, compute the base appropriate for this set of
; ifields.  Check that ifields are not shared among isas with
; inconsistent base insn lengths.
"ifields have inconsistent isa/base-insn-size values:"; Given FLD-LIST, compute the bitmask of constant values in the base part
; of the insn (i.e. the opcode field).
;
; FIXME: Need to add support for constant fields appearing outside the base
; insn.  One way would be to record with each insn the value for each constant
; field.  That would allow code to straightforwardly fetch it.  Another would
; be to only record constant values appearing outside the base insn.
;
; See also (insn-value).
;
; word-offset
; start
; length
; word-length
; Find the fields that have constant values.
; Return the <iformat> search key for a sorted field list.
; This determines how iformats differ from each other.
; It also speeds up searching as the search key can be anything
; (though at present searching isn't as fast as it could be).
; INSN is passed so that we can include its sanytize attribute, if present,
; so sanytized sources work (needed formats don't disappear).
" (""-nosan-"" "" "")"; Create an <iformat> object for INSN.
; INDEX is the ordinal to assign to the result or -1 if unknown.
; SEARCH-KEY is the search key used to determine the iformat's uniqueness.
; IFLDS is a sorted list of INSN's ifields.
"e.g. "; Sformats.
; From <ident>:
; - NAME is derived from number.
; - COMMENT is the assembler syntax of an example insn that
;   uses the format.
; Index into the sformat table.
; Sort key, used to determine insns with identical formats.
; Non-#f if insns with this format are cti insns.
; IN-OPS is a list of input operands.
; OUT-OPS is a list of output operands.
; These are used to distinguish the format from others,
; so that the extract and read operations can be based on the
; sformat.
; The extract fns use this data to record the necessary
; information for profiling [which isn't necessarily a property
; of the field list].  We could have one extraction function
; per instruction, but there's a *lot* of duplicated code, and
; the semantic operands rarely contribute to extra formats.
; The parallel execution support uses this data to record the
; input (or output) values based on the instruction format,
; again cutting down on duplicated code.
; Length of all insns with this format.
; Since insns with different iformats can have the same sformat
; we need to ensure ifield extraction works among the various
; iformats.  We do this by ensuring all insns with the same
; sformat have the same length.
; Cached list of all ifields used.
; This can be derived from IN-OPS/OUT-OPS but is computed once
; and cached here for speed.
; An example insn that uses the format.
; This is used for debugging purposes, but also to help get
; sanytization (spelled wrong on purpose) right.
; <sformat-argbuf> entry
; FIXME: Temporary location, to be moved elsewhere
; Accessor fns.
; Return the <sformat> search key for a sorted field list and semantic
; operands.
; This determines how sformats differ from each other.
; It also speeds up searching as the search key can be anything
; (though at present searching isn't as fast as it could be).
;
; INSN is passed so that we can include its sanytize attribute, if present,
; so sanytized sources work (needed formats don't disappear).
; SORTED-USED-IFLDS is a sorted list of ifields used by SEM-{IN,OUT}-OPS.
; Note that it is not the complete set of ifields used by INSN.
;
; We assume INSN's <iformat> has been recorded.
;
; Note: It's important to minimize the number of created sformats.  It keeps
; the generated code smaller (and sometimes faster - more usable common
; fragments in pbb simulators).  Don't cause spurious differences.
" (""-nosan-"" "; ??? Including memory operands currently
; isn't necessary and it can account for some
; spurious differences.  On the other hand
; leaving it out doesn't seem like the right
; thing to do.
""" "; CGEN_OPERAND_INSTANCE_COND_REF is stored
; with the operand in the operand instance
; table thus formats must be distinguished
; by this.
" cond"""")"" ("" "")"; Create an <sformat> object for INSN.
; INDEX is the ordinal to assign to the result or -1 if unknown.
; SEARCH-KEY is the search key used to determine the sformat's uniqueness.
; {IN,OUT}-OPS are lists of INSN's input/output operands.
; SORTED-USED-IFLDS is a sorted list of ifields used by {IN,OUT}-OPS.
; Note that it is not the complete set of ifields used by INSN.
;
; We assume INSN's <iformat> has already been recorded.
"e.g. "; Sort IFLDS by dependencies and then by starting bit number.
; ??? Something like this is preferable.
;(not (ifld-lsb0? (car ifld-list)))
; FIXME: quick hack.
; Return a sorted list of ifields used by IN-OPS, OUT-OPS.
; The ifields are sorted by dependencies and then by start bit.
; The important points are to help distinguish sformat's by the ifields used
; and to put ifields that others depend on first.
; The format descriptor is used to sort formats.
; This is a utility class internal to this file.
; There is one instance per insn.
; #t if insn is a cti insn
; sorted list of insn's ifields
; computed set of input/output operands
; set of ifields used by IN-OPS,OUT-OPS.
; computed set of attributes
; Accessors.
; Compute an iformat descriptor used to build an <iformat> object for INSN.
;
; If COMPUTE-SFORMAT? is #t compile the semantics and compute the semantic
; format (same as instruction format except that operands are used to
; distinguish insns).
; Attributes derivable from the semantics are also computed.
; This is all done at the same time to minimize the number of times the
; semantic code is traversed.
;
; The result is (descriptor compiled-semantics attrs).
; `descriptor' is #f for insns with an empty field list
; (this happens for virtual insns).
; `compiled-semantics' is #f if COMPUTE-SFORMAT? is #f.
; `attrs' is an <attr-list> object of attributes derived from the semantics.
;
; ??? We never traverse the semantics of virtual insns.
; First sort by starting bit number the list of fields in INSN.
; ??? Something like this is preferable, but
; if the first insn is a virtual insn there are
; no fields.
;(not (ifld-lsb0? (car (insn-iflds insn))))
; Field list is unspecified.
; FIXME: error checking (e.g. missing or overlapping bits)
; Compute list of input and output operands if asked for.
; FIXME: context
; FIXME: context
; Subroutine of ifmt-compute!, to simplify it.
; Lookup INSN's iformat in IFMT-LIST and if not found add it.
; FMT-DESC is INSN's <fmt-desc> object.
; IFMT-LIST is append!'d to and the found iformat is stored in INSN.
; Format was found, use it.
"Using iformat "".\n"; Format wasn't found, create new entry.
"Creating iformat "".\n"; Subroutine of ifmt-compute!, to simplify it.
; Lookup INSN's sformat in SFMT-LIST and if not found add it.
; FMT-DESC is INSN's <fmt-desc> object.
; SFMT-LIST is append!'d to and the found sformat is stored in INSN.
;
; We assume INSN's <iformat> has already been recorded.
; Format was found, use it.
"Using sformat "".\n"; Format wasn't found, create new entry.
"Creating sformat "".\n"; Main entry point.
; Given a list of insns, compute the set of instruction formats, semantic
; formats, semantic attributes, and compiled semantics for each insn.
;
; The computed <iformat> object is stored in the `ifmt' field of each insn.
;
; Attributes derived from the semantic code are added to the insn's attributes,
; but they don't override any prespecified values.
;
; If COMPUTE-SFORMAT? is #t, the computed <sformat> object is stored in the
; `sfmt' field of each insn, and the processed semantic code is stored in the
; `compiled-semantics' field of each insn.
;
; The `fmt-desc' field of each insn is used to store an <fmt-desc> object
; which contains the search keys, sorted field list, input-operands, and
; output-operands, and is not used outside this procedure.
;
; The result is a list of two lists: the set of computed iformats, and the
; set of computed sformats.
;
; *** This is the most expensive calculation in CGEN.   ***
; *** (mainly because of the detailed semantic parsing) ***
"Computing instruction formats and analyzing semantics ...\n"; First analyze each insn, storing the result in fmt-desc.
; If asked to, convert the semantic code to a compiled form to simplify more
; intelligent processing of it later.
"Scanning operands of "": "" ...\n"; Now for each insn, look up the ifield list in the format table (and if not
; found add it), and set the ifmt/sfmt elements of the insn.
"empty iformat for unspecified field list"; attrs
; number
; key
; fields
; mask-length
; length
; mask
; eg-insn
"empty sformat for unspecified field list"; attrs
; number
; key
; cti?
; sem-in-ops
; sem-out-ops
; length
; used iflds
; eg-insn
"Processing format for "": "" ...\n"; Must compute <iformat> before <sformat>, the latter
; needs the former.
; No field list present, use empty format.
; Done.  Return the computed iformat and sformat lists.
 

Go to most recent revision | Compare with Previous | Blame | View Log

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.