Merge from subtype.
[cacao.git] / src / vm / jit / disass.h
1 /* src/vm/jit/disass.h - disassembler header
2
3    Copyright (C) 1996-2005, 2006, 2007, 2008
4    CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5
6    This file is part of CACAO.
7
8    This program is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2, or (at
11    your option) any later version.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23 */
24
25
26 #ifndef _DISASS_H
27 #define _DISASS_H
28
29 #include "config.h"
30
31 #if defined(WITH_BINUTILS_DISASSEMBLER)
32 # include <dis-asm.h>
33 #endif
34
35 #include "vm/types.h"
36
37 #include "vm/global.h"
38
39 #if defined(ENABLE_DISASSEMBLER)
40
41 /* some macros ****************************************************************/
42
43 #if defined(ENABLE_JIT)
44 # if defined(ENABLE_INTRP)
45
46 #define DISASSINSTR(code) \
47     do { \
48         if (opt_intrp) \
49             (code) = intrp_disassinstr((u1*) (code));   \
50         else \
51             (code) = disassinstr((u1*) (code)); \
52     } while (0)
53
54 #define DISASSEMBLE(start,end) \
55     do { \
56         if (opt_intrp) \
57             intrp_disassemble((start), (end)); \
58         else \
59             disassemble((start), (end)); \
60     } while (0)
61
62 # else /* defined(ENABLE_INTRP) */
63
64 #define DISASSINSTR(code) \
65     (code) = disassinstr((u1*) (code))
66
67 #define DISASSEMBLE(start,end) \
68     disassemble((start), (end))
69
70 # endif /* defined(ENABLE_INTRP) */
71 #else /* defined(ENABLE_JIT) */
72
73 #define DISASSINSTR(code) \
74     (code) = intrp_disassinstr((u1*) (code))
75
76 #define DISASSEMBLE(start,end) \
77     intrp_disassemble((start), (end))
78
79 #endif /* defined(ENABLE_JIT) */
80
81
82 /* export global variables ****************************************************/
83
84 #if defined(WITH_BINUTILS_DISASSEMBLER)
85 extern disassemble_info info;
86 extern bool disass_initialized;
87 #endif
88
89 #if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
90 extern char disass_buf[512];
91 extern s4   disass_len;
92 #endif
93
94
95 /* function prototypes *******************************************************/
96
97 #ifdef __cplusplus
98 extern "C" {
99 #endif
100
101 #if defined(ENABLE_JIT)
102 void disassemble(u1 *start, u1 *end);
103 #endif
104
105 #if defined(WITH_BINUTILS_DISASSEMBLER)
106 void disass_printf(PTR p, const char *fmt, ...);
107
108 int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info);
109 #endif
110
111 /* machine dependent functions */
112
113 #if defined(ENABLE_JIT)
114 u1 *disassinstr(u1 *code);
115 #endif
116
117 #if defined(ENABLE_INTRP)
118 u1 *intrp_disassinstr(u1 *code);
119 void intrp_disassemble(u1 *start, u1 *end);
120 #endif
121
122 #ifdef __cplusplus
123 } // extern "C"
124 #endif
125
126 #endif /* defined(ENABLE_DISASSEMBLER) */
127
128 #endif // _DISASS_H
129
130
131 /*
132  * These are local overrides for various environment variables in Emacs.
133  * Please do not remove this and leave it at the end of the file, where
134  * Emacs will automagically detect them.
135  * ---------------------------------------------------------------------
136  * Local variables:
137  * mode: c
138  * indent-tabs-mode: t
139  * c-basic-offset: 4
140  * tab-width: 4
141  * End:
142  */