From: Doug Evans Date: Sun, 25 Oct 2009 16:30:42 +0000 (+0000) Subject: Change internal representation of rtx attribute values. X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=656630748355aaeceddde1c18ad1035f09e4e928;p=cgen.git Change internal representation of rtx attribute values. * attr.scm (/attr-val-is-rtx?): New function. (attr-value): Call it. (atlist-attr-value-no-default, attr-lookup-default): Ditto. --- diff --git a/ChangeLog b/ChangeLog index d9f0864..ff4690b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-10-25 Doug Evans + + Change internal representation of rtx attribute values. + * attr.scm (/attr-val-is-rtx?): New function. + (attr-value): Call it. + (atlist-attr-value-no-default, attr-lookup-default): Ditto. + 2009-10-24 Doug Evans * gen-all-doc: Add sh.cpu. diff --git a/attr.scm b/attr.scm index dab7633..24297b0 100644 --- a/attr.scm +++ b/attr.scm @@ -195,9 +195,10 @@ (define (enum-attr-make name value) (cons name value)) -;;; Return a procedure to parse an attribute. -;;; RIGHT-TYPE? is a procedure that verifies the value is the right type. -;;; MESSAGE is printed if there is an error. +;; Return a procedure to parse an attribute. +;; RIGHT-TYPE? is a procedure that verifies the value is the right type. +;; MESSAGE is printed if there is an error. +;; The result of the parsed attribute is (name . value). (define (/parse-simple-attribute right-type? message) (lambda (self context val) @@ -488,6 +489,17 @@ (send atlist 'attr-present? attr) ) +;; Return #t if attribute value VAL is an rtx expression. +;; RTXs in attributes are recorded as a list of one element +;; which is the rtx. +;; I.e., ((rtx foo bar)). + +(define (/attr-val-is-rtx? val) + (and (pair? val) + (null? (cdr val)) + (pair? (car val))) ;; pair? -> cheap non-null-list? +) + ; Expand attribute value ATVAL, which is an rtx expression. ; OWNER is the containing object or #f if there is none. ; OWNER is needed if an attribute is defined in terms of other attributes. @@ -509,7 +521,7 @@ (define (attr-value alist attr owner) (let ((a (assq-ref alist attr))) (if a - (if (pair? a) ; pair? -> cheap non-null-list? + (if (/attr-val-is-rtx? a) (/attr-eval a owner) a) (attr-lookup-default attr owner))) @@ -527,7 +539,7 @@ (define (atlist-attr-value-no-default atlist attr owner) (let ((a (assq-ref (atlist-attrs atlist) attr))) (if a - (if (pair? a) ; pair? -> cheap non-null-list? + (if (/attr-val-is-rtx? a) (/attr-eval a owner) a) nil)) @@ -545,7 +557,7 @@ #f (let ((deflt (attr-default at))) (if deflt - (if (pair? deflt) ; pair? -> cheap non-null-list? + (if (/attr-val-is-rtx? deflt) (/attr-eval deflt owner) deflt) ; If no default was provided, use the first value.