(<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.
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.
(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
(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))))
)