1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-05 23:20:38 +02:00
Commit graph

19998 commits

Author SHA1 Message Date
Andy Wingo
80c162b67c Port effects analysis to CPS2
* module/Makefile.am (CPS2_LANG_SOURCES): Add effects-analysis.scm.
* module/language/cps2/effects-analysis.scm: New file, based on
  cps/effects-analysis.scm.
* module/language/cps2/utils.scm (intmap-map):
  (compute-defining-expressions, compute-constant-values): New helpers.
2015-05-20 19:18:45 +02:00
Andy Wingo
7d4ede040d Fix bug in CPS2 simplify's "transform-conts"
* module/language/cps2/simplify.scm (transform-conts): Return a persistent intmap.
2015-05-20 19:18:45 +02:00
Andy Wingo
102e677b98 intmaps and intsets print with abbreviated key ranges
* module/language/cps/intset.scm (intset-key-ranges, range-string):
  (print-helper, print-intset, print-transient-intset): New helpers.
  Install as intset printers.
* module/language/cps/intmap.scm (intmap-key-ranges, range-string):
  (print-helper): New helpers.
  (print-intmap, print-transient-intmap): Call the new helpers.
2015-05-20 19:18:45 +02:00
Andy Wingo
1403df4140 Add arity to worklist-fold
* module/language/cps2/utils.scm (worklist-fold): Add two-seeded arity.
  (worklist-fold2): Remove.

* module/language/cps2/renumber.scm (compute-tail-path-lengths): Adapt.
2015-05-20 19:18:45 +02:00
Andy Wingo
5f7c8e5cb3 Variadic intset-fold, intmap-fold
* module/language/cps/intmap.scm (intmap-fold): Add two-seeded arity.
* module/language/cps/intset.scm (intset-fold): Merge intset-fold2
  into this function, as a two-seeded arity.

* module/language/cps2/simplify.scm (compute-eta-reductions):
  (compute-singly-referenced-labels, compute-beta-reductions): Adapt
  intset-fold2 callers.
2015-05-20 19:18:45 +02:00
Andy Wingo
2b06e90ca4 Intmaps do not treat #f specially as a value
* module/language/cps/intmap.scm: Intmaps can now contain any value;
  #f does not indicate the absence of a value.  Instead we use a unique
  private sentinel to mark absent values or branches.
  (*absent*, absent?, present?): New helpers.
  (new-branch): Initialize empty elements to *absent*.
  (clone-branch-with-edit): New helper.
  (clone-branch-and-set): Use clone-branch-with-edit.
  (writable-branch): Use clone-branch-with-edit
  (empty-intmap): Initialize value to *absent*.
  (add-level): clone-branch-and-set doesn't take #f as a branch any
  more; use new-branch.
  (branch-empty?, make-intmap/prune, intmap-add!):
  (intmap-add, intmap-remove, intmap-next, intmap-prev):
  (intmap-fold, intmap-union, intmap-intersect): Use absent? to detect
  absent branches / values.
  (intmap-ref): Likewise.  Instead of returning #f if the value is not
  found, call the optional not-found procedure.  By default this will
  signal an error.

* module/language/cps/types.scm:
* module/language/cps2/renumber.scm:
* module/language/cps2/simplify.scm: Adapt to intmap-ref signalling an
  error by default if the value is not found.

* module/language/tree-il/compile-cps2.scm: Adapt to intmap-add
  signalling an error if #f was in the intmap as a value.
2015-05-20 19:18:45 +02:00
Andy Wingo
cb7aa0b3b1 Add two-argument fixpoint arity
* module/language/cps2/utils.scm (fixpoint): Add two-argument arity.
2015-05-20 19:18:45 +02:00
Andy Wingo
4632f3d998 Fix bug compiling fixpoint combinator
* module/language/tree-il/peval.scm (<operand>): Rename "alias-value"
  field to "alias", which is now an operand and not an expression.
  This allows the operand to capture its environment; before, the
  alias was being visited in its use environment instead of its
  definition environment.
  (peval): Adapt to operand change.  Fix construction of rest bindings
  as well.
* test-suite/tests/peval.test ("partial evaluation"): New test.
2015-05-20 19:18:45 +02:00
Andy Wingo
e0e47cb527 Fix fixpoint
* module/language/cps2/utils.scm (fixpoint): Fix embarrassing bug
  where it wouldn't actually fixpoint!  Didn't show up in practice
  because CPS2 hasn't run after contification yet.
2015-05-20 19:18:45 +02:00
Andy Wingo
fa7df5ed3a Fix sub/- primcall bug
* module/language/tree-il/compile-cps2.scm (convert): Fix bug
  in (apply - ...), because the instruction for "-" is "sub", and
  "sub" lookup was failing.  Caught by numbers.test.  Really I would
  like to get rid of $prim, somehow.
2015-05-20 19:18:45 +02:00
pcpa
9a90a28360 alpha: Add initial jit_va_ calls to alpha
* lib/jit_alpha-cpu.c, lib/jit_alpha-fpu.c, lib/jit_alpha.c:
	Add base support to jit vararg functions to the alpha backend.
2015-05-20 13:09:22 -03:00
pcpa
fdd55b903a hppa: Add initial jit_va_ calls to hppa
* lib/jit_hppa-cpu.c, lib/jit_hppa-fpu.c, lib/jit_hppa.c:
	Add base support to jit vararg functions to the hppa backend.
2015-05-19 19:39:28 -03:00
Andy Wingo
ef5f2fcaaa Add optimization pass over CPS2
* module/language/cps2/optimize.scm: New file.
* module/language/cps2/simplify.scm: New file, factored out of
  simplify2.scm.

* module/language/cps/simplify2.scm: Remove, as it's obsolete.

* module/language/cps2/compile-cps.scm: Optimize the CPS.

* module/Makefile.am: Adapt for added and deleted files.
2015-05-12 21:53:42 +02:00
Andy Wingo
b31af02faf Consolidate CPS2 above CPS in the compiler
This is an intermediate step.  We'll replace CPS bit by bit.  If it
turns out to be a terrible idea we can just revert.

* module/Makefile.am (TREE_IL_LANG_SOURCES): Remove compile-cps.scm.
  (CPS_LANG_SOURCES): Remove arities.scm.

* module/language/cps/arities.scm: Remove.
* module/language/tree-il/compile-cps.scm: Remove.

* module/language/tree-il/spec.scm: Remove use of compile-cps.scm.

* module/language/cps/compile-bytecode.scm: Remove use of arities.scm.
  Instead, incoming terms are expected to call their continuations
  with the correct number of arguments.
2015-05-11 22:43:25 +02:00
Andy Wingo
9833c545cc Adapt return arities in Tree-IL -> CPS2 conversion
* module/language/tree-il/compile-cps2.scm (adapt-arity): New
  procedure.  This is equivalent to (language cps arities), but as it
  is a necessary pass and not an optimization it's more proper to put
  it in the converter itself.  Unlike with the nested CPS
  representation, it's possible to look up continuations without
  making a DFG.
  (convert): Adapt arities as necessary.
2015-05-11 22:43:20 +02:00
Andy Wingo
3ab3cdecda Build CPS2 with transient intmaps
* module/language/tree-il/compile-cps2.scm (with-cps)
  (cps-convert/thunk): Use transient intmaps.
2015-05-11 22:43:19 +02:00
Paulo Andrade
6d8f8eb604 ia64: Add initial jit_va_ calls to ia64
* lib/jit_ia64-cpu.c, lib/jit_ia64-fpu.c, lib/jit_ia64.c:
	Add base support to jit vararg functions to the ia64 backend.
2015-05-10 19:35:40 -03:00
Paulo Andrade
a3063df782 ia64: Do not use a dangling pointer for double to integer copy
* lib/jit_ia64-fpu.c, lib/jit_ia64.c: Correct movi_d_w
	and movi_f_w implementation to work when not using a
	data buffer. This causes the check varargs.tst to
	work when passing "-d" to the lightning test tool.
2015-05-10 18:33:05 -03:00
Paulo Andrade
f48e07b58b ia64: Implement cache flush.
* lib/jit_ia64.c: Implement inline assembly cache flush,
	required on multiprocessor systems.
2015-05-10 16:22:26 -03:00
Andy Wingo
5928d16a8e Tree-IL -> CPS2 -> CPS
* module/language/tree-il/spec.scm (tree-il): Compile to CPS2 instead of CPS.
2015-05-09 16:52:09 +02:00
Andy Wingo
219b6f82a2 compute-dom-edges returns a persistent intmap
* module/language/cps/utils.scm (compute-dom-edges): Return a
  persistent intmap.  Fixes strange bootstrapping failures that I
  don't understand :/.
2015-05-09 16:52:09 +02:00
Andy Wingo
7fedd7b7ad Fix another intset transient bug
* module/language/cps/intset.scm (intset-add!): If the root is a
  branch but isn't editable, be sure to actually update the transient
  intset's root to store the writable root.
2015-05-09 14:52:47 +02:00
Andy Wingo
f95a794a3d Fix intset-add! transient bug
* module/language/cps/intset.scm (intset-add!): Fix as in
  0f082bd3f7.
2015-05-09 13:46:18 +02:00
Andy Wingo
d99fedc5fd Fix convert-cps2 for "not" primcalls
* module/language/tree-il/compile-cps2.scm (convert): Fix typo in "not"
  compilation.
2015-05-08 15:44:50 +02:00
Andy Wingo
0f082bd3f7 Fix intmap-add! transient bug
* module/language/cps/intmap.scm (intmap-add!): Fix a bug creating a
  transient branch out of a persistent branch.
2015-05-08 14:09:40 +02:00
Andy Wingo
09869e781b Register up cps2 compiler with language tower
* module/language/tree-il/compile-cps2.scm (compile-cps2): Rename from compile-cps.
* module/language/cps2/spec.scm: New file.
* module/Makefile.am (CPS2_LANG_SOURCES): Add spec.scm.
* module/language/tree-il/spec.scm (tree-il): Declare compiler to cps2.
2015-05-08 13:35:08 +02:00
Andy Wingo
7cd61e2bf6 cps2: Fix parse-cps for `prompt'
* module/language/cps2.scm (parse-cps): Fix for `prompt'.
2015-05-08 13:19:59 +02:00
Andy Wingo
773595f0db Add compiler from tree-il to cps2
* module/language/tree-il/compile-cps2.scm: New file.
* module/Makefile.am: Add the file to the build.
2015-05-08 11:46:46 +02:00
Andy Wingo
6485e89276 Beginnings of CPS2 language.
The tentative plan is to replace CPS with CPS2, and to rename CPS2 to
CPS.  We will add a pass to compile tree-il to CPS2, then work from
the top down to replace the CPS compiler passes.

* module/language/cps2.scm:
* module/language/cps2/compile-cps.scm:
* module/language/cps2/renumber.scm:
* module/language/cps2/utils.scm: New files.

* module/Makefile.am: Add new files to build.
2015-05-08 11:46:46 +02:00
Andy Wingo
6ffb6e69ed Add printers for <intmap> and <transient-intmap>
* module/language/cps/intmap.scm (intmap->alist, print-intmap)
  (print-transient-intmap): New functions.
  Install the new functions as printers for <intmap> and <transient-intmap>.
2015-05-08 11:46:46 +02:00
pcpa
a5ab4c7718 mips: Add initial jit_va_ calls to mips
* lib/jit_mips-cpu.c, lib/jit_mips-fpu.c, lib/jit_mips.c:
	Add base support to jit vararg functions to the mips backend.
	Currently only supported on the o32 abi, until access to a
	n32 system is arranged.
2015-05-06 20:02:17 -03:00
pcpa
b42bb8b7a1 Remove wrong comment after cut and paste 2015-05-05 20:57:18 -03:00
pcpa
cc217f0608 ppc: Add initial jit_va_ calls to ppc
* lib/jit_ppc-cpu.c, lib/jit_ppc-fpu.c, lib/jit_ppc.c:
	Add base support to jit vararg functions to the PowerPC backend.
2015-05-05 20:55:05 -03:00
pcpa
2c8b5e530c s390: Add initial jit_va_ calls to s390
* lib/jit_s390-cpu.c, lib/jit_s390-fpu.c, lib/jit_s390.c:
	Add base support to jit vararg functions to the s390 backend.
2015-05-02 21:15:16 -03:00
pcpa
8cb302f337 arm: Add initial jit_va_ calls to arm
* lib/jit_arm-cpu.c, lib/jit_arm-swf.c, lib/jit_arm-vfp.c,
	lib/jit_arm.c: Add base support to jit vararg
	functions to the arm backend.
2015-05-01 14:05:00 -03:00
pcpa
0986ae8a86 aarch64: Add initial jit_va_ calls to aarch64
* lib/jit_aarch64-cpu.c, lib/jit_aarch64-fpu.c,
	lib/jit_aarch64.c: Add base support to jit vararg
	functions to the aarch64 backend.
2015-04-30 17:40:14 -03:00
pcpa
6329945281 Correct update of on stack vararg double argument pointer 2015-04-30 14:04:32 -03:00
pcpa
e4fe5186e6 Update the correct fp offset and add assertions 2015-04-30 10:17:17 -03:00
pcpa
d639674549 Add initial support to implement vararg jit functions
* include/lightning.h, include/lightning/jit_private.h,
	lib/jit_names.c, lib/lightning.c: Add initial support
	for the new jit_va_start, jit_va_arg, jit_va_arg_d, and
	jit_va_end interfaces. The jit_va_start call is supposed
	to return a va_list compatible pointer, but not yet
	decided if it will be "declared" stdarg compatible,
	as for now only x86 support has been added (and should
	be compatible), but issues may arise on other backends.

	* check/lightning.c: Add wrappers to call the new jit_va_*
	interfaces.

	* lib/jit_x86-cpu.c, lib/jit_x86.c: Implement the new
	jit_va_* for x86.

	* lib/jit_x86-sz.c: Add fields, but not yet fully updated,
	as this is an intermediate commit.

	* lib/jit_aarch64-sz.c, lib/jit_aarch64.c,
	lib/jit_alpha-sz.c, lib/jit_alpha.c,
	lib/jit_arm-sz.c, lib/jit_arm.c,
	lib/jit_hppa-sz.c, lib/jit_hppa.c,
	lib/jit_ia64-sz.c, lib/jit_ia64.c,
	lib/jit_mips-sz.c, lib/jit_mips.c,
	lib/jit_ppc-sz.c, lib/jit_ppc.c,
	lib/jit_s390-sz.c, lib/jit_s390.c,
	lib/jit_sparc-sz.c, lib/jit_sparc.c: Prepare for the
	new jit_va_* interfaces. Not yet implemented, and will
	cause an assertion if used.

	* check/va_list.tst: Simple early test case, that works
	on x86_64, x32, ix86, cygwin, and cygwin64.
2015-04-27 21:12:32 -03:00
pcpa
a15f261afc Update copyright date 2015-04-26 14:33:41 -03:00
Andy Wingo
eb9d442840 Add "cps2" experiment
* module/Makefile.am: Add new file to makefile.
* module/language/cps/simplify2.scm: New file.
2015-04-08 17:19:28 +02:00
Andy Wingo
49cc76ab75 Transient intsets
* module/language/cps/intset.scm (make-atomic-reference)
  (get-atomic-reference, set-atomic-reference!): New functions.
  (*branch-size-with-edit*, *edit-index*): New constants.
  (<transient-intset>): New data type.
  (new-branch, clone-branch-and-set): Adapt to set edit field.
  (transient-intset, persistent-intset): New exports.
  (intset-add!): New interface, supporting "transient" intsets.
  (intset-ref, intset-next, intset-prev, intset-fold, intset-fold2):
  Work with transients.
2015-04-08 17:18:04 +02:00
Andy Wingo
95db570528 Add "transient" intmap interface
* module/language/cps/intmap.scm (make-atomic-reference):
  (get-atomic-reference, set-atomic-reference!): New helpers.
  (*branch-size-with-edit*, *edit-index*): Branches now have a trailing
  field, an atomic reference to their owner.
  (<transient-intmap>): New record type.  A mutable intmap.
  (new-branch): Set the "edit" field on the branch.
  (clone-branch-and-set): No editor for this field.
  (assert-readable!, writable-branch): New helpers.
  (transient-intmap, persistent-intmap): New exported functions.
  (intmap-add!): New function.
  (intmap-next, intmap-prev, intmap-ref): Work on transient intmaps.
  (intmap-fold): Persist the intmap before folding over it.
2015-04-08 17:17:59 +02:00
Andy Wingo
cf512e3268 32-way branching in intmap.scm, not 16-way
* module/language/cps/intmap.scm (*branch-bits*): Switch to 32-way
  branching.  Marginally faster on lookup, and creation costs can be
  amortized via using the transient interface.  Marginal speedup for
  assembler.scm compilation.
2015-04-01 10:53:23 +02:00
Andy Wingo
048d5d340e Intset-next micro-optimizations
* module/language/cps/intset.scm (intset-next): Micro-optimizations.
2015-04-01 10:53:23 +02:00
Andy Wingo
9c8d2b85e8 Add intset-fold, intset-fold2
* module/language/cps/intset.scm (intset-fold, intset-fold2): New
  functions.
2015-04-01 10:53:23 +02:00
Andy Wingo
b7668bd949 Add intmap-fold.
* module/language/cps/intmap.scm (intmap-fold): New function.
2015-04-01 10:53:21 +02:00
Andy Wingo
2a24395a0f Add intmap-prev
* module/language/cps/intmap.scm (intmap-next): Starting index is
  optional.
  (intmap-prev): New function.
2015-04-01 10:28:19 +02:00
Andy Wingo
33ab2838de Default "meet" operator is meet-error for intmap
* module/language/cps/intmap.scm (meet-error): New helper.
  (intmap-add, intmap-union, intmap-intersect): The "meet" argument is
  optional and defaults to meet-error.
2015-04-01 10:28:19 +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