Issue #43 - Add -O0 to disable optimizations

This is the first step to being able to specify optimization level from the command line. This will be more important as more optimizations are added and when (if) some of them are not always safe to apply.
This commit is contained in:
Justin Ethier 2016-11-11 17:19:04 -05:00
parent f3741ca67a
commit 66993ebce5

View file

@ -22,6 +22,8 @@
(scheme cyclone macros) (scheme cyclone macros)
(scheme cyclone libraries)) (scheme cyclone libraries))
(define *optimization-level* 2) ;; Default level
;; Code emission. ;; Code emission.
; c-compile-and-emit : (string -> A) exp -> void ; c-compile-and-emit : (string -> A) exp -> void
@ -228,10 +230,11 @@
(trace:info "---------------- after CPS:") (trace:info "---------------- after CPS:")
(trace:info input-program) ;pretty-print (trace:info input-program) ;pretty-print
(when (> *optimization-level* 0)
(set! input-program (set! input-program
(optimize-cps input-program)) (optimize-cps input-program))
(trace:info "---------------- after cps optimizations:") (trace:info "---------------- after cps optimizations:")
(trace:info input-program) (trace:info input-program))
(set! input-program (set! input-program
(map (map
@ -380,6 +383,11 @@
(equal? #\- (string-ref arg 0))))) (equal? #\- (string-ref arg 0)))))
args)) args))
(compile? #t)) (compile? #t))
;; Set optimization level(s)
(if (member "-O0" args)
(set! *optimization-level* 0))
;; TODO: place more optimization reading here as necessary
;; End optimizations
(if (member "-t" args) (if (member "-t" args)
(set! *trace-level* 4)) ;; Show all trace output (set! *trace-level* 4)) ;; Show all trace output
(if (member "-d" args) (if (member "-d" args)
@ -392,6 +400,8 @@
-d Only generate intermediate C files, do not compile them -d Only generate intermediate C files, do not compile them
-h, --help Display usage information -h, --help Display usage information
-v Display version information -v Display version information
-Ox Optimization level, higher means more optimizations will
be used. Set to 0 to disable optimizations.
--autogen Cyclone developer use only, create autogen.out file --autogen Cyclone developer use only, create autogen.out file
") ")
(newline)) (newline))