LCOV - code coverage report
Current view: top level - vm/jit - reg.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 38 42 90.5 %
Date: 2017-07-14 10:03:36 Functions: 1 1 100.0 %

          Line data    Source code
       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      103042 : void reg_setup(jitdata *jd)
      43             : {
      44             :         methodinfo   *m;
      45             :         registerdata *rd;
      46             :         s4            i;
      47             : 
      48             :         /* get required compiler data */
      49             : 
      50      103042 :         m  = jd->m;
      51      103042 :         rd = jd->rd;
      52             : 
      53             :         /* setup the integer register table */
      54             : 
      55      103042 :         rd->tmpintregs = DMNEW(s4, INT_TMP_CNT);
      56      103042 :         rd->savintregs = DMNEW(s4, INT_SAV_CNT);
      57      103042 :         rd->freeargintregs = DMNEW(s4, INT_ARG_CNT);
      58      103042 :         rd->freetmpintregs = DMNEW(s4, INT_TMP_CNT);
      59      103042 :         rd->freesavintregs = DMNEW(s4, INT_SAV_CNT);
      60             : 
      61      103042 :         rd->argintreguse = 0;
      62      103042 :         rd->tmpintreguse = 0;
      63      103042 :         rd->savintreguse = 0;
      64             : 
      65     1751714 :         for (i = 0; i < INT_REG_CNT; i++) {
      66     1648672 :                 switch (nregdescint[i]) {
      67             :                 case REG_RET:
      68      103042 :                         rd->intreg_ret = i;
      69      103042 :                         break;
      70             :                 case REG_SAV:
      71      515210 :                         rd->savintregs[rd->savintreguse++] = i;
      72      515210 :                         break;
      73             :                 case REG_TMP:
      74      103042 :                         rd->tmpintregs[rd->tmpintreguse++] = i;
      75             :                         break;
      76             :                 }
      77             :         }
      78      103042 :         assert(rd->savintreguse == INT_SAV_CNT);
      79      103042 :         assert(rd->tmpintreguse == INT_TMP_CNT);
      80             : 
      81             :         /* setup the float register table */
      82             : 
      83      103042 :         rd->tmpfltregs = DMNEW(s4, FLT_TMP_CNT);
      84      103042 :         rd->savfltregs = DMNEW(s4, FLT_SAV_CNT);
      85      103042 :         rd->freeargfltregs = DMNEW(s4, FLT_ARG_CNT);
      86      103042 :         rd->freetmpfltregs = DMNEW(s4, FLT_TMP_CNT);
      87      103042 :         rd->freesavfltregs = DMNEW(s4, FLT_SAV_CNT);
      88             : 
      89      103042 :         rd->argfltreguse = 0;
      90      103042 :         rd->tmpfltreguse = 0;
      91      103042 :         rd->savfltreguse = 0;
      92             : 
      93     1751714 :         for (i = 0; i < FLT_REG_CNT; i++) {
      94     1648672 :                 switch (nregdescfloat[i]) {
      95             :                 case REG_RET:
      96           0 :                         rd->fltreg_ret = i;
      97           0 :                         break;
      98             :                 case REG_SAV:
      99           0 :                         rd->savfltregs[rd->savfltreguse++] = i;
     100           0 :                         break;
     101             :                 case REG_TMP:
     102      515210 :                         rd->tmpfltregs[rd->tmpfltreguse++] = i;
     103             :                         break;
     104             :                 }
     105             :         }
     106      103042 :         assert(rd->savfltreguse == FLT_SAV_CNT);
     107      103042 :         assert(rd->tmpfltreguse == FLT_TMP_CNT);
     108             : 
     109      103042 :         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      103042 :         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      103042 :         rd->argintreguse = 0;
     126      103042 :         rd->argfltreguse = 0;
     127      103042 : }
     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             :  */

Generated by: LCOV version 1.11