* Updated header: Added 2006. Changed address of FSF. Changed email
[cacao.git] / src / vm / jit / dseg.h
1 /* src/vm/jit/dseg.c - data segment handling stuff
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: Reinhard Grafl
28             Andreas  Krall
29
30    Changes: Christian Thalinger
31             Joseph Wenninger
32
33    $Id: dseg.h 4357 2006-01-22 23:33:38Z twisti $
34
35 */
36
37
38 #ifndef _DSEG_H
39 #define _DSEG_H
40
41 /* forward typedefs ***********************************************************/
42
43 typedef struct jumpref jumpref;
44 typedef struct dataref dataref;
45 typedef struct patchref patchref;
46 typedef struct linenumberref linenumberref;
47
48
49 #include "config.h"
50
51 #include "vm/types.h"
52
53 #include "vm/jit/jit.h"
54 #include "vm/jit/codegen-common.h"
55
56
57 /* global macros **************************************************************/
58
59 #if SIZEOF_VOID_P == 8
60 # define dseg_addaddress(cd,value)    dseg_adds8((cd), (s8) (value))
61 #else
62 # define dseg_addaddress(cd,value)    dseg_adds4((cd), (s4) (value))
63 #endif
64
65
66 /* jumpref ********************************************************************/
67
68 struct jumpref {
69         s4          tablepos;       /* patching position in data segment          */
70         basicblock *target;         /* target basic block                         */
71         jumpref    *next;           /* next element in jumpref list               */
72 };
73
74
75 /* dataref ********************************************************************/
76
77 struct dataref {
78         s4       datapos;           /* patching position in generated code        */
79         dataref *next;              /* next element in dataref list               */
80 };
81
82
83 /* patchref *******************************************************************/
84
85 struct patchref {
86         s4           branchpos;
87         functionptr  patcher;
88         voidptr      ref;
89         patchref    *next;
90         s4           disp;
91 };
92
93
94 /* linenumberref **************************************************************/
95
96 struct linenumberref {
97         s4             tablepos;    /* patching position in data segment          */
98         s4             targetmpc;   /* machine code program counter of first      */
99                                     /* instruction for given line                 */
100         u2             linenumber;  /* line number, used for inserting into the   */
101                                     /* table and for validty checking             */
102         linenumberref *next;        /* next element in linenumberref list         */
103 };
104
105
106 /* function prototypes ********************************************************/
107
108 void dseg_increase(codegendata *cd);
109
110 s4 dseg_adds4_increase(codegendata *cd, s4 value);
111 s4 dseg_adds4(codegendata *cd, s4 value);
112
113 s4 dseg_adds8_increase(codegendata *cd, s8 value);
114 s4 dseg_adds8(codegendata *cd, s8 value);
115
116 s4 dseg_addfloat_increase(codegendata *cd, float value);
117 s4 dseg_addfloat(codegendata *cd, float value);
118
119 s4 dseg_adddouble_increase(codegendata *cd, double value);
120 s4 dseg_adddouble(codegendata *cd, double value);
121
122 void dseg_addtarget(codegendata *cd, basicblock *target);
123
124 void dseg_addlinenumbertablesize(codegendata *cd);
125 void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *ptr);
126
127 void dseg_createlinenumbertable(codegendata *cd);
128
129 #if defined(__I386__) || defined(__X86_64__) || defined(__XDSPCORE__) || defined(ENABLE_INTRP)
130 void dseg_adddata(codegendata *cd, u1 *ptr);
131 void dseg_resolve_datareferences(codegendata *cd, methodinfo *m);
132 #endif
133
134 #if !defined(NDEBUG)
135 void dseg_display(methodinfo *m, codegendata *cd);
136 #endif
137
138 #endif /* _DSEG_H */
139
140
141 /*
142  * These are local overrides for various environment variables in Emacs.
143  * Please do not remove this and leave it at the end of the file, where
144  * Emacs will automagically detect them.
145  * ---------------------------------------------------------------------
146  * Local variables:
147  * mode: c
148  * indent-tabs-mode: t
149  * c-basic-offset: 4
150  * tab-width: 4
151  * End:
152  */