1 ; GCC "intrinsics" file entry point.
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.
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 ; Fix up Scheme to be what we use (guile is always in flux).
17 (primitive-load-path (string-append srcdir "/guile.scm"))
19 (load (string-append srcdir "/read.scm"))
20 (load (string-append srcdir "/intrinsics.scm"))
23 (define intrinsics-isas '())
25 (define intrinsics-arguments
27 (list "-K" "isa" "keep isa <isa> in intrinsics" #f
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)))))
41 ; Kept global so it's available to the other .scm files.
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.
52 (define (find-srcdir argv)
53 (let loop ((argv argv))
55 (error "`-s srcdir' not present, can't load cgen"))
56 (if (string=? "-s" (car argv))
58 (if (null? (cdr argv))
59 (error "missing srcdir arg to `-s'"))
64 ; Main routine, parses options and calls generators.
66 (define (cgen-intrinsics argv)
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))
78 #:app-name "intrinsics"
79 #:arg-spec intrinsics-arguments
80 #:analyze intrinsics-analyze!)
84 (cgen-intrinsics (program-arguments))