* Moved data segment stuff from codegen.inc.
[cacao.git] / src / vm / jit / dseg.h
1 /* src/vm/jit/dseg.c - data segment handling stuff
2
3    Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    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., 59 Temple Place - Suite 330, Boston, MA
23    02111-1307, USA.
24
25    Contact: cacao@complang.tuwien.ac.at
26
27    Authors: Reinhard Grafl
28             Andreas  Krall
29
30    Changes: Christian Thalinger
31             Joseph Wenninger
32
33    $Id: dseg.h 4011 2005-12-30 14:16:49Z 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 void dseg_adddata(codegendata *cd, u1 *ptr);
124
125 void dseg_addlinenumbertablesize(codegendata *cd);
126 void dseg_addlinenumber(codegendata *cd, u2 linenumber, u1 *ptr);
127 void dseg_createlinenumbertable(codegendata *cd);
128
129 #if !defined(NDEBUG)
130 void dseg_display(methodinfo *m, codegendata *cd);
131 #endif
132
133 #endif /* _DSEG_H */
134
135
136 /*
137  * These are local overrides for various environment variables in Emacs.
138  * Please do not remove this and leave it at the end of the file, where
139  * Emacs will automagically detect them.
140  * ---------------------------------------------------------------------
141  * Local variables:
142  * mode: c
143  * indent-tabs-mode: t
144  * c-basic-offset: 4
145  * tab-width: 4
146  * End:
147  */