0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "opto/matcher.hpp"
1879N/A#include "opto/multnode.hpp"
1879N/A#include "opto/opcodes.hpp"
1879N/A#include "opto/phaseX.hpp"
1879N/A#include "opto/regmask.hpp"
1879N/A#include "opto/type.hpp"
0N/A
0N/A//=============================================================================
0N/A//------------------------------MultiNode--------------------------------------
0N/Aconst RegMask &MultiNode::out_RegMask() const {
0N/A return RegMask::Empty;
0N/A}
0N/A
0N/ANode *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
0N/A
0N/A//------------------------------proj_out---------------------------------------
0N/A// Get a named projection
0N/AProjNode* MultiNode::proj_out(uint which_proj) const {
0N/A assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
0N/A assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
0N/A for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
0N/A Node *p = fast_out(i);
0N/A if( !p->is_Proj() ) {
0N/A assert(p == this && this->is_Start(), "else must be proj");
0N/A continue;
0N/A }
0N/A ProjNode *proj = p->as_Proj();
0N/A if( proj->_con == which_proj ) {
0N/A assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
0N/A return proj;
0N/A }
0N/A }
0N/A return NULL;
0N/A}
0N/A
0N/A//=============================================================================
0N/A//------------------------------ProjNode---------------------------------------
0N/Auint ProjNode::hash() const {
0N/A // only one input
0N/A return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
0N/A}
0N/Auint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
0N/Auint ProjNode::size_of() const { return sizeof(ProjNode); }
0N/A
0N/A// Test if we propagate interesting control along this projection
0N/Abool ProjNode::is_CFG() const {
0N/A Node *def = in(0);
0N/A return (_con == TypeFunc::Control && def->is_CFG());
0N/A}
0N/A
0N/Aconst Type *ProjNode::bottom_type() const {
0N/A if (in(0) == NULL) return Type::TOP;
0N/A const Type *tb = in(0)->bottom_type();
0N/A if( tb == Type::TOP ) return Type::TOP;
0N/A if( tb == Type::BOTTOM ) return Type::BOTTOM;
0N/A const TypeTuple *t = tb->is_tuple();
0N/A return t->field_at(_con);
0N/A}
0N/A
0N/Aconst TypePtr *ProjNode::adr_type() const {
0N/A if (bottom_type() == Type::MEMORY) {
0N/A // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
0N/A const TypePtr* adr_type = in(0)->adr_type();
0N/A #ifdef ASSERT
0N/A if (!is_error_reported() && !Node::in_dump())
0N/A assert(adr_type != NULL, "source must have adr_type");
0N/A #endif
0N/A return adr_type;
0N/A }
0N/A assert(bottom_type()->base() != Type::Memory, "no other memories?");
0N/A return NULL;
0N/A}
0N/A
0N/Abool ProjNode::pinned() const { return in(0)->pinned(); }
0N/A#ifndef PRODUCT
0N/Avoid ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
0N/A#endif
0N/A
0N/A//----------------------------check_con----------------------------------------
0N/Avoid ProjNode::check_con() const {
0N/A Node* n = in(0);
0N/A if (n == NULL) return; // should be assert, but NodeHash makes bogons
0N/A if (n->is_Mach()) return; // mach. projs. are not type-safe
0N/A if (n->is_Start()) return; // alas, starts can have mach. projs. also
0N/A if (_con == SCMemProjNode::SCMEMPROJCON ) return;
0N/A const Type* t = n->bottom_type();
0N/A if (t == Type::TOP) return; // multi is dead
0N/A assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
0N/A}
0N/A
0N/A//------------------------------Value------------------------------------------
0N/Aconst Type *ProjNode::Value( PhaseTransform *phase ) const {
0N/A if( !in(0) ) return Type::TOP;
0N/A const Type *t = phase->type(in(0));
0N/A if( t == Type::TOP ) return t;
0N/A if( t == Type::BOTTOM ) return t;
0N/A return t->is_tuple()->field_at(_con);
0N/A}
0N/A
0N/A//------------------------------out_RegMask------------------------------------
0N/A// Pass the buck uphill
0N/Aconst RegMask &ProjNode::out_RegMask() const {
0N/A return RegMask::Empty;
0N/A}
0N/A
0N/A//------------------------------ideal_reg--------------------------------------
0N/Auint ProjNode::ideal_reg() const {
0N/A return Matcher::base2reg[bottom_type()->base()];
0N/A}