diff options
author | Andy Wingo <wingo@pobox.com> | 2011-06-02 17:41:45 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-06-02 17:45:58 +0200 |
commit | a881a4ae3bc1f2cc00ac7274e286271b6f55287c (patch) | |
tree | 7c7bd3456d31952f5db8fc180fba5b849d7407f9 /libguile | |
parent | 7081d4f981a53ef488b823a1f76d33619d715d7f (diff) | |
download | guile-a881a4ae3bc1f2cc00ac7274e286271b6f55287c.tar.gz |
add <primcall> to tree-il
* libguile/expand.c:
* libguile/expand.h (SCM_EXPANDED_PRIMCALL_TYPE_NAME):
(SCM_EXPANDED_PRIMCALL_FIELD_NAMES):
(SCM_EXPANDED_PRIMCALL_SRC):
(SCM_EXPANDED_PRIMCALL_NAME):
(SCM_EXPANDED_PRIMCALL_ARGS):
(SCM_MAKE_EXPANDED_PRIMCALL): Add "primcall" Tree-IL type.
* doc/ref/compiler.texi (Tree-IL): Update docs.
* libguile/memoize.c (memoize): Memoizer for primcalls.
* module/ice-9/psyntax.scm: Build primcalls, sometimes. Also change
build-primref to just make a primitive-ref.
* module/language/tree-il.scm: Add primcall to the exports, parsers,
serializers, etc.
* module/language/tree-il/analyze.scm:
* module/language/tree-il/compile-glil.scm:
* module/language/tree-il/fix-letrec.scm:
* module/language/tree-il/inline.scm:
* module/language/tree-il/primitives.scm:
* module/language/elisp/compile-tree-il.scm: Add primcall support.
* test-suite/tests/tree-il.test: Use primcalls sometimes.
Diffstat (limited to 'libguile')
-rw-r--r-- | libguile/expand.c | 1 | ||||
-rw-r--r-- | libguile/expand.h | 14 | ||||
-rw-r--r-- | libguile/memoize.c | 14 |
3 files changed, 29 insertions, 0 deletions
diff --git a/libguile/expand.c b/libguile/expand.c index 2b5b2ebf5..af6eb7d12 100644 --- a/libguile/expand.c +++ b/libguile/expand.c @@ -1244,6 +1244,7 @@ scm_init_expand () DEFINE_NAMES (TOPLEVEL_DEFINE); DEFINE_NAMES (CONDITIONAL); DEFINE_NAMES (CALL); + DEFINE_NAMES (PRIMCALL); DEFINE_NAMES (SEQUENCE); DEFINE_NAMES (LAMBDA); DEFINE_NAMES (LAMBDA_CASE); diff --git a/libguile/expand.h b/libguile/expand.h index 7406a8eed..b4e6a2132 100644 --- a/libguile/expand.h +++ b/libguile/expand.h @@ -48,6 +48,7 @@ typedef enum SCM_EXPANDED_TOPLEVEL_DEFINE, SCM_EXPANDED_CONDITIONAL, SCM_EXPANDED_CALL, + SCM_EXPANDED_PRIMCALL, SCM_EXPANDED_SEQUENCE, SCM_EXPANDED_LAMBDA, SCM_EXPANDED_LAMBDA_CASE, @@ -241,6 +242,19 @@ enum #define SCM_MAKE_EXPANDED_CALL(src, proc, args) \ scm_c_make_struct (exp_vtables[SCM_EXPANDED_CALL], 0, SCM_NUM_EXPANDED_CALL_FIELDS, SCM_UNPACK (src), SCM_UNPACK (proc), SCM_UNPACK (args)) +#define SCM_EXPANDED_PRIMCALL_TYPE_NAME "primcall" +#define SCM_EXPANDED_PRIMCALL_FIELD_NAMES \ + { "src", "name", "args", } +enum + { + SCM_EXPANDED_PRIMCALL_SRC, + SCM_EXPANDED_PRIMCALL_NAME, + SCM_EXPANDED_PRIMCALL_ARGS, + SCM_NUM_EXPANDED_PRIMCALL_FIELDS, + }; +#define SCM_MAKE_EXPANDED_PRIMCALL(src, name, args) \ + scm_c_make_struct (exp_vtables[SCM_EXPANDED_PRIMCALL], 0, SCM_NUM_EXPANDED_PRIMCALL_FIELDS, SCM_UNPACK (src), SCM_UNPACK (name), SCM_UNPACK (args)) + #define SCM_EXPANDED_SEQUENCE_TYPE_NAME "sequence" #define SCM_EXPANDED_SEQUENCE_FIELD_NAMES \ { "src", "exps", } diff --git a/libguile/memoize.c b/libguile/memoize.c index f13de74da..d1537f9fb 100644 --- a/libguile/memoize.c +++ b/libguile/memoize.c @@ -263,6 +263,20 @@ memoize (SCM exp, SCM env) return MAKMEMO_CALL (memoize (proc, env), scm_ilength (args), args); } + case SCM_EXPANDED_PRIMCALL: + { + SCM proc, args; + + if (scm_is_eq (scm_current_module (), scm_the_root_module ())) + proc = MAKMEMO_TOP_REF (REF (exp, PRIMCALL, NAME)); + else + proc = MAKMEMO_MOD_REF (list_of_guile, REF (exp, PRIMCALL, NAME), + SCM_BOOL_F); + args = memoize_exps (REF (exp, PRIMCALL, ARGS), env); + + return MAKMEMO_CALL (proc, scm_ilength (args), args); + } + case SCM_EXPANDED_SEQUENCE: return MAKMEMO_BEGIN (memoize_exps (REF (exp, SEQUENCE, EXPS), env)); |