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, model.h, model.cxx
4 ; Copyright (C) 2000, 2003, 2009 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 (load (string-append srcdir "/read.scm"))
14 (load (string-append srcdir "/utils-sim.scm"))
15 (load (string-append srcdir "/sid.scm"))
16 (load (string-append srcdir "/sid-cpu.scm"))
17 (load (string-append srcdir "/sid-model.scm"))
18 (load (string-append srcdir "/sid-decode.scm"))
23 (list "-H" "file" "generate desc.h in <file>"
25 (lambda (arg) (file-write arg cgen-desc.h)))
26 (list "-C" "file" "generate cpu.h in <file>"
28 (lambda (arg) (file-write arg cgen-cpu.h)))
29 (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>"
34 (lambda (arg) (file-write arg cgen-decode.h)))
35 (list "-D" "file" "generate decode.cxx in <file>"
37 (lambda (arg) (file-write arg cgen-decode.cxx)))
38 (list "-W" "file" "generate write.cxx in <file>"
40 (lambda (arg) (file-write arg cgen-write.cxx)))
41 (list "-S" "file" "generate semantics.cxx in <file>"
43 (lambda (arg) (file-write arg cgen-semantics.cxx)))
44 (list "-X" "file" "generate sem-switch.cxx in <file>"
46 (lambda (arg) (file-write arg cgen-sem-switch.cxx)))
47 (list "-M" "file" "generate model.cxx in <file>"
49 (lambda (arg) (file-write arg cgen-model.cxx)))
50 (list "-N" "file" "generate model.h in <file>"
52 (lambda (arg) (file-write arg cgen-model.h)))
56 ; Kept global so it's available to the other .scm files.
59 ; Scan argv for -s srcdir.
60 ; We can't process any other args until we find the cgen source dir.
61 ; The result is srcdir.
62 ; We assume "-s" isn't the argument to another option. Unwise, yes.
63 ; Alternatives are to require it to be the first argument or at least preceed
64 ; any option with a "-s" argument, or to put knowledge of the common argument
65 ; set and common argument parsing code in every top level file.
67 (define (find-srcdir argv)
68 (let loop ((argv argv))
70 (error "`-s srcdir' not present, can't load cgen"))
71 (if (string=? "-s" (car argv))
73 (if (null? (cdr argv))
74 (error "missing srcdir arg to `-s'"))
79 ; Main routine, parses options and calls generators.
81 (define (cgen-sim argv)
84 ; Find and set srcdir, then load all Scheme code.
85 ; Drop the first argument, it is the script name (i.e. argv[0]).
86 (set! srcdir (find-srcdir (cdr argv)))
87 (set! %load-path (cons srcdir %load-path))
94 #:arg-spec sim-arguments
97 #:analyze sim-analyze!)
101 (cgen-sim (program-arguments))