OSDN Git Service

Add -Wshadow to the gcc command line options used when compiling the binutils.
[pf3gnuchains/pf3gnuchains4x.git] / cgen / cgen-intrinsics.scm
1 ; GCC "intrinsics" file entry point.
2 ;
3 ; This is invoked to build support files for registering intrinsic
4 ; functions within gcc. this code has a fair bit of target-specific
5 ; code in it. it's not a general-purpose module yet.
6 ;
7 ; Copyright (C) 2000, 2009 Red Hat, Inc.
8 ; This file is part of CGEN.
9 ;
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.).
12
13 ; Load the various support routines.
14
15 (define (load-files srcdir)
16   ; Fix up Scheme to be what we use (guile is always in flux).
17   (primitive-load-path (string-append srcdir "/guile.scm"))
18
19   (load (string-append srcdir "/read.scm"))
20   (load (string-append srcdir "/intrinsics.scm"))
21 )
22
23 (define intrinsics-isas '())
24
25 (define intrinsics-arguments
26   (list
27    (list "-K" "isa" "keep isa <isa> in intrinsics" #f
28          (lambda (args)
29            (for-each
30             (lambda (arg) (set! intrinsics-isas (cons (string->symbol arg) intrinsics-isas)))
31             (string-cut args #\,))))
32    (list "-M" "file" "generate insns.md in <file>" #f
33          (lambda (arg) (file-write arg insns.md)))
34    (list "-N" "file" "generate intrinsics.h in <file>" #f
35          (lambda (arg) (file-write arg intrinsics.h)))
36    (list "-P" "file" "generate intrinsic-protos.h in <file>" #f
37          (lambda (arg) (file-write arg intrinsic-protos.h)))
38    (list "-T" "file" "generate intrinsic-testsuite.c in <file>" #f
39          (lambda (arg) (file-write arg intrinsic-testsuite.c)))))
40
41 ; Kept global so it's available to the other .scm files.
42 (define srcdir ".")
43
44 ; Scan argv for -s srcdir.
45 ; We can't process any other args until we find the cgen source dir.
46 ; The result is srcdir.
47 ; We assume "-s" isn't the argument to another option.  Unwise, yes.
48 ; Alternatives are to require it to be the first argument or at least preceed
49 ; any option with a "-s" argument, or to put knowledge of the common argument
50 ; set and common argument parsing code in every top level file.
51
52 (define (find-srcdir argv)
53   (let loop ((argv argv))
54     (if (null? argv)
55         (error "`-s srcdir' not present, can't load cgen"))
56     (if (string=? "-s" (car argv))
57         (begin
58           (if (null? (cdr argv))
59               (error "missing srcdir arg to `-s'"))
60           (cadr argv))
61         (loop (cdr argv))))     
62 )
63
64 ; Main routine, parses options and calls generators.
65
66 (define (cgen-intrinsics argv)
67   (let ()
68
69     ; Find and set srcdir, then load all Scheme code.
70     ; Drop the first argument, it is the script name (i.e. argv[0]).
71     (set! srcdir (find-srcdir (cdr argv)))
72     (set! %load-path (cons srcdir %load-path))
73     (load-files srcdir)
74
75     (display-argv argv)
76
77     (cgen #:argv argv
78           #:app-name "intrinsics"
79           #:arg-spec intrinsics-arguments
80           #:analyze intrinsics-analyze!)
81     )
82 )
83
84 (cgen-intrinsics (program-arguments))