* merged with tip (040f180a056b)
[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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include "config.h"
34
35 #if defined(WITH_BINUTILS_DISASSEMBLER)
36 # include <dis-asm.h>
37 #endif
38
39 #include "vm/types.h"
40
41 #include "vm/global.h"
42
43 #if defined(ENABLE_DISASSEMBLER)
44
45 /* some macros ****************************************************************/
46
47 #if defined(ENABLE_JIT)
48 # if defined(ENABLE_INTRP)
49
50 #define DISASSINSTR(code) \
51     do { \
52         if (opt_intrp) \
53             (code) = intrp_disassinstr((code)); \
54         else \
55             (code) = disassinstr((code)); \
56     } while (0)
57
58 #define DISASSEMBLE(start,end) \
59     do { \
60         if (opt_intrp) \
61             intrp_disassemble((start), (end)); \
62         else \
63             disassemble((start), (end)); \
64     } while (0)
65
66 # else /* defined(ENABLE_INTRP) */
67
68 #define DISASSINSTR(code) \
69     (code) = disassinstr((code))
70
71 #define DISASSEMBLE(start,end) \
72     disassemble((start), (end))
73
74 # endif /* defined(ENABLE_INTRP) */
75 #else /* defined(ENABLE_JIT) */
76
77 #define DISASSINSTR(code) \
78     (code) = intrp_disassinstr((code))
79
80 #define DISASSEMBLE(start,end) \
81     intrp_disassemble((start), (end))
82
83 #endif /* defined(ENABLE_JIT) */
84
85
86 /* export global variables ****************************************************/
87
88 #if defined(WITH_BINUTILS_DISASSEMBLER)
89 extern disassemble_info info;
90 extern bool disass_initialized;
91 #endif
92
93 #if defined(__I386__) || defined(__X86_64__) || defined(__S390__) || defined(__M68K__)
94 extern char disass_buf[512];
95 extern s4   disass_len;
96 #endif
97
98
99 /* function prototypes *******************************************************/
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 #endif /* defined(ENABLE_DISASSEMBLER) */
123
124 #ifdef __cplusplus
125 }
126 #endif
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  */