Foreign procedures are RTL programs
[bpt/guile.git] / libguile / instructions.h
CommitLineData
b0ca878c 1/* Copyright (C) 2001, 2009, 2012, 2013 Free Software Foundation, Inc.
17e90c5e 2 *
560b9c25 3 * This library is free software; you can redistribute it and/or
53befeb7
NJ
4 * modify it under the terms of the GNU Lesser General Public License
5 * as published by the Free Software Foundation; either version 3 of
6 * the License, or (at your option) any later version.
17e90c5e 7 *
53befeb7
NJ
8 * This library is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
560b9c25
AW
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
17e90c5e 12 *
560b9c25
AW
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
53befeb7
NJ
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16 * 02110-1301 USA
560b9c25 17 */
17e90c5e 18
8f5cfc81
KN
19#ifndef _SCM_INSTRUCTIONS_H_
20#define _SCM_INSTRUCTIONS_H_
17e90c5e
KN
21
22#include <libguile.h>
510ca126
AW
23#include <libguile/vm-operations.h>
24
25enum scm_rtl_opcode
26 {
27#define ENUM(opcode, tag, name, meta) scm_rtl_op_##tag = opcode,
28 FOR_EACH_VM_OPERATION(ENUM)
29#undef ENUM
30 };
31
062888f7 32#define SCM_PACK_RTL_8_8_8(op,a,b,c) ((op) | ((a) << 8) | ((b) << 16) | ((c) << 24))
510ca126 33#define SCM_PACK_RTL_8_16(op,a,b) ((op) | ((a) << 8) | ((b) << 16))
062888f7 34#define SCM_PACK_RTL_16_8(op,a,b) ((op) | ((a) << 8) | ((b) << 24))
b0ca878c 35#define SCM_PACK_RTL_12_12(op,a,b) ((op) | ((a) << 8) | ((b) << 20))
510ca126
AW
36#define SCM_PACK_RTL_24(op,a) ((op) | ((a) << 8))
37
38#define SCM_UNPACK_RTL_8_8_8(op,a,b,c) \
39 do \
40 { \
41 a = (op >> 8) & 0xff; \
42 b = (op >> 16) & 0xff; \
43 c = op >> 24; \
44 } \
45 while (0)
46
47#define SCM_UNPACK_RTL_8_16(op,a,b) \
48 do \
49 { \
50 a = (op >> 8) & 0xff; \
51 b = op >> 16; \
52 } \
53 while (0)
54
55#define SCM_UNPACK_RTL_16_8(op,a,b) \
56 do \
57 { \
58 a = (op >> 8) & 0xffff; \
59 b = op >> 24; \
60 } \
61 while (0)
62
63#define SCM_UNPACK_RTL_12_12(op,a,b) \
64 do \
65 { \
66 a = (op >> 8) & 0xfff; \
67 b = op >> 20; \
68 } \
69 while (0)
70
71#define SCM_UNPACK_RTL_24(op,a) \
72 do \
73 { \
74 a = op >> 8; \
75 } \
76 while (0)
17e90c5e 77
e6eb2467 78#define SCM_VM_NUM_INSTRUCTIONS (1<<8)
53e28ed9
AW
79#define SCM_VM_INSTRUCTION_MASK (SCM_VM_NUM_INSTRUCTIONS-1)
80
17e90c5e
KN
81enum scm_opcode {
82#define VM_INSTRUCTION_TO_OPCODE 1
aeeff258
AW
83#include <libguile/vm-expand.h>
84#include <libguile/vm-i-system.i>
85#include <libguile/vm-i-scheme.i>
86#include <libguile/vm-i-loader.i>
17e90c5e 87#undef VM_INSTRUCTION_TO_OPCODE
17e90c5e
KN
88};
89
510ca126
AW
90SCM_INTERNAL SCM scm_rtl_instruction_list (void);
91
560b9c25
AW
92SCM_API SCM scm_instruction_list (void);
93SCM_API SCM scm_instruction_p (SCM obj);
94SCM_API SCM scm_instruction_length (SCM inst);
95SCM_API SCM scm_instruction_pops (SCM inst);
96SCM_API SCM scm_instruction_pushes (SCM inst);
97SCM_API SCM scm_instruction_to_opcode (SCM inst);
98SCM_API SCM scm_opcode_to_instruction (SCM op);
fcd4901b 99
560b9c25
AW
100SCM_INTERNAL void scm_bootstrap_instructions (void);
101SCM_INTERNAL void scm_init_instructions (void);
17e90c5e 102
8f5cfc81 103#endif /* _SCM_INSTRUCTIONS_H_ */
17e90c5e
KN
104
105/*
106 Local Variables:
107 c-file-style: "gnu"
108 End:
109*/