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