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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [semantics.scm] - Rev 6

Compare with Previous | Blame | View Log

; Routines for instruction semantic analysis.
; Copyright (C) 2000, 2009 Red Hat, Inc.
; This file is part of CGEN.
; See file COPYING.CGEN for details.
;
; Semantic expression compilation.
; This is more involved than normal rtx compilation as we need to keep
; track of the inputs and outputs.  Various attributes that can be derived
; from the code are also computed.
; Subroutine of -rtx-find-op to determine if two modes are equivalent.
; Two modes are equivalent if they're equal, or if their sem-mode fields
; are equal.
; Subroutine of semantic-compile to find OP in OP-LIST.
; OP-LIST is a list of operand expressions: (type expr mode name indx-sel).
; The result is the list element or #f if not found.
; TYPE is one of -op- reg mem.
; EXPR is the constructed `xop' rtx expression for the operand,
;   ignored in the search.
; MODE must match, as defined by -rtx-mode-equiv?.
; NAME is the hardware element name, ifield name, or '-op-'.
; INDX-SEL must match if present in either.
;
; ??? Does this need to take "conditionally-referenced" into account?
; The first cdr is to drop the dummy first arg.
; Subroutine of semantic-compile to determine how the operand in
; position OP-POS of EXPR is used.
; The result is one of 'use, 'set, 'set-quiet.
; "use" means "input operand".
; operand 0 is the option list, operand 1 is the mode
; (if you want to complain, fine, it's not like it would be unexpected)
; Subroutine of semantic-compile:process-expr!, to simplify it.
; Looks up the operand in the current set, returns it if found,
; otherwise adds it.
; REF-TYPE is one of 'use, 'set, 'set-quiet.
; Adds COND-CTI/UNCOND-CTI to SEM-ATTRS if the operand is a set of the pc.
;(display (list op-name mode ref-type)) (newline) (force-output)
; The first #f is a placeholder for the object.
; If already present, return the object, otherwise add it.
; We can't set the operand number yet 'cus we don't know it.
; However, when it's computed we'll need to set all associated
; operands.  This is done by creating shared rtx (a la gcc) - the
; operand number then need only be updated in one place.
; Set the object rtx in `try', now that we have it.
; Add the operand to in/out-ops.
; Subroutine of semantic-compile:process-expr!, to simplify it.
; If the mode is DFLT, use the object's natural mode.
; #f is a place-holder for the object (filled in later)
; If already present, return the object, otherwise add it.
; Set the object rtx in `try', now that we have it.
; Add the operand to in/out-ops.
"unknown reg"; Subroutine of semantic-compile:process-expr!, to simplify it.
"memory must have explicit mode"; If already present, return the object, otherwise add it.
; Set the object in `try', now that we have it.
; Add the operand to in/out-ops.
; Subroutine of semantic-compile:process-expr!, to simplify it.
"unknown ifield"; If already present, return the object, otherwise add it.
; Subroutine of semantic-compile:process-expr!, to simplify it.
;
; ??? There are various optimizations (both space usage in ARGBUF and time
; spent in semantic code) that can be done on code that uses index-of
; (see i960's movq insn).  Later.
"only `(index-of operand)' is currently supported""only ifield indices are currently supported"; The rest of this is identical to -build-ifield-operand!.
; If already present, return the object, otherwise add it.
; (send (op:type op) 'get-index-mode)
; Build the tstate known value list for INSN.
; This is built from the ifield-assertion list.
; Structure to record the result of semantic-compile.
; Accessors.
; Traverse each element in SEM-CODE, converting them to canonical form,
; and computing the input and output operands.
; The result is an object of four elements (built with csem-make).
; The first is a list of the canonical form of each element in SEM-CODE:
; operand and ifield elements specified without `operand' or `ifield' have it
; prepended, and operand numbers are computed for each operand.
; Operand numbers are needed when emitting "write" handlers for LIW cpus.
; Having the operand numbers available is also useful for efficient
; modeling: recording operand references can be done with a bitmask (one host
; insn), and the code to do the modeling can be kept out of the code that
; performs the insn.
; The second is the list of input <operand> objects.
; The third is the list of output <operand> objects.
; The fourth is an <attr-list> object of attributes that can be computed from
; the semantics.
; The possibilities are: UNCOND-CTI, COND-CTI, SKIP-CTI, DELAY-SLOT.
; ??? Combine *-CTI into an enum attribute.
;
; CONTEXT is a <context> object or #f if there is none.
; INSN is the <insn> object.
;
; ??? Specifying operand ordinals in the source would simplify this and speed
; it up.  On the other hand that makes the source form more complex.  Maybe the
; complexity will prove necessary, but following the goal of "incremental
; complication", we don't do this yet.
; Another way to simplify this and speed it up would be to add lists of
; input/output operands to the instruction description.
;
; ??? This calls rtx-simplify which calls rtx-traverse as it's simpler to
; simplify EXPR first, and then compile it.  On the other hand it's slower
; (two calls to rtx-traverse!).
; These record the result of traversing SEM-CODE.
; They're lists of (type object mode name [args ...]).
; TYPE is one of: -op- reg mem.
; `-op-' is just something unique and is only used internally.
; OBJECT is the constructed <operand> object.
; The first element is just a dummy so that append! always works.
; List of attributes computed from SEM-CODE.
; The first element is just a dummy so that append! always works.
; Called for expressions encountered in SEM-CODE.
; Don't waste cpu here, this is part of the slowest piece in CGEN.
; Registers.
; ??? could verify reg is a scalar
; The register number is either a number or an
; expression.
; ??? This is a departure from GCC RTL that might have
; significant ramifications.  On the other hand in cases
; where it matters the expression could always be
; required to reduce to a constant (or some such).
"invalid register number"; Memory.
; Operands.
; Give operand new name.
"name: invalid argument:"; (op:set-num! result (caddr expr))
; Specify a reference to a local variable
; nothing to do
; Instruction fields.
"can't set an `ifield'"; Hardware indices.
; For registers this is the register number.
; For memory this is the address.
; For constants, this is the constant.
"can't set an `index-of'"; Machine generate the SKIP-CTI attribute.
; Machine generate the DELAY-SLOT attribute.
; If this is a syntax expression, the operands won't have been
; processed, so tell our caller we want it to by returning #f.
; We do the same for non-syntax expressions to keep things
; simple.  This requires collaboration with the traversal
; handlers which are defined to do what we want if we return #f.
; Whew.  We're now ready to traverse the expression.
; Traverse the expression recording the operands and building objects
; for most elements in the source representation.
; This also performs various simplifications.
; In particular machine dependent code for non-selected machines
; is discarded.
;(display "in:  ") (display in-ops) (newline)
;(display "out: ") (display out-ops) (newline)
;(force-output)
; Now that we have the nub of all input and output operands,
; we can assign operand numbers.  Inputs and outputs are not defined
; separately, output operand numbers follow inputs.  This simplifies the
; code which keeps track of such things: it can use one variable.
; The assignment is defined to be arbitrary.  If there comes a day
; when we need to prespecify operand numbers, revisit.
; The operand lists are sorted to avoid spurious differences in generated
; code (for example unnecessary extra entries can be created in the
; ARGBUF struct).
; Drop dummy first arg and sort operand lists.
"  "" ""\n""Input operands:\n""Output operands:\n""End of operands.\n"""; Traverse SEM-CODE, computing attributes derivable from it.
; The result is an <attr-list> object of attributes that can be computed from
; the semantics.
; The possibilities are: UNCOND-CTI, COND-CTI, SKIP-CTI, DELAY-SLOT.
; This computes the same values as semantic-compile, but for speed is
; focused on attributes only.
; ??? Combine *-CTI into an enum attribute.
;
; CONTEXT is a <context> object or #f if there is none.
; INSN is the <insn> object.
; List of attributes computed from SEM-CODE.
; The first element is just a dummy so that append! always works.
; Called for expressions encountered in SEM-CODE.
; Don't change these to '(FOO), since
; we use append!.
; If this is a syntax expression, the operands won't have been
; processed, so tell our caller we want it to by returning #f.
; We do the same for non-syntax expressions to keep things
; simple.  This requires collaboration with the traversal
; handlers which are defined to do what we want if we return #f.
; Traverse the expression recording the attributes.
; Drop dummy first arg.
""

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.