src/share/vm/opto/machnode.cpp

Wed, 10 Aug 2016 14:59:21 +0200

author
simonis
date
Wed, 10 Aug 2016 14:59:21 +0200
changeset 8608
0d78aecb0948
parent 7161
fc2c88ea11a9
child 7535
7ae4e26cb1e0
child 9513
e044997c2eda
permissions
-rw-r--r--

8152172: PPC64: Support AES intrinsics
Summary: Add support for AES intrinsics on PPC64.
Reviewed-by: kvn, mdoerr, simonis, zmajo
Contributed-by: Hiroshi H Horii <horii@jp.ibm.com>

duke@435 1 /*
drchase@7161 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_interface/collectedHeap.hpp"
stefank@2314 27 #include "opto/machnode.hpp"
stefank@2314 28 #include "opto/regalloc.hpp"
duke@435 29
duke@435 30 //=============================================================================
duke@435 31 // Return the value requested
duke@435 32 // result register lookup, corresponding to int_format
duke@435 33 int MachOper::reg(PhaseRegAlloc *ra_, const Node *node) const {
duke@435 34 return (int)ra_->get_encode(node);
duke@435 35 }
duke@435 36 // input register lookup, corresponding to ext_format
duke@435 37 int MachOper::reg(PhaseRegAlloc *ra_, const Node *node, int idx) const {
duke@435 38 return (int)(ra_->get_encode(node->in(idx)));
duke@435 39 }
duke@435 40 intptr_t MachOper::constant() const { return 0x00; }
coleenp@4037 41 relocInfo::relocType MachOper::constant_reloc() const { return relocInfo::none; }
duke@435 42 jdouble MachOper::constantD() const { ShouldNotReachHere(); return 0.0; }
duke@435 43 jfloat MachOper::constantF() const { ShouldNotReachHere(); return 0.0; }
duke@435 44 jlong MachOper::constantL() const { ShouldNotReachHere(); return CONST64(0) ; }
duke@435 45 TypeOopPtr *MachOper::oop() const { return NULL; }
duke@435 46 int MachOper::ccode() const { return 0x00; }
duke@435 47 // A zero, default, indicates this value is not needed.
duke@435 48 // May need to lookup the base register, as done in int_ and ext_format
duke@435 49 int MachOper::base (PhaseRegAlloc *ra_, const Node *node, int idx) const { return 0x00; }
duke@435 50 int MachOper::index(PhaseRegAlloc *ra_, const Node *node, int idx) const { return 0x00; }
duke@435 51 int MachOper::scale() const { return 0x00; }
duke@435 52 int MachOper::disp (PhaseRegAlloc *ra_, const Node *node, int idx) const { return 0x00; }
duke@435 53 int MachOper::constant_disp() const { return 0; }
duke@435 54 int MachOper::base_position() const { return -1; } // no base input
duke@435 55 int MachOper::index_position() const { return -1; } // no index input
duke@435 56 // Check for PC-Relative displacement
coleenp@4037 57 relocInfo::relocType MachOper::disp_reloc() const { return relocInfo::none; }
duke@435 58 // Return the label
duke@435 59 Label* MachOper::label() const { ShouldNotReachHere(); return 0; }
duke@435 60 intptr_t MachOper::method() const { ShouldNotReachHere(); return 0; }
duke@435 61
duke@435 62
duke@435 63 //------------------------------negate-----------------------------------------
duke@435 64 // Negate conditional branches. Error for non-branch operands
duke@435 65 void MachOper::negate() {
duke@435 66 ShouldNotCallThis();
duke@435 67 }
duke@435 68
duke@435 69 //-----------------------------type--------------------------------------------
duke@435 70 const Type *MachOper::type() const {
duke@435 71 return Type::BOTTOM;
duke@435 72 }
duke@435 73
duke@435 74 //------------------------------in_RegMask-------------------------------------
duke@435 75 const RegMask *MachOper::in_RegMask(int index) const {
duke@435 76 ShouldNotReachHere();
duke@435 77 return NULL;
duke@435 78 }
duke@435 79
duke@435 80 //------------------------------dump_spec--------------------------------------
duke@435 81 // Print any per-operand special info
duke@435 82 #ifndef PRODUCT
duke@435 83 void MachOper::dump_spec(outputStream *st) const { }
duke@435 84 #endif
duke@435 85
duke@435 86 //------------------------------hash-------------------------------------------
duke@435 87 // Print any per-operand special info
duke@435 88 uint MachOper::hash() const {
duke@435 89 ShouldNotCallThis();
duke@435 90 return 5;
duke@435 91 }
duke@435 92
duke@435 93 //------------------------------cmp--------------------------------------------
duke@435 94 // Print any per-operand special info
duke@435 95 uint MachOper::cmp( const MachOper &oper ) const {
duke@435 96 ShouldNotCallThis();
duke@435 97 return opcode() == oper.opcode();
duke@435 98 }
duke@435 99
duke@435 100 //------------------------------hash-------------------------------------------
duke@435 101 // Print any per-operand special info
duke@435 102 uint labelOper::hash() const {
duke@435 103 return _block_num;
duke@435 104 }
duke@435 105
duke@435 106 //------------------------------cmp--------------------------------------------
duke@435 107 // Print any per-operand special info
duke@435 108 uint labelOper::cmp( const MachOper &oper ) const {
duke@435 109 return (opcode() == oper.opcode()) && (_label == oper.label());
duke@435 110 }
duke@435 111
duke@435 112 //------------------------------hash-------------------------------------------
duke@435 113 // Print any per-operand special info
duke@435 114 uint methodOper::hash() const {
duke@435 115 return (uint)_method;
duke@435 116 }
duke@435 117
duke@435 118 //------------------------------cmp--------------------------------------------
duke@435 119 // Print any per-operand special info
duke@435 120 uint methodOper::cmp( const MachOper &oper ) const {
duke@435 121 return (opcode() == oper.opcode()) && (_method == oper.method());
duke@435 122 }
duke@435 123
duke@435 124
duke@435 125 //=============================================================================
duke@435 126 //------------------------------MachNode---------------------------------------
duke@435 127
duke@435 128 //------------------------------emit-------------------------------------------
duke@435 129 void MachNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
duke@435 130 #ifdef ASSERT
duke@435 131 tty->print("missing MachNode emit function: ");
duke@435 132 dump();
duke@435 133 #endif
duke@435 134 ShouldNotCallThis();
duke@435 135 }
duke@435 136
goetz@6478 137 //---------------------------postalloc_expand----------------------------------
goetz@6478 138 // Expand node after register allocation.
goetz@6478 139 void MachNode::postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_) {}
goetz@6478 140
duke@435 141 //------------------------------size-------------------------------------------
duke@435 142 // Size of instruction in bytes
duke@435 143 uint MachNode::size(PhaseRegAlloc *ra_) const {
duke@435 144 // If a virtual was not defined for this specific instruction,
twisti@1040 145 // Call the helper which finds the size by emitting the bits.
duke@435 146 return MachNode::emit_size(ra_);
duke@435 147 }
duke@435 148
duke@435 149 //------------------------------size-------------------------------------------
duke@435 150 // Helper function that computes size by emitting code
duke@435 151 uint MachNode::emit_size(PhaseRegAlloc *ra_) const {
duke@435 152 // Emit into a trash buffer and count bytes emitted.
duke@435 153 assert(ra_ == ra_->C->regalloc(), "sanity");
duke@435 154 return ra_->C->scratch_emit_size(this);
duke@435 155 }
duke@435 156
duke@435 157
duke@435 158
duke@435 159 //------------------------------hash-------------------------------------------
duke@435 160 uint MachNode::hash() const {
duke@435 161 uint no = num_opnds();
duke@435 162 uint sum = rule();
duke@435 163 for( uint i=0; i<no; i++ )
duke@435 164 sum += _opnds[i]->hash();
duke@435 165 return sum+Node::hash();
duke@435 166 }
duke@435 167
duke@435 168 //-----------------------------cmp---------------------------------------------
duke@435 169 uint MachNode::cmp( const Node &node ) const {
duke@435 170 MachNode& n = *((Node&)node).as_Mach();
duke@435 171 uint no = num_opnds();
duke@435 172 if( no != n.num_opnds() ) return 0;
duke@435 173 if( rule() != n.rule() ) return 0;
duke@435 174 for( uint i=0; i<no; i++ ) // All operands must match
duke@435 175 if( !_opnds[i]->cmp( *n._opnds[i] ) )
duke@435 176 return 0; // mis-matched operands
duke@435 177 return 1; // match
duke@435 178 }
duke@435 179
duke@435 180 // Return an equivalent instruction using memory for cisc_operand position
duke@435 181 MachNode *MachNode::cisc_version(int offset, Compile* C) {
duke@435 182 ShouldNotCallThis();
duke@435 183 return NULL;
duke@435 184 }
duke@435 185
duke@435 186 void MachNode::use_cisc_RegMask() {
duke@435 187 ShouldNotReachHere();
duke@435 188 }
duke@435 189
duke@435 190
duke@435 191 //-----------------------------in_RegMask--------------------------------------
duke@435 192 const RegMask &MachNode::in_RegMask( uint idx ) const {
duke@435 193 uint numopnds = num_opnds(); // Virtual call for number of operands
duke@435 194 uint skipped = oper_input_base(); // Sum of leaves skipped so far
duke@435 195 if( idx < skipped ) {
duke@435 196 assert( ideal_Opcode() == Op_AddP, "expected base ptr here" );
duke@435 197 assert( idx == 1, "expected base ptr here" );
duke@435 198 // debug info can be anywhere
duke@435 199 return *Compile::current()->matcher()->idealreg2spillmask[Op_RegP];
duke@435 200 }
duke@435 201 uint opcnt = 1; // First operand
duke@435 202 uint num_edges = _opnds[1]->num_edges(); // leaves for first operand
duke@435 203 while( idx >= skipped+num_edges ) {
duke@435 204 skipped += num_edges;
duke@435 205 opcnt++; // Bump operand count
duke@435 206 assert( opcnt < numopnds, "Accessing non-existent operand" );
duke@435 207 num_edges = _opnds[opcnt]->num_edges(); // leaves for next operand
duke@435 208 }
duke@435 209
duke@435 210 const RegMask *rm = cisc_RegMask();
duke@435 211 if( rm == NULL || (int)opcnt != cisc_operand() ) {
duke@435 212 rm = _opnds[opcnt]->in_RegMask(idx-skipped);
duke@435 213 }
duke@435 214 return *rm;
duke@435 215 }
duke@435 216
duke@435 217 //-----------------------------memory_inputs--------------------------------
duke@435 218 const MachOper* MachNode::memory_inputs(Node* &base, Node* &index) const {
duke@435 219 const MachOper* oper = memory_operand();
duke@435 220
duke@435 221 if (oper == (MachOper*)-1) {
duke@435 222 base = NodeSentinel;
duke@435 223 index = NodeSentinel;
duke@435 224 } else {
duke@435 225 base = NULL;
duke@435 226 index = NULL;
duke@435 227 if (oper != NULL) {
duke@435 228 // It has a unique memory operand. Find its index.
duke@435 229 int oper_idx = num_opnds();
duke@435 230 while (--oper_idx >= 0) {
duke@435 231 if (_opnds[oper_idx] == oper) break;
duke@435 232 }
duke@435 233 int oper_pos = operand_index(oper_idx);
duke@435 234 int base_pos = oper->base_position();
duke@435 235 if (base_pos >= 0) {
duke@435 236 base = _in[oper_pos+base_pos];
duke@435 237 }
duke@435 238 int index_pos = oper->index_position();
duke@435 239 if (index_pos >= 0) {
duke@435 240 index = _in[oper_pos+index_pos];
duke@435 241 }
duke@435 242 }
duke@435 243 }
duke@435 244
duke@435 245 return oper;
duke@435 246 }
duke@435 247
duke@435 248 //-----------------------------get_base_and_disp----------------------------
duke@435 249 const Node* MachNode::get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const {
duke@435 250
duke@435 251 // Find the memory inputs using our helper function
duke@435 252 Node* base;
duke@435 253 Node* index;
duke@435 254 const MachOper* oper = memory_inputs(base, index);
duke@435 255
duke@435 256 if (oper == NULL) {
duke@435 257 // Base has been set to NULL
duke@435 258 offset = 0;
duke@435 259 } else if (oper == (MachOper*)-1) {
duke@435 260 // Base has been set to NodeSentinel
duke@435 261 // There is not a unique memory use here. We will fall to AliasIdxBot.
duke@435 262 offset = Type::OffsetBot;
duke@435 263 } else {
duke@435 264 // Base may be NULL, even if offset turns out to be != 0
duke@435 265
duke@435 266 intptr_t disp = oper->constant_disp();
duke@435 267 int scale = oper->scale();
duke@435 268 // Now we have collected every part of the ADLC MEMORY_INTER.
duke@435 269 // See if it adds up to a base + offset.
duke@435 270 if (index != NULL) {
kvn@656 271 const Type* t_index = index->bottom_type();
roland@4159 272 if (t_index->isa_narrowoop() || t_index->isa_narrowklass()) { // EncodeN, LoadN, LoadConN, LoadNKlass,
roland@4159 273 // EncodeNKlass, LoadConNklass.
kvn@651 274 // Memory references through narrow oops have a
kvn@651 275 // funny base so grab the type from the index:
kvn@651 276 // [R12 + narrow_oop_reg<<3 + offset]
kvn@651 277 assert(base == NULL, "Memory references through narrow oops have no base");
kvn@651 278 offset = disp;
kvn@656 279 adr_type = t_index->make_ptr()->add_offset(offset);
kvn@651 280 return NULL;
kvn@651 281 } else if (!index->is_Con()) {
duke@435 282 disp = Type::OffsetBot;
duke@435 283 } else if (disp != Type::OffsetBot) {
kvn@656 284 const TypeX* ti = t_index->isa_intptr_t();
duke@435 285 if (ti == NULL) {
duke@435 286 disp = Type::OffsetBot; // a random constant??
duke@435 287 } else {
duke@435 288 disp += ti->get_con() << scale;
duke@435 289 }
duke@435 290 }
duke@435 291 }
duke@435 292 offset = disp;
duke@435 293
duke@435 294 // In i486.ad, indOffset32X uses base==RegI and disp==RegP,
duke@435 295 // this will prevent alias analysis without the following support:
duke@435 296 // Lookup the TypePtr used by indOffset32X, a compile-time constant oop,
duke@435 297 // Add the offset determined by the "base", or use Type::OffsetBot.
duke@435 298 if( adr_type == TYPE_PTR_SENTINAL ) {
duke@435 299 const TypePtr *t_disp = oper->disp_as_type(); // only !NULL for indOffset32X
duke@435 300 if (t_disp != NULL) {
duke@435 301 offset = Type::OffsetBot;
duke@435 302 const Type* t_base = base->bottom_type();
duke@435 303 if (t_base->isa_intptr_t()) {
duke@435 304 const TypeX *t_offset = t_base->is_intptr_t();
duke@435 305 if( t_offset->is_con() ) {
duke@435 306 offset = t_offset->get_con();
duke@435 307 }
duke@435 308 }
duke@435 309 adr_type = t_disp->add_offset(offset);
kvn@1286 310 } else if( base == NULL && offset != 0 && offset != Type::OffsetBot ) {
kvn@1286 311 // Use ideal type if it is oop ptr.
kvn@1286 312 const TypePtr *tp = oper->type()->isa_ptr();
kvn@1286 313 if( tp != NULL) {
kvn@1286 314 adr_type = tp;
kvn@1286 315 }
duke@435 316 }
duke@435 317 }
duke@435 318
duke@435 319 }
duke@435 320 return base;
duke@435 321 }
duke@435 322
duke@435 323
duke@435 324 //---------------------------------adr_type---------------------------------
duke@435 325 const class TypePtr *MachNode::adr_type() const {
duke@435 326 intptr_t offset = 0;
duke@435 327 const TypePtr *adr_type = TYPE_PTR_SENTINAL; // attempt computing adr_type
duke@435 328 const Node *base = get_base_and_disp(offset, adr_type);
duke@435 329 if( adr_type != TYPE_PTR_SENTINAL ) {
duke@435 330 return adr_type; // get_base_and_disp has the answer
duke@435 331 }
duke@435 332
duke@435 333 // Direct addressing modes have no base node, simply an indirect
duke@435 334 // offset, which is always to raw memory.
duke@435 335 // %%%%% Someday we'd like to allow constant oop offsets which
duke@435 336 // would let Intel load from static globals in 1 instruction.
duke@435 337 // Currently Intel requires 2 instructions and a register temp.
duke@435 338 if (base == NULL) {
duke@435 339 // NULL base, zero offset means no memory at all (a null pointer!)
duke@435 340 if (offset == 0) {
duke@435 341 return NULL;
duke@435 342 }
duke@435 343 // NULL base, any offset means any pointer whatever
duke@435 344 if (offset == Type::OffsetBot) {
duke@435 345 return TypePtr::BOTTOM;
duke@435 346 }
duke@435 347 // %%% make offset be intptr_t
hseigel@5784 348 assert(!Universe::heap()->is_in_reserved(cast_to_oop(offset)), "must be a raw ptr");
duke@435 349 return TypeRawPtr::BOTTOM;
duke@435 350 }
duke@435 351
duke@435 352 // base of -1 with no particular offset means all of memory
duke@435 353 if (base == NodeSentinel) return TypePtr::BOTTOM;
duke@435 354
duke@435 355 const Type* t = base->bottom_type();
kvn@5111 356 if (t->isa_narrowoop() && Universe::narrow_oop_shift() == 0) {
kvn@1108 357 // 32-bit unscaled narrow oop can be the base of any address expression
kvn@1108 358 t = t->make_ptr();
kvn@1108 359 }
kvn@5111 360 if (t->isa_narrowklass() && Universe::narrow_klass_shift() == 0) {
roland@4159 361 // 32-bit unscaled narrow oop can be the base of any address expression
roland@4159 362 t = t->make_ptr();
roland@4159 363 }
duke@435 364 if (t->isa_intptr_t() && offset != 0 && offset != Type::OffsetBot) {
duke@435 365 // We cannot assert that the offset does not look oop-ish here.
duke@435 366 // Depending on the heap layout the cardmark base could land
duke@435 367 // inside some oopish region. It definitely does for Win2K.
duke@435 368 // The sum of cardmark-base plus shift-by-9-oop lands outside
duke@435 369 // the oop-ish area but we can't assert for that statically.
duke@435 370 return TypeRawPtr::BOTTOM;
duke@435 371 }
duke@435 372
duke@435 373 const TypePtr *tp = t->isa_ptr();
duke@435 374
duke@435 375 // be conservative if we do not recognize the type
duke@435 376 if (tp == NULL) {
kvn@1108 377 assert(false, "this path may produce not optimal code");
duke@435 378 return TypePtr::BOTTOM;
duke@435 379 }
duke@435 380 assert(tp->base() != Type::AnyPtr, "not a bare pointer");
duke@435 381
duke@435 382 return tp->add_offset(offset);
duke@435 383 }
duke@435 384
duke@435 385
duke@435 386 //-----------------------------operand_index---------------------------------
duke@435 387 int MachNode::operand_index( uint operand ) const {
duke@435 388 if( operand < 1 ) return -1;
duke@435 389 assert(operand < num_opnds(), "oob");
duke@435 390 if( _opnds[operand]->num_edges() == 0 ) return -1;
duke@435 391
duke@435 392 uint skipped = oper_input_base(); // Sum of leaves skipped so far
duke@435 393 for (uint opcnt = 1; opcnt < operand; opcnt++) {
duke@435 394 uint num_edges = _opnds[opcnt]->num_edges(); // leaves for operand
duke@435 395 skipped += num_edges;
duke@435 396 }
duke@435 397 return skipped;
duke@435 398 }
duke@435 399
goetz@6487 400 int MachNode::operand_index(const MachOper *oper) const {
goetz@6487 401 uint skipped = oper_input_base(); // Sum of leaves skipped so far
goetz@6487 402 uint opcnt;
goetz@6487 403 for (opcnt = 1; opcnt < num_opnds(); opcnt++) {
goetz@6487 404 if (_opnds[opcnt] == oper) break;
goetz@6487 405 uint num_edges = _opnds[opcnt]->num_edges(); // leaves for operand
goetz@6487 406 skipped += num_edges;
goetz@6487 407 }
goetz@6487 408 if (_opnds[opcnt] != oper) return -1;
goetz@6487 409 return skipped;
goetz@6487 410 }
duke@435 411
duke@435 412 //------------------------------peephole---------------------------------------
duke@435 413 // Apply peephole rule(s) to this instruction
duke@435 414 MachNode *MachNode::peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ) {
duke@435 415 return NULL;
duke@435 416 }
duke@435 417
duke@435 418 //------------------------------add_case_label---------------------------------
duke@435 419 // Adds the label for the case
duke@435 420 void MachNode::add_case_label( int index_num, Label* blockLabel) {
duke@435 421 ShouldNotCallThis();
duke@435 422 }
duke@435 423
duke@435 424 //------------------------------method_set-------------------------------------
duke@435 425 // Set the absolute address of a method
duke@435 426 void MachNode::method_set( intptr_t addr ) {
duke@435 427 ShouldNotCallThis();
duke@435 428 }
duke@435 429
duke@435 430 //------------------------------rematerialize----------------------------------
duke@435 431 bool MachNode::rematerialize() const {
duke@435 432 // Temps are always rematerializable
duke@435 433 if (is_MachTemp()) return true;
duke@435 434
duke@435 435 uint r = rule(); // Match rule
duke@435 436 if( r < Matcher::_begin_rematerialize ||
duke@435 437 r >= Matcher::_end_rematerialize )
duke@435 438 return false;
duke@435 439
duke@435 440 // For 2-address instructions, the input live range is also the output
duke@435 441 // live range. Remateralizing does not make progress on the that live range.
duke@435 442 if( two_adr() ) return false;
duke@435 443
duke@435 444 // Check for rematerializing float constants, or not
duke@435 445 if( !Matcher::rematerialize_float_constants ) {
duke@435 446 int op = ideal_Opcode();
duke@435 447 if( op == Op_ConF || op == Op_ConD )
duke@435 448 return false;
duke@435 449 }
duke@435 450
duke@435 451 // Defining flags - can't spill these! Must remateralize.
duke@435 452 if( ideal_reg() == Op_RegFlags )
duke@435 453 return true;
duke@435 454
duke@435 455 // Stretching lots of inputs - don't do it.
duke@435 456 if( req() > 2 )
duke@435 457 return false;
duke@435 458
duke@435 459 // Don't remateralize somebody with bound inputs - it stretches a
duke@435 460 // fixed register lifetime.
duke@435 461 uint idx = oper_input_base();
kvn@3882 462 if (req() > idx) {
duke@435 463 const RegMask &rm = in_RegMask(idx);
kvn@3882 464 if (rm.is_bound(ideal_reg()))
duke@435 465 return false;
duke@435 466 }
duke@435 467
duke@435 468 return true;
duke@435 469 }
duke@435 470
duke@435 471 #ifndef PRODUCT
duke@435 472 //------------------------------dump_spec--------------------------------------
duke@435 473 // Print any per-operand special info
duke@435 474 void MachNode::dump_spec(outputStream *st) const {
duke@435 475 uint cnt = num_opnds();
duke@435 476 for( uint i=0; i<cnt; i++ )
duke@435 477 _opnds[i]->dump_spec(st);
duke@435 478 const TypePtr *t = adr_type();
duke@435 479 if( t ) {
duke@435 480 Compile* C = Compile::current();
duke@435 481 if( C->alias_type(t)->is_volatile() )
duke@435 482 st->print(" Volatile!");
duke@435 483 }
duke@435 484 }
duke@435 485
duke@435 486 //------------------------------dump_format------------------------------------
duke@435 487 // access to virtual
duke@435 488 void MachNode::dump_format(PhaseRegAlloc *ra, outputStream *st) const {
duke@435 489 format(ra, st); // access to virtual
duke@435 490 }
duke@435 491 #endif
duke@435 492
duke@435 493 //=============================================================================
duke@435 494 #ifndef PRODUCT
duke@435 495 void MachTypeNode::dump_spec(outputStream *st) const {
duke@435 496 _bottom_type->dump_on(st);
duke@435 497 }
duke@435 498 #endif
duke@435 499
twisti@2350 500
twisti@2350 501 //=============================================================================
twisti@2350 502 int MachConstantNode::constant_offset() {
twisti@2350 503 // Bind the offset lazily.
twisti@3310 504 if (_constant.offset() == -1) {
twisti@2350 505 Compile::ConstantTable& constant_table = Compile::current()->constant_table();
twisti@3310 506 int offset = constant_table.find_offset(_constant);
twisti@3310 507 // If called from Compile::scratch_emit_size return the
twisti@3310 508 // pre-calculated offset.
twisti@3310 509 // NOTE: If the AD file does some table base offset optimizations
twisti@3310 510 // later the AD file needs to take care of this fact.
twisti@3310 511 if (Compile::current()->in_scratch_emit_size()) {
twisti@3310 512 return constant_table.calculate_table_base_offset() + offset;
twisti@3310 513 }
twisti@3310 514 _constant.set_offset(constant_table.table_base_offset() + offset);
twisti@2350 515 }
twisti@3310 516 return _constant.offset();
twisti@2350 517 }
twisti@2350 518
goetz@6481 519 int MachConstantNode::constant_offset_unchecked() const {
goetz@6481 520 return _constant.offset();
goetz@6481 521 }
twisti@2350 522
duke@435 523 //=============================================================================
duke@435 524 #ifndef PRODUCT
duke@435 525 void MachNullCheckNode::format( PhaseRegAlloc *ra_, outputStream *st ) const {
duke@435 526 int reg = ra_->get_reg_first(in(1)->in(_vidx));
kvn@4478 527 st->print("%s %s", Name(), Matcher::regName[reg]);
duke@435 528 }
duke@435 529 #endif
duke@435 530
duke@435 531 void MachNullCheckNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {
duke@435 532 // only emits entries in the null-pointer exception handler table
duke@435 533 }
kvn@3037 534 void MachNullCheckNode::label_set(Label* label, uint block_num) {
kvn@3037 535 // Nothing to emit
kvn@3037 536 }
kvn@3051 537 void MachNullCheckNode::save_label( Label** label, uint* block_num ) {
kvn@3051 538 // Nothing to emit
kvn@3051 539 }
duke@435 540
duke@435 541 const RegMask &MachNullCheckNode::in_RegMask( uint idx ) const {
duke@435 542 if( idx == 0 ) return RegMask::Empty;
duke@435 543 else return in(1)->as_Mach()->out_RegMask();
duke@435 544 }
duke@435 545
duke@435 546 //=============================================================================
duke@435 547 const Type *MachProjNode::bottom_type() const {
duke@435 548 if( _ideal_reg == fat_proj ) return Type::BOTTOM;
duke@435 549 // Try the normal mechanism first
duke@435 550 const Type *t = in(0)->bottom_type();
duke@435 551 if( t->base() == Type::Tuple ) {
duke@435 552 const TypeTuple *tt = t->is_tuple();
duke@435 553 if (_con < tt->cnt())
duke@435 554 return tt->field_at(_con);
duke@435 555 }
duke@435 556 // Else use generic type from ideal register set
duke@435 557 assert((uint)_ideal_reg < (uint)_last_machine_leaf && Type::mreg2type[_ideal_reg], "in bounds");
duke@435 558 return Type::mreg2type[_ideal_reg];
duke@435 559 }
duke@435 560
duke@435 561 const TypePtr *MachProjNode::adr_type() const {
duke@435 562 if (bottom_type() == Type::MEMORY) {
duke@435 563 // in(0) might be a narrow MemBar; otherwise we will report TypePtr::BOTTOM
duke@435 564 const TypePtr* adr_type = in(0)->adr_type();
duke@435 565 #ifdef ASSERT
duke@435 566 if (!is_error_reported() && !Node::in_dump())
duke@435 567 assert(adr_type != NULL, "source must have adr_type");
duke@435 568 #endif
duke@435 569 return adr_type;
duke@435 570 }
duke@435 571 assert(bottom_type()->base() != Type::Memory, "no other memories?");
duke@435 572 return NULL;
duke@435 573 }
duke@435 574
duke@435 575 #ifndef PRODUCT
duke@435 576 void MachProjNode::dump_spec(outputStream *st) const {
duke@435 577 ProjNode::dump_spec(st);
duke@435 578 switch (_ideal_reg) {
duke@435 579 case unmatched_proj: st->print("/unmatched"); break;
duke@435 580 case fat_proj: st->print("/fat"); if (WizardMode) _rout.dump(); break;
duke@435 581 }
duke@435 582 }
duke@435 583 #endif
duke@435 584
duke@435 585 //=============================================================================
duke@435 586 #ifndef PRODUCT
duke@435 587 void MachIfNode::dump_spec(outputStream *st) const {
duke@435 588 st->print("P=%f, C=%f",_prob, _fcnt);
duke@435 589 }
duke@435 590 #endif
duke@435 591
duke@435 592 //=============================================================================
duke@435 593 uint MachReturnNode::size_of() const { return sizeof(*this); }
duke@435 594
duke@435 595 //------------------------------Registers--------------------------------------
duke@435 596 const RegMask &MachReturnNode::in_RegMask( uint idx ) const {
duke@435 597 return _in_rms[idx];
duke@435 598 }
duke@435 599
duke@435 600 const TypePtr *MachReturnNode::adr_type() const {
duke@435 601 // most returns and calls are assumed to consume & modify all of memory
duke@435 602 // the matcher will copy non-wide adr_types from ideal originals
duke@435 603 return _adr_type;
duke@435 604 }
duke@435 605
duke@435 606 //=============================================================================
duke@435 607 const Type *MachSafePointNode::bottom_type() const { return TypeTuple::MEMBAR; }
duke@435 608
duke@435 609 //------------------------------Registers--------------------------------------
duke@435 610 const RegMask &MachSafePointNode::in_RegMask( uint idx ) const {
duke@435 611 // Values in the domain use the users calling convention, embodied in the
duke@435 612 // _in_rms array of RegMasks.
duke@435 613 if( idx < TypeFunc::Parms ) return _in_rms[idx];
duke@435 614
duke@435 615 if (SafePointNode::needs_polling_address_input() &&
duke@435 616 idx == TypeFunc::Parms &&
duke@435 617 ideal_Opcode() == Op_SafePoint) {
duke@435 618 return MachNode::in_RegMask(idx);
duke@435 619 }
duke@435 620
duke@435 621 // Values outside the domain represent debug info
duke@435 622 return *Compile::current()->matcher()->idealreg2spillmask[in(idx)->ideal_reg()];
duke@435 623 }
duke@435 624
duke@435 625
duke@435 626 //=============================================================================
duke@435 627
duke@435 628 uint MachCallNode::cmp( const Node &n ) const
duke@435 629 { return _tf == ((MachCallNode&)n)._tf; }
duke@435 630 const Type *MachCallNode::bottom_type() const { return tf()->range(); }
duke@435 631 const Type *MachCallNode::Value(PhaseTransform *phase) const { return tf()->range(); }
duke@435 632
duke@435 633 #ifndef PRODUCT
duke@435 634 void MachCallNode::dump_spec(outputStream *st) const {
duke@435 635 st->print("# ");
duke@435 636 tf()->dump_on(st);
duke@435 637 if (_cnt != COUNT_UNKNOWN) st->print(" C=%f",_cnt);
duke@435 638 if (jvms() != NULL) jvms()->dump_spec(st);
duke@435 639 }
duke@435 640 #endif
duke@435 641
duke@435 642 bool MachCallNode::return_value_is_used() const {
duke@435 643 if (tf()->range()->cnt() == TypeFunc::Parms) {
duke@435 644 // void return
duke@435 645 return false;
duke@435 646 }
duke@435 647
duke@435 648 // find the projection corresponding to the return value
duke@435 649 for (DUIterator_Fast imax, i = fast_outs(imax); i < imax; i++) {
duke@435 650 Node *use = fast_out(i);
duke@435 651 if (!use->is_Proj()) continue;
duke@435 652 if (use->as_Proj()->_con == TypeFunc::Parms) {
duke@435 653 return true;
duke@435 654 }
duke@435 655 }
duke@435 656 return false;
duke@435 657 }
duke@435 658
drchase@7161 659 // Similar to cousin class CallNode::returns_pointer
drchase@7161 660 // Because this is used in deoptimization, we want the type info, not the data
drchase@7161 661 // flow info; the interpreter will "use" things that are dead to the optimizer.
drchase@7161 662 bool MachCallNode::returns_pointer() const {
drchase@7161 663 const TypeTuple *r = tf()->range();
drchase@7161 664 return (r->cnt() > TypeFunc::Parms &&
drchase@7161 665 r->field_at(TypeFunc::Parms)->isa_ptr());
drchase@7161 666 }
duke@435 667
duke@435 668 //------------------------------Registers--------------------------------------
goetz@6484 669 const RegMask &MachCallNode::in_RegMask(uint idx) const {
duke@435 670 // Values in the domain use the users calling convention, embodied in the
duke@435 671 // _in_rms array of RegMasks.
goetz@6484 672 if (idx < tf()->domain()->cnt()) {
goetz@6484 673 return _in_rms[idx];
goetz@6484 674 }
goetz@6484 675 if (idx == mach_constant_base_node_input()) {
goetz@6484 676 return MachConstantBaseNode::static_out_RegMask();
goetz@6484 677 }
duke@435 678 // Values outside the domain represent debug info
duke@435 679 return *Compile::current()->matcher()->idealreg2debugmask[in(idx)->ideal_reg()];
duke@435 680 }
duke@435 681
duke@435 682 //=============================================================================
duke@435 683 uint MachCallJavaNode::size_of() const { return sizeof(*this); }
duke@435 684 uint MachCallJavaNode::cmp( const Node &n ) const {
duke@435 685 MachCallJavaNode &call = (MachCallJavaNode&)n;
duke@435 686 return MachCallNode::cmp(call) && _method->equals(call._method);
duke@435 687 }
duke@435 688 #ifndef PRODUCT
duke@435 689 void MachCallJavaNode::dump_spec(outputStream *st) const {
twisti@1572 690 if (_method_handle_invoke)
twisti@1572 691 st->print("MethodHandle ");
twisti@1572 692 if (_method) {
duke@435 693 _method->print_short_name(st);
duke@435 694 st->print(" ");
duke@435 695 }
duke@435 696 MachCallNode::dump_spec(st);
duke@435 697 }
duke@435 698 #endif
duke@435 699
twisti@1572 700 //------------------------------Registers--------------------------------------
twisti@1572 701 const RegMask &MachCallJavaNode::in_RegMask(uint idx) const {
twisti@1572 702 // Values in the domain use the users calling convention, embodied in the
twisti@1572 703 // _in_rms array of RegMasks.
goetz@6484 704 if (idx < tf()->domain()->cnt()) {
goetz@6484 705 return _in_rms[idx];
goetz@6484 706 }
goetz@6484 707 if (idx == mach_constant_base_node_input()) {
goetz@6484 708 return MachConstantBaseNode::static_out_RegMask();
goetz@6484 709 }
twisti@1572 710 // Values outside the domain represent debug info
twisti@1572 711 Matcher* m = Compile::current()->matcher();
twisti@1572 712 // If this call is a MethodHandle invoke we have to use a different
twisti@1572 713 // debugmask which does not include the register we use to save the
twisti@1572 714 // SP over MH invokes.
twisti@1572 715 RegMask** debugmask = _method_handle_invoke ? m->idealreg2mhdebugmask : m->idealreg2debugmask;
twisti@1572 716 return *debugmask[in(idx)->ideal_reg()];
twisti@1572 717 }
twisti@1572 718
duke@435 719 //=============================================================================
duke@435 720 uint MachCallStaticJavaNode::size_of() const { return sizeof(*this); }
duke@435 721 uint MachCallStaticJavaNode::cmp( const Node &n ) const {
duke@435 722 MachCallStaticJavaNode &call = (MachCallStaticJavaNode&)n;
duke@435 723 return MachCallJavaNode::cmp(call) && _name == call._name;
duke@435 724 }
duke@435 725
duke@435 726 //----------------------------uncommon_trap_request----------------------------
duke@435 727 // If this is an uncommon trap, return the request code, else zero.
duke@435 728 int MachCallStaticJavaNode::uncommon_trap_request() const {
duke@435 729 if (_name != NULL && !strcmp(_name, "uncommon_trap")) {
duke@435 730 return CallStaticJavaNode::extract_uncommon_trap_request(this);
duke@435 731 }
duke@435 732 return 0;
duke@435 733 }
duke@435 734
duke@435 735 #ifndef PRODUCT
duke@435 736 // Helper for summarizing uncommon_trap arguments.
duke@435 737 void MachCallStaticJavaNode::dump_trap_args(outputStream *st) const {
duke@435 738 int trap_req = uncommon_trap_request();
duke@435 739 if (trap_req != 0) {
duke@435 740 char buf[100];
duke@435 741 st->print("(%s)",
duke@435 742 Deoptimization::format_trap_request(buf, sizeof(buf),
duke@435 743 trap_req));
duke@435 744 }
duke@435 745 }
duke@435 746
duke@435 747 void MachCallStaticJavaNode::dump_spec(outputStream *st) const {
duke@435 748 st->print("Static ");
duke@435 749 if (_name != NULL) {
duke@435 750 st->print("wrapper for: %s", _name );
duke@435 751 dump_trap_args(st);
duke@435 752 st->print(" ");
duke@435 753 }
duke@435 754 MachCallJavaNode::dump_spec(st);
duke@435 755 }
duke@435 756 #endif
duke@435 757
duke@435 758 //=============================================================================
duke@435 759 #ifndef PRODUCT
duke@435 760 void MachCallDynamicJavaNode::dump_spec(outputStream *st) const {
duke@435 761 st->print("Dynamic ");
duke@435 762 MachCallJavaNode::dump_spec(st);
duke@435 763 }
duke@435 764 #endif
duke@435 765 //=============================================================================
duke@435 766 uint MachCallRuntimeNode::size_of() const { return sizeof(*this); }
duke@435 767 uint MachCallRuntimeNode::cmp( const Node &n ) const {
duke@435 768 MachCallRuntimeNode &call = (MachCallRuntimeNode&)n;
duke@435 769 return MachCallNode::cmp(call) && !strcmp(_name,call._name);
duke@435 770 }
duke@435 771 #ifndef PRODUCT
duke@435 772 void MachCallRuntimeNode::dump_spec(outputStream *st) const {
duke@435 773 st->print("%s ",_name);
duke@435 774 MachCallNode::dump_spec(st);
duke@435 775 }
duke@435 776 #endif
duke@435 777 //=============================================================================
duke@435 778 // A shared JVMState for all HaltNodes. Indicates the start of debug info
duke@435 779 // is at TypeFunc::Parms. Only required for SOE register spill handling -
duke@435 780 // to indicate where the stack-slot-only debug info inputs begin.
duke@435 781 // There is no other JVM state needed here.
duke@435 782 JVMState jvms_for_throw(0);
duke@435 783 JVMState *MachHaltNode::jvms() const {
duke@435 784 return &jvms_for_throw;
duke@435 785 }
duke@435 786
duke@435 787 //=============================================================================
duke@435 788 #ifndef PRODUCT
duke@435 789 void labelOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {
duke@435 790 st->print("B%d", _block_num);
duke@435 791 }
duke@435 792 #endif // PRODUCT
duke@435 793
duke@435 794 //=============================================================================
duke@435 795 #ifndef PRODUCT
duke@435 796 void methodOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {
duke@435 797 st->print(INTPTR_FORMAT, _method);
duke@435 798 }
duke@435 799 #endif // PRODUCT

mercurial