* libguile/instructions.h: Guard in BUILDING_LIBGUILE.
(SCM_PACK_OP_24):
(SCM_PACK_OP_8_8_8):
(SCM_PACK_OP_8_16):
(SCM_PACK_OP_16_8):
(SCM_PACK_OP_12_12): Rename from SCM_PACK_RTL_*, and splice in the
opcode.
(SCM_PACK_OP_ARG_8_24): New helper.
* libguile/vm.c:
* libguile/gsubr.c:
* libguile/foreign.c:
* libguile/control.c:
* libguile/continuations.c: Adapt.
static const scm_t_uint32 continuation_stub_code[] =
{
- SCM_PACK_RTL_24 (scm_op_continuation_call, 0)
+ SCM_PACK_OP_24 (continuation_call, 0)
};
static SCM
static const scm_t_uint32 compose_continuation_code[] =
{
- SCM_PACK_RTL_24 (scm_op_compose_continuation, 0)
+ SCM_PACK_OP_24 (compose_continuation, 0)
};
/* We support calling foreign functions with up to 100 arguments. */
#define CODE(nreq) \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ee, nreq + 1), \
- SCM_PACK_RTL_12_12 (scm_op_foreign_call, 0, 1)
+ SCM_PACK_OP_24 (assert_nargs_ee, nreq + 1), \
+ SCM_PACK_OP_12_12 (foreign_call, 0, 1)
#define CODE_10(n) \
CODE (n + 0), CODE (n + 1), CODE (n + 2), CODE (n + 3), CODE (n + 4), \
/* A: req; B: opt; C: rest */
#define A(nreq) \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ee, nreq + 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0), \
+ SCM_PACK_OP_24 (assert_nargs_ee, nreq + 1), \
+ SCM_PACK_OP_24 (subr_call, 0), \
0, \
0
#define B(nopt) \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_le, nopt + 1), \
- SCM_PACK_RTL_24 (scm_op_alloc_frame, nopt + 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0), \
+ SCM_PACK_OP_24 (assert_nargs_le, nopt + 1), \
+ SCM_PACK_OP_24 (alloc_frame, nopt + 1), \
+ SCM_PACK_OP_24 (subr_call, 0), \
0
#define C() \
- SCM_PACK_RTL_24 (scm_op_bind_rest, 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0), \
+ SCM_PACK_OP_24 (bind_rest, 1), \
+ SCM_PACK_OP_24 (subr_call, 0), \
0, \
0
#define AB(nreq, nopt) \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ge, nreq + 1), \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_le, nreq + nopt + 1), \
- SCM_PACK_RTL_24 (scm_op_alloc_frame, nreq + nopt + 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0)
+ SCM_PACK_OP_24 (assert_nargs_ge, nreq + 1), \
+ SCM_PACK_OP_24 (assert_nargs_le, nreq + nopt + 1), \
+ SCM_PACK_OP_24 (alloc_frame, nreq + nopt + 1), \
+ SCM_PACK_OP_24 (subr_call, 0)
#define AC(nreq) \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ge, nreq + 1), \
- SCM_PACK_RTL_24 (scm_op_bind_rest, nreq + 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0), \
+ SCM_PACK_OP_24 (assert_nargs_ge, nreq + 1), \
+ SCM_PACK_OP_24 (bind_rest, nreq + 1), \
+ SCM_PACK_OP_24 (subr_call, 0), \
0
#define BC(nopt) \
- SCM_PACK_RTL_24 (scm_op_bind_rest, nopt + 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0), \
+ SCM_PACK_OP_24 (bind_rest, nopt + 1), \
+ SCM_PACK_OP_24 (subr_call, 0), \
0, \
0
#define ABC(nreq, nopt) \
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ge, nreq + 1), \
- SCM_PACK_RTL_24 (scm_op_bind_rest, nreq + nopt + 1), \
- SCM_PACK_RTL_24 (scm_op_subr_call, 0), \
+ SCM_PACK_OP_24 (assert_nargs_ge, nreq + 1), \
+ SCM_PACK_OP_24 (bind_rest, nreq + nopt + 1), \
+ SCM_PACK_OP_24 (subr_call, 0), \
0
#include <libguile.h>
#include <libguile/vm-operations.h>
+#ifdef BUILDING_LIBGUILE
+
enum scm_opcode
{
#define ENUM(opcode, tag, name, meta) scm_op_##tag = opcode,
#undef ENUM
};
-#define SCM_PACK_RTL_8_8_8(op,a,b,c) ((op) | ((a) << 8) | ((b) << 16) | ((c) << 24))
-#define SCM_PACK_RTL_8_16(op,a,b) ((op) | ((a) << 8) | ((b) << 16))
-#define SCM_PACK_RTL_16_8(op,a,b) ((op) | ((a) << 8) | ((b) << 24))
-#define SCM_PACK_RTL_12_12(op,a,b) ((op) | ((a) << 8) | ((b) << 20))
-#define SCM_PACK_RTL_24(op,a) ((op) | ((a) << 8))
+#define SCM_PACK_OP_24(op,arg) (scm_op_##op | (arg) << 8)
+#define SCM_PACK_OP_8_8_8(op,a,b,c) SCM_PACK_OP_24 (op, (a) | ((b) << 8) | ((c) << 16))
+#define SCM_PACK_OP_8_16(op,a,b) SCM_PACK_OP_24 (op, (a) | (b) << 8)
+#define SCM_PACK_OP_16_8(op,a,b) SCM_PACK_OP_24 (op, (a) | (b) << 16)
+#define SCM_PACK_OP_12_12(op,a,b) SCM_PACK_OP_24 (op, (a) | (b) << 12)
+#define SCM_PACK_OP_ARG_8_24(a,b) ((a) | ((b) << 8))
#define SCM_UNPACK_RTL_8_8_8(op,a,b,c) \
do \
#define SCM_VM_NUM_INSTRUCTIONS (1<<8)
#define SCM_VM_INSTRUCTION_MASK (SCM_VM_NUM_INSTRUCTIONS-1)
+#endif /* BUILDING_LIBGUILE */
+
SCM_INTERNAL SCM scm_instruction_list (void);
SCM_INTERNAL void scm_bootstrap_instructions (void);
static SCM vm_builtin_call_with_current_continuation;
static const scm_t_uint32 vm_boot_continuation_code[] = {
- SCM_PACK_RTL_24 (scm_op_halt, 0)
+ SCM_PACK_OP_24 (halt, 0)
};
static const scm_t_uint32 vm_builtin_apply_code[] = {
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ge, 3),
- SCM_PACK_RTL_24 (scm_op_tail_apply, 0), /* proc in r1, args from r2 */
+ SCM_PACK_OP_24 (assert_nargs_ge, 3),
+ SCM_PACK_OP_24 (tail_apply, 0), /* proc in r1, args from r2 */
};
static const scm_t_uint32 vm_builtin_values_code[] = {
- SCM_PACK_RTL_24 (scm_op_return_values, 0) /* vals from r1 */
+ SCM_PACK_OP_24 (return_values, 0) /* vals from r1 */
};
static const scm_t_uint32 vm_builtin_abort_to_prompt_code[] = {
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ge, 2),
- SCM_PACK_RTL_24 (scm_op_abort, 0), /* tag in r1, vals from r2 */
+ SCM_PACK_OP_24 (assert_nargs_ge, 2),
+ SCM_PACK_OP_24 (abort, 0), /* tag in r1, vals from r2 */
/* FIXME: Partial continuation should capture caller regs. */
- SCM_PACK_RTL_24 (scm_op_return_values, 0) /* vals from r1 */
+ SCM_PACK_OP_24 (return_values, 0) /* vals from r1 */
};
static const scm_t_uint32 vm_builtin_call_with_values_code[] = {
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ee, 3),
- SCM_PACK_RTL_24 (scm_op_alloc_frame, 7),
- SCM_PACK_RTL_12_12 (scm_op_mov, 6, 1),
- SCM_PACK_RTL_24 (scm_op_call, 6), SCM_PACK_RTL_24 (0, 1),
- SCM_PACK_RTL_12_12 (scm_op_mov, 0, 2),
- SCM_PACK_RTL_24 (scm_op_tail_call_shuffle, 7)
+ SCM_PACK_OP_24 (assert_nargs_ee, 3),
+ SCM_PACK_OP_24 (alloc_frame, 7),
+ SCM_PACK_OP_12_12 (mov, 6, 1),
+ SCM_PACK_OP_24 (call, 6), SCM_PACK_OP_ARG_8_24 (0, 1),
+ SCM_PACK_OP_12_12 (mov, 0, 2),
+ SCM_PACK_OP_24 (tail_call_shuffle, 7)
};
static const scm_t_uint32 vm_builtin_call_with_current_continuation_code[] = {
- SCM_PACK_RTL_24 (scm_op_assert_nargs_ee, 2),
- SCM_PACK_RTL_24 (scm_op_call_cc, 0)
+ SCM_PACK_OP_24 (assert_nargs_ee, 2),
+ SCM_PACK_OP_24 (call_cc, 0)
};