author | kvn |
Thu, 11 Aug 2011 12:08:11 -0700 | |
changeset 10264 | 6879f93d268d |
parent 10255 | bab46e6f7661 |
child 10266 | 2ea344c79e33 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4751
diff
changeset
|
2 |
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4751
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4751
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4751
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_OPTO_MACHNODE_HPP |
26 |
#define SHARE_VM_OPTO_MACHNODE_HPP |
|
27 |
||
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" |
|
33 |
||
1 | 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; |
|
56 |
||
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); } |
|
62 |
||
63 |
// Opcode |
|
64 |
virtual uint opcode() const = 0; |
|
65 |
||
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; |
|
71 |
||
72 |
// Methods to output the encoding of the operand |
|
73 |
||
74 |
// Negate conditional branches. Error for non-branch Nodes |
|
75 |
virtual void negate(); |
|
76 |
||
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; |
|
82 |
||
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 |
} |
|
96 |
||
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 |
|
105 |
||
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 |
|
125 |
||
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; } |
|
129 |
||
130 |
// Return the label |
|
131 |
virtual Label *label() const; |
|
132 |
||
133 |
// Return the method's address |
|
134 |
virtual intptr_t method() const; |
|
135 |
||
136 |
// Hash and compare over operands are currently identical |
|
137 |
virtual uint hash() const; |
|
138 |
virtual uint cmp( const MachOper &oper ) const; |
|
139 |
||
140 |
// Virtual clone, since I do not know how big the MachOper is. |
|
141 |
virtual MachOper *clone(Compile* C) const = 0; |
|
142 |
||
143 |
// Return ideal Type from simple operands. Fail for complex operands. |
|
144 |
virtual const Type *type() const; |
|
145 |
||
146 |
// Set an integer offset if we have one, or error otherwise |
|
147 |
virtual void set_con( jint c0 ) { ShouldNotReachHere(); } |
|
148 |
||
149 |
#ifndef PRODUCT |
|
150 |
// Return name of operand |
|
151 |
virtual const char *Name() const { return "???";} |
|
152 |
||
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; |
|
156 |
||
157 |
virtual void dump_spec(outputStream *st) const; // Print per-operand info |
|
158 |
#endif |
|
159 |
}; |
|
160 |
||
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; } |
|
176 |
||
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; |
|
181 |
||
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(); |
|
186 |
||
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; } |
|
190 |
||
10264 | 191 |
// Avoid back to back some instructions on some CPUs. |
192 |
bool avoid_back_to_back() const { return (flags() & Flag_avoid_back_to_back) != 0; } |
|
193 |
||
1 | 194 |
// First index in _in[] corresponding to operand, or -1 if there is none |
195 |
int operand_index(uint operand) const; |
|
196 |
||
197 |
// Register class input is expected in |
|
198 |
virtual const RegMask &in_RegMask(uint) const; |
|
199 |
||
200 |
// cisc-spillable instructions redefine for use by in_RegMask |
|
201 |
virtual const RegMask *cisc_RegMask() const { return NULL; } |
|
202 |
||
203 |
// If this instruction is a 2-address instruction, then return the |
|
204 |
// index of the input which must match the output. Not nessecary |
|
205 |
// for instructions which bind the input and output register to the |
|
206 |
// same singleton regiser (e.g., Intel IDIV which binds AX to be |
|
207 |
// both an input and an output). It is nessecary when the input and |
|
208 |
// output have choices - but they must use the same choice. |
|
209 |
virtual uint two_adr( ) const { return 0; } |
|
210 |
||
211 |
// Array of complex operand pointers. Each corresponds to zero or |
|
212 |
// more leafs. Must be set by MachNode constructor to point to an |
|
213 |
// internal array of MachOpers. The MachOper array is sized by |
|
214 |
// specific MachNodes described in the ADL. |
|
215 |
uint _num_opnds; |
|
216 |
MachOper **_opnds; |
|
217 |
uint num_opnds() const { return _num_opnds; } |
|
218 |
||
219 |
// Emit bytes into cbuf |
|
220 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
221 |
// Size of instruction in bytes |
|
222 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
223 |
// Helper function that computes size by emitting code |
|
224 |
virtual uint emit_size(PhaseRegAlloc *ra_) const; |
|
225 |
||
226 |
// Return the alignment required (in units of relocInfo::addr_unit()) |
|
227 |
// for this instruction (must be a power of 2) |
|
228 |
virtual int alignment_required() const { return 1; } |
|
229 |
||
230 |
// Return the padding (in bytes) to be emitted before this |
|
231 |
// instruction to properly align it. |
|
232 |
virtual int compute_padding(int current_offset) const { return 0; } |
|
233 |
||
234 |
// Return number of relocatable values contained in this instruction |
|
235 |
virtual int reloc() const { return 0; } |
|
236 |
||
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; |
|
240 |
||
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. |
|
4751 | 244 |
virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; } |
1 | 245 |
|
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()]; } |
|
249 |
||
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; |
|
259 |
||
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; |
|
266 |
||
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; } |
|
271 |
||
272 |
// Call "get_base_and_disp" to decide which category of memory is used here. |
|
273 |
virtual const class TypePtr *adr_type() const; |
|
274 |
||
275 |
// Negate conditional branches. Error for non-branch Nodes |
|
276 |
virtual void negate(); |
|
277 |
||
278 |
// Apply peephole rule(s) to this instruction |
|
279 |
virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C ); |
|
280 |
||
281 |
// Top-level ideal Opcode matched |
|
282 |
virtual int ideal_Opcode() const { return Op_Node; } |
|
283 |
||
284 |
// Set the branch inside jump MachNodes. Error for non-branch Nodes. |
|
10252 | 285 |
virtual void label_set( Label* label, uint block_num ); |
1 | 286 |
|
287 |
// Adds the label for the case |
|
288 |
virtual void add_case_label( int switch_val, Label* blockLabel); |
|
289 |
||
290 |
// Set the absolute address for methods |
|
291 |
virtual void method_set( intptr_t addr ); |
|
292 |
||
293 |
// Should we clone rather than spill this instruction? |
|
294 |
bool rematerialize() const; |
|
295 |
||
296 |
// Get the pipeline info |
|
297 |
static const Pipeline *pipeline_class(); |
|
298 |
virtual const Pipeline *pipeline() const; |
|
299 |
||
300 |
#ifndef PRODUCT |
|
301 |
virtual const char *Name() const = 0; // Machine-specific name |
|
302 |
virtual void dump_spec(outputStream *st) const; // Print per-node info |
|
303 |
void dump_format(PhaseRegAlloc *ra, outputStream *st) const; // access to virtual |
|
304 |
#endif |
|
305 |
}; |
|
306 |
||
307 |
//------------------------------MachIdealNode---------------------------- |
|
308 |
// Machine specific versions of nodes that must be defined by user. |
|
309 |
// These are not converted by matcher from ideal nodes to machine nodes |
|
310 |
// but are inserted into the code by the compiler. |
|
311 |
class MachIdealNode : public MachNode { |
|
312 |
public: |
|
313 |
MachIdealNode( ) {} |
|
314 |
||
315 |
// Define the following defaults for non-matched machine nodes |
|
316 |
virtual uint oper_input_base() const { return 0; } |
|
317 |
virtual uint rule() const { return 9999999; } |
|
318 |
virtual const class Type *bottom_type() const { return _opnds == NULL ? Type::CONTROL : MachNode::bottom_type(); } |
|
319 |
}; |
|
320 |
||
321 |
//------------------------------MachTypeNode---------------------------- |
|
322 |
// Machine Nodes that need to retain a known Type. |
|
323 |
class MachTypeNode : public MachNode { |
|
324 |
virtual uint size_of() const { return sizeof(*this); } // Size is bigger |
|
325 |
public: |
|
326 |
const Type *_bottom_type; |
|
327 |
||
328 |
virtual const class Type *bottom_type() const { return _bottom_type; } |
|
329 |
#ifndef PRODUCT |
|
330 |
virtual void dump_spec(outputStream *st) const; |
|
331 |
#endif |
|
332 |
}; |
|
333 |
||
334 |
//------------------------------MachBreakpointNode---------------------------- |
|
335 |
// Machine breakpoint or interrupt Node |
|
336 |
class MachBreakpointNode : public MachIdealNode { |
|
337 |
public: |
|
338 |
MachBreakpointNode( ) {} |
|
339 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
340 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
341 |
||
342 |
#ifndef PRODUCT |
|
343 |
virtual const char *Name() const { return "Breakpoint"; } |
|
344 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
345 |
#endif |
|
346 |
}; |
|
347 |
||
7433 | 348 |
//------------------------------MachConstantBaseNode-------------------------- |
349 |
// Machine node that represents the base address of the constant table. |
|
350 |
class MachConstantBaseNode : public MachIdealNode { |
|
351 |
public: |
|
352 |
static const RegMask& _out_RegMask; // We need the out_RegMask statically in MachConstantNode::in_RegMask(). |
|
353 |
||
354 |
public: |
|
355 |
MachConstantBaseNode() : MachIdealNode() { |
|
356 |
init_class_id(Class_MachConstantBase); |
|
357 |
} |
|
358 |
virtual const class Type* bottom_type() const { return TypeRawPtr::NOTNULL; } |
|
359 |
virtual uint ideal_reg() const { return Op_RegP; } |
|
360 |
virtual uint oper_input_base() const { return 1; } |
|
361 |
||
362 |
virtual void emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const; |
|
363 |
virtual uint size(PhaseRegAlloc* ra_) const; |
|
364 |
virtual bool pinned() const { return UseRDPCForConstantTableBase; } |
|
365 |
||
366 |
static const RegMask& static_out_RegMask() { return _out_RegMask; } |
|
367 |
virtual const RegMask& out_RegMask() const { return static_out_RegMask(); } |
|
368 |
||
369 |
#ifndef PRODUCT |
|
370 |
virtual const char* Name() const { return "MachConstantBaseNode"; } |
|
371 |
virtual void format(PhaseRegAlloc*, outputStream* st) const; |
|
372 |
#endif |
|
373 |
}; |
|
374 |
||
375 |
//------------------------------MachConstantNode------------------------------- |
|
376 |
// Machine node that holds a constant which is stored in the constant table. |
|
377 |
class MachConstantNode : public MachNode { |
|
378 |
protected: |
|
379 |
Compile::Constant _constant; // This node's constant. |
|
380 |
||
381 |
public: |
|
382 |
MachConstantNode() : MachNode() { |
|
383 |
init_class_id(Class_MachConstant); |
|
384 |
} |
|
385 |
||
386 |
virtual void eval_constant(Compile* C) { |
|
387 |
#ifdef ASSERT |
|
388 |
tty->print("missing MachConstantNode eval_constant function: "); |
|
389 |
dump(); |
|
390 |
#endif |
|
391 |
ShouldNotCallThis(); |
|
392 |
} |
|
393 |
||
394 |
virtual const RegMask &in_RegMask(uint idx) const { |
|
395 |
if (idx == mach_constant_base_node_input()) |
|
396 |
return MachConstantBaseNode::static_out_RegMask(); |
|
397 |
return MachNode::in_RegMask(idx); |
|
398 |
} |
|
399 |
||
400 |
// Input edge of MachConstantBaseNode. |
|
401 |
uint mach_constant_base_node_input() const { return req() - 1; } |
|
402 |
||
403 |
int constant_offset(); |
|
404 |
int constant_offset() const { return ((MachConstantNode*) this)->constant_offset(); } |
|
405 |
}; |
|
406 |
||
1 | 407 |
//------------------------------MachUEPNode----------------------------------- |
408 |
// Machine Unvalidated Entry Point Node |
|
409 |
class MachUEPNode : public MachIdealNode { |
|
410 |
public: |
|
411 |
MachUEPNode( ) {} |
|
412 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
413 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
414 |
||
415 |
#ifndef PRODUCT |
|
416 |
virtual const char *Name() const { return "Unvalidated-Entry-Point"; } |
|
417 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
418 |
#endif |
|
419 |
}; |
|
420 |
||
421 |
//------------------------------MachPrologNode-------------------------------- |
|
422 |
// Machine function Prolog Node |
|
423 |
class MachPrologNode : public MachIdealNode { |
|
424 |
public: |
|
425 |
MachPrologNode( ) {} |
|
426 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
427 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
428 |
virtual int reloc() const; |
|
429 |
||
430 |
#ifndef PRODUCT |
|
431 |
virtual const char *Name() const { return "Prolog"; } |
|
432 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
433 |
#endif |
|
434 |
}; |
|
435 |
||
436 |
//------------------------------MachEpilogNode-------------------------------- |
|
437 |
// Machine function Epilog Node |
|
438 |
class MachEpilogNode : public MachIdealNode { |
|
439 |
public: |
|
440 |
MachEpilogNode(bool do_poll = false) : _do_polling(do_poll) {} |
|
441 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
442 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
443 |
virtual int reloc() const; |
|
444 |
virtual const Pipeline *pipeline() const; |
|
445 |
||
446 |
private: |
|
447 |
bool _do_polling; |
|
448 |
||
449 |
public: |
|
450 |
bool do_polling() const { return _do_polling; } |
|
451 |
||
452 |
// Offset of safepoint from the beginning of the node |
|
453 |
int safepoint_offset() const; |
|
454 |
||
455 |
#ifndef PRODUCT |
|
456 |
virtual const char *Name() const { return "Epilog"; } |
|
457 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
458 |
#endif |
|
459 |
}; |
|
460 |
||
461 |
//------------------------------MachNopNode----------------------------------- |
|
462 |
// Machine function Nop Node |
|
463 |
class MachNopNode : public MachIdealNode { |
|
464 |
private: |
|
465 |
int _count; |
|
466 |
public: |
|
467 |
MachNopNode( ) : _count(1) {} |
|
468 |
MachNopNode( int count ) : _count(count) {} |
|
469 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
470 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
471 |
||
472 |
virtual const class Type *bottom_type() const { return Type::CONTROL; } |
|
473 |
||
474 |
virtual int ideal_Opcode() const { return Op_Con; } // bogus; see output.cpp |
|
475 |
virtual const Pipeline *pipeline() const; |
|
476 |
#ifndef PRODUCT |
|
477 |
virtual const char *Name() const { return "Nop"; } |
|
478 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
479 |
virtual void dump_spec(outputStream *st) const { } // No per-operand info |
|
480 |
#endif |
|
481 |
}; |
|
482 |
||
483 |
//------------------------------MachSpillCopyNode------------------------------ |
|
484 |
// Machine SpillCopy Node. Copies 1 or 2 words from any location to any |
|
485 |
// location (stack or register). |
|
486 |
class MachSpillCopyNode : public MachIdealNode { |
|
487 |
const RegMask *_in; // RegMask for input |
|
488 |
const RegMask *_out; // RegMask for output |
|
489 |
const Type *_type; |
|
490 |
public: |
|
491 |
MachSpillCopyNode( Node *n, const RegMask &in, const RegMask &out ) : |
|
492 |
MachIdealNode(), _in(&in), _out(&out), _type(n->bottom_type()) { |
|
493 |
init_class_id(Class_MachSpillCopy); |
|
494 |
init_flags(Flag_is_Copy); |
|
495 |
add_req(NULL); |
|
496 |
add_req(n); |
|
497 |
} |
|
498 |
virtual uint size_of() const { return sizeof(*this); } |
|
499 |
void set_out_RegMask(const RegMask &out) { _out = &out; } |
|
500 |
void set_in_RegMask(const RegMask &in) { _in = ∈ } |
|
501 |
virtual const RegMask &out_RegMask() const { return *_out; } |
|
502 |
virtual const RegMask &in_RegMask(uint) const { return *_in; } |
|
503 |
virtual const class Type *bottom_type() const { return _type; } |
|
504 |
virtual uint ideal_reg() const { return Matcher::base2reg[_type->base()]; } |
|
505 |
virtual uint oper_input_base() const { return 1; } |
|
506 |
uint implementation( CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, outputStream* st ) const; |
|
507 |
||
508 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
509 |
virtual uint size(PhaseRegAlloc *ra_) const; |
|
510 |
||
511 |
#ifndef PRODUCT |
|
512 |
virtual const char *Name() const { return "MachSpillCopy"; } |
|
513 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
514 |
#endif |
|
515 |
}; |
|
516 |
||
517 |
//------------------------------MachNullChkNode-------------------------------- |
|
518 |
// Machine-dependent null-pointer-check Node. Points a real MachNode that is |
|
519 |
// also some kind of memory op. Turns the indicated MachNode into a |
|
520 |
// conditional branch with good latency on the ptr-not-null path and awful |
|
521 |
// latency on the pointer-is-null path. |
|
522 |
||
523 |
class MachNullCheckNode : public MachIdealNode { |
|
524 |
public: |
|
525 |
const uint _vidx; // Index of memop being tested |
|
526 |
MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachIdealNode(), _vidx(vidx) { |
|
527 |
init_class_id(Class_MachNullCheck); |
|
10255 | 528 |
init_flags(Flag_is_Branch); |
1 | 529 |
add_req(ctrl); |
530 |
add_req(memop); |
|
531 |
} |
|
532 |
||
533 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; |
|
10252 | 534 |
virtual void label_set(Label* label, uint block_num); |
1 | 535 |
virtual bool pinned() const { return true; }; |
536 |
virtual void negate() { } |
|
537 |
virtual const class Type *bottom_type() const { return TypeTuple::IFBOTH; } |
|
538 |
virtual uint ideal_reg() const { return NotAMachineReg; } |
|
539 |
virtual const RegMask &in_RegMask(uint) const; |
|
540 |
virtual const RegMask &out_RegMask() const { return RegMask::Empty; } |
|
541 |
#ifndef PRODUCT |
|
542 |
virtual const char *Name() const { return "NullCheck"; } |
|
543 |
virtual void format( PhaseRegAlloc *, outputStream *st ) const; |
|
544 |
#endif |
|
545 |
}; |
|
546 |
||
547 |
//------------------------------MachProjNode---------------------------------- |
|
548 |
// Machine-dependent Ideal projections (how is that for an oxymoron). Really |
|
549 |
// just MachNodes made by the Ideal world that replicate simple projections |
|
550 |
// but with machine-dependent input & output register masks. Generally |
|
551 |
// produced as part of calling conventions. Normally I make MachNodes as part |
|
552 |
// of the Matcher process, but the Matcher is ill suited to issues involving |
|
553 |
// frame handling, so frame handling is all done in the Ideal world with |
|
554 |
// occasional callbacks to the machine model for important info. |
|
555 |
class MachProjNode : public ProjNode { |
|
556 |
public: |
|
10255 | 557 |
MachProjNode( Node *multi, uint con, const RegMask &out, uint ideal_reg ) : ProjNode(multi,con), _rout(out), _ideal_reg(ideal_reg) { |
558 |
init_class_id(Class_MachProj); |
|
559 |
} |
|
1 | 560 |
RegMask _rout; |
561 |
const uint _ideal_reg; |
|
562 |
enum projType { |
|
563 |
unmatched_proj = 0, // Projs for Control, I/O, memory not matched |
|
564 |
fat_proj = 999 // Projs killing many regs, defined by _rout |
|
565 |
}; |
|
566 |
virtual int Opcode() const; |
|
567 |
virtual const Type *bottom_type() const; |
|
568 |
virtual const TypePtr *adr_type() const; |
|
569 |
virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; } |
|
570 |
virtual const RegMask &out_RegMask() const { return _rout; } |
|
571 |
virtual uint ideal_reg() const { return _ideal_reg; } |
|
572 |
// Need size_of() for virtual ProjNode::clone() |
|
573 |
virtual uint size_of() const { return sizeof(MachProjNode); } |
|
574 |
#ifndef PRODUCT |
|
575 |
virtual void dump_spec(outputStream *st) const; |
|
576 |
#endif |
|
577 |
}; |
|
578 |
||
579 |
//------------------------------MachIfNode------------------------------------- |
|
580 |
// Machine-specific versions of IfNodes |
|
581 |
class MachIfNode : public MachNode { |
|
582 |
virtual uint size_of() const { return sizeof(*this); } // Size is bigger |
|
583 |
public: |
|
584 |
float _prob; // Probability branch goes either way |
|
585 |
float _fcnt; // Frequency counter |
|
586 |
MachIfNode() : MachNode() { |
|
587 |
init_class_id(Class_MachIf); |
|
588 |
} |
|
589 |
#ifndef PRODUCT |
|
590 |
virtual void dump_spec(outputStream *st) const; |
|
591 |
#endif |
|
592 |
}; |
|
593 |
||
10255 | 594 |
//------------------------------MachGotoNode----------------------------------- |
595 |
// Machine-specific versions of GotoNodes |
|
596 |
class MachGotoNode : public MachNode { |
|
597 |
public: |
|
598 |
MachGotoNode() : MachNode() { |
|
599 |
init_class_id(Class_MachGoto); |
|
600 |
} |
|
601 |
}; |
|
602 |
||
1 | 603 |
//------------------------------MachFastLockNode------------------------------------- |
604 |
// Machine-specific versions of FastLockNodes |
|
605 |
class MachFastLockNode : public MachNode { |
|
606 |
virtual uint size_of() const { return sizeof(*this); } // Size is bigger |
|
607 |
public: |
|
608 |
BiasedLockingCounters* _counters; |
|
609 |
||
610 |
MachFastLockNode() : MachNode() {} |
|
611 |
}; |
|
612 |
||
613 |
//------------------------------MachReturnNode-------------------------------- |
|
614 |
// Machine-specific versions of subroutine returns |
|
615 |
class MachReturnNode : public MachNode { |
|
616 |
virtual uint size_of() const; // Size is bigger |
|
617 |
public: |
|
618 |
RegMask *_in_rms; // Input register masks, set during allocation |
|
619 |
ReallocMark _nesting; // assertion check for reallocations |
|
620 |
const TypePtr* _adr_type; // memory effects of call or return |
|
621 |
MachReturnNode() : MachNode() { |
|
622 |
init_class_id(Class_MachReturn); |
|
623 |
_adr_type = TypePtr::BOTTOM; // the default: all of memory |
|
624 |
} |
|
625 |
||
626 |
void set_adr_type(const TypePtr* atp) { _adr_type = atp; } |
|
627 |
||
628 |
virtual const RegMask &in_RegMask(uint) const; |
|
629 |
virtual bool pinned() const { return true; }; |
|
630 |
virtual const TypePtr *adr_type() const; |
|
631 |
}; |
|
632 |
||
633 |
//------------------------------MachSafePointNode----------------------------- |
|
634 |
// Machine-specific versions of safepoints |
|
635 |
class MachSafePointNode : public MachReturnNode { |
|
636 |
public: |
|
637 |
OopMap* _oop_map; // Array of OopMap info (8-bit char) for GC |
|
638 |
JVMState* _jvms; // Pointer to list of JVM State Objects |
|
639 |
uint _jvmadj; // Extra delta to jvms indexes (mach. args) |
|
640 |
OopMap* oop_map() const { return _oop_map; } |
|
641 |
void set_oop_map(OopMap* om) { _oop_map = om; } |
|
642 |
||
643 |
MachSafePointNode() : MachReturnNode(), _oop_map(NULL), _jvms(NULL), _jvmadj(0) { |
|
644 |
init_class_id(Class_MachSafePoint); |
|
645 |
} |
|
646 |
||
647 |
virtual JVMState* jvms() const { return _jvms; } |
|
648 |
void set_jvms(JVMState* s) { |
|
649 |
_jvms = s; |
|
650 |
} |
|
651 |
virtual const Type *bottom_type() const; |
|
652 |
||
653 |
virtual const RegMask &in_RegMask(uint) const; |
|
654 |
||
655 |
// Functionality from old debug nodes |
|
656 |
Node *returnadr() const { return in(TypeFunc::ReturnAdr); } |
|
657 |
Node *frameptr () const { return in(TypeFunc::FramePtr); } |
|
658 |
||
659 |
Node *local(const JVMState* jvms, uint idx) const { |
|
660 |
assert(verify_jvms(jvms), "jvms must match"); |
|
661 |
return in(_jvmadj + jvms->locoff() + idx); |
|
662 |
} |
|
663 |
Node *stack(const JVMState* jvms, uint idx) const { |
|
664 |
assert(verify_jvms(jvms), "jvms must match"); |
|
665 |
return in(_jvmadj + jvms->stkoff() + idx); |
|
666 |
} |
|
667 |
Node *monitor_obj(const JVMState* jvms, uint idx) const { |
|
668 |
assert(verify_jvms(jvms), "jvms must match"); |
|
669 |
return in(_jvmadj + jvms->monitor_obj_offset(idx)); |
|
670 |
} |
|
671 |
Node *monitor_box(const JVMState* jvms, uint idx) const { |
|
672 |
assert(verify_jvms(jvms), "jvms must match"); |
|
673 |
return in(_jvmadj + jvms->monitor_box_offset(idx)); |
|
674 |
} |
|
675 |
void set_local(const JVMState* jvms, uint idx, Node *c) { |
|
676 |
assert(verify_jvms(jvms), "jvms must match"); |
|
677 |
set_req(_jvmadj + jvms->locoff() + idx, c); |
|
678 |
} |
|
679 |
void set_stack(const JVMState* jvms, uint idx, Node *c) { |
|
680 |
assert(verify_jvms(jvms), "jvms must match"); |
|
681 |
set_req(_jvmadj + jvms->stkoff() + idx, c); |
|
682 |
} |
|
683 |
void set_monitor(const JVMState* jvms, uint idx, Node *c) { |
|
684 |
assert(verify_jvms(jvms), "jvms must match"); |
|
685 |
set_req(_jvmadj + jvms->monoff() + idx, c); |
|
686 |
} |
|
687 |
}; |
|
688 |
||
689 |
//------------------------------MachCallNode---------------------------------- |
|
690 |
// Machine-specific versions of subroutine calls |
|
691 |
class MachCallNode : public MachSafePointNode { |
|
692 |
protected: |
|
693 |
virtual uint hash() const { return NO_HASH; } // CFG nodes do not hash |
|
694 |
virtual uint cmp( const Node &n ) const; |
|
695 |
virtual uint size_of() const = 0; // Size is bigger |
|
696 |
public: |
|
697 |
const TypeFunc *_tf; // Function type |
|
698 |
address _entry_point; // Address of the method being called |
|
699 |
float _cnt; // Estimate of number of times called |
|
700 |
uint _argsize; // Size of argument block on stack |
|
701 |
||
702 |
const TypeFunc* tf() const { return _tf; } |
|
703 |
const address entry_point() const { return _entry_point; } |
|
704 |
const float cnt() const { return _cnt; } |
|
705 |
uint argsize() const { return _argsize; } |
|
706 |
||
707 |
void set_tf(const TypeFunc* tf) { _tf = tf; } |
|
708 |
void set_entry_point(address p) { _entry_point = p; } |
|
709 |
void set_cnt(float c) { _cnt = c; } |
|
710 |
void set_argsize(int s) { _argsize = s; } |
|
711 |
||
712 |
MachCallNode() : MachSafePointNode() { |
|
713 |
init_class_id(Class_MachCall); |
|
714 |
} |
|
715 |
||
716 |
virtual const Type *bottom_type() const; |
|
717 |
virtual bool pinned() const { return false; } |
|
718 |
virtual const Type *Value( PhaseTransform *phase ) const; |
|
719 |
virtual const RegMask &in_RegMask(uint) const; |
|
720 |
virtual int ret_addr_offset() { return 0; } |
|
721 |
||
722 |
bool returns_long() const { return tf()->return_type() == T_LONG; } |
|
723 |
bool return_value_is_used() const; |
|
724 |
#ifndef PRODUCT |
|
725 |
virtual void dump_spec(outputStream *st) const; |
|
726 |
#endif |
|
727 |
}; |
|
728 |
||
729 |
//------------------------------MachCallJavaNode------------------------------ |
|
730 |
// "Base" class for machine-specific versions of subroutine calls |
|
731 |
class MachCallJavaNode : public MachCallNode { |
|
732 |
protected: |
|
733 |
virtual uint cmp( const Node &n ) const; |
|
734 |
virtual uint size_of() const; // Size is bigger |
|
735 |
public: |
|
736 |
ciMethod* _method; // Method being direct called |
|
737 |
int _bci; // Byte Code index of call byte code |
|
738 |
bool _optimized_virtual; // Tells if node is a static call or an optimized virtual |
|
4566 | 739 |
bool _method_handle_invoke; // Tells if the call has to preserve SP |
1 | 740 |
MachCallJavaNode() : MachCallNode() { |
741 |
init_class_id(Class_MachCallJava); |
|
742 |
} |
|
4566 | 743 |
|
744 |
virtual const RegMask &in_RegMask(uint) const; |
|
745 |
||
1 | 746 |
#ifndef PRODUCT |
747 |
virtual void dump_spec(outputStream *st) const; |
|
748 |
#endif |
|
749 |
}; |
|
750 |
||
751 |
//------------------------------MachCallStaticJavaNode------------------------ |
|
752 |
// Machine-specific versions of monomorphic subroutine calls |
|
753 |
class MachCallStaticJavaNode : public MachCallJavaNode { |
|
754 |
virtual uint cmp( const Node &n ) const; |
|
755 |
virtual uint size_of() const; // Size is bigger |
|
756 |
public: |
|
757 |
const char *_name; // Runtime wrapper name |
|
758 |
MachCallStaticJavaNode() : MachCallJavaNode() { |
|
759 |
init_class_id(Class_MachCallStaticJava); |
|
760 |
} |
|
761 |
||
762 |
// If this is an uncommon trap, return the request code, else zero. |
|
763 |
int uncommon_trap_request() const; |
|
764 |
||
765 |
virtual int ret_addr_offset(); |
|
766 |
#ifndef PRODUCT |
|
767 |
virtual void dump_spec(outputStream *st) const; |
|
768 |
void dump_trap_args(outputStream *st) const; |
|
769 |
#endif |
|
770 |
}; |
|
771 |
||
772 |
//------------------------------MachCallDynamicJavaNode------------------------ |
|
773 |
// Machine-specific versions of possibly megamorphic subroutine calls |
|
774 |
class MachCallDynamicJavaNode : public MachCallJavaNode { |
|
775 |
public: |
|
776 |
int _vtable_index; |
|
777 |
MachCallDynamicJavaNode() : MachCallJavaNode() { |
|
778 |
init_class_id(Class_MachCallDynamicJava); |
|
779 |
DEBUG_ONLY(_vtable_index = -99); // throw an assert if uninitialized |
|
780 |
} |
|
781 |
virtual int ret_addr_offset(); |
|
782 |
#ifndef PRODUCT |
|
783 |
virtual void dump_spec(outputStream *st) const; |
|
784 |
#endif |
|
785 |
}; |
|
786 |
||
787 |
//------------------------------MachCallRuntimeNode---------------------------- |
|
788 |
// Machine-specific versions of subroutine calls |
|
789 |
class MachCallRuntimeNode : public MachCallNode { |
|
790 |
virtual uint cmp( const Node &n ) const; |
|
791 |
virtual uint size_of() const; // Size is bigger |
|
792 |
public: |
|
793 |
const char *_name; // Printable name, if _method is NULL |
|
794 |
MachCallRuntimeNode() : MachCallNode() { |
|
795 |
init_class_id(Class_MachCallRuntime); |
|
796 |
} |
|
797 |
virtual int ret_addr_offset(); |
|
798 |
#ifndef PRODUCT |
|
799 |
virtual void dump_spec(outputStream *st) const; |
|
800 |
#endif |
|
801 |
}; |
|
802 |
||
803 |
class MachCallLeafNode: public MachCallRuntimeNode { |
|
804 |
public: |
|
805 |
MachCallLeafNode() : MachCallRuntimeNode() { |
|
806 |
init_class_id(Class_MachCallLeaf); |
|
807 |
} |
|
808 |
}; |
|
809 |
||
810 |
//------------------------------MachHaltNode----------------------------------- |
|
811 |
// Machine-specific versions of halt nodes |
|
812 |
class MachHaltNode : public MachReturnNode { |
|
813 |
public: |
|
814 |
virtual JVMState* jvms() const; |
|
815 |
}; |
|
816 |
||
817 |
||
818 |
//------------------------------MachTempNode----------------------------------- |
|
819 |
// Node used by the adlc to construct inputs to represent temporary registers |
|
820 |
class MachTempNode : public MachNode { |
|
821 |
private: |
|
822 |
MachOper *_opnd_array[1]; |
|
823 |
||
824 |
public: |
|
825 |
virtual const RegMask &out_RegMask() const { return *_opnds[0]->in_RegMask(0); } |
|
826 |
virtual uint rule() const { return 9999999; } |
|
827 |
virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {} |
|
828 |
||
829 |
MachTempNode(MachOper* oper) { |
|
830 |
init_class_id(Class_MachTemp); |
|
831 |
_num_opnds = 1; |
|
832 |
_opnds = _opnd_array; |
|
833 |
add_req(NULL); |
|
834 |
_opnds[0] = oper; |
|
835 |
} |
|
836 |
virtual uint size_of() const { return sizeof(MachTempNode); } |
|
837 |
||
838 |
#ifndef PRODUCT |
|
839 |
virtual void format(PhaseRegAlloc *, outputStream *st ) const {} |
|
840 |
virtual const char *Name() const { return "MachTemp";} |
|
841 |
#endif |
|
842 |
}; |
|
843 |
||
844 |
||
845 |
||
846 |
//------------------------------labelOper-------------------------------------- |
|
847 |
// Machine-independent version of label operand |
|
848 |
class labelOper : public MachOper { |
|
849 |
private: |
|
850 |
virtual uint num_edges() const { return 0; } |
|
851 |
public: |
|
852 |
// Supported for fixed size branches |
|
853 |
Label* _label; // Label for branch(es) |
|
854 |
||
855 |
uint _block_num; |
|
856 |
||
857 |
labelOper() : _block_num(0), _label(0) {} |
|
858 |
||
859 |
labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {} |
|
860 |
||
861 |
labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {} |
|
862 |
||
863 |
virtual MachOper *clone(Compile* C) const; |
|
864 |
||
10252 | 865 |
virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; } |
1 | 866 |
|
867 |
virtual uint opcode() const; |
|
868 |
||
869 |
virtual uint hash() const; |
|
870 |
virtual uint cmp( const MachOper &oper ) const; |
|
871 |
#ifndef PRODUCT |
|
872 |
virtual const char *Name() const { return "Label";} |
|
873 |
||
874 |
virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const; |
|
875 |
virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); } |
|
876 |
#endif |
|
877 |
}; |
|
878 |
||
879 |
||
880 |
//------------------------------methodOper-------------------------------------- |
|
881 |
// Machine-independent version of method operand |
|
882 |
class methodOper : public MachOper { |
|
883 |
private: |
|
884 |
virtual uint num_edges() const { return 0; } |
|
885 |
public: |
|
886 |
intptr_t _method; // Address of method |
|
887 |
methodOper() : _method(0) {} |
|
888 |
methodOper(intptr_t method) : _method(method) {} |
|
889 |
||
890 |
virtual MachOper *clone(Compile* C) const; |
|
891 |
||
892 |
virtual intptr_t method() const { return _method; } |
|
893 |
||
894 |
virtual uint opcode() const; |
|
895 |
||
896 |
virtual uint hash() const; |
|
897 |
virtual uint cmp( const MachOper &oper ) const; |
|
898 |
#ifndef PRODUCT |
|
899 |
virtual const char *Name() const { return "Method";} |
|
900 |
||
901 |
virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const; |
|
902 |
virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); } |
|
903 |
#endif |
|
904 |
}; |
|
7397 | 905 |
|
906 |
#endif // SHARE_VM_OPTO_MACHNODE_HPP |