LCOV - code coverage report
Current view: top level - vm/jit - emit-common.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 81 122 66.4 %
Date: 2017-07-14 10:03:36 Functions: 17 28 60.7 %

          Line data    Source code
       1             : /* src/vm/jit/emit-common.cpp - common code emitter functions
       2             : 
       3             :    Copyright (C) 2006-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/emit-common.hpp"
      26             : #include "config.h"
      27             : #include <algorithm>
      28             : #include <cassert>                      // for assert
      29             : #include <stdint.h>                     // for int32_t, uint32_t
      30             : #include <list>                         // for _List_iterator, etc
      31             : #include "arch.hpp"
      32             : #include "codegen.hpp"
      33             : #include "codegen-common.hpp"           // for codegendata, etc
      34             : #include "toolbox/list.hpp"             // for DumpList, LockedList, List
      35             : #include "vm/jit/code.hpp"              // for codeinfo
      36             : #include "vm/jit/ir/instruction.hpp"    // for instruction, etc
      37             : #include "vm/jit/jit.hpp"               // for basicblock, jitdata
      38             : #include "vm/jit/patcher-common.hpp"    // for patchref_t
      39             : #include "vm/options.hpp"
      40             : #include "vm/statistics.hpp"
      41             : #include "vm/types.hpp"                 // for s4, u1, u4
      42             : 
      43             : struct varinfo;
      44             : 
      45             : STAT_REGISTER_VAR(int,count_branches_resolved,0,"resolved branches","resolved branches")
      46             : 
      47             : STAT_REGISTER_VAR_EXTERN(int,count_mov_reg_reg,0,"count_mov_reg_reg","Moves reg -> reg")
      48             : STAT_REGISTER_VAR_EXTERN(int,count_mov_mem_reg,0,"count_mov_mem_reg","Moves mem -> reg")
      49             : STAT_REGISTER_VAR_EXTERN(int,count_mov_reg_mem,0,"count_mov_reg_mem","Moves reg -> mem")
      50             : //STAT_REGISTER_VAR_EXTERN(int,count_mov_mem_mem,0,"count_mov_mem_mem","Moves mem -> mem")
      51             : 
      52             : STAT_REGISTER_SUM_GROUP(emit_branch_stat,"emit branch","Number of branch_emit (total)")
      53             : STAT_REGISTER_GROUP_VAR(int,count_emit_branch_8bit,0,"emit branch 8bit","Number of branch_emit ( 8bit offset)",emit_branch_stat)
      54             : STAT_REGISTER_GROUP_VAR(int,count_emit_branch_16bit,0,"emit branch 16bit","Number of branch_emit (16bit offset)",emit_branch_stat)
      55             : STAT_REGISTER_GROUP_VAR(int,count_emit_branch_32bit,0,"emit branch 32bit","Number of branch_emit (32bit offset)",emit_branch_stat)
      56             : STAT_REGISTER_GROUP_VAR(int,count_emit_branch_64bit,0,"emit branch 64bit","Number of branch_emit (64bit offset)",emit_branch_stat)
      57             : /* emit_load_s1 ****************************************************************
      58             : 
      59             :    Emits a possible load of the first source operand.
      60             : 
      61             : *******************************************************************************/
      62             : 
      63     1103293 : s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg)
      64             : {
      65             :         varinfo *src;
      66             :         s4       reg;
      67             : 
      68     1103293 :         src = VAROP(iptr->s1);
      69             : 
      70     1103293 :         reg = emit_load(jd, iptr, src, tempreg);
      71             : 
      72     1103293 :         return reg;
      73             : }
      74             : 
      75             : 
      76             : /* emit_load_s2 ****************************************************************
      77             : 
      78             :    Emits a possible load of the second source operand.
      79             : 
      80             : *******************************************************************************/
      81             : 
      82      747869 : s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg)
      83             : {
      84             :         varinfo *src;
      85             :         s4       reg;
      86             : 
      87      747869 :         src = VAROP(iptr->sx.s23.s2);
      88             : 
      89      747869 :         reg = emit_load(jd, iptr, src, tempreg);
      90             : 
      91      747869 :         return reg;
      92             : }
      93             : 
      94             : 
      95             : /* emit_load_s3 ****************************************************************
      96             : 
      97             :    Emits a possible load of the third source operand.
      98             : 
      99             : *******************************************************************************/
     100             : 
     101      130682 : s4 emit_load_s3(jitdata *jd, instruction *iptr, s4 tempreg)
     102             : {
     103             :         varinfo *src;
     104             :         s4       reg;
     105             : 
     106      130682 :         src = VAROP(iptr->sx.s23.s3);
     107             : 
     108      130682 :         reg = emit_load(jd, iptr, src, tempreg);
     109             : 
     110      130682 :         return reg;
     111             : }
     112             : 
     113             : 
     114             : /* emit_load_s1_low ************************************************************
     115             : 
     116             :    Emits a possible load of the low 32-bits of the first long source
     117             :    operand.
     118             : 
     119             : *******************************************************************************/
     120             : 
     121             : #if SIZEOF_VOID_P == 4
     122             : s4 emit_load_s1_low(jitdata *jd, instruction *iptr, s4 tempreg)
     123             : {
     124             :         varinfo *src;
     125             :         s4       reg;
     126             : 
     127             :         src = VAROP(iptr->s1);
     128             : 
     129             :         reg = emit_load_low(jd, iptr, src, tempreg);
     130             : 
     131             :         return reg;
     132             : }
     133             : #endif
     134             : 
     135             : 
     136             : /* emit_load_s2_low ************************************************************
     137             : 
     138             :    Emits a possible load of the low 32-bits of the second long source
     139             :    operand.
     140             : 
     141             : *******************************************************************************/
     142             : 
     143             : #if SIZEOF_VOID_P == 4
     144             : s4 emit_load_s2_low(jitdata *jd, instruction *iptr, s4 tempreg)
     145             : {
     146             :         varinfo *src;
     147             :         s4       reg;
     148             : 
     149             :         src = VAROP(iptr->sx.s23.s2);
     150             : 
     151             :         reg = emit_load_low(jd, iptr, src, tempreg);
     152             : 
     153             :         return reg;
     154             : }
     155             : #endif
     156             : 
     157             : 
     158             : /* emit_load_s3_low ************************************************************
     159             : 
     160             :    Emits a possible load of the low 32-bits of the third long source
     161             :    operand.
     162             : 
     163             : *******************************************************************************/
     164             : 
     165             : #if SIZEOF_VOID_P == 4
     166             : s4 emit_load_s3_low(jitdata *jd, instruction *iptr, s4 tempreg)
     167             : {
     168             :         varinfo *src;
     169             :         s4       reg;
     170             : 
     171             :         src = VAROP(iptr->sx.s23.s3);
     172             : 
     173             :         reg = emit_load_low(jd, iptr, src, tempreg);
     174             : 
     175             :         return reg;
     176             : }
     177             : #endif
     178             : 
     179             : 
     180             : /* emit_load_s1_high ***********************************************************
     181             : 
     182             :    Emits a possible load of the high 32-bits of the first long source
     183             :    operand.
     184             : 
     185             : *******************************************************************************/
     186             : 
     187             : #if SIZEOF_VOID_P == 4
     188             : s4 emit_load_s1_high(jitdata *jd, instruction *iptr, s4 tempreg)
     189             : {
     190             :         varinfo *src;
     191             :         s4       reg;
     192             : 
     193             :         src = VAROP(iptr->s1);
     194             : 
     195             :         reg = emit_load_high(jd, iptr, src, tempreg);
     196             : 
     197             :         return reg;
     198             : }
     199             : #endif
     200             : 
     201             : 
     202             : /* emit_load_s2_high ***********************************************************
     203             : 
     204             :    Emits a possible load of the high 32-bits of the second long source
     205             :    operand.
     206             : 
     207             : *******************************************************************************/
     208             : 
     209             : #if SIZEOF_VOID_P == 4
     210             : s4 emit_load_s2_high(jitdata *jd, instruction *iptr, s4 tempreg)
     211             : {
     212             :         varinfo *src;
     213             :         s4       reg;
     214             : 
     215             :         src = VAROP(iptr->sx.s23.s2);
     216             : 
     217             :         reg = emit_load_high(jd, iptr, src, tempreg);
     218             : 
     219             :         return reg;
     220             : }
     221             : #endif
     222             : 
     223             : 
     224             : /* emit_load_s3_high ***********************************************************
     225             : 
     226             :    Emits a possible load of the high 32-bits of the third long source
     227             :    operand.
     228             : 
     229             : *******************************************************************************/
     230             : 
     231             : #if SIZEOF_VOID_P == 4
     232             : s4 emit_load_s3_high(jitdata *jd, instruction *iptr, s4 tempreg)
     233             : {
     234             :         varinfo *src;
     235             :         s4       reg;
     236             : 
     237             :         src = VAROP(iptr->sx.s23.s3);
     238             : 
     239             :         reg = emit_load_high(jd, iptr, src, tempreg);
     240             : 
     241             :         return reg;
     242             : }
     243             : #endif
     244             : 
     245             : 
     246             : /* emit_store_dst **************************************************************
     247             : 
     248             :    This function generates the code to store the result of an
     249             :    operation back into a spilled pseudo-variable.  If the
     250             :    pseudo-variable has not been spilled in the first place, this
     251             :    function will generate nothing.
     252             :     
     253             : *******************************************************************************/
     254             : 
     255     1315942 : void emit_store_dst(jitdata *jd, instruction *iptr, s4 d)
     256             : {
     257     1315942 :         emit_store(jd, iptr, VAROP(iptr->dst), d);
     258     1315942 : }
     259             : 
     260             : 
     261             : /* emit_patcher_traps **********************************************************
     262             : 
     263             :    Generates the code for the patcher traps.
     264             : 
     265             : *******************************************************************************/
     266             : 
     267       86399 : void emit_patcher_traps(jitdata *jd)
     268             : {
     269       86399 :         codeinfo* code = jd->code;
     270             : 
     271             :         // Generate patcher traps code.
     272      315322 :         for (PatcherListTy::iterator i = code->patchers->begin(),
     273       86399 :                         e = code->patchers->end(); i != e; ++i) {
     274      142524 :                 PatcherPtrTy& pr = *i;
     275      142524 :                 pr->emit();
     276             :         }
     277       86399 : }
     278             : 
     279             : 
     280             : /* emit_bccz *******************************************************************
     281             : 
     282             :    Emit conditional and unconditional branch instructions on integer
     283             :    regiseters.
     284             : 
     285             : *******************************************************************************/
     286             : 
     287      270405 : void emit_bccz(codegendata *cd, basicblock *target, s4 condition, s4 reg, u4 options)
     288             : {
     289             :         s4 branchmpc;
     290             :         s4 disp;
     291             : 
     292             :         /* Target basic block already has an PC, so we can generate the
     293             :            branch immediately. */
     294             : 
     295      270405 :         if ((target->mpc >= 0)) {
     296             :                 STATISTICS(count_branches_resolved++);
     297             : 
     298             :                 /* calculate the mpc of the branch instruction */
     299             : 
     300      141437 :                 branchmpc = cd->mcodeptr - cd->mcodebase;
     301      141437 :                 disp      = target->mpc - branchmpc;
     302             : 
     303             : #if defined(ENABLE_STATISTICS)
     304             :                 if ((int8_t)disp == disp)  count_emit_branch_8bit++;
     305             :                 else if ((int16_t)disp == disp) count_emit_branch_16bit++;
     306             :                 else if ((int32_t)disp == disp) count_emit_branch_32bit++;
     307             : # if SIZEOF_VOID_P == 8
     308             :                 else if ((int64_t)disp == disp) count_emit_branch_64bit++;
     309             : # endif
     310             : #endif
     311             : 
     312      141437 :                 emit_branch(cd, disp, condition, reg, options);
     313             :         }
     314             :         else {
     315             :                 /* current mcodeptr is the correct position,
     316             :                    afterwards emit the NOPs */
     317             : 
     318      128968 :                 codegen_add_branch_ref(cd, target, condition, reg, options);
     319             : 
     320             :                 /* generate NOPs as placeholder for branch code */
     321             : 
     322      128968 :                 BRANCH_NOPS;
     323             :         }
     324      270405 : }
     325             : 
     326             : 
     327             : /* emit_bcc ********************************************************************
     328             : 
     329             :    Emit conditional and unconditional branch instructions on condition
     330             :    codes.
     331             : 
     332             : *******************************************************************************/
     333             : 
     334      141437 : void emit_bcc(codegendata *cd, basicblock *target, s4 condition, u4 options)
     335             : {
     336      141437 :         emit_bccz(cd, target, condition, -1, options);
     337      141437 : }
     338             : 
     339             : 
     340             : /* emit_br *********************************************************************
     341             : 
     342             :    Wrapper for unconditional branches.
     343             : 
     344             : *******************************************************************************/
     345             : 
     346       34830 : void emit_br(codegendata *cd, basicblock *target)
     347             : {
     348       34830 :         emit_bcc(cd, target, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE);
     349       34830 : }
     350             : 
     351             : 
     352             : /* emit_bxxz *******************************************************************
     353             : 
     354             :    Wrappers for branches on one integer register.
     355             : 
     356             : *******************************************************************************/
     357             : 
     358             : #if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
     359             : 
     360             : void emit_beqz(codegendata *cd, basicblock *target, s4 reg)
     361             : {
     362             :         emit_bccz(cd, target, BRANCH_EQ, reg, BRANCH_OPT_NONE);
     363             : }
     364             : 
     365             : void emit_bnez(codegendata *cd, basicblock *target, s4 reg)
     366             : {
     367             :         emit_bccz(cd, target, BRANCH_NE, reg, BRANCH_OPT_NONE);
     368             : }
     369             : 
     370             : void emit_bltz(codegendata *cd, basicblock *target, s4 reg)
     371             : {
     372             :         emit_bccz(cd, target, BRANCH_LT, reg, BRANCH_OPT_NONE);
     373             : }
     374             : 
     375             : void emit_bgez(codegendata *cd, basicblock *target, s4 reg)
     376             : {
     377             :         emit_bccz(cd, target, BRANCH_GE, reg, BRANCH_OPT_NONE);
     378             : }
     379             : 
     380             : void emit_bgtz(codegendata *cd, basicblock *target, s4 reg)
     381             : {
     382             :         emit_bccz(cd, target, BRANCH_GT, reg, BRANCH_OPT_NONE);
     383             : }
     384             : 
     385             : void emit_blez(codegendata *cd, basicblock *target, s4 reg)
     386             : {
     387             :         emit_bccz(cd, target, BRANCH_LE, reg, BRANCH_OPT_NONE);
     388             : }
     389             : 
     390             : #endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */
     391             : 
     392             : 
     393             : /* emit_bxx ********************************************************************
     394             : 
     395             :    Wrappers for branches on two integer registers.
     396             : 
     397             :    We use PACK_REGS here, so we don't have to change the branchref
     398             :    data structure and the emit_bccz function.
     399             : 
     400             : *******************************************************************************/
     401             : 
     402             : #if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
     403             : 
     404             : void emit_beq(codegendata *cd, basicblock *target, s4 s1, s4 s2)
     405             : {
     406             :         emit_bccz(cd, target, BRANCH_EQ, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
     407             : }
     408             : 
     409             : void emit_bne(codegendata *cd, basicblock *target, s4 s1, s4 s2)
     410             : {
     411             :         emit_bccz(cd, target, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
     412             : }
     413             : 
     414             : #endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */
     415             : 
     416             : 
     417             : /* emit_bxx ********************************************************************
     418             : 
     419             :    Wrappers for branches on condition codes.
     420             : 
     421             : *******************************************************************************/
     422             : 
     423             : #if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
     424             : 
     425         480 : void emit_beq(codegendata *cd, basicblock *target)
     426             : {
     427         480 :         emit_bcc(cd, target, BRANCH_EQ, BRANCH_OPT_NONE);
     428         480 : }
     429             : 
     430           0 : void emit_bne(codegendata *cd, basicblock *target)
     431             : {
     432           0 :         emit_bcc(cd, target, BRANCH_NE, BRANCH_OPT_NONE);
     433           0 : }
     434             : 
     435           0 : void emit_blt(codegendata *cd, basicblock *target)
     436             : {
     437           0 :         emit_bcc(cd, target, BRANCH_LT, BRANCH_OPT_NONE);
     438           0 : }
     439             : 
     440           0 : void emit_bge(codegendata *cd, basicblock *target)
     441             : {
     442           0 :         emit_bcc(cd, target, BRANCH_GE, BRANCH_OPT_NONE);
     443           0 : }
     444             : 
     445           0 : void emit_bgt(codegendata *cd, basicblock *target)
     446             : {
     447           0 :         emit_bcc(cd, target, BRANCH_GT, BRANCH_OPT_NONE);
     448           0 : }
     449             : 
     450           0 : void emit_ble(codegendata *cd, basicblock *target)
     451             : {
     452           0 :         emit_bcc(cd, target, BRANCH_LE, BRANCH_OPT_NONE);
     453           0 : }
     454             : 
     455             : #if SUPPORT_BRANCH_CONDITIONAL_UNSIGNED_CONDITIONS
     456           0 : void emit_bult(codegendata *cd, basicblock *target)
     457             : {
     458           0 :         emit_bcc(cd, target, BRANCH_ULT, BRANCH_OPT_NONE);
     459           0 : }
     460             : 
     461           0 : void emit_bule(codegendata *cd, basicblock *target)
     462             : {
     463           0 :         emit_bcc(cd, target, BRANCH_ULE, BRANCH_OPT_NONE);
     464           0 : }
     465             : 
     466           0 : void emit_buge(codegendata *cd, basicblock *target)
     467             : {
     468           0 :         emit_bcc(cd, target, BRANCH_UGE, BRANCH_OPT_NONE);
     469           0 : }
     470             : 
     471          72 : void emit_bugt(codegendata *cd, basicblock *target)
     472             : {
     473          72 :         emit_bcc(cd, target, BRANCH_UGT, BRANCH_OPT_NONE);
     474          72 : }
     475             : #endif
     476             : 
     477             : #if defined(__POWERPC__) || defined(__POWERPC64__)
     478             : void emit_bnan(codegendata *cd, basicblock *target)
     479             : {
     480             :         emit_bcc(cd, target, BRANCH_NAN, BRANCH_OPT_NONE);
     481             : }
     482             : #endif
     483             : 
     484             : #endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */
     485             : 
     486             : 
     487             : /* emit_label_bccz *************************************************************
     488             : 
     489             :    Emit a branch to a label.  Possibly emit the branch, if it is a
     490             :    backward branch.
     491             : 
     492             : *******************************************************************************/
     493             : 
     494       29858 : void emit_label_bccz(codegendata *cd, s4 label, s4 condition, s4 reg, u4 options)
     495             : {
     496             :         // Search if the label is already in the list.
     497       29858 :         DumpList<branch_label_ref_t*>::iterator it;
     498       63938 :         for (it = cd->brancheslabel->begin(); it != cd->brancheslabel->end(); it++) {
     499       34080 :                 branch_label_ref_t* br = *it;
     500             : 
     501             :                 /* is this entry the correct label? */
     502             : 
     503       34080 :                 if (br->label == label)
     504           0 :                         break;
     505             :         }
     506             : 
     507       29858 :         if (it == cd->brancheslabel->end()) {
     508             :                 /* current mcodeptr is the correct position,
     509             :                    afterwards emit the NOPs */
     510             : 
     511       29858 :                 codegen_branch_label_add(cd, label, condition, reg, options);
     512             : 
     513             :                 /* generate NOPs as placeholder for branch code */
     514             : 
     515       29858 :                 BRANCH_NOPS;
     516       29858 :                 return;
     517             :         }
     518             : 
     519             :         // Branch reference was found.
     520           0 :         branch_label_ref_t* br = *it;
     521             : 
     522             :         /* calculate the mpc of the branch instruction */
     523             : 
     524           0 :         int32_t mpc  = cd->mcodeptr - cd->mcodebase;
     525           0 :         int32_t disp = br->mpc - mpc;
     526             : 
     527             : #if defined(ENABLE_STATISTICS)
     528             :         if ((int8_t)disp == disp)  count_emit_branch_8bit++;
     529             :         else if ((int16_t)disp == disp) count_emit_branch_16bit++;
     530             :         else if ((int32_t)disp == disp) count_emit_branch_32bit++;
     531             : # if SIZEOF_VOID_P == 8
     532             :         else if ((int64_t)disp == disp) count_emit_branch_64bit++;
     533             : # endif
     534             : #endif
     535             : 
     536           0 :         emit_branch(cd, disp, condition, reg, options);
     537             : 
     538             :         // Now remove the branch reference.
     539           0 :         cd->brancheslabel->remove(br);
     540             : }
     541             : 
     542             : 
     543             : /* emit_label ******************************************************************
     544             : 
     545             :    Emit a label for a branch.  Possibly emit the branch, if it is a
     546             :    forward branch.
     547             : 
     548             : *******************************************************************************/
     549             : 
     550       29858 : void emit_label(codegendata *cd, s4 label)
     551             : {
     552             :         u1* mcodeptr;
     553             : 
     554             :         // Search if the label is already in the list.
     555       29858 :         DumpList<branch_label_ref_t*>::iterator it;
     556       56122 :         for (it = cd->brancheslabel->begin(); it != cd->brancheslabel->end(); it++) {
     557       56122 :                 branch_label_ref_t* br = *it;
     558             : 
     559             :                 /* is this entry the correct label? */
     560             : 
     561       56122 :                 if (br->label == label)
     562       29858 :                         break;
     563             :         }
     564             : 
     565       29858 :         if (it == cd->brancheslabel->end()) {
     566             :                 /* No branch reference found, add the label to the list (use
     567             :                    invalid values for condition and register). */
     568             : 
     569           0 :                 codegen_branch_label_add(cd, label, -1, -1, BRANCH_OPT_NONE );
     570           0 :                 return;
     571             :         }
     572             : 
     573             :         // Branch reference was found.
     574       29858 :         branch_label_ref_t* br = *it;
     575             : 
     576             :         // Calculate the mpc of the branch instruction.
     577       29858 :         int32_t mpc  = cd->mcodeptr - cd->mcodebase;
     578       29858 :         int32_t disp = mpc - br->mpc;
     579             : 
     580             :         /* temporary set the mcodeptr */
     581             : 
     582       29858 :         mcodeptr     = cd->mcodeptr;
     583       29858 :         cd->mcodeptr = cd->mcodebase + br->mpc;
     584             : 
     585             : #if defined(ENABLE_STATISTICS)
     586             :         if ((int8_t)disp == disp)  count_emit_branch_8bit++;
     587             :         else if ((int16_t)disp == disp) count_emit_branch_16bit++;
     588             :         else if ((int32_t)disp == disp) count_emit_branch_32bit++;
     589             : # if SIZEOF_VOID_P == 8
     590             :         else if ((int64_t)disp == disp) count_emit_branch_64bit++;
     591             : # endif
     592             : #endif
     593             : 
     594       29858 :         emit_branch(cd, disp, br->condition, br->reg, br->options);
     595             : 
     596             :         /* restore mcodeptr */
     597             : 
     598       29858 :         cd->mcodeptr = mcodeptr;
     599             : 
     600             :         // Now remove the branch reference.
     601       29858 :         cd->brancheslabel->remove(br);
     602             : }
     603             : 
     604             : 
     605             : /* emit_label_bcc **************************************************************
     606             : 
     607             :    Emit conditional and unconditional label-branch instructions on
     608             :    condition codes.
     609             : 
     610             : *******************************************************************************/
     611             : 
     612       29858 : void emit_label_bcc(codegendata *cd, s4 label, s4 condition, u4 options)
     613             : {
     614       29858 :         emit_label_bccz(cd, label, condition, -1, options);
     615       29858 : }
     616             : 
     617             : 
     618             : /* emit_label_br ***************************************************************
     619             : 
     620             :    Wrapper for unconditional label-branches.
     621             : 
     622             : *******************************************************************************/
     623             : 
     624        2260 : void emit_label_br(codegendata *cd, s4 label)
     625             : {
     626        2260 :         emit_label_bcc(cd, label, BRANCH_UNCONDITIONAL, BRANCH_OPT_NONE);
     627        2260 : }
     628             : 
     629             : 
     630             : /* emit_label_bxxz *************************************************************
     631             : 
     632             :    Wrappers for label-branches on one integer register.
     633             : 
     634             : *******************************************************************************/
     635             : 
     636             : #if SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER
     637             : 
     638             : void emit_label_beqz(codegendata* cd, int label, int reg)
     639             : {
     640             :         emit_label_bccz(cd, label, BRANCH_EQ, reg, BRANCH_OPT_NONE);
     641             : }
     642             : 
     643             : void emit_label_bnez(codegendata* cd, int label, int reg)
     644             : {
     645             :         emit_label_bccz(cd, label, BRANCH_NE, reg, BRANCH_OPT_NONE);
     646             : }
     647             : 
     648             : void emit_label_bltz(codegendata* cd, int label, int reg)
     649             : {
     650             :         emit_label_bccz(cd, label, BRANCH_LT, reg, BRANCH_OPT_NONE);
     651             : }
     652             : 
     653             : void emit_label_bgtz(codegendata* cd, int label, int reg)
     654             : {
     655             :         emit_label_bccz(cd, label, BRANCH_GT, reg, BRANCH_OPT_NONE);
     656             : }
     657             : 
     658             : #endif /* SUPPORT_BRANCH_CONDITIONAL_ONE_INTEGER_REGISTER */
     659             : 
     660             : 
     661             : /* emit_label_bxx **************************************************************
     662             : 
     663             :    Wrappers for label-branches on two integer registers.
     664             : 
     665             :    We use PACK_REGS here, so we don't have to change the branchref
     666             :    data structure and the emit_bccz function.
     667             : 
     668             : *******************************************************************************/
     669             : 
     670             : #if SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS
     671             : 
     672             : void emit_label_beq(codegendata* cd, int label, int s1, int s2)
     673             : {
     674             :         emit_label_bccz(cd, label, BRANCH_EQ, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
     675             : }
     676             : 
     677             : void emit_label_bne(codegendata* cd, int label, int s1, int s2)
     678             : {
     679             :         emit_label_bccz(cd, label, BRANCH_NE, PACK_REGS(s1, s2), BRANCH_OPT_NONE);
     680             : }
     681             : 
     682             : #endif /* SUPPORT_BRANCH_CONDITIONAL_TWO_INTEGER_REGISTERS */
     683             : 
     684             : 
     685             : /* emit_label_bxx **************************************************************
     686             : 
     687             :    Wrappers for label-branches on condition codes.
     688             : 
     689             : *******************************************************************************/
     690             : 
     691             : #if SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER
     692             : 
     693       15197 : void emit_label_beq(codegendata *cd, s4 label)
     694             : {
     695       15197 :         emit_label_bcc(cd, label, BRANCH_EQ, BRANCH_OPT_NONE);
     696       15197 : }
     697             : 
     698       10271 : void emit_label_bne(codegendata *cd, s4 label)
     699             : {
     700       10271 :         emit_label_bcc(cd, label, BRANCH_NE, BRANCH_OPT_NONE);
     701       10271 : }
     702             : 
     703           0 : void emit_label_blt(codegendata *cd, s4 label)
     704             : {
     705           0 :         emit_label_bcc(cd, label, BRANCH_LT, BRANCH_OPT_NONE);
     706           0 : }
     707             : 
     708           0 : void emit_label_bge(codegendata *cd, s4 label)
     709             : {
     710           0 :         emit_label_bcc(cd, label, BRANCH_GE, BRANCH_OPT_NONE);
     711           0 : }
     712             : 
     713        2130 : void emit_label_bgt(codegendata *cd, s4 label)
     714             : {
     715        2130 :         emit_label_bcc(cd, label, BRANCH_GT, BRANCH_OPT_NONE);
     716        2130 : }
     717             : 
     718           0 : void emit_label_ble(codegendata *cd, s4 label)
     719             : {
     720           0 :         emit_label_bcc(cd, label, BRANCH_LE, BRANCH_OPT_NONE);
     721           0 : }
     722             : 
     723             : #endif /* SUPPORT_BRANCH_CONDITIONAL_CONDITION_REGISTER */
     724             : 
     725             : 
     726             : /*
     727             :  * These are local overrides for various environment variables in Emacs.
     728             :  * Please do not remove this and leave it at the end of the file, where
     729             :  * Emacs will automagically detect them.
     730             :  * ---------------------------------------------------------------------
     731             :  * Local variables:
     732             :  * mode: c++
     733             :  * indent-tabs-mode: t
     734             :  * c-basic-offset: 4
     735             :  * tab-width: 4
     736             :  * End:
     737             :  * vim:noexpandtab:sw=4:ts=4:
     738             :  */

Generated by: LCOV version 1.11