From b5a52b496112f882485373c89863791f695c3423 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Fri, 8 May 2020 23:07:30 +0200 Subject: [PATCH] Wire up the baseline compiler to -O0 * module/language/tree-il/spec.scm (join): Use match rather than pmatch. (tree-il): Declare compiler to bytecode. (choose-compiler): New implementation. Note, the baseline compiler probably doesn't even work!!! --- module/language/tree-il/spec.scm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/module/language/tree-il/spec.scm b/module/language/tree-il/spec.scm index 8ee4bf35c..441ff7e8a 100644 --- a/module/language/tree-il/spec.scm +++ b/module/language/tree-il/spec.scm @@ -20,9 +20,10 @@ (define-module (language tree-il spec) #:use-module (system base language) - #:use-module (system base pmatch) + #:use-module (ice-9 match) #:use-module (language tree-il) #:use-module (language tree-il compile-cps) + #:use-module (language tree-il compile-bytecode) #:use-module ((language tree-il analyze) #:select (make-analyzer)) #:use-module ((language tree-il optimize) #:select (make-lowerer)) #:export (tree-il)) @@ -31,12 +32,19 @@ (apply write (unparse-tree-il exp) port)) (define (join exps env) - (pmatch exps + (match exps (() (make-void #f)) - ((,x) x) - ((,x . ,rest) + ((x) x) + ((x . rest) (make-seq #f x (join rest env))) - (else (error "what!" exps env)))) + (_ (error "what!" exps env)))) + +(define (choose-compiler target optimization-level opts) + (if (match (memq #:cps? opts) + ((_ cps? . _) cps?) + (#f (<= 1 optimization-level))) + (cons 'cps compile-cps) + (cons 'bytecode compile-bytecode))) (define-language tree-il #:title "Tree Intermediate Language" @@ -44,7 +52,9 @@ #:printer write-tree-il #:parser parse-tree-il #:joiner join - #:compilers `((cps . ,compile-cps)) + #:compilers `((cps . ,compile-cps) + (bytecode . ,compile-bytecode)) + #:compiler-chooser choose-compiler #:analyzer make-analyzer #:lowerer make-lowerer #:for-humans? #f)