1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00
Commit graph

81 commits

Author SHA1 Message Date
Andy Wingo
4aabc205cc Add missing files
Last commit meant to rename files, not delete them.  Whoops!
2015-07-22 18:27:37 +02:00
Andy Wingo
420423f9a0 Remove CPS optimization passes and closure conversion
* module/language/cps/closure-conversion.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm: Remove these files, obsoleted by CPS2.

* module/Makefile.am: Update.
2015-07-16 07:58:36 +02:00
Andy Wingo
50fcdfece3 Remove "free" field of $fun
* module/language/cps.scm ($fun): Remove unused "free" field.
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt all callers.
2015-04-01 10:10:10 +02:00
Andy Wingo
34ff3af9f0 Replace $letrec with $rec
* module/language/cps.scm ($rec): Replace $letrec with $rec, which is an
  expression, not a term.  This means that the names bound by the letrec
  appear twice: once in the $rec term, and once in the continuation.
  This is not very elegant, but the situation is better than it was
  before.  Adapt all callers.

* doc/ref/compiler.texi (CPS in Guile): Incomplete documentation
  updates.  I'll update these later when the IL settles down.
2015-04-01 10:10:10 +02:00
Andy Wingo
a9ec16f9c5 Remove $void CPS expression type
* module/language/cps.scm: Remove the $void expression type, replaced by
  $const of the unspecified value.
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Update callers.
2015-03-11 21:51:33 +01:00
Andy Wingo
7700e67226 Remove dead case in CSE
* module/language/cps/cse.scm (apply-cse): Remove a case that couldn't
  occur.
2014-07-22 12:18:07 +02:00
Andy Wingo
6fc634f8a3 CSE allocate-struct fix
* module/language/cps/cse.scm (compute-equivalent-subexpressions):
  Fix handling of allocate-struct in tail position.
2014-07-21 21:38:17 +02:00
Andy Wingo
c1a41f96b4 CSE comments
* module/language/cps/cse.scm (compute-available-expressions): Add
  clarifying comment.
2014-07-03 09:03:45 +02:00
Andy Wingo
072b5a277c CSE truth inference pass uses intsets
* module/language/cps/cse.scm (compute-truthy-expressions): Rewrite to
  use intsets instead of bitvectors.
  (apply-cse): Adapt.
2014-06-29 19:47:38 +02:00
Andy Wingo
6fe36f220e Rewrite CSE to use intsets.
* module/language/cps/cse.scm: Rewrite using intsets.
2014-06-29 14:26:02 +02:00
Andy Wingo
38c7bd0e77 Refactor dominator computation
* module/language/cps/cse.scm:
* module/language/cps/dfg.scm (compute-idoms, compute-dom-edges): Move
  these procedures from cse.scm to dfg.scm.
  Remove loop-detection code; that can come back later but it is
  bitrotten for now.
2014-06-19 08:48:07 +02:00
Andy Wingo
59258f7cad Remove $kif
* module/language/cps.scm: Remove $kif.

* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm: Adapt.
2014-05-31 21:43:12 -04:00
Andy Wingo
92805e2197 Add $branch expression type
* module/language/cps.scm ($branch): New expression type; will replace
  $kif.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/type-fold.scm:
* module/language/cps/types.scm:
* module/language/cps/verify.scm: Adapt to $branch expression type.
2014-05-31 21:15:06 -04:00
Andy Wingo
5d25fdae37 Rewrite effects analysis to be precise for fields.
* module/language/cps/effects-analysis.scm: Rewrite so that instead of
  the depends/causes effects, there is just &type-check, &allocation,
  &read, and &write.  The object kind is a separate part of the
  bitfield, and the field in the object (if appropriate) is another
  field.  Effects are still a fixnum.  This enables precise effects for
  vectors and structs on all architectures.

  This kind of effects analysis was not possible in Tree-IL because
  Tree-IL relied on logior-ing effects of subexpressions, whereas with
  CPS we have no sub-expressions and we do flow analysis instead.

  (effect-clobbers?): Replace effects-commute? with this inherently
  directional and precise predicate.

* module/language/cps/cse.scm (compute-always-available-expressions):
  (compute-equivalent-subexpressions): Adapt to effects analysis
  change.
* module/language/cps/dce.scm (compute-live-code): Likewise.
2014-05-08 10:39:49 +02:00
Andy Wingo
466bdf7ee3 CSE effects analysis cleanup
* module/language/cps/cse.scm (compute-always-available-expressions):
  Use constant? instead of zero?, to avoid punching through the effects
  abstraction.
2014-05-07 17:10:15 +02:00
Andy Wingo
c8d87b4745 Synthetic definitions take advantage of CSE'd vars
* module/language/cps/cse.scm (compute-available-expressions):
  Simplify initialization.
  (compute-equivalent-subexpressions): When synthesizing definitions,
  use substed vars.  Add synthetic definitions after processing an
  expression, to take advantage of the substed vars.
2014-05-07 15:28:12 +02:00
Andy Wingo
41812daa78 Add auxiliary definitions for boxes
* module/language/cps/cse.scm (compute-equivalent-subexpressions): Add
  auxiliary definitions for boxes.
2014-05-03 12:21:43 +02:00
Andy Wingo
6119a90595 CSE does scalar replacement of aggregates
* module/language/cps/effects-analysis.scm (effects-clobber): New
  helper.
  (length): Only depend on &cdr.
  (synthesize-definition-effects!): New interface.

* module/language/cps/cse.scm (compute-available-expressions): Don't
  count out constructors here -- we'll do that below.
  (compute-defs): Add a comment.
  (compute-equivalent-subexpressions): Synthesize getter calls at
  constructor/setter sites, so that (set-car! x y) can cause a
  future (car x) to just reference y.  The equiv-labels set now stores
  the defined vars, so there is no need for the defs vector.
  (cse, apply-cse): Adapt to compute-equivalent-subexpressions change.
2014-05-02 17:47:20 +02:00
Andy Wingo
405805fbc3 Separate make-cont-folder into global and local variants
* module/language/cps.scm (make-global-cont-folder)
  (make-local-cont-folder): Separate this macro in two.  It's hot and
  the difference can be important for perf.

* module/language/cps/dfg.scm (compute-label-and-var-ranges):
* module/language/cps/cse.scm (compute-label-and-var-ranges):
* module/language/cps/dce.scm (compute-live-code): Adapt.
2014-04-11 18:32:54 +02:00
Andy Wingo
a0329d0109 Root higher-order CPS term is always $kfun $cont
* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/tree-il/compile-cps.scm: Adapt to produce and consume
  raw $kfun $cont instances.

* .dir-locals.el: Update $letrec indentation.
2014-04-11 14:01:27 +02:00
Andy Wingo
a16af11320 compute-dfg takes a $kfun $cont, not a $fun
* module/language/cps/dfg.scm (compute-dfg): Take a $kfun $cont instead
  of a $fun.

* module/language/cps/arities.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/simplify.scm:
* module/language/cps/specialize-primcalls.scm: Adapt callers.
2014-04-11 11:22:06 +02:00
Andy Wingo
686a6490f4 Function defined by make-cont-folder takes a cont, not a $fun
* module/language/cps.scm (make-cont-folder): Take a cont instead of a
  $fun.
  (with-fresh-name-state): Adapt.

* module/language/cps/cse.scm (compute-label-and-var-ranges):
* module/language/cps/dce.scm (compute-live-code):
* module/language/cps/dfg.scm (compute-dfg):
* module/language/cps/elide-values.scm (elide-values):
* module/language/cps/reify-primitives.scm (reify-primitives):
* module/language/cps/renumber.scm (compute-new-labels-and-vars):
  (renumber): Adapt.
2014-04-11 10:12:37 +02:00
Andy Wingo
8320f50431 Rename $kentry to $kfun
* module/language/cps.scm ($kfun): Rename from $kentry.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/effects-analysis.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt users.
2014-04-10 12:11:35 +02:00
Andy Wingo
24b611e81c src and meta are fields of $kentry, not $fun
* module/language/cps.scm ($kentry, $fun): Attach "src" and "meta" on
  the $kentry, not the $fun.  This prepares us for $callk to $kentry
  continuations that have no corresponding $fun.

* module/language/cps/arities.scm:
* module/language/cps/closure-conversion.scm:
* module/language/cps/compile-bytecode.scm:
* module/language/cps/constructors.scm:
* module/language/cps/contification.scm:
* module/language/cps/cse.scm:
* module/language/cps/dce.scm:
* module/language/cps/dfg.scm:
* module/language/cps/elide-values.scm:
* module/language/cps/prune-bailouts.scm:
* module/language/cps/prune-top-level-scopes.scm:
* module/language/cps/reify-primitives.scm:
* module/language/cps/renumber.scm:
* module/language/cps/self-references.scm:
* module/language/cps/simplify.scm:
* module/language/cps/slot-allocation.scm:
* module/language/cps/specialize-primcalls.scm:
* module/language/cps/verify.scm:
* module/language/tree-il/compile-cps.scm: Adapt.
2014-04-10 10:50:17 +02:00
Andy Wingo
d03c3c7795 Flow-sensitive analysis of truth values
* module/language/cps/cse.scm (compute-truthy-expressions):
  (compute-equivalent-subexpressions, apply-cse): Arrange to infer
  truthiness of expressions, and use that information to elide redundant
  tests.
2014-04-06 10:38:48 +02:00
Andy Wingo
df1bdc1ea7 Minor cleanup/optimization in CSE
* module/language/cps/cse.scm (compute-available-expressions): Remove
  needless for-each definition.
  (compute-equivalent-subexpressions): Optimize for-each/2.
2014-04-05 14:38:37 +02:00
Andy Wingo
4fef637362 Remove &bailout; replace uses of &unknown-effects with &all-effects
* module/language/cps/effects-analysis.scm (&bailout): Remove effect.
  (&unknown-effects): Remove.  Replace uses with &all-effects.
* module/language/cps/cse.scm:
2014-04-05 11:40:22 +02:00
Andy Wingo
9382794ab6 Remove parts of CSE that deal with bailout
* module/language/cps/cse.scm (compute-available-expressions, cse):
  (compute-idoms, compute-equivalent-subexpressions, apply-cse): Remove
  attempts to deal with bailout, as the bailout pass handles that
  already.
2014-04-05 11:40:21 +02:00
Andy Wingo
8c6a0b7e13 More bailout preparation work
* module/language/cps/cse.scm (compute-available-expressions): Compute a
  bailout set -- or at least, set things up so that we can do so.
  (compute-idoms): Don't add predecessors that bail out.
  (apply-cse, cse, compute-equivalent-subexpressions): Thread the
  bailout set through the computations.
2014-04-04 14:29:11 +02:00
Andy Wingo
780ad383bb Prepare for CSE bailout propagation
* module/language/cps/cse.scm (compute-available-expressions): Prepare
  for being able to prune joins from bailouts.  Always loop after the
  first iteration.

* module/language/cps/effects-analysis.scm: Remove &possible-bailout.
  Rename &definite-bailout to &bailout, and rename
  &all-effects-but-bailout to &unknown-effects.
2014-04-04 14:22:51 +02:00
Andy Wingo
7a08e47967 Add common subexpression elimination pass on CPS
* module/language/cps/cse.scm: New file.
* module/language/cps/compile-bytecode.scm: Wire up CSE, on by default.
  Currently using the #:cps-cse? keyword.

* module/Makefile.am: Add new file.
2014-04-04 12:15:10 +02:00