comparison src/share/vm/opto/multnode.cpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 #include "incls/_precompiled.incl"
26 #include "incls/_multnode.cpp.incl"
27
28 //=============================================================================
29 //------------------------------MultiNode--------------------------------------
30 const RegMask &MultiNode::out_RegMask() const {
31 return RegMask::Empty;
32 }
33
34 Node *MultiNode::match( const ProjNode *proj, const Matcher *m ) { return proj->clone(); }
35
36 //------------------------------proj_out---------------------------------------
37 // Get a named projection
38 ProjNode* MultiNode::proj_out(uint which_proj) const {
39 assert(Opcode() != Op_If || which_proj == (uint)true || which_proj == (uint)false, "must be 1 or 0");
40 assert(Opcode() != Op_If || outcnt() == 2, "bad if #1");
41 for( DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++ ) {
42 Node *p = fast_out(i);
43 if( !p->is_Proj() ) {
44 assert(p == this && this->is_Start(), "else must be proj");
45 continue;
46 }
47 ProjNode *proj = p->as_Proj();
48 if( proj->_con == which_proj ) {
49 assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2");
50 return proj;
51 }
52 }
53 return NULL;
54 }
55
56 //=============================================================================
57 //------------------------------ProjNode---------------------------------------
58 uint ProjNode::hash() const {
59 // only one input
60 return (uintptr_t)in(TypeFunc::Control) + (_con << 1) + (_is_io_use ? 1 : 0);
61 }
62 uint ProjNode::cmp( const Node &n ) const { return _con == ((ProjNode&)n)._con && ((ProjNode&)n)._is_io_use == _is_io_use; }
63 uint ProjNode::size_of() const { return sizeof(ProjNode); }
64
65 // Test if we propagate interesting control along this projection
66 bool ProjNode::is_CFG() const {
67 Node *def = in(0);
68 return (_con == TypeFunc::Control && def->is_CFG());
69 }
70
71 const Type *ProjNode::bottom_type() const {
72 if (in(0) == NULL) return Type::TOP;
73 const Type *tb = in(0)->bottom_type();
74 if( tb == Type::TOP ) return Type::TOP;
75 if( tb == Type::BOTTOM ) return Type::BOTTOM;
76 const TypeTuple *t = tb->is_tuple();
77 return t->field_at(_con);
78 }
79
80 const TypePtr *ProjNode::adr_type() const {
81 if (bottom_type() == Type::MEMORY) {
82 // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
83 const TypePtr* adr_type = in(0)->adr_type();
84 #ifdef ASSERT
85 if (!is_error_reported() && !Node::in_dump())
86 assert(adr_type != NULL, "source must have adr_type");
87 #endif
88 return adr_type;
89 }
90 assert(bottom_type()->base() != Type::Memory, "no other memories?");
91 return NULL;
92 }
93
94 bool ProjNode::pinned() const { return in(0)->pinned(); }
95 #ifndef PRODUCT
96 void ProjNode::dump_spec(outputStream *st) const { st->print("#%d",_con); if(_is_io_use) st->print(" (i_o_use)");}
97 #endif
98
99 //----------------------------check_con----------------------------------------
100 void ProjNode::check_con() const {
101 Node* n = in(0);
102 if (n == NULL) return; // should be assert, but NodeHash makes bogons
103 if (n->is_Mach()) return; // mach. projs. are not type-safe
104 if (n->is_Start()) return; // alas, starts can have mach. projs. also
105 if (_con == SCMemProjNode::SCMEMPROJCON ) return;
106 const Type* t = n->bottom_type();
107 if (t == Type::TOP) return; // multi is dead
108 assert(_con < t->is_tuple()->cnt(), "ProjNode::_con must be in range");
109 }
110
111 //------------------------------Value------------------------------------------
112 const Type *ProjNode::Value( PhaseTransform *phase ) const {
113 if( !in(0) ) return Type::TOP;
114 const Type *t = phase->type(in(0));
115 if( t == Type::TOP ) return t;
116 if( t == Type::BOTTOM ) return t;
117 return t->is_tuple()->field_at(_con);
118 }
119
120 //------------------------------out_RegMask------------------------------------
121 // Pass the buck uphill
122 const RegMask &ProjNode::out_RegMask() const {
123 return RegMask::Empty;
124 }
125
126 //------------------------------ideal_reg--------------------------------------
127 uint ProjNode::ideal_reg() const {
128 return Matcher::base2reg[bottom_type()->base()];
129 }