Tue, 23 Nov 2010 13:22:55 -0800
6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #ifndef SHARE_VM_OPTO_MACHNODE_HPP
26 #define SHARE_VM_OPTO_MACHNODE_HPP
28 #include "opto/callnode.hpp"
29 #include "opto/matcher.hpp"
30 #include "opto/multnode.hpp"
31 #include "opto/node.hpp"
32 #include "opto/regmask.hpp"
34 class BufferBlob;
35 class CodeBuffer;
36 class JVMState;
37 class MachCallDynamicJavaNode;
38 class MachCallJavaNode;
39 class MachCallLeafNode;
40 class MachCallNode;
41 class MachCallRuntimeNode;
42 class MachCallStaticJavaNode;
43 class MachEpilogNode;
44 class MachIfNode;
45 class MachNullCheckNode;
46 class MachOper;
47 class MachProjNode;
48 class MachPrologNode;
49 class MachReturnNode;
50 class MachSafePointNode;
51 class MachSpillCopyNode;
52 class Matcher;
53 class PhaseRegAlloc;
54 class RegMask;
55 class State;
57 //---------------------------MachOper------------------------------------------
58 class MachOper : public ResourceObj {
59 public:
60 // Allocate right next to the MachNodes in the same arena
61 void *operator new( size_t x, Compile* C ) { return C->node_arena()->Amalloc_D(x); }
63 // Opcode
64 virtual uint opcode() const = 0;
66 // Number of input edges.
67 // Generally at least 1
68 virtual uint num_edges() const { return 1; }
69 // Array of Register masks
70 virtual const RegMask *in_RegMask(int index) const;
72 // Methods to output the encoding of the operand
74 // Negate conditional branches. Error for non-branch Nodes
75 virtual void negate();
77 // Return the value requested
78 // result register lookup, corresponding to int_format
79 virtual int reg(PhaseRegAlloc *ra_, const Node *node) const;
80 // input register lookup, corresponding to ext_format
81 virtual int reg(PhaseRegAlloc *ra_, const Node *node, int idx) const;
83 // helpers for MacroAssembler generation from ADLC
84 Register as_Register(PhaseRegAlloc *ra_, const Node *node) const {
85 return ::as_Register(reg(ra_, node));
86 }
87 Register as_Register(PhaseRegAlloc *ra_, const Node *node, int idx) const {
88 return ::as_Register(reg(ra_, node, idx));
89 }
90 FloatRegister as_FloatRegister(PhaseRegAlloc *ra_, const Node *node) const {
91 return ::as_FloatRegister(reg(ra_, node));
92 }
93 FloatRegister as_FloatRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const {
94 return ::as_FloatRegister(reg(ra_, node, idx));
95 }
97 #if defined(IA32) || defined(AMD64)
98 XMMRegister as_XMMRegister(PhaseRegAlloc *ra_, const Node *node) const {
99 return ::as_XMMRegister(reg(ra_, node));
100 }
101 XMMRegister as_XMMRegister(PhaseRegAlloc *ra_, const Node *node, int idx) const {
102 return ::as_XMMRegister(reg(ra_, node, idx));
103 }
104 #endif
106 virtual intptr_t constant() const;
107 virtual bool constant_is_oop() const;
108 virtual jdouble constantD() const;
109 virtual jfloat constantF() const;
110 virtual jlong constantL() const;
111 virtual TypeOopPtr *oop() const;
112 virtual int ccode() const;
113 // A zero, default, indicates this value is not needed.
114 // May need to lookup the base register, as done in int_ and ext_format
115 virtual int base (PhaseRegAlloc *ra_, const Node *node, int idx) const;
116 virtual int index(PhaseRegAlloc *ra_, const Node *node, int idx) const;
117 virtual int scale() const;
118 // Parameters needed to support MEMORY_INTERFACE access to stackSlot
119 virtual int disp (PhaseRegAlloc *ra_, const Node *node, int idx) const;
120 // Check for PC-Relative displacement
121 virtual bool disp_is_oop() const;
122 virtual int constant_disp() const; // usu. 0, may return Type::OffsetBot
123 virtual int base_position() const; // base edge position, or -1
124 virtual int index_position() const; // index edge position, or -1
126 // Access the TypeKlassPtr of operands with a base==RegI and disp==RegP
127 // Only returns non-null value for i486.ad's indOffset32X
128 virtual const TypePtr *disp_as_type() const { return NULL; }
130 // Return the label
131 virtual Label *label() const;
133 // Return the method's address
134 virtual intptr_t method() const;
136 // Hash and compare over operands are currently identical
137 virtual uint hash() const;
138 virtual uint cmp( const MachOper &oper ) const;
140 // Virtual clone, since I do not know how big the MachOper is.
141 virtual MachOper *clone(Compile* C) const = 0;
143 // Return ideal Type from simple operands. Fail for complex operands.
144 virtual const Type *type() const;
146 // Set an integer offset if we have one, or error otherwise
147 virtual void set_con( jint c0 ) { ShouldNotReachHere(); }
149 #ifndef PRODUCT
150 // Return name of operand
151 virtual const char *Name() const { return "???";}
153 // Methods to output the text version of the operand
154 virtual void int_format(PhaseRegAlloc *,const MachNode *node, outputStream *st) const = 0;
155 virtual void ext_format(PhaseRegAlloc *,const MachNode *node,int idx, outputStream *st) const=0;
157 virtual void dump_spec(outputStream *st) const; // Print per-operand info
158 #endif
159 };
161 //------------------------------MachNode---------------------------------------
162 // Base type for all machine specific nodes. All node classes generated by the
163 // ADLC inherit from this class.
164 class MachNode : public Node {
165 public:
166 MachNode() : Node((uint)0), _num_opnds(0), _opnds(NULL) {
167 init_class_id(Class_Mach);
168 }
169 // Required boilerplate
170 virtual uint size_of() const { return sizeof(MachNode); }
171 virtual int Opcode() const; // Always equal to MachNode
172 virtual uint rule() const = 0; // Machine-specific opcode
173 // Number of inputs which come before the first operand.
174 // Generally at least 1, to skip the Control input
175 virtual uint oper_input_base() const { return 1; }
177 // Copy inputs and operands to new node of instruction.
178 // Called from cisc_version() and short_branch_version().
179 // !!!! The method's body is defined in ad_<arch>.cpp file.
180 void fill_new_machnode(MachNode *n, Compile* C) const;
182 // Return an equivalent instruction using memory for cisc_operand position
183 virtual MachNode *cisc_version(int offset, Compile* C);
184 // Modify this instruction's register mask to use stack version for cisc_operand
185 virtual void use_cisc_RegMask();
187 // Support for short branches
188 virtual MachNode *short_branch_version(Compile* C) { return NULL; }
189 bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; }
191 // First index in _in[] corresponding to operand, or -1 if there is none
192 int operand_index(uint operand) const;
194 // Register class input is expected in
195 virtual const RegMask &in_RegMask(uint) const;
197 // cisc-spillable instructions redefine for use by in_RegMask
198 virtual const RegMask *cisc_RegMask() const { return NULL; }
200 // If this instruction is a 2-address instruction, then return the
201 // index of the input which must match the output. Not nessecary
202 // for instructions which bind the input and output register to the
203 // same singleton regiser (e.g., Intel IDIV which binds AX to be
204 // both an input and an output). It is nessecary when the input and
205 // output have choices - but they must use the same choice.
206 virtual uint two_adr( ) const { return 0; }
208 // Array of complex operand pointers. Each corresponds to zero or
209 // more leafs. Must be set by MachNode constructor to point to an
210 // internal array of MachOpers. The MachOper array is sized by
211 // specific MachNodes described in the ADL.
212 uint _num_opnds;
213 MachOper **_opnds;
214 uint num_opnds() const { return _num_opnds; }
216 // Emit bytes into cbuf
217 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
218 // Size of instruction in bytes
219 virtual uint size(PhaseRegAlloc *ra_) const;
220 // Helper function that computes size by emitting code
221 virtual uint emit_size(PhaseRegAlloc *ra_) const;
223 // Return the alignment required (in units of relocInfo::addr_unit())
224 // for this instruction (must be a power of 2)
225 virtual int alignment_required() const { return 1; }
227 // Return the padding (in bytes) to be emitted before this
228 // instruction to properly align it.
229 virtual int compute_padding(int current_offset) const { return 0; }
231 // Return number of relocatable values contained in this instruction
232 virtual int reloc() const { return 0; }
234 // Return number of words used for double constants in this instruction
235 virtual int const_size() const { return 0; }
237 // Hash and compare over operands. Used to do GVN on machine Nodes.
238 virtual uint hash() const;
239 virtual uint cmp( const Node &n ) const;
241 // Expand method for MachNode, replaces nodes representing pseudo
242 // instructions with a set of nodes which represent real machine
243 // instructions and compute the same value.
244 virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; }
246 // Bottom_type call; value comes from operand0
247 virtual const class Type *bottom_type() const { return _opnds[0]->type(); }
248 virtual uint ideal_reg() const { const Type *t = _opnds[0]->type(); return t == TypeInt::CC ? Op_RegFlags : Matcher::base2reg[t->base()]; }
250 // If this is a memory op, return the base pointer and fixed offset.
251 // If there are no such, return NULL. If there are multiple addresses
252 // or the address is indeterminate (rare cases) then return (Node*)-1,
253 // which serves as node bottom.
254 // If the offset is not statically determined, set it to Type::OffsetBot.
255 // This method is free to ignore stack slots if that helps.
256 #define TYPE_PTR_SENTINAL ((const TypePtr*)-1)
257 // Passing TYPE_PTR_SENTINAL as adr_type asks for computation of the adr_type if possible
258 const Node* get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const;
260 // Helper for get_base_and_disp: find the base and index input nodes.
261 // Returns the MachOper as determined by memory_operand(), for use, if
262 // needed by the caller. If (MachOper *)-1 is returned, base and index
263 // are set to NodeSentinel. If (MachOper *) NULL is returned, base and
264 // index are set to NULL.
265 const MachOper* memory_inputs(Node* &base, Node* &index) const;
267 // Helper for memory_inputs: Which operand carries the necessary info?
268 // By default, returns NULL, which means there is no such operand.
269 // If it returns (MachOper*)-1, this means there are multiple memories.
270 virtual const MachOper* memory_operand() const { return NULL; }
272 // Call "get_base_and_disp" to decide which category of memory is used here.
273 virtual const class TypePtr *adr_type() const;
275 // Negate conditional branches. Error for non-branch Nodes
276 virtual void negate();
278 // Apply peephole rule(s) to this instruction
279 virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C );
281 // Check for PC-Relative addressing
282 bool is_pc_relative() const { return (flags() & Flag_is_pc_relative) != 0; }
284 // Top-level ideal Opcode matched
285 virtual int ideal_Opcode() const { return Op_Node; }
287 // Set the branch inside jump MachNodes. Error for non-branch Nodes.
288 virtual void label_set( Label& label, uint block_num );
290 // Adds the label for the case
291 virtual void add_case_label( int switch_val, Label* blockLabel);
293 // Set the absolute address for methods
294 virtual void method_set( intptr_t addr );
296 // Should we clone rather than spill this instruction?
297 bool rematerialize() const;
299 // Get the pipeline info
300 static const Pipeline *pipeline_class();
301 virtual const Pipeline *pipeline() const;
303 #ifndef PRODUCT
304 virtual const char *Name() const = 0; // Machine-specific name
305 virtual void dump_spec(outputStream *st) const; // Print per-node info
306 void dump_format(PhaseRegAlloc *ra, outputStream *st) const; // access to virtual
307 #endif
308 };
310 //------------------------------MachIdealNode----------------------------
311 // Machine specific versions of nodes that must be defined by user.
312 // These are not converted by matcher from ideal nodes to machine nodes
313 // but are inserted into the code by the compiler.
314 class MachIdealNode : public MachNode {
315 public:
316 MachIdealNode( ) {}
318 // Define the following defaults for non-matched machine nodes
319 virtual uint oper_input_base() const { return 0; }
320 virtual uint rule() const { return 9999999; }
321 virtual const class Type *bottom_type() const { return _opnds == NULL ? Type::CONTROL : MachNode::bottom_type(); }
322 };
324 //------------------------------MachTypeNode----------------------------
325 // Machine Nodes that need to retain a known Type.
326 class MachTypeNode : public MachNode {
327 virtual uint size_of() const { return sizeof(*this); } // Size is bigger
328 public:
329 const Type *_bottom_type;
331 virtual const class Type *bottom_type() const { return _bottom_type; }
332 #ifndef PRODUCT
333 virtual void dump_spec(outputStream *st) const;
334 #endif
335 };
337 //------------------------------MachBreakpointNode----------------------------
338 // Machine breakpoint or interrupt Node
339 class MachBreakpointNode : public MachIdealNode {
340 public:
341 MachBreakpointNode( ) {}
342 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
343 virtual uint size(PhaseRegAlloc *ra_) const;
345 #ifndef PRODUCT
346 virtual const char *Name() const { return "Breakpoint"; }
347 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
348 #endif
349 };
351 //------------------------------MachUEPNode-----------------------------------
352 // Machine Unvalidated Entry Point Node
353 class MachUEPNode : public MachIdealNode {
354 public:
355 MachUEPNode( ) {}
356 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
357 virtual uint size(PhaseRegAlloc *ra_) const;
359 #ifndef PRODUCT
360 virtual const char *Name() const { return "Unvalidated-Entry-Point"; }
361 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
362 #endif
363 };
365 //------------------------------MachPrologNode--------------------------------
366 // Machine function Prolog Node
367 class MachPrologNode : public MachIdealNode {
368 public:
369 MachPrologNode( ) {}
370 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
371 virtual uint size(PhaseRegAlloc *ra_) const;
372 virtual int reloc() const;
374 #ifndef PRODUCT
375 virtual const char *Name() const { return "Prolog"; }
376 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
377 #endif
378 };
380 //------------------------------MachEpilogNode--------------------------------
381 // Machine function Epilog Node
382 class MachEpilogNode : public MachIdealNode {
383 public:
384 MachEpilogNode(bool do_poll = false) : _do_polling(do_poll) {}
385 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
386 virtual uint size(PhaseRegAlloc *ra_) const;
387 virtual int reloc() const;
388 virtual const Pipeline *pipeline() const;
390 private:
391 bool _do_polling;
393 public:
394 bool do_polling() const { return _do_polling; }
396 // Offset of safepoint from the beginning of the node
397 int safepoint_offset() const;
399 #ifndef PRODUCT
400 virtual const char *Name() const { return "Epilog"; }
401 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
402 #endif
403 };
405 //------------------------------MachNopNode-----------------------------------
406 // Machine function Nop Node
407 class MachNopNode : public MachIdealNode {
408 private:
409 int _count;
410 public:
411 MachNopNode( ) : _count(1) {}
412 MachNopNode( int count ) : _count(count) {}
413 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
414 virtual uint size(PhaseRegAlloc *ra_) const;
416 virtual const class Type *bottom_type() const { return Type::CONTROL; }
418 virtual int ideal_Opcode() const { return Op_Con; } // bogus; see output.cpp
419 virtual const Pipeline *pipeline() const;
420 #ifndef PRODUCT
421 virtual const char *Name() const { return "Nop"; }
422 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
423 virtual void dump_spec(outputStream *st) const { } // No per-operand info
424 #endif
425 };
427 //------------------------------MachSpillCopyNode------------------------------
428 // Machine SpillCopy Node. Copies 1 or 2 words from any location to any
429 // location (stack or register).
430 class MachSpillCopyNode : public MachIdealNode {
431 const RegMask *_in; // RegMask for input
432 const RegMask *_out; // RegMask for output
433 const Type *_type;
434 public:
435 MachSpillCopyNode( Node *n, const RegMask &in, const RegMask &out ) :
436 MachIdealNode(), _in(&in), _out(&out), _type(n->bottom_type()) {
437 init_class_id(Class_MachSpillCopy);
438 init_flags(Flag_is_Copy);
439 add_req(NULL);
440 add_req(n);
441 }
442 virtual uint size_of() const { return sizeof(*this); }
443 void set_out_RegMask(const RegMask &out) { _out = &out; }
444 void set_in_RegMask(const RegMask &in) { _in = ∈ }
445 virtual const RegMask &out_RegMask() const { return *_out; }
446 virtual const RegMask &in_RegMask(uint) const { return *_in; }
447 virtual const class Type *bottom_type() const { return _type; }
448 virtual uint ideal_reg() const { return Matcher::base2reg[_type->base()]; }
449 virtual uint oper_input_base() const { return 1; }
450 uint implementation( CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, outputStream* st ) const;
452 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
453 virtual uint size(PhaseRegAlloc *ra_) const;
455 #ifndef PRODUCT
456 virtual const char *Name() const { return "MachSpillCopy"; }
457 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
458 #endif
459 };
461 //------------------------------MachNullChkNode--------------------------------
462 // Machine-dependent null-pointer-check Node. Points a real MachNode that is
463 // also some kind of memory op. Turns the indicated MachNode into a
464 // conditional branch with good latency on the ptr-not-null path and awful
465 // latency on the pointer-is-null path.
467 class MachNullCheckNode : public MachIdealNode {
468 public:
469 const uint _vidx; // Index of memop being tested
470 MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachIdealNode(), _vidx(vidx) {
471 init_class_id(Class_MachNullCheck);
472 init_flags(Flag_is_Branch | Flag_is_pc_relative);
473 add_req(ctrl);
474 add_req(memop);
475 }
477 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
478 virtual bool pinned() const { return true; };
479 virtual void negate() { }
480 virtual const class Type *bottom_type() const { return TypeTuple::IFBOTH; }
481 virtual uint ideal_reg() const { return NotAMachineReg; }
482 virtual const RegMask &in_RegMask(uint) const;
483 virtual const RegMask &out_RegMask() const { return RegMask::Empty; }
484 #ifndef PRODUCT
485 virtual const char *Name() const { return "NullCheck"; }
486 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
487 #endif
488 };
490 //------------------------------MachProjNode----------------------------------
491 // Machine-dependent Ideal projections (how is that for an oxymoron). Really
492 // just MachNodes made by the Ideal world that replicate simple projections
493 // but with machine-dependent input & output register masks. Generally
494 // produced as part of calling conventions. Normally I make MachNodes as part
495 // of the Matcher process, but the Matcher is ill suited to issues involving
496 // frame handling, so frame handling is all done in the Ideal world with
497 // occasional callbacks to the machine model for important info.
498 class MachProjNode : public ProjNode {
499 public:
500 MachProjNode( Node *multi, uint con, const RegMask &out, uint ideal_reg ) : ProjNode(multi,con), _rout(out), _ideal_reg(ideal_reg) {}
501 RegMask _rout;
502 const uint _ideal_reg;
503 enum projType {
504 unmatched_proj = 0, // Projs for Control, I/O, memory not matched
505 fat_proj = 999 // Projs killing many regs, defined by _rout
506 };
507 virtual int Opcode() const;
508 virtual const Type *bottom_type() const;
509 virtual const TypePtr *adr_type() const;
510 virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; }
511 virtual const RegMask &out_RegMask() const { return _rout; }
512 virtual uint ideal_reg() const { return _ideal_reg; }
513 // Need size_of() for virtual ProjNode::clone()
514 virtual uint size_of() const { return sizeof(MachProjNode); }
515 #ifndef PRODUCT
516 virtual void dump_spec(outputStream *st) const;
517 #endif
518 };
520 //------------------------------MachIfNode-------------------------------------
521 // Machine-specific versions of IfNodes
522 class MachIfNode : public MachNode {
523 virtual uint size_of() const { return sizeof(*this); } // Size is bigger
524 public:
525 float _prob; // Probability branch goes either way
526 float _fcnt; // Frequency counter
527 MachIfNode() : MachNode() {
528 init_class_id(Class_MachIf);
529 }
530 #ifndef PRODUCT
531 virtual void dump_spec(outputStream *st) const;
532 #endif
533 };
535 //------------------------------MachFastLockNode-------------------------------------
536 // Machine-specific versions of FastLockNodes
537 class MachFastLockNode : public MachNode {
538 virtual uint size_of() const { return sizeof(*this); } // Size is bigger
539 public:
540 BiasedLockingCounters* _counters;
542 MachFastLockNode() : MachNode() {}
543 };
545 //------------------------------MachReturnNode--------------------------------
546 // Machine-specific versions of subroutine returns
547 class MachReturnNode : public MachNode {
548 virtual uint size_of() const; // Size is bigger
549 public:
550 RegMask *_in_rms; // Input register masks, set during allocation
551 ReallocMark _nesting; // assertion check for reallocations
552 const TypePtr* _adr_type; // memory effects of call or return
553 MachReturnNode() : MachNode() {
554 init_class_id(Class_MachReturn);
555 _adr_type = TypePtr::BOTTOM; // the default: all of memory
556 }
558 void set_adr_type(const TypePtr* atp) { _adr_type = atp; }
560 virtual const RegMask &in_RegMask(uint) const;
561 virtual bool pinned() const { return true; };
562 virtual const TypePtr *adr_type() const;
563 };
565 //------------------------------MachSafePointNode-----------------------------
566 // Machine-specific versions of safepoints
567 class MachSafePointNode : public MachReturnNode {
568 public:
569 OopMap* _oop_map; // Array of OopMap info (8-bit char) for GC
570 JVMState* _jvms; // Pointer to list of JVM State Objects
571 uint _jvmadj; // Extra delta to jvms indexes (mach. args)
572 OopMap* oop_map() const { return _oop_map; }
573 void set_oop_map(OopMap* om) { _oop_map = om; }
575 MachSafePointNode() : MachReturnNode(), _oop_map(NULL), _jvms(NULL), _jvmadj(0) {
576 init_class_id(Class_MachSafePoint);
577 init_flags(Flag_is_safepoint_node);
578 }
580 virtual JVMState* jvms() const { return _jvms; }
581 void set_jvms(JVMState* s) {
582 _jvms = s;
583 }
584 bool is_safepoint_node() const { return (flags() & Flag_is_safepoint_node) != 0; }
585 virtual const Type *bottom_type() const;
587 virtual const RegMask &in_RegMask(uint) const;
589 // Functionality from old debug nodes
590 Node *returnadr() const { return in(TypeFunc::ReturnAdr); }
591 Node *frameptr () const { return in(TypeFunc::FramePtr); }
593 Node *local(const JVMState* jvms, uint idx) const {
594 assert(verify_jvms(jvms), "jvms must match");
595 return in(_jvmadj + jvms->locoff() + idx);
596 }
597 Node *stack(const JVMState* jvms, uint idx) const {
598 assert(verify_jvms(jvms), "jvms must match");
599 return in(_jvmadj + jvms->stkoff() + idx);
600 }
601 Node *monitor_obj(const JVMState* jvms, uint idx) const {
602 assert(verify_jvms(jvms), "jvms must match");
603 return in(_jvmadj + jvms->monitor_obj_offset(idx));
604 }
605 Node *monitor_box(const JVMState* jvms, uint idx) const {
606 assert(verify_jvms(jvms), "jvms must match");
607 return in(_jvmadj + jvms->monitor_box_offset(idx));
608 }
609 void set_local(const JVMState* jvms, uint idx, Node *c) {
610 assert(verify_jvms(jvms), "jvms must match");
611 set_req(_jvmadj + jvms->locoff() + idx, c);
612 }
613 void set_stack(const JVMState* jvms, uint idx, Node *c) {
614 assert(verify_jvms(jvms), "jvms must match");
615 set_req(_jvmadj + jvms->stkoff() + idx, c);
616 }
617 void set_monitor(const JVMState* jvms, uint idx, Node *c) {
618 assert(verify_jvms(jvms), "jvms must match");
619 set_req(_jvmadj + jvms->monoff() + idx, c);
620 }
621 };
623 //------------------------------MachCallNode----------------------------------
624 // Machine-specific versions of subroutine calls
625 class MachCallNode : public MachSafePointNode {
626 protected:
627 virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash
628 virtual uint cmp( const Node &n ) const;
629 virtual uint size_of() const = 0; // Size is bigger
630 public:
631 const TypeFunc *_tf; // Function type
632 address _entry_point; // Address of the method being called
633 float _cnt; // Estimate of number of times called
634 uint _argsize; // Size of argument block on stack
636 const TypeFunc* tf() const { return _tf; }
637 const address entry_point() const { return _entry_point; }
638 const float cnt() const { return _cnt; }
639 uint argsize() const { return _argsize; }
641 void set_tf(const TypeFunc* tf) { _tf = tf; }
642 void set_entry_point(address p) { _entry_point = p; }
643 void set_cnt(float c) { _cnt = c; }
644 void set_argsize(int s) { _argsize = s; }
646 MachCallNode() : MachSafePointNode() {
647 init_class_id(Class_MachCall);
648 init_flags(Flag_is_Call);
649 }
651 virtual const Type *bottom_type() const;
652 virtual bool pinned() const { return false; }
653 virtual const Type *Value( PhaseTransform *phase ) const;
654 virtual const RegMask &in_RegMask(uint) const;
655 virtual int ret_addr_offset() { return 0; }
657 bool returns_long() const { return tf()->return_type() == T_LONG; }
658 bool return_value_is_used() const;
659 #ifndef PRODUCT
660 virtual void dump_spec(outputStream *st) const;
661 #endif
662 };
664 //------------------------------MachCallJavaNode------------------------------
665 // "Base" class for machine-specific versions of subroutine calls
666 class MachCallJavaNode : public MachCallNode {
667 protected:
668 virtual uint cmp( const Node &n ) const;
669 virtual uint size_of() const; // Size is bigger
670 public:
671 ciMethod* _method; // Method being direct called
672 int _bci; // Byte Code index of call byte code
673 bool _optimized_virtual; // Tells if node is a static call or an optimized virtual
674 bool _method_handle_invoke; // Tells if the call has to preserve SP
675 MachCallJavaNode() : MachCallNode() {
676 init_class_id(Class_MachCallJava);
677 }
679 virtual const RegMask &in_RegMask(uint) const;
681 #ifndef PRODUCT
682 virtual void dump_spec(outputStream *st) const;
683 #endif
684 };
686 //------------------------------MachCallStaticJavaNode------------------------
687 // Machine-specific versions of monomorphic subroutine calls
688 class MachCallStaticJavaNode : public MachCallJavaNode {
689 virtual uint cmp( const Node &n ) const;
690 virtual uint size_of() const; // Size is bigger
691 public:
692 const char *_name; // Runtime wrapper name
693 MachCallStaticJavaNode() : MachCallJavaNode() {
694 init_class_id(Class_MachCallStaticJava);
695 }
697 // If this is an uncommon trap, return the request code, else zero.
698 int uncommon_trap_request() const;
700 virtual int ret_addr_offset();
701 #ifndef PRODUCT
702 virtual void dump_spec(outputStream *st) const;
703 void dump_trap_args(outputStream *st) const;
704 #endif
705 };
707 //------------------------------MachCallDynamicJavaNode------------------------
708 // Machine-specific versions of possibly megamorphic subroutine calls
709 class MachCallDynamicJavaNode : public MachCallJavaNode {
710 public:
711 int _vtable_index;
712 MachCallDynamicJavaNode() : MachCallJavaNode() {
713 init_class_id(Class_MachCallDynamicJava);
714 DEBUG_ONLY(_vtable_index = -99); // throw an assert if uninitialized
715 }
716 virtual int ret_addr_offset();
717 #ifndef PRODUCT
718 virtual void dump_spec(outputStream *st) const;
719 #endif
720 };
722 //------------------------------MachCallRuntimeNode----------------------------
723 // Machine-specific versions of subroutine calls
724 class MachCallRuntimeNode : public MachCallNode {
725 virtual uint cmp( const Node &n ) const;
726 virtual uint size_of() const; // Size is bigger
727 public:
728 const char *_name; // Printable name, if _method is NULL
729 MachCallRuntimeNode() : MachCallNode() {
730 init_class_id(Class_MachCallRuntime);
731 }
732 virtual int ret_addr_offset();
733 #ifndef PRODUCT
734 virtual void dump_spec(outputStream *st) const;
735 #endif
736 };
738 class MachCallLeafNode: public MachCallRuntimeNode {
739 public:
740 MachCallLeafNode() : MachCallRuntimeNode() {
741 init_class_id(Class_MachCallLeaf);
742 }
743 };
745 //------------------------------MachHaltNode-----------------------------------
746 // Machine-specific versions of halt nodes
747 class MachHaltNode : public MachReturnNode {
748 public:
749 virtual JVMState* jvms() const;
750 };
753 //------------------------------MachTempNode-----------------------------------
754 // Node used by the adlc to construct inputs to represent temporary registers
755 class MachTempNode : public MachNode {
756 private:
757 MachOper *_opnd_array[1];
759 public:
760 virtual const RegMask &out_RegMask() const { return *_opnds[0]->in_RegMask(0); }
761 virtual uint rule() const { return 9999999; }
762 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {}
764 MachTempNode(MachOper* oper) {
765 init_class_id(Class_MachTemp);
766 _num_opnds = 1;
767 _opnds = _opnd_array;
768 add_req(NULL);
769 _opnds[0] = oper;
770 }
771 virtual uint size_of() const { return sizeof(MachTempNode); }
773 #ifndef PRODUCT
774 virtual void format(PhaseRegAlloc *, outputStream *st ) const {}
775 virtual const char *Name() const { return "MachTemp";}
776 #endif
777 };
781 //------------------------------labelOper--------------------------------------
782 // Machine-independent version of label operand
783 class labelOper : public MachOper {
784 private:
785 virtual uint num_edges() const { return 0; }
786 public:
787 // Supported for fixed size branches
788 Label* _label; // Label for branch(es)
790 uint _block_num;
792 labelOper() : _block_num(0), _label(0) {}
794 labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {}
796 labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {}
798 virtual MachOper *clone(Compile* C) const;
800 virtual Label *label() const { return _label; }
802 virtual uint opcode() const;
804 virtual uint hash() const;
805 virtual uint cmp( const MachOper &oper ) const;
806 #ifndef PRODUCT
807 virtual const char *Name() const { return "Label";}
809 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
810 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
811 #endif
812 };
815 //------------------------------methodOper--------------------------------------
816 // Machine-independent version of method operand
817 class methodOper : public MachOper {
818 private:
819 virtual uint num_edges() const { return 0; }
820 public:
821 intptr_t _method; // Address of method
822 methodOper() : _method(0) {}
823 methodOper(intptr_t method) : _method(method) {}
825 virtual MachOper *clone(Compile* C) const;
827 virtual intptr_t method() const { return _method; }
829 virtual uint opcode() const;
831 virtual uint hash() const;
832 virtual uint cmp( const MachOper &oper ) const;
833 #ifndef PRODUCT
834 virtual const char *Name() const { return "Method";}
836 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
837 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
838 #endif
839 };
841 #endif // SHARE_VM_OPTO_MACHNODE_HPP