CACAO
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 
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 
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 */
115 # else
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  */
int argintreguse
Definition: reg.hpp:86
Definition: jit.hpp:126
int * freemem
Definition: reg.hpp:81
int * savintregs
Definition: reg.hpp:71
#define REG_SAV
Definition: jit.hpp:442
int * freeargfltregs
Definition: reg.hpp:77
int * freetmpfltregs
Definition: reg.hpp:78
s4 nregdescint[]
Definition: md-abi.cpp:41
#define INT_REG_CNT
Definition: md-abi.hpp:72
int * tmpfltregs
Definition: reg.hpp:72
int * freesavfltregs
Definition: reg.hpp:79
int savintreguse
Definition: reg.hpp:88
int intreg_ret
Definition: reg.hpp:67
int * freetmpintregs
Definition: reg.hpp:75
#define INT_SAV_CNT
Definition: md-abi.hpp:73
int * freesavintregs
Definition: reg.hpp:76
#define REG_RET
Definition: jit.hpp:440
#define FLT_TMP_CNT
Definition: md-abi.hpp:82
int fltreg_ret
Definition: reg.hpp:68
int tmpintreguse
Definition: reg.hpp:87
void reg_setup(jitdata *jd)
Definition: reg.cpp:42
#define INT_ARG_CNT
Definition: md-abi.hpp:74
int tmpfltreguse
Definition: reg.hpp:90
s4 maxstack
Definition: method.hpp:83
MIIterator i
int32_t s4
Definition: types.hpp:45
int argfltreguse
Definition: reg.hpp:89
int * savfltregs
Definition: reg.hpp:73
registerdata * rd
Definition: jit.hpp:130
int savfltreguse
Definition: reg.hpp:91
#define INT_TMP_CNT
Definition: md-abi.hpp:75
#define FLT_SAV_CNT
Definition: md-abi.hpp:80
int memuse
Definition: reg.hpp:84
int * tmpintregs
Definition: reg.hpp:70
methodinfo * m
Definition: jit.hpp:127
#define FLT_ARG_CNT
Definition: md-abi.hpp:81
#define DMNEW(type, num)
Definition: dumpmemory.hpp:371
#define REG_TMP
Definition: jit.hpp:443
s4 nregdescfloat[]
Definition: md-abi.cpp:98
#define LA_SIZE_IN_POINTERS
Definition: md-abi.hpp:95
#define FLT_REG_CNT
Definition: md-abi.hpp:79
int * freeargintregs
Definition: reg.hpp:74