1 ; CPU description file generator for the GNU Binutils.
2 ; This is invoked to build: $arch-desc.[ch], $arch-opinst.c,
3 ; $arch-opc.h, $arch-opc.c, $arch-asm.in, $arch-dis.in, and $arch-ibld.[ch].
4 ; Copyright (C) 2000, 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 "/desc.scm"))
15 (load (string-append srcdir "/desc-cpu.scm"))
16 (load (string-append srcdir "/opcodes.scm"))
17 (load (string-append srcdir "/opc-asmdis.scm"))
18 (load (string-append srcdir "/opc-ibld.scm"))
19 (load (string-append srcdir "/opc-itab.scm"))
20 (load (string-append srcdir "/opc-opinst.scm"))
25 (list "-OPC" "file" "specify path to .opc file"
26 (lambda (arg) (set-opc-file-path! arg))
28 (list "-H" "file" "generate $arch-desc.h in <file>"
30 (lambda (arg) (file-write arg cgen-desc.h)))
31 (list "-C" "file" "generate $arch-desc.c in <file>"
33 (lambda (arg) (file-write arg cgen-desc.c)))
34 (list "-O" "file" "generate $arch-opc.h in <file>"
36 (lambda (arg) (file-write arg cgen-opc.h)))
37 (list "-P" "file" "generate $arch-opc.c in <file>"
39 (lambda (arg) (file-write arg cgen-opc.c)))
40 (list "-Q" "file" "generate $arch-opinst.c in <file>"
42 (lambda (arg) (file-write arg cgen-opinst.c)))
43 (list "-B" "file" "generate $arch-ibld.h in <file>"
45 (lambda (arg) (file-write arg cgen-ibld.h)))
46 (list "-L" "file" "generate $arch-ibld.in in <file>"
48 (lambda (arg) (file-write arg cgen-ibld.in)))
49 (list "-A" "file" "generate $arch-asm.in in <file>"
51 (lambda (arg) (file-write arg cgen-asm.in)))
52 (list "-D" "file" "generate $arch-dis.in in <file>"
54 (lambda (arg) (file-write arg cgen-dis.in)))
58 ; (-R "file" "generate $cpu-reloc.h") ; FIXME: wip (rename to -abi.h?)
59 ; (-S "file" "generate cpu-$cpu.c") ; FIXME: wip (bfd's cpu-$cpu.c)
60 ; ((-R) (file-write *arg* cgen-reloc.c))
61 ; ((-S) (file-write *arg* cgen-bfdcpu.c))
63 ; Kept global so it's available to the other .scm files.
66 ; Scan argv for -s srcdir.
67 ; We can't process any other args until we find the cgen source dir.
68 ; The result is srcdir.
69 ; We assume "-s" isn't the argument to another option. Unwise, yes.
70 ; Alternatives are to require it to be the first argument or at least preceed
71 ; any option with a "-s" argument, or to put knowledge of the common argument
72 ; set and common argument parsing code in every top level file.
74 (define (find-srcdir argv)
75 (let loop ((argv argv))
77 (error "`-s srcdir' not present, can't load cgen"))
78 (if (string=? "-s" (car argv))
80 (if (null? (cdr argv))
81 (error "missing srcdir arg to `-s'"))
86 ; Main routine, parses options and calls generators.
88 (define (cgen-opc argv)
91 ; Find and set srcdir, then load all Scheme code.
92 ; Drop the first argument, it is the script name (i.e. argv[0]).
93 (set! srcdir (find-srcdir (cdr argv)))
94 (set! %load-path (cons srcdir %load-path))
101 #:arg-spec opc-arguments
103 #:finish opcodes-finish!
104 #:analyze opcodes-analyze!)
108 (cgen-opc (program-arguments))