src/share/vm/opto/multnode.cpp

changeset 435
a61af66fc99e
child 1907
c18cbe5936b8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/multnode.cpp	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,129 @@
     1.4 +/*
     1.5 + * Copyright 1997-2006 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.24 + * have any questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "incls/_precompiled.incl"
    1.29 +#include "incls/_multnode.cpp.incl"
    1.30 +
    1.31 +//=============================================================================
    1.32 +//------------------------------MultiNode--------------------------------------
    1.33 +const RegMask &MultiNode::out_RegMask() const {
    1.34 +  return RegMask::Empty;
    1.35 +}
    1.36 +
    1.37 +Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
    1.38 +
    1.39 +//------------------------------proj_out---------------------------------------
    1.40 +// Get a named projection
    1.41 +ProjNode* MultiNode::proj_out(uint which_proj) const {
    1.42 +  assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
    1.43 +  assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
    1.44 +  for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
    1.45 +    Node *p = fast_out(i);
    1.46 +    if( !p->is_Proj() ) {
    1.47 +      assert(p == this && this->is_Start(), "else must be proj");
    1.48 +      continue;
    1.49 +    }
    1.50 +    ProjNode *proj = p->as_Proj();
    1.51 +    if( proj->_con == which_proj ) {
    1.52 +      assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
    1.53 +      return proj;
    1.54 +    }
    1.55 +  }
    1.56 +  return NULL;
    1.57 +}
    1.58 +
    1.59 +//=============================================================================
    1.60 +//------------------------------ProjNode---------------------------------------
    1.61 +uint ProjNode::hash() const {
    1.62 +  // only one input
    1.63 +  return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
    1.64 +}
    1.65 +uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
    1.66 +uint ProjNode::size_of() const { return sizeof(ProjNode); }
    1.67 +
    1.68 +// Test if we propagate interesting control along this projection
    1.69 +bool ProjNode::is_CFG() const {
    1.70 +  Node *def = in(0);
    1.71 +  return (_con == TypeFunc::Control && def->is_CFG());
    1.72 +}
    1.73 +
    1.74 +const Type *ProjNode::bottom_type() const {
    1.75 +  if (in(0) == NULL)  return Type::TOP;
    1.76 +  const Type *tb = in(0)->bottom_type();
    1.77 +  if( tb == Type::TOP ) return Type::TOP;
    1.78 +  if( tb == Type::BOTTOM ) return Type::BOTTOM;
    1.79 +  const TypeTuple *t = tb->is_tuple();
    1.80 +  return t->field_at(_con);
    1.81 +}
    1.82 +
    1.83 +const TypePtr *ProjNode::adr_type() const {
    1.84 +  if (bottom_type() == Type::MEMORY) {
    1.85 +    // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
    1.86 +    const TypePtr* adr_type = in(0)->adr_type();
    1.87 +    #ifdef ASSERT
    1.88 +    if (!is_error_reported() && !Node::in_dump())
    1.89 +      assert(adr_type != NULL, "source must have adr_type");
    1.90 +    #endif
    1.91 +    return adr_type;
    1.92 +  }
    1.93 +  assert(bottom_type()->base() != Type::Memory, "no other memories?");
    1.94 +  return NULL;
    1.95 +}
    1.96 +
    1.97 +bool ProjNode::pinned() const { return in(0)->pinned(); }
    1.98 +#ifndef PRODUCT
    1.99 +void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
   1.100 +#endif
   1.101 +
   1.102 +//----------------------------check_con----------------------------------------
   1.103 +void ProjNode::check_con() const {
   1.104 +  Node* n = in(0);
   1.105 +  if (n == NULL)       return;  // should be assert, but NodeHash makes bogons
   1.106 +  if (n->is_Mach())    return;  // mach. projs. are not type-safe
   1.107 +  if (n->is_Start())   return;  // alas, starts can have mach. projs. also
   1.108 +  if (_con == SCMemProjNode::SCMEMPROJCON ) return;
   1.109 +  const Type* t = n->bottom_type();
   1.110 +  if (t == Type::TOP)  return;  // multi is dead
   1.111 +  assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
   1.112 +}
   1.113 +
   1.114 +//------------------------------Value------------------------------------------
   1.115 +const Type *ProjNode::Value( PhaseTransform *phase ) const {
   1.116 +  if( !in(0) ) return Type::TOP;
   1.117 +  const Type *t = phase->type(in(0));
   1.118 +  if( t == Type::TOP ) return t;
   1.119 +  if( t == Type::BOTTOM ) return t;
   1.120 +  return t->is_tuple()->field_at(_con);
   1.121 +}
   1.122 +
   1.123 +//------------------------------out_RegMask------------------------------------
   1.124 +// Pass the buck uphill
   1.125 +const RegMask &ProjNode::out_RegMask() const {
   1.126 +  return RegMask::Empty;
   1.127 +}
   1.128 +
   1.129 +//------------------------------ideal_reg--------------------------------------
   1.130 +uint ProjNode::ideal_reg() const {
   1.131 +  return Matcher::base2reg[bottom_type()->base()];
   1.132 +}

mercurial