3 (declare (standard-bindings) (block))
5 (include "pic18-sim.scm")
6 (include "utilities.scm")
8 (include "operators.scm")
10 (include "parser.scm")
12 (include "optimizations.scm")
13 (include "code-generation.scm")
16 ;------------------------------------------------------------------------------
18 ;; temporary solution, to support more than int
19 (set! ##six-types ;; TODO signed types ?
31 ;; TODO typedef should add to this list
33 '(current-exception-handler (lambda (exc) (##repl))) ; when not running in the repl
35 (define (read-source filename)
36 (shell-command (string-append "cpp -P " filename " > " filename ".tmp"))
37 ;; (##read-all-as-a-begin-expr-from-path ;; TODO use vectorized notation to have info on errors (where in the source)
38 ;; (string-append filename ".tmp")
39 ;; (readtable-start-syntax-set (current-readtable) 'six)
43 (string-append filename ".tmp")
45 (input-port-readtable-set!
47 (readtable-start-syntax-set
48 (input-port-readtable (current-input-port))
53 (define (main filename)
55 (output-port-readtable-set!
57 (readtable-sharing-allowed?-set
58 (output-port-readtable (current-output-port))
61 (let ((source (read-source filename)))
62 '(pretty-print source)
63 (let* ((ast (parse source)))
65 (let ((cfg (generate-cfg ast)))
68 (remove-branch-cascades-and-dead-code cfg)
69 (remove-converging-branches cfg)
70 (remove-dead-instructions cfg)
74 (let ((code (code-gen filename cfg)))
76 '(display "------------------ GENERATED CODE\n")
77 (asm-display-listing (current-output-port))
78 (asm-write-hex-file (string-append filename ".hex"))
80 '(display "------------------ EXECUTION USING SIMULATOR\n")
81 (execute-hex-file (string-append filename ".hex"))
84 (include "../statprof/statprof.scm")
85 (define (profile) ; profile using picobit
86 (time (with-exception-catcher
87 ;; to have the profiling results even it the compilation fails
90 (write-profile-report "profiling-picobit"))
93 (main "tests/picobit/picobit-vm-sixpic.c")
95 (write-profile-report "profiling-picobit")))))