From ac3c17ddf5d8f4962f381d70405c7f0b496ad141 Mon Sep 17 00:00:00 2001 From: Doug Evans Date: Fri, 20 Dec 2002 07:58:32 +0000 Subject: [PATCH] * utils-sim.scm (gen-profile-sym): New fn. (,sbuf-profile-sym): New method. (,sbuf-profile-elm): Use it. * sim.scm (,gen-record-profile): Use sbuf-profile-sym instead of hardcoding symbol name. (,gen-profile-code): Ditto. (,gen-profile-code): Use gen-profile-sym instead of hardcoding symbol name. --- ChangeLog | 9 +++++++++ sim.scm | 45 +++++++++++++++++++-------------------------- utils-sim.scm | 20 ++++++++++++++++++-- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5b51f2c..2b9a4d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2002-12-19 Doug Evans + * utils-sim.scm (gen-profile-sym): New fn. + (,sbuf-profile-sym): New method. + (,sbuf-profile-elm): Use it. + * sim.scm (,gen-record-profile): Use sbuf-profile-sym instead + of hardcoding symbol name. + (,gen-profile-code): Ditto. + (,gen-profile-code): Use gen-profile-sym instead of hardcoding + symbol name. + * mode.scm (mode-sem-mode): New fn. * operand.scm (op:new-mode): Update. mode-name. (op-natural-mode?) New fn. diff --git a/sim.scm b/sim.scm index 65dd0b9..840c732 100644 --- a/sim.scm +++ b/sim.scm @@ -1341,8 +1341,7 @@ (if (hw-scalar? (op:type self)) "" (string-append " " - (gen-argbuf-ref (string-append (if out? "out_" "in_") - (gen-sym self))) + (gen-argbuf-ref (send self 'sbuf-profile-sym out?)) " = " (send (op:type self) 'gen-record-profile (op:index self) sfmt estate) @@ -1364,8 +1363,7 @@ "" (string-append ", " (gen-argbuf-ref - (string-append (if out? "out_" "in_") - (gen-sym self))))) + (send self 'sbuf-profile-sym out?)))) ");\n")) ) @@ -1575,14 +1573,13 @@ (not (insn-op-lookup (car arg) insn (if out? 'out 'in)))) "" - (string-append " " - (if out? "out_" "in_") - (gen-c-symbol (car arg)) - " = " - (gen-argbuf-ref - (string-append (if out? "out_" "in_") - (gen-c-symbol (car arg)))) - ";\n")))) + (let ((sym (gen-profile-sym (gen-c-symbol (car arg)) + out?))) + (string-append " " + sym + " = " + (gen-argbuf-ref sym) + ";\n"))))) ; Return C code to declare variable to hold unit argument ARG. ; OUT? is #f for input args, #t for output args. @@ -1592,8 +1589,8 @@ (string-append " " (mode:c-type (mode:lookup (cadr arg))) " " - (if out? "out_" "in_") - (gen-c-symbol (car arg)) + (gen-profile-sym (gen-c-symbol (car arg)) + out?) " = " (if (null? (cddr arg)) "0" @@ -1606,8 +1603,8 @@ (if (null? (cdr arg)) ; ignore scalars "" (string-append ", " - (if out? "out_" "in_") - (gen-c-symbol (car arg)))))) + (gen-profile-sym (gen-c-symbol (car arg)) + out?))))) ) (string-list @@ -1645,24 +1642,20 @@ ((cycles) "") ((in) (if (caddr arg) - (string-append " in_" - (gen-c-symbol (cadr arg)) + (string-append " " + (gen-profile-sym (gen-c-symbol (cadr arg)) #f) " = " (gen-argbuf-ref - (string-append - "in_" - (gen-c-symbol (caddr arg)))) + (gen-profile-sym (gen-c-symbol (caddr arg)) #f)) ";\n") "")) ((out) (if (caddr arg) - (string-append " out_" - (gen-c-symbol (cadr arg)) + (string-append " " + (gen-profile-sym (gen-c-symbol (cadr arg)) #t) " = " (gen-argbuf-ref - (string-append - "out_" - (gen-c-symbol (caddr arg)))) + (gen-profile-sym (gen-c-symbol (caddr arg)) #t)) ";\n") "")) (else diff --git a/utils-sim.scm b/utils-sim.scm index 2481c5e..b049a61 100644 --- a/utils-sim.scm +++ b/utils-sim.scm @@ -399,6 +399,23 @@ (list "unsigned short" 16))) ) +; Utility to return name of variable/structure-member to use to record +; profiling data for SYM. + +(define (gen-profile-sym sym out?) + (string-append (if out? "out_" "in_") + (if (symbol? sym) (symbol->string sym) sym)) +) + +; Return name of variable/structure-member to use to record data needed for +; profiling operand SELF. + +(method-make! + 'sbuf-profile-sym + (lambda (self out?) + (gen-profile-sym (gen-sym self) out?)) +) + ; sbuf-profile-elm method. ; Return the ARGBUF member needed for profiling SELF in SFMT. ; The result is (var-name "C-type" approx-bitsize) or #f if unneeded. @@ -408,8 +425,7 @@ (lambda (self sfmt out?) (if (hw-scalar? (op:type self)) #f - (cons (string-append (if out? "out_" "in_") - (gen-sym self)) + (cons (send self 'sbuf-profile-sym out?) (send (op:type self) 'sbuf-profile-data)))) ) -- 2.43.5