OSDN Git Service

From 2001-03-01 Tom Rix <trix@redhat.com>:
[pf3gnuchains/pf3gnuchains3x.git] / cgen / dev.scm
1 ; CGEN Debugging support.
2 ; Copyright (C) 2000 Red Hat, Inc.
3 ; This file is part of CGEN.
4 ; See file COPYING.CGEN for details.
5
6 ; This file is loaded in during an interactive guile session to
7 ; develop and debug CGEN.  The user visible procs are:
8 ;
9 ; (use-c)
10 ; (load-opc)
11 ; (load-sim)
12 ; (load-sid)
13 ; (cload #:arch arch #:machs "mach-list" #:isas "isa-list" #:options "options")
14 \f
15 ; First load fixup.scm to coerce guile into something we've been using.
16 ; Guile is always in flux.
17 (load "fixup.scm")
18
19 (define srcdir ".")
20 (set! %load-path (cons srcdir %load-path))
21
22 ; Utility to enable/disable compiled-in C code.
23
24 (define (use-c) (set! CHECK-LOADED? #t))
25 (define (no-c) (set! CHECK-LOADED? #f))
26
27 ; Also defined in read.scm, but we need it earlier.
28 (define APPLICATION 'UNKNOWN)
29
30 ; Supply the path name and suffic for the .cpu file and delete the analyzer
31 ; arg from cpu-load to lessen the typing.
32 (define (cload . args)
33   (let ((arch #f)
34         (keep-mach "all")
35         (keep-isa "all")
36         (options ""))
37
38     ; Doesn't check if (cadr args) exists or if #:arch was specified, but
39     ; this is a debugging tool!
40     (let loop ((args args))
41       (if (null? args)
42           #f ; done
43           (begin
44             (case (car args)
45               ((#:arch) (set! arch (cadr args)))
46               ((#:machs) (set! keep-mach (cadr args)))
47               ((#:isas) (set! keep-isa (cadr args)))
48               ((#:options) (set! options (cadr args)))
49               (else (error "unknown option:" (car args))))
50             (loop (cddr args)))))
51
52     (case APPLICATION
53       ((UNKNOWN) (error "application not loaded"))
54       ((DESC) (cpu-load (string-append arch ".cpu")
55                         keep-mach keep-isa options
56                         desc-init!
57                         desc-finish!
58                         desc-analyze!))
59       ((OPCODES) (cpu-load (string-append arch ".cpu")
60                            keep-mach keep-isa options
61                            opcodes-init!
62                            opcodes-finish!
63                            opcodes-analyze!))
64       ((GAS-TEST) (cpu-load (string-append arch ".cpu")
65                             keep-mach keep-isa options
66                             gas-test-init!
67                             gas-test-finish!
68                             gas-test-analyze!))
69       ((SIMULATOR) (cpu-load (string-append arch ".cpu")
70                              keep-mach keep-isa options
71                              sim-init!
72                              sim-finish!
73                              sim-analyze!))
74       ((SIM-TEST) (cpu-load (string-append arch ".cpu")
75                             keep-mach keep-isa options
76                             sim-test-init!
77                             sim-test-finish!
78                             sim-test-analyze!))
79       (else (error "unknown application:" APPLICATION))))
80 )
81
82 ; Use the debugging evaluator.
83 (if (not (defined? 'DEBUG-EVAL))
84     (define DEBUG-EVAL #t))
85
86 ; Tell maybe-load to always load the file.
87 (if (not (defined? 'CHECK-LOADED?))
88     (define CHECK-LOADED? #f))
89
90 (define (load-opc)
91   (load "read")
92   (load "desc")
93   (load "desc-cpu")
94   (load "opcodes")
95   (load "opc-asmdis")
96   (load "opc-ibld")
97   (load "opc-itab")
98   (load "opc-opinst")
99   (set! verbose-level 3)
100   (set! APPLICATION 'OPCODES)
101 )
102
103 (define (load-gtest)
104   (load-opc)
105   (load "gas-test")
106   (set! verbose-level 3)
107   (set! APPLICATION 'GAS-TEST)
108 )
109
110 (define (load-sid)
111   (load "read")
112   (load "utils-sim")
113   (load "sid")
114   (load "sid-cpu")
115   (load "sid-model")
116   (load "sid-decode")
117   (set! verbose-level 3)
118   (set! APPLICATION 'SIMULATOR)
119 )
120
121 (define (load-sim)
122   (load "read")
123   (load "desc")
124   (load "desc-cpu")
125   (load "utils-sim")
126   (load "sim")
127   (load "sim-arch")
128   (load "sim-cpu")
129   (load "sim-model")
130   (load "sim-decode")
131   (set! verbose-level 3)
132   (set! APPLICATION 'SIMULATOR)
133 )
134
135 (define (load-stest)
136   (load-opc)
137   (load "sim-test")
138   (set! verbose-level 3)
139   (set! APPLICATION 'SIM-TEST)
140 )
141
142 (display "
143 First enable compiled in C code if desired.
144
145 (use-c)
146
147 Then choose the application via one of:
148
149 (load-opc)
150 (load-gtest)
151 (load-sim)
152 (load-stest)
153 ")
154
155 (display "(load-sid)\n")
156
157 (display "\
158
159 Then load the .cpu file with:
160
161 (cload #:arch \"arch\" #:machs \"keep-mach\" #:isas \"keep-isa\" #:options \"options\")
162
163 keep-mach:
164 comma separated list of machs to keep or `all'
165
166 keep-isa:
167 comma separated list of isas to keep or `all'
168
169 opcode options:
170 [none yet]
171
172 gas test options:
173 [none yet]
174 \n")
175
176 (display "\
177 sim options:
178 with-scache
179 with-profile=fn
180
181 sim test options:
182 [none yet]
183 \n")
184
185 (display "\
186 sid options:
187 [wip]
188 \n")
189
190 ; If ~/.cgenrc exists, load it.
191
192 (let ((cgenrc (string-append (getenv 'HOME) "/.cgenrc")))
193   (if (file-exists? cgenrc)
194       (load cgenrc))
195 )