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 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 "/fixup.scm"))
18 (primitive-load-path (string-append srcdir "/guile.scm"))
20 (load (string-append srcdir "/read.scm"))
21 (load (string-append srcdir "/intrinsics.scm"))
24 (define intrinsics-isas '())
26 (define intrinsics-arguments
28 (list "-K" "isa" "keep isa <isa> in intrinsics" #f
31 (lambda (arg) (set! intrinsics-isas (cons (string->symbol arg) intrinsics-isas)))
32 (string-cut args #\,))))
33 (list "-M" "file" "generate insns.md in <file>" #f
34 (lambda (arg) (file-write arg insns.md)))
35 (list "-N" "file" "generate intrinsics.h in <file>" #f
36 (lambda (arg) (file-write arg intrinsics.h)))
37 (list "-P" "file" "generate intrinsic-protos.h in <file>" #f
38 (lambda (arg) (file-write arg intrinsic-protos.h)))
39 (list "-T" "file" "generate intrinsic-testsuite.c in <file>" #f
40 (lambda (arg) (file-write arg intrinsic-testsuite.c)))))
42 ; Kept global so it's available to the other .scm files.
45 ; Scan argv for -s srcdir.
46 ; We can't process any other args until we find the cgen source dir.
47 ; The result is srcdir.
48 ; We assume "-s" isn't the argument to another option. Unwise, yes.
49 ; Alternatives are to require it to be the first argument or at least preceed
50 ; any option with a "-s" argument, or to put knowledge of the common argument
51 ; set and common argument parsing code in every top level file.
53 (define (find-srcdir argv)
54 (let loop ((argv argv))
56 (error "`-s srcdir' not present, can't load cgen"))
57 (if (string=? "-s" (car argv))
59 (if (null? (cdr argv))
60 (error "missing srcdir arg to `-s'"))
65 ; Main routine, parses options and calls generators.
67 (define (cgen-intrinsics argv)
70 ; Find and set srcdir, then load all Scheme code.
71 ; Drop the first argument, it is the script name (i.e. argv[0]).
72 (set! srcdir (find-srcdir (cdr argv)))
73 (set! %load-path (cons srcdir %load-path))
79 #:app-name "intrinsics"
80 #:arg-spec intrinsics-arguments
81 #:analyze intrinsics-analyze!)
85 (cgen-intrinsics (program-arguments))