This is the mail archive of the
cgen@sources.redhat.com
mailing list for the CGEN project.
[Patch] More thorough cpu.h hardware struct
- To: cgen at sources dot redhat dot com
- Subject: [Patch] More thorough cpu.h hardware struct
- From: Ben Elliston <bje at redhat dot com>
- Date: Fri, 24 Nov 2000 09:25:36 +1100
I'd like to apply the following patch, but would like it reviewed
first for tastefulness. Thanks!
Ben
2000-11-24 Ben Elliston <bje@redhat.com>
* sim-cpu.scm (-gen-hardware-struct): New function.
(-gen-hardware-types): If with-multiple-isa is specified, emit all
hardware elements wich have share one or more ISAs with the ISAs
being kept.
*** sim-cpu.scm 2000/11/20 19:03:33 1.2
--- sim-cpu.scm 2000/11/23 22:22:40
***************
*** 40,45 ****
--- 40,62 ----
(and (register? hw) (not (obj-has-attr? hw 'VIRTUAL)))
)
+ ; Subroutine of -gen-hardware-types to generate the struct containing
+ ; hardware elements of one isa.
+
+ (define (-gen-hardware-struct hw-list)
+ (if (null? hw-list)
+ ; If struct is empty, leave it out to simplify generated code.
+ ""
+ (string-list-map (lambda (hw)
+ (string-list
+ (gen-decl hw)
+ (gen-obj-sanitize hw
+ (string-list
+ (send hw 'gen-get-macro)
+ (send hw 'gen-set-macro)))))
+ (find hw-need-storage? hw-list)))
+ )
+
; Return C type declarations of all of the hardware elements.
; The name of the type is prepended with the cpu family name.
***************
*** 49,63 ****
"typedef struct {\n"
" /* Hardware elements. */\n"
" struct {\n"
! (string-list-map (lambda (hw)
! (string-list
! (gen-decl hw)
! (gen-obj-sanitize hw
! (string-list
! (send hw 'gen-get-macro)
! (send hw 'gen-set-macro)))
! ))
! (find hw-need-storage? (current-hw-list)))
" } hardware;\n"
"#define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware)\n"
;" /* CPU profiling state information. */\n"
--- 66,84 ----
"typedef struct {\n"
" /* Hardware elements. */\n"
" struct {\n"
! (if (with-multiple-isa?)
! (let ((keep-isas (current-keep-isa-name-list))
! (candidates (find hw-need-storage? (current-hw-list))))
! (-gen-hardware-struct
! (find (lambda (hw)
! (>= (count-common
! keep-isas
! (bitset-attr->list
! (obj-attr-value hw 'ISA)))
! 1))
! candidates)))
! (-gen-hardware-struct (find hw-need-storage? (current-hw-list)))
! )
" } hardware;\n"
"#define CPU_CGEN_HW(cpu) (& (cpu)->cpu_data.hardware)\n"
;" /* CPU profiling state information. */\n"