mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-28 22:10:29 +02:00
Add $switch CPS term kind
* module/language/cps.scm ($switch): New term. * doc/ref/compiler.texi (CPS in Guile): Add documentation. * module/language/cps.scm (build-term, parse-cps, unparse-cps) * module/language/cps/closure-conversion.scm (compute-non-operator-uses) (compute-singly-referenced-labels, rewrite-shared-closure-calls) (compute-free-vars, convert-one) * module/language/cps/compile-bytecode.scm (compile-function) * module/language/cps/contification.scm (compute-singly-referenced-labels) (compute-contification-candidates, apply-contification) * module/language/cps/cse.scm (compute-truthy-expressions) (forward-cont, term-successors, eliminate-common-subexpressions-in-fun) * module/language/cps/dce.scm (compute-known-allocations) (compute-live-code, process-eliminations) * module/language/cps/devirtualize-integers.scm (compute-use-counts) (peel-trace) * module/language/cps/effects-analysis.scm (compute-effects) * module/language/cps/licm.scm (hoist-one, hoist-in-loop) * module/language/cps/loop-instrumentation.scm (compute-loop-headers) * module/language/cps/peel-loops.scm (rename-cont) * module/language/cps/renumber.scm (sort-labels-locally, renumber) * module/language/cps/rotate-loops.scm (rotate-loop) (rotate-loops-in-function) * module/language/cps/self-references.scm (resolve-self-references) * module/language/cps/simplify.scm (compute-singly-referenced-vars) (eta-reduce, compute-singly-referenced-labels, beta-reduce) * module/language/cps/slot-allocation.scm (compute-defs-and-uses) (add-prompt-control-flow-edges, compute-var-representations) * module/language/cps/specialize-numbers.scm (compute-significant-bits) * module/language/cps/split-rec.scm (compute-free-vars) * module/language/cps/type-fold.scm (local-type-fold) * module/language/cps/types.scm (successor-count, infer-types) * module/language/cps/utils.scm (compute-function-body) (compute-successors, compute-predecessors) * module/language/cps/verify.scm (compute-available-definitions) (check-valid-var-uses, check-arities): Add support for new term.
This commit is contained in:
parent
a7f4a6f1c4
commit
cd5ab6377b
24 changed files with 236 additions and 48 deletions
|
@ -1,6 +1,6 @@
|
|||
;;; Continuation-passing style (CPS) intermediate language (IL)
|
||||
|
||||
;; Copyright (C) 2013, 2014, 2015, 2017, 2018 Free Software Foundation, Inc.
|
||||
;; Copyright (C) 2013-2015,2017-2018,2020 Free Software Foundation, Inc.
|
||||
|
||||
;;;; This library is free software; you can redistribute it and/or
|
||||
;;;; modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -127,7 +127,7 @@
|
|||
$kreceive $kargs $kfun $ktail $kclause
|
||||
|
||||
;; Terms.
|
||||
$continue $branch $prompt $throw
|
||||
$continue $branch $switch $prompt $throw
|
||||
|
||||
;; Expressions.
|
||||
$const $prim $fun $rec $const-fun $code
|
||||
|
@ -180,6 +180,7 @@
|
|||
;; Terms.
|
||||
(define-cps-type $continue k src exp)
|
||||
(define-cps-type $branch kf kt src op param args)
|
||||
(define-cps-type $switch kf kt* src arg)
|
||||
(define-cps-type $prompt k kh src escape? tag)
|
||||
(define-cps-type $throw src op param args)
|
||||
|
||||
|
@ -221,7 +222,7 @@
|
|||
(make-$kclause (build-arity arity) kbody kalternate))))
|
||||
|
||||
(define-syntax build-term
|
||||
(syntax-rules (unquote $continue $branch $prompt $throw)
|
||||
(syntax-rules (unquote $continue $branch $switch $prompt $throw)
|
||||
((_ (unquote exp))
|
||||
exp)
|
||||
((_ ($continue k src exp))
|
||||
|
@ -232,6 +233,8 @@
|
|||
(make-$branch kf kt src op param (list arg ...)))
|
||||
((_ ($branch kf kt src op param args))
|
||||
(make-$branch kf kt src op param args))
|
||||
((_ ($switch kf kt* src arg))
|
||||
(make-$switch kf kt* src arg))
|
||||
((_ ($prompt k kh src escape? tag))
|
||||
(make-$prompt k kh src escape? tag))
|
||||
((_ ($throw src op param (unquote args)))
|
||||
|
@ -299,6 +302,8 @@
|
|||
(build-term ($continue k (src exp) ,(parse-cps exp))))
|
||||
(('branch kf kt op param arg ...)
|
||||
(build-term ($branch kf kt (src exp) op param arg)))
|
||||
(('switch kf (kt* ...) arg)
|
||||
(build-term ($switch kf kt* (src exp) arg)))
|
||||
(('prompt k kh escape? tag)
|
||||
(build-term ($prompt k kh (src exp) escape? tag)))
|
||||
(('throw op param arg ...)
|
||||
|
@ -350,6 +355,8 @@
|
|||
`(continue ,k ,(unparse-cps exp)))
|
||||
(($ $branch kf kt src op param args)
|
||||
`(branch ,kf ,kt ,op ,param ,@args))
|
||||
(($ $switch kf kt* src arg)
|
||||
`(switch ,kf ,kt* ,arg))
|
||||
(($ $prompt k kh src escape? tag)
|
||||
`(prompt ,k ,kh ,escape? ,tag))
|
||||
(($ $throw src op param args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue