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

111 commits

Author SHA1 Message Date
Andy Wingo
a1a482e0e9 and, or, cond etc use syntax-rules, compile scheme through tree-il
* libguile/vm-i-system.c:
* libguile/vm-engine.h (ASSERT_BOUND): New assertion, that a value is
  bound. Used by local-ref and external-ref in paranoid mode.

* module/ice-9/boot-9.scm (and, or, cond, case, do): Since we are
  switching to use psyntax as the first pass of the compiler, and perhaps
  soon of the interpreter too, we need to make sure it expands out all
  forms to primitive expressions. So define expanders for these derived
  syntax forms, as in the R5RS report.

* module/ice-9/psyntax-pp.scm: Regenerate, with core forms fully
  expanded.

* module/ice-9/psyntax.scm (build-void): New constructor, for making
  undefined values.
  (build-primref): Add in a hack so that primitive refs in the boot
  module expand out to toplevel refs, not module refs.
  (chi-void): Use build-void.
  (if): Define an expander for if that calls build-conditional.

* module/language/scheme/compile-tree-il.scm (compile-tree-il): Use let*
  so as not to depend on binding order for the result of
  (current-module).

* module/language/scheme/spec.scm (scheme): Switch over to tree-il as the
  primary intermediate language. Not yet fully tested, but at least it
  can compile psyntax-pp.scm.

* module/language/tree-il/analyze.scm (analyze-lexicals): Arguments don't
  count towards a function's nlocs.

* module/language/tree-il/compile-glil.scm (*comp-module*, compile-glil):
  Define a "compilation module" fluid.
  (flatten-lambda): Fix a call to make-glil-argument. Fix bug in
  heapifying arguments.
  (flatten): Fix number of arguments passed to apply instruction. Add a
  special case for `(values ...)'. If inlining primitive-refs fails,
  try expanding into toplevel-refs if the comp-module's variable is the
  same as the root variable.

* module/language/tree-il/optimize.scm (resolve-primitives!): Add missing
  src variable for <module-ref>.

* test-suite/tests/tree-il.test ("lambda"): Fix nlocs counts. Add a
  closure test case.
2009-05-20 11:15:22 +02:00
Andy Wingo
dce042f1f7 special cases for more types of known applications
* module/language/tree-il/compile-glil.scm (flatten): Handle a number of
  interesting applications, and fix a bug for calls in `drop' contexts.

* module/language/tree-il/inline.scm: Define expanders for apply,
  call-with-values, call-with-current-continuation, and values.
2009-05-18 01:08:34 +02:00
Andy Wingo
112edbaea3 inline calls to some primitives
* module/system/base/pmatch.scm: Wrap consequents in (let () ) instead of
  (begin ) so that they can have local definitions.

* module/language/tree-il/compile-glil.scm: Inline some calls to
  primitives.
2009-05-17 23:24:26 +02:00
Andy Wingo
1eec95f8de define `delay' in terms of make-promise
* module/ice-9/boot-9.scm (delay): Define `delay' in terms of
  make-promise.

* module/ice-9/psyntax-pp.scm (compile): Regenerated with a fully
  compiled Guile, so that the gensym numbers are the same.

* module/language/tree-il/compile-glil.scm: Add some notes about what
  needs doing to catch up to the old compiler.
2009-05-17 18:04:36 +02:00
Andy Wingo
2ce77f2d95 and now, we residualize the original names into the metadata. yay!
* module/language/tree-il/compile-glil.scm (vars->bind-list)
  (emit-bindings, flatten-lambda, flatten): Write the original names into
  <glil-bind> structures. Yaaaaay!
2009-05-17 16:46:46 +02:00
Andy Wingo
696495f4d2 actually pass original ids on to tree-il data types
* module/ice-9/psyntax.scm (build-lambda, build-let, build-named-let)
  (build-letrec): Actually pass along the original ids to tree-il
  constructors.

* module/ice-9/psyntax-pp.scm: Regenerated.

* module/language/tree-il.scm: Add fields in <lambda>, <let>, and
  <letrec> for the original variable names.

* module/language/tree-il/compile-glil.scm (compile-glil): Adapt for new
  make-lambda arg.
2009-05-17 16:39:55 +02:00
Andy Wingo
cf10678fe7 tree-il -> glil compiler works now, at least in initial tests
* module/language/tree-il/analyze.scm: Break analyzer out into its own
  file.

* module/language/tree-il/compile-glil.scm: Port the GHIL->GLIL compiler
  over to work on tree-il. Works, but still misses a number of important
  optimizations.

* module/language/tree-il.scm: Add <void>. Not used quite yet.

* module/language/glil.scm: Remove <glil-argument>, as it is the same as
  <glil-local> (minus an offset).

* module/language/glil/compile-assembly.scm:
* module/language/glil/decompile-assembly.scm:
* module/language/ghil/compile-glil.scm: Adapt for <glil-argument>
* removal.

* module/Makefile.am (TREE_IL_LANG_SOURCES): Reorder, and add
  analyze.scm.
2009-05-15 23:44:14 +02:00
Andy Wingo
073bb617eb add lexical analyzer and allocator
* module/language/tree-il/optimize.scm: Rework to just export the
  optimize! procedure.

* module/language/tree-il/compile-glil.scm (analyze-lexicals): New
  function, analyzes and allocates lexical variables. Almost ready to
  compile now.
  (codegen): Dedent.
2009-05-14 00:11:54 +02:00
Andy Wingo
9efc833d65 add tree-il optimizer
* module/language/tree-il/optimize.scm: New module, for optimizations.
  Currently all we have is resolving some toplevel refs to primitive
  refs.

* module/Makefile.am: Add new module.

* module/language/tree-il.scm: Fix exports for accessors for `src'.

* module/language/tree-il/compile-glil.scm: Tweaks, things still aren't
  working yet.
2009-05-11 23:23:34 +02:00
Andy Wingo
b81d329e44 more work on tree-il compilation
* module/language/scheme/amatch.scm: Remove, this approach won't be used.

* module/Makefile.am: Adjust for additions and removals.

* module/language/scheme/compile-ghil.scm: Remove an vestigial debugging
  statement.

* module/language/scheme/spec.scm:
* module/language/scheme/compile-tree-il.scm:
* module/language/scheme/decompile-tree-il.scm: Add tree-il compiler and
  decompiler.

* module/language/tree-il/compile-glil.scm: Add some notes.

* module/language/tree-il/spec.scm: No need to wrap expressions in
  lambdas -- GHIL needs somewhere to put its variables, we don't.
2009-05-08 12:56:18 +02:00
Andy Wingo
811d10f5a2 new language: tree-il. psyntax generates it when run in compile mode.
* module/Makefile.am: Add tree-il sources.

* module/ice-9/compile-psyntax.scm: Adjust for sc-expand producing
  tree-il in compile mode.

* module/ice-9/psyntax.scm: Switch from expand-support to tree-il for
  generating output in compile mode. Completely generate tree-il -- the
  output wasn't Scheme before, but now it's completely not Scheme.

* module/ice-9/psyntax-pp.scm: Regenerated.

* module/language/scheme/compile-ghil.scm: Strip structures using
  tree-il, not expand-support.

* module/language/tree-il.scm:
* module/language/tree-il/spec.scm
* module/language/tree-il/compile-glil.scm: New language. It will compile
  to GLIL, though it doesn't yet.
2009-05-07 17:32:01 +02:00