CACAO
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
source
cacao
src
vm
jit
reg.cpp
Go to the documentation of this file.
1
/* src/vm/jit/reg.cpp - register allocator setup
2
3
Copyright (C) 1996-2013
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
#include "
vm/jit/reg.hpp
"
26
#include <cassert>
// for assert
27
#include "config.h"
28
#include "arch.hpp"
29
#include "md-abi.hpp"
30
#include "
mm/dumpmemory.hpp
"
// for DNEW, DMNEW
31
#include "
vm/jit/abi.hpp
"
// for nregdescfloat, nregdescint
32
#include "
vm/jit/jit.hpp
"
// for jitdata
33
#include "
vm/method.hpp
"
// for methodinfo
34
#include "
vm/types.hpp
"
// for s4
35
36
/* reg_setup *******************************************************************
37
38
TODO
39
40
*******************************************************************************/
41
42
void
reg_setup
(
jitdata
*jd)
43
{
44
methodinfo
*m;
45
registerdata
*rd;
46
s4
i
;
47
48
/* get required compiler data */
49
50
m = jd->
m
;
51
rd = jd->
rd
;
52
53
/* setup the integer register table */
54
55
rd->
tmpintregs
=
DMNEW
(
s4
,
INT_TMP_CNT
);
56
rd->
savintregs
=
DMNEW
(
s4
,
INT_SAV_CNT
);
57
rd->
freeargintregs
=
DMNEW
(
s4
,
INT_ARG_CNT
);
58
rd->
freetmpintregs
=
DMNEW
(
s4
,
INT_TMP_CNT
);
59
rd->
freesavintregs
=
DMNEW
(
s4
,
INT_SAV_CNT
);
60
61
rd->
argintreguse
= 0;
62
rd->
tmpintreguse
= 0;
63
rd->
savintreguse
= 0;
64
65
for
(i = 0; i <
INT_REG_CNT
; i++) {
66
switch
(
nregdescint
[i]) {
67
case
REG_RET
:
68
rd->
intreg_ret
=
i
;
69
break
;
70
case
REG_SAV
:
71
rd->
savintregs
[rd->
savintreguse
++] =
i
;
72
break
;
73
case
REG_TMP
:
74
rd->
tmpintregs
[rd->
tmpintreguse
++] =
i
;
75
break
;
76
}
77
}
78
assert(rd->
savintreguse
==
INT_SAV_CNT
);
79
assert(rd->
tmpintreguse
==
INT_TMP_CNT
);
80
81
/* setup the float register table */
82
83
rd->
tmpfltregs
=
DMNEW
(
s4
,
FLT_TMP_CNT
);
84
rd->
savfltregs
=
DMNEW
(
s4
,
FLT_SAV_CNT
);
85
rd->
freeargfltregs
=
DMNEW
(
s4
,
FLT_ARG_CNT
);
86
rd->
freetmpfltregs
=
DMNEW
(
s4
,
FLT_TMP_CNT
);
87
rd->
freesavfltregs
=
DMNEW
(
s4
,
FLT_SAV_CNT
);
88
89
rd->
argfltreguse
= 0;
90
rd->
tmpfltreguse
= 0;
91
rd->
savfltreguse
= 0;
92
93
for
(i = 0; i <
FLT_REG_CNT
; i++) {
94
switch
(
nregdescfloat
[i]) {
95
case
REG_RET
:
96
rd->
fltreg_ret
=
i
;
97
break
;
98
case
REG_SAV
:
99
rd->
savfltregs
[rd->
savfltreguse
++] =
i
;
100
break
;
101
case
REG_TMP
:
102
rd->
tmpfltregs
[rd->
tmpfltreguse
++] =
i
;
103
break
;
104
}
105
}
106
assert(rd->
savfltreguse
==
FLT_SAV_CNT
);
107
assert(rd->
tmpfltreguse
==
FLT_TMP_CNT
);
108
109
rd->
freemem
=
DMNEW
(
s4
, m->
maxstack
);
110
111
#if defined(SPECIALMEMUSE)
112
# if defined(__DARWIN__)
113
/* 6*4=24 byte linkage area + 8*4=32 byte minimum parameter Area */
114
rd->
memuse
=
LA_SIZE_IN_POINTERS
+
INT_ARG_CNT
;
115
# else
116
rd->
memuse
=
LA_SIZE_IN_POINTERS
;
117
# endif
118
#else
119
rd->
memuse
= 0;
/* init to zero -> analyse_stack will set it to a higher */
120
/* value, if appropriate */
121
#endif
122
123
/* Set rd->arg*reguse to *_ARG_CNBT to not use unused argument */
124
/* registers as temp registers */
125
rd->
argintreguse
= 0;
126
rd->
argfltreguse
= 0;
127
}
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
* vim:noexpandtab:sw=4:ts=4:
142
*/
registerdata::argintreguse
int argintreguse
Definition:
reg.hpp:86
jitdata
Definition:
jit.hpp:126
registerdata::freemem
int * freemem
Definition:
reg.hpp:81
registerdata::savintregs
int * savintregs
Definition:
reg.hpp:71
REG_SAV
#define REG_SAV
Definition:
jit.hpp:442
registerdata::freeargfltregs
int * freeargfltregs
Definition:
reg.hpp:77
registerdata::freetmpfltregs
int * freetmpfltregs
Definition:
reg.hpp:78
nregdescint
s4 nregdescint[]
Definition:
md-abi.cpp:41
INT_REG_CNT
#define INT_REG_CNT
Definition:
md-abi.hpp:72
registerdata::tmpfltregs
int * tmpfltregs
Definition:
reg.hpp:72
registerdata::freesavfltregs
int * freesavfltregs
Definition:
reg.hpp:79
registerdata::savintreguse
int savintreguse
Definition:
reg.hpp:88
registerdata::intreg_ret
int intreg_ret
Definition:
reg.hpp:67
types.hpp
registerdata
Definition:
reg.hpp:66
registerdata::freetmpintregs
int * freetmpintregs
Definition:
reg.hpp:75
INT_SAV_CNT
#define INT_SAV_CNT
Definition:
md-abi.hpp:73
registerdata::freesavintregs
int * freesavintregs
Definition:
reg.hpp:76
REG_RET
#define REG_RET
Definition:
jit.hpp:440
dumpmemory.hpp
FLT_TMP_CNT
#define FLT_TMP_CNT
Definition:
md-abi.hpp:82
registerdata::fltreg_ret
int fltreg_ret
Definition:
reg.hpp:68
registerdata::tmpintreguse
int tmpintreguse
Definition:
reg.hpp:87
reg_setup
void reg_setup(jitdata *jd)
Definition:
reg.cpp:42
INT_ARG_CNT
#define INT_ARG_CNT
Definition:
md-abi.hpp:74
registerdata::tmpfltreguse
int tmpfltreguse
Definition:
reg.hpp:90
methodinfo::maxstack
s4 maxstack
Definition:
method.hpp:83
i
MIIterator i
Definition:
LivetimeAnalysisPass.cpp:149
s4
int32_t s4
Definition:
types.hpp:45
registerdata::argfltreguse
int argfltreguse
Definition:
reg.hpp:89
registerdata::savfltregs
int * savfltregs
Definition:
reg.hpp:73
jitdata::rd
registerdata * rd
Definition:
jit.hpp:130
method.hpp
registerdata::savfltreguse
int savfltreguse
Definition:
reg.hpp:91
INT_TMP_CNT
#define INT_TMP_CNT
Definition:
md-abi.hpp:75
jit.hpp
FLT_SAV_CNT
#define FLT_SAV_CNT
Definition:
md-abi.hpp:80
methodinfo
Definition:
method.hpp:68
registerdata::memuse
int memuse
Definition:
reg.hpp:84
registerdata::tmpintregs
int * tmpintregs
Definition:
reg.hpp:70
jitdata::m
methodinfo * m
Definition:
jit.hpp:127
FLT_ARG_CNT
#define FLT_ARG_CNT
Definition:
md-abi.hpp:81
DMNEW
#define DMNEW(type, num)
Definition:
dumpmemory.hpp:371
reg.hpp
REG_TMP
#define REG_TMP
Definition:
jit.hpp:443
nregdescfloat
s4 nregdescfloat[]
Definition:
md-abi.cpp:98
abi.hpp
LA_SIZE_IN_POINTERS
#define LA_SIZE_IN_POINTERS
Definition:
md-abi.hpp:95
FLT_REG_CNT
#define FLT_REG_CNT
Definition:
md-abi.hpp:79
registerdata::freeargintregs
int * freeargintregs
Definition:
reg.hpp:74
Generated on Fri Aug 4 2017 03:01:54 for CACAO by
1.8.5