1 ; Simulator generator entry point.
2 ; This is invoked to build: arch.h, cpu-<cpu>.h, memops.h, semops.h, decode.h,
3 ; decode.c, defs.h, extract.c, semantics.c, ops.c, model.c, mainloop.in.
5 ; memops.h, semops.h, ops.c, mainloop.in are either deprecated or wip.
7 ; Copyright (C) 2000, 2009 Red Hat, Inc.
8 ; This file is part of CGEN.
10 ; This is a standalone script, we don't load anything until we parse the
11 ; -s argument (keeps reliance off of environment variables, etc.).
13 ; Load the various support routines.
15 (define (load-files srcdir)
16 (load (string-append srcdir "/read.scm"))
17 (load (string-append srcdir "/utils-sim.scm"))
18 (load (string-append srcdir "/sim.scm"))
19 (load (string-append srcdir "/sim-arch.scm"))
20 (load (string-append srcdir "/sim-cpu.scm"))
21 (load (string-append srcdir "/sim-model.scm"))
22 (load (string-append srcdir "/sim-decode.scm"))
27 (list "-A" "file" "generate arch.h in <file>"
29 (lambda (arg) (file-write arg cgen-arch.h)))
30 (list "-B" "file" "generate arch.c in <file>"
32 (lambda (arg) (file-write arg cgen-arch.c)))
33 (list "-C" "file" "generate cpu-<cpu>.h in <file>"
35 (lambda (arg) (file-write arg cgen-cpu.h)))
36 (list "-U" "file" "generate cpu-<cpu>.c in <file>"
38 (lambda (arg) (file-write arg cgen-cpu.c)))
39 (list "-N" "file" "generate cpu-all.h in <file>"
41 (lambda (arg) (file-write arg cgen-cpuall.h)))
42 (list "-F" "file" "generate memops.h in <file>"
44 (lambda (arg) (file-write arg cgen-mem-ops.h)))
45 (list "-G" "file" "generate defs.h in <file>"
47 (lambda (arg) (file-write arg cgen-defs.h)))
48 (list "-P" "file" "generate semops.h in <file>"
50 (lambda (arg) (file-write arg cgen-sem-ops.h)))
51 (list "-T" "file" "generate decode.h in <file>"
53 (lambda (arg) (file-write arg cgen-decode.h)))
54 (list "-D" "file" "generate decode.c in <file>"
56 (lambda (arg) (file-write arg cgen-decode.c)))
57 (list "-E" "file" "generate extract.c in <file>"
59 (lambda (arg) (file-write arg cgen-extract.c)))
60 (list "-R" "file" "generate read.c in <file>"
62 (lambda (arg) (file-write arg cgen-read.c)))
63 (list "-W" "file" "generate write.c in <file>"
65 (lambda (arg) (file-write arg cgen-write.c)))
66 (list "-S" "file" "generate semantics.c in <file>"
68 (lambda (arg) (file-write arg cgen-semantics.c)))
69 (list "-X" "file" "generate sem-switch.c in <file>"
71 (lambda (arg) (file-write arg cgen-sem-switch.c)))
72 (list "-O" "file" "generate ops.c in <file>"
74 (lambda (arg) (file-write arg cgen-ops.c)))
75 (list "-M" "file" "generate model.c in <file>"
77 (lambda (arg) (file-write arg cgen-model.c)))
78 (list "-L" "file" "generate mainloop.in in <file>"
80 (lambda (arg) (file-write arg cgen-mainloop.in)))
84 ; Kept global so it's available to the other .scm files.
87 ; Scan argv for -s srcdir.
88 ; We can't process any other args until we find the cgen source dir.
89 ; The result is srcdir.
90 ; We assume "-s" isn't the argument to another option. Unwise, yes.
91 ; Alternatives are to require it to be the first argument or at least preceed
92 ; any option with a "-s" argument, or to put knowledge of the common argument
93 ; set and common argument parsing code in every top level file.
95 (define (find-srcdir argv)
96 (let loop ((argv argv))
98 (error "`-s srcdir' not present, can't load cgen"))
99 (if (string=? "-s" (car argv))
101 (if (null? (cdr argv))
102 (error "missing srcdir arg to `-s'"))
107 ; Main routine, parses options and calls generators.
109 (define (cgen-sim argv)
112 ; Find and set srcdir, then load all Scheme code.
113 ; Drop the first argument, it is the script name (i.e. argv[0]).
114 (set! srcdir (find-srcdir (cdr argv)))
115 (set! %load-path (cons srcdir %load-path))
122 #:arg-spec sim-arguments
125 #:analyze sim-analyze!)
129 (cgen-sim (program-arguments))