1 ; Simulator generator entry point.
2 ; This is invoked to build: desc.h, cpu.h, defs.h, decode.h, decode.cxx,
3 ; semantics.cxx, sem-switch.cxx.
4 ; Copyright (C) 2000 Red Hat, Inc.
5 ; This file is part of CGEN.
7 ; This is a standalone script, we don't load anything until we parse the
8 ; -s argument (keeps reliance off of environment variables, etc.).
10 ; Load the various support routines.
12 (define (load-files srcdir)
13 ; Fix up Scheme to be what we use (guile is always in flux).
14 (primitive-load-path (string-append srcdir "/fixup.scm"))
16 (load (string-append srcdir "/read.scm"))
17 (load (string-append srcdir "/utils-sim.scm"))
18 (load (string-append srcdir "/sid.scm"))
19 (load (string-append srcdir "/sid-cpu.scm"))
20 (load (string-append srcdir "/sid-model.scm"))
21 (load (string-append srcdir "/sid-decode.scm"))
26 (list '-H "file" "generate desc.h in <file>"
27 (lambda (arg) (file-write arg cgen-desc.h)))
28 (list '-C "file" "generate cpu.h in <file>"
29 (lambda (arg) (file-write arg cgen-cpu.h)))
30 (list '-E "file" "generate defs.h in <file>"
31 (lambda (arg) (file-write arg cgen-defs.h)))
32 (list '-T "file" "generate decode.h in <file>"
33 (lambda (arg) (file-write arg cgen-decode.h)))
34 (list '-D "file" "generate decode.cxx in <file>"
35 (lambda (arg) (file-write arg cgen-decode.cxx)))
36 (list '-W "file" "generate write.cxx in <file>"
37 (lambda (arg) (file-write arg cgen-write.cxx)))
38 (list '-S "file" "generate semantics.cxx in <file>"
39 (lambda (arg) (file-write arg cgen-semantics.cxx)))
40 (list '-X "file" "generate sem-switch.cxx in <file>"
41 (lambda (arg) (file-write arg cgen-sem-switch.cxx)))
42 (list '-M "file" "generate model.cxx in <file>"
43 (lambda (arg) (file-write arg cgen-model.cxx)))
47 ; Kept global so it's available to the other .scm files.
50 ; Scan argv for -s srcdir.
51 ; We can't process any other args until we find the cgen source dir.
52 ; The result is srcdir.
53 ; We assume "-s" isn't the argument to another option. Unwise, yes.
54 ; Alternatives are to require it to be the first argument or at least preceed
55 ; any option with a "-s" argument, or to put knowledge of the common argument
56 ; set and common argument parsing code in every top level file.
58 (define (find-srcdir argv)
59 (let loop ((argv argv))
61 (error "`-s srcdir' not present, can't load cgen"))
62 (if (string=? "-s" (car argv))
64 (if (null? (cdr argv))
65 (error "missing srcdir arg to `-s'"))
70 ; Main routine, parses options and calls generators.
72 (define (cgen-sim argv)
75 ; Find and set srcdir, then load all Scheme code.
76 ; Drop the first argument, it is the script name (i.e. argv[0]).
77 (set! srcdir (find-srcdir (cdr argv)))
78 (set! %load-path (cons srcdir %load-path))
85 #:arg-spec sim-arguments
88 #:analyze sim-analyze!)
92 (cgen-sim (program-arguments))