]> sourceware.org Git - cgen.git/commitdiff
* utils-sim.scm (gen-profile-sym): New fn.
authorDoug Evans <xdje42@gmail.com>
Fri, 20 Dec 2002 07:58:32 +0000 (07:58 +0000)
committerDoug Evans <xdje42@gmail.com>
Fri, 20 Dec 2002 07:58:32 +0000 (07:58 +0000)
(<operand>,sbuf-profile-sym): New method.
(<operand>,sbuf-profile-elm): Use it.
* sim.scm (<operand>,gen-record-profile): Use sbuf-profile-sym instead
of hardcoding symbol name.
(<operand>,gen-profile-code): Ditto.
(<unit>,gen-profile-code): Use gen-profile-sym instead of hardcoding
symbol name.

ChangeLog
sim.scm
utils-sim.scm

index 5b51f2c208042a60b62625ade1963d58320f4996..2b9a4d689a6d7f709a7ca90d37d046ec3f9c530e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2002-12-19  Doug Evans  <dje@sebabeach.org>
 
+       * utils-sim.scm (gen-profile-sym): New fn.
+       (<operand>,sbuf-profile-sym): New method.
+       (<operand>,sbuf-profile-elm): Use it.
+       * sim.scm (<operand>,gen-record-profile): Use sbuf-profile-sym instead
+       of hardcoding symbol name.
+       (<operand>,gen-profile-code): Ditto.
+       (<unit>,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 65dd0b9c044d5af21995b45b734ae5c5109f53a1..840c7328d33ec375c442a05fb88dd789bfa421a9 100644 (file)
--- a/sim.scm
+++ b/sim.scm
    (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)
                      ""
                      (string-append ", "
                                     (gen-argbuf-ref
-                                     (string-append (if out? "out_" "in_")
-                                                    (gen-sym self)))))
+                                     (send self 'sbuf-profile-sym out?))))
                  ");\n"))
 )
 \f
                               (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.
                              (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"
                         (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
                      ((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
index 2481c5e5095eb6e4949f9957a078f3c0a4eb6760..b049a614ba9cd6dd1395256ff425588bd5958481 100644 (file)
        (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!
+ <operand> '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 <sformat> SFMT.
 ; The result is (var-name "C-type" approx-bitsize) or #f if unneeded.
  (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))))
 )
 
This page took 0.03754 seconds and 5 git commands to generate.