* Updated header: Added 2006. Changed address of FSF. Changed email
[cacao.git] / src / vm / jit / disass.h
1 /* src/vm/jit/disass.h - disassembler header
2
3    Copyright (C) 1996-2005, 2006 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    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes:
30
31    $Id: disass.h 4357 2006-01-22 23:33:38Z twisti $
32
33 */
34
35
36 #ifndef _DISASS_H
37 #define _DISASS_H
38
39 #include "config.h"
40
41 #if defined(WITH_BINUTILS_DISASSEMBLER)
42 # include <dis-asm.h>
43 #endif
44
45 #include "vm/types.h"
46
47
48 /* some macros ****************************************************************/
49
50 #if defined(ENABLE_JIT)
51 # if defined(ENABLE_INTRP)
52
53 #define DISASSINSTR(code) \
54     do { \
55         if (opt_intrp) \
56             (code) = intrp_disassinstr((code)); \
57         else \
58             (code) = disassinstr((code)); \
59     } while (0)
60
61 #define DISASSEMBLE(start,end) \
62     do { \
63         if (opt_intrp) \
64             intrp_disassemble((start), (end)); \
65         else \
66             disassemble((start), (end)); \
67     } while (0)
68
69 # else /* defined(ENABLE_INTRP) */
70
71 #define DISASSINSTR(code) \
72     (code) = disassinstr((code))
73
74 #define DISASSEMBLE(start,end) \
75     disassemble((start), (end))
76
77 # endif /* defined(ENABLE_INTRP) */
78 #else /* defined(ENABLE_JIT) */
79
80 #define DISASSINSTR(code) \
81     (code) = intrp_disassinstr((code))
82
83 #define DISASSEMBLE(start,end) \
84     intrp_disassemble((start), (end))
85
86 #endif /* defined(ENABLE_JIT) */
87
88
89 /* export global variables ****************************************************/
90
91 #if defined(WITH_BINUTILS_DISASSEMBLER)
92 extern disassemble_info info;
93 extern bool disass_initialized;
94 #endif
95
96 extern char *regs[];
97
98 #if defined(__I386__) || defined(__X86_64__)
99 extern char disass_buf[512];
100 extern s4   disass_len;
101 #endif
102
103
104 /* function prototypes *******************************************************/
105
106 #if defined(ENABLE_JIT)
107 void disassemble(u1 *start, u1 *end);
108 #endif
109
110 #if defined(WITH_BINUTILS_DISASSEMBLER)
111 void disass_printf(PTR p, const char *fmt, ...);
112
113 int disass_buffer_read_memory(bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info);
114 #endif
115
116 /* machine dependent functions */
117
118 #if defined(ENABLE_JIT)
119 u1 *disassinstr(u1 *code);
120 #endif
121
122 #if defined(ENABLE_INTRP)
123 u1 *intrp_disassinstr(u1 *code);
124 void intrp_disassemble(u1 *start, u1 *end);
125 #endif
126
127 #endif /* _DISASS_H */
128
129
130 /*
131  * These are local overrides for various environment variables in Emacs.
132  * Please do not remove this and leave it at the end of the file, where
133  * Emacs will automagically detect them.
134  * ---------------------------------------------------------------------
135  * Local variables:
136  * mode: c
137  * indent-tabs-mode: t
138  * c-basic-offset: 4
139  * tab-width: 4
140  * End:
141  */