URL
https://opencores.org/ocsvn/scarts/scarts/trunk
Subversion Repositories scarts
[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [rtl-xform.scm] - Rev 6
Compare with Previous | Blame | View Log
;; Various RTL transformations. ;; ;; Copyright (C) 2000, 2009 Red Hat, Inc. ;; This file is part of CGEN. ;; See file COPYING.CGEN for details. ;; ;; In particular: ;; rtx-simplify ;; rtx-solve ;; rtx-canonicalize ;; rtx-compile ;; rtx-trim-for-doc ;; rtx-simplify (and supporting cast) ; Subroutine of -rtx-simplify-expr-fn to compare two values for equality. ; If both are constants and they're equal return #f/#t. ; INVERT? = #f -> return #t if equal, #t -> return #f if equal. ; Returns 'unknown if either argument is not a constant. ; Subroutine of -rtx-simplify-expr-fn to see if MAYBE-CONST is ; an element of NUMBER-LIST. ; NUMBER-LIST is a `number-list' rtx. ; INVERT? is #t if looking for non-membership. ; #f/#t is only returned for definitive answers. ; If INVERT? is #f: ; - return #f if MAYBE-CONST is not in NUMBER-LIST ; - return #t if MAYBE-CONST is in NUMBER-LIST and it has only one member ; - return 'member if MAYBE-CONST is in NUMBER-LIST and it has many members ; - otherwise return 'unknown ; If INVERT? is #t: ; - return #t if MAYBE-CONST is not in NUMBER-LIST ; - return #f if MAYBE-CONST is in NUMBER-LIST and it has only one member ; - return 'member if MAYBE-CONST is in NUMBER-LIST and it has many members ; - otherwise return 'unknown ; Subroutine of -rtx-simplify-expr-fn to simplify an eq-attr of (current-mach). ; CONTEXT is a <context> object or #f if there is none. ; If all currently selected machs will yield the same value ; for the attribute, we can simplify. ; Ensure at least one mach is selected. "While simplifying rtl""no machs selected"; All values equal to the first one? ; Convert internal boolean attribute value ; #f/#t to external value FALSE/TRUE. ; FIXME:revisit. ; couldn't simplify ; Subroutine of -rtx-simplify-expr-fn to simplify an eq-attr of (current-insn). "While simplifying rtl""No current insn for `(current-insn)'"; Subroutine of rtx-simplify. ; This is the EXPR-FN argument to rtx-traverse. ;(display "Processing ") (display (rtx-dump expr)) (newline) ; Value of arg0 is unknown or has side-effects. ; Value of arg0 is unknown or has side-effects. ; Fold if's to their then or else part if we can determine the ; result of the test. ; ??? Was this but that calls rtx-traverse again which ; resets the temp stack! ; (rtx-simplify context (caddr expr)))) ; Sanity check, mode must be VOID. "rtx-simplify: non-void-mode `if' missing `else' part"; Can't simplify. ; We could traverse the then/else clauses here, but it's simpler ; to have our caller do it. The cost is retraversing `test'. ; That didn't work. See if we have an ifield/operand with a ; known range of values. ; Recognize attribute requests of current-insn, current-mach. ; If the value is a single number, return that. ; It can be one of several, represented as a number list. ; (rtx-make 'const 'INT known-val) ; If the value is a single number, return that. ; It can be one of several, represented as a number list. ; (rtx-make 'const 'INT known-val) ; Leave EXPR unchanged and continue. ; Simplify an rtl expression. ; ; EXPR must be in source form. ; The result is a possibly simplified EXPR, still in source form. ; ; CONTEXT is a <context> object or #f, used for error messages. ; OWNER is the owner of the expression (e.g. <insn>) or #f if there is none. ; ; KNOWN is an alist of known values. Each element is (name . value) where ; NAME is an ifield/operand name and VALUE is a const/number-list rtx. ; FIXME: Need ranges, later. ; ; The following operations are performed: ; - unselected machine dependent code is removed (eq-attr of (current-mach)) ; - if's are reduced to either then/else if we can determine that the test is ; a compile-time constant ; - orif/andif ; - eq/ne ; - not ; ; ??? Will become more intelligent as needed. ;; Return an insn's semantics simplified. ;; CONTEXT is a <context> object or #f, used for error messages. ;; rtx-solve (and supporting cast) ; Utilities for equation solving. ; ??? At the moment this is only focused on ifield assertions. ; ??? That there exist more sophisticated versions than this one can take ; as a given. This works for the task at hand and will evolve or be replaced ; as necessary. ; ??? This makes the simplifying assumption that no expr has side-effects. ; Subroutine of rtx-solve. ; This is the EXPR-FN argument to rtx-traverse. ; wip ; Return a boolean indicating if {expr} equates to "true". ; If the expression can't be reduced to #f/#t, return '?. ; ??? Use rtx-eval instead of rtx-traverse? ; ; EXPR must be in source form. ; CONTEXT is a <context> object, used for error messages. ; OWNER is the owner of the expression (e.g. <insn>) or #f if there is none. ; KNOWN is an alist of known values. Each element is (name . value) where ; NAME is an ifield/operand name and VALUE is a const/number-list rtx. ; FIXME: Need ranges, later. ; ; This is akin to rtx-simplify except it's geared towards solving ifield ; assertions. It's not unreasonable to combine them. The worry is the ; efficiency lost. ; ??? Will become more intelligent as needed. ; First simplify, then solve. ; FIXME: for now ; (-rtx-traverse simplified-expr #f 'DFLT #f 0 ; (tstate-make context owner ; (/fastcall-make -solve-expr-fn) ; (rtx-env-empty-stack) ; #f #f known 0) ; #f)) ;; rtx-canonicalize (and supporting cast) ; RTX canonicalization. ; ??? wip ; Subroutine of rtx-canonicalize. ; Return canonical form of rtx expression EXPR. ; CONTEXT is a <context> object or #f if there is none. ; It is used for error message. ; RTX-OBJ is the <rtx-func> object of (car expr). ; Return canonical form of EXPR. ; CONTEXT is a <context> object or #f if there is none. ; It is used for error message. ; ; Does: ; - operand shortcuts expanded ; - numbers -> (const number) ; - operand-name -> (operand operand-name) ; - ifield-name -> (ifield ifield-name) ; - no options -> null option list ; - absent result mode of those that require a mode -> DFLT ; - rtx macros are expanded ; ; EXPR is returned in source form. We could speed up future processing by ; transforming it into a more compiled form, but that makes debugging more ; difficult, so for now we don't. ; FIXME: wip "While canonicalizing rtl""can't canonicalize""While canonicalizing rtl""can't canonicalize";; rtx-compile (and supporting cast) ; Convert rtl expression EXPR from source form to compiled form. ; The expression is validated and rtx macros are expanded as well. ; CONTEXT is a <context> object or #f if there is none. ; It is used in error messages. ; EXTRA-VARS-ALIST is an association list of extra (symbol <mode> value) ; elements to be used during value lookup. ; ; This does the same operation that rtx-traverse does, except that it provides ; a standard value for EXPR-FN. ; ; ??? In the future the compiled form may be the same as the source form ; except that all elements would be converted to their respective objects. ; (cond ; The intent of this is to handle sequences/closures, but is it needed? ; ((rtx-style-syntax? rtx-obj) ; ((rtx-evaluator rtx-obj) rtx-obj expr mode ; parent-expr op-pos tstate)) ; (else ; rtx-obj ;; rtx-trim-for-doc (and supporting cast) ; RTX trimming (removing fluff not normally needed for the human viewer). ; Subroutine of -rtx-trim-for-doc to simplify it. ; Trim all the arguments of rtx NAME. ; skip options, mode ; Remember, types may be an improper list. ;(display arg (current-error-port)) (newline (current-error-port)) ;(display type (current-error-port)) (newline (current-error-port)) ; shouldn't get here ; leave arg untouched ; leave arg untouched ; leave arg untouched for now ; leave arg untouched for now ; leave arg untouched ; hopefully(wip!) shouldn't get here ; unknown arg type ; Given a fully specified rtx expression, usually the result of rtx-simplify, ; remove bits unnecessary for documentation purposes. ; rtx-simplify adds a lot of verbosity because in the process of ; simplifying the rtl it produces fully-specified rtl. ; Examples of things to remove: empty options list, DFLT mode. ; ; NOTE: While having to trim the result of rtx-simplify may seem ironical, ; it isn't. You need to keep separate the notions of simplifying "1+1" to "2" ; and trimming the clutter from "(const () BI 0)" yielding "0". ; ??? cheap rtx? ; No special support is needed, except it's nice to remove nop ; statements. These can be created when an `if' get simplified. ; ignore ; Not an rtx expression, must be number, symbol, string.