205 uint num_opnds() const { return _num_opnds; }
206
207 // Emit bytes into cbuf
208 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
209 // Size of instruction in bytes
210 virtual uint size(PhaseRegAlloc *ra_) const;
211 // Helper function that computes size by emitting code
212 virtual uint emit_size(PhaseRegAlloc *ra_) const;
213
214 // Return the alignment required (in units of relocInfo::addr_unit())
215 // for this instruction (must be a power of 2)
216 virtual int alignment_required() const { return 1; }
217
218 // Return the padding (in bytes) to be emitted before this
219 // instruction to properly align it.
220 virtual int compute_padding(int current_offset) const { return 0; }
221
222 // Return number of relocatable values contained in this instruction
223 virtual int reloc() const { return 0; }
224
225 // Return number of words used for double constants in this instruction
226 virtual int const_size() const { return 0; }
227
228 // Hash and compare over operands. Used to do GVN on machine Nodes.
229 virtual uint hash() const;
230 virtual uint cmp( const Node &n ) const;
231
232 // Expand method for MachNode, replaces nodes representing pseudo
233 // instructions with a set of nodes which represent real machine
234 // instructions and compute the same value.
235 virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; }
236
237 // Bottom_type call; value comes from operand0
238 virtual const class Type *bottom_type() const { return _opnds[0]->type(); }
239 virtual uint ideal_reg() const { const Type *t = _opnds[0]->type(); return t == TypeInt::CC ? Op_RegFlags : Matcher::base2reg[t->base()]; }
240
241 // If this is a memory op, return the base pointer and fixed offset.
242 // If there are no such, return NULL. If there are multiple addresses
243 // or the address is indeterminate (rare cases) then return (Node*)-1,
244 // which serves as node bottom.
245 // If the offset is not statically determined, set it to Type::OffsetBot.
246 // This method is free to ignore stack slots if that helps.
247 #define TYPE_PTR_SENTINAL ((const TypePtr*)-1)
322 virtual const class Type *bottom_type() const { return _bottom_type; }
323 #ifndef PRODUCT
324 virtual void dump_spec(outputStream *st) const;
325 #endif
326 };
327
328 //------------------------------MachBreakpointNode----------------------------
329 // Machine breakpoint or interrupt Node
330 class MachBreakpointNode : public MachIdealNode {
331 public:
332 MachBreakpointNode( ) {}
333 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
334 virtual uint size(PhaseRegAlloc *ra_) const;
335
336 #ifndef PRODUCT
337 virtual const char *Name() const { return "Breakpoint"; }
338 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
339 #endif
340 };
341
342 //------------------------------MachUEPNode-----------------------------------
343 // Machine Unvalidated Entry Point Node
344 class MachUEPNode : public MachIdealNode {
345 public:
346 MachUEPNode( ) {}
347 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
348 virtual uint size(PhaseRegAlloc *ra_) const;
349
350 #ifndef PRODUCT
351 virtual const char *Name() const { return "Unvalidated-Entry-Point"; }
352 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
353 #endif
354 };
355
356 //------------------------------MachPrologNode--------------------------------
357 // Machine function Prolog Node
358 class MachPrologNode : public MachIdealNode {
359 public:
360 MachPrologNode( ) {}
361 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
|
205 uint num_opnds() const { return _num_opnds; }
206
207 // Emit bytes into cbuf
208 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
209 // Size of instruction in bytes
210 virtual uint size(PhaseRegAlloc *ra_) const;
211 // Helper function that computes size by emitting code
212 virtual uint emit_size(PhaseRegAlloc *ra_) const;
213
214 // Return the alignment required (in units of relocInfo::addr_unit())
215 // for this instruction (must be a power of 2)
216 virtual int alignment_required() const { return 1; }
217
218 // Return the padding (in bytes) to be emitted before this
219 // instruction to properly align it.
220 virtual int compute_padding(int current_offset) const { return 0; }
221
222 // Return number of relocatable values contained in this instruction
223 virtual int reloc() const { return 0; }
224
225 // Hash and compare over operands. Used to do GVN on machine Nodes.
226 virtual uint hash() const;
227 virtual uint cmp( const Node &n ) const;
228
229 // Expand method for MachNode, replaces nodes representing pseudo
230 // instructions with a set of nodes which represent real machine
231 // instructions and compute the same value.
232 virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; }
233
234 // Bottom_type call; value comes from operand0
235 virtual const class Type *bottom_type() const { return _opnds[0]->type(); }
236 virtual uint ideal_reg() const { const Type *t = _opnds[0]->type(); return t == TypeInt::CC ? Op_RegFlags : Matcher::base2reg[t->base()]; }
237
238 // If this is a memory op, return the base pointer and fixed offset.
239 // If there are no such, return NULL. If there are multiple addresses
240 // or the address is indeterminate (rare cases) then return (Node*)-1,
241 // which serves as node bottom.
242 // If the offset is not statically determined, set it to Type::OffsetBot.
243 // This method is free to ignore stack slots if that helps.
244 #define TYPE_PTR_SENTINAL ((const TypePtr*)-1)
319 virtual const class Type *bottom_type() const { return _bottom_type; }
320 #ifndef PRODUCT
321 virtual void dump_spec(outputStream *st) const;
322 #endif
323 };
324
325 //------------------------------MachBreakpointNode----------------------------
326 // Machine breakpoint or interrupt Node
327 class MachBreakpointNode : public MachIdealNode {
328 public:
329 MachBreakpointNode( ) {}
330 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
331 virtual uint size(PhaseRegAlloc *ra_) const;
332
333 #ifndef PRODUCT
334 virtual const char *Name() const { return "Breakpoint"; }
335 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
336 #endif
337 };
338
339 //------------------------------MachConstantBaseNode--------------------------
340 // Machine node that represents the base address of the constant
341 // table.
342 class MachConstantBaseNode : public MachIdealNode {
343 public:
344 class Constant {
345 private:
346 BasicType _type;
347 jvalue _value;
348 int _offset; // offset of this constant (in bytes) relative to the constant table base.
349 bool _can_be_reused; // true (default) if the value can be shared with other users.
350
351 public:
352 Constant() : _type(T_ILLEGAL), _offset(-1), _can_be_reused(true) { _value.l = 0; }
353 Constant(BasicType type, jvalue value, bool can_be_reused = true) :
354 _type(type),
355 _value(value),
356 _offset(-1),
357 _can_be_reused(can_be_reused)
358 {}
359
360 bool operator==(const Constant& other);
361
362 BasicType type() const { return _type; }
363
364 jlong get_jlong() const { return _value.j; }
365 jfloat get_jfloat() const { return _value.f; }
366 jdouble get_jdouble() const { return _value.d; }
367 jobject get_jobject() const { return _value.l; }
368
369 int offset() const { return _offset; }
370 void set_offset(int offset) { _offset = offset; }
371
372 bool can_be_reused() const { return _can_be_reused; }
373 };
374
375 private:
376 GrowableArray<Constant> _constants; // Constant table of this node.
377 int _table_base_offset; // Offset of the table base that gets added to the constant offsets.
378 static const RegMask& _out_RegMask; // We need the out_RegMask statically in MachConstantNode::in_RegMask().
379
380 protected:
381 void set_table_base_offset(int x) { _table_base_offset = x; }
382 // MachConstantBaseNode::emit is const but we need to modify the object.
383 void set_table_base_offset(int x) const { ((MachConstantBaseNode*) this)->set_table_base_offset(x); }
384
385 void emit_constant_table(CodeBuffer& cb);
386 void emit_constant_table(CodeBuffer& cb) const { ((MachConstantBaseNode*) this)->emit_constant_table(cb); }
387
388 // Returns the offset of the last entry (the top) of the constant table.
389 int top_constant_offset() const { assert(_constants.top().offset() != -1, "constant not yet bound"); return _constants.top().offset(); }
390
391 public:
392 MachConstantBaseNode() :
393 MachIdealNode(),
394 _table_base_offset(-1) // We can use -1 here since the constant table is always bigger than 2 bytes (-(size / 2), see MachConstantBaseNode::emit).
395 {
396 init_class_id(Class_MachConstantBase);
397 add_req(NULL);
398 }
399 virtual const class Type* bottom_type() const { return TypeRawPtr::NOTNULL; }
400 virtual uint ideal_reg() const { return Op_RegP; }
401 virtual uint oper_input_base() const { return 1; }
402
403 virtual void emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const;
404 virtual uint size(PhaseRegAlloc* ra_) const;
405 virtual bool pinned() const { return true; }
406
407 static const RegMask& static_out_RegMask() { return _out_RegMask; }
408 virtual const RegMask& out_RegMask() const { return static_out_RegMask(); }
409
410 #ifndef PRODUCT
411 virtual const char* Name() const { return "MachConstantBaseNode"; }
412 virtual void format(PhaseRegAlloc*, outputStream* st) const;
413 #endif
414
415 int table_base_offset() const { assert(_table_base_offset != -1, "table base offset not yet set"); return _table_base_offset; }
416
417 int add_constant(Constant& con);
418 int calculate_constant_table_size();
419 int find_constant_offset(Constant& con) const;
420 };
421
422 //------------------------------MachConstantNode-------------------------------
423 // Machine node that holds a constant which is stored in the constant
424 // table.
425 class MachConstantNode : public MachNode {
426 private:
427 MachConstantBaseNode::Constant _constant;
428
429 public:
430 MachConstantNode() : MachNode() {
431 init_class_id(Class_MachConstant);
432 }
433
434 virtual void eval_constant() {
435 #ifdef ASSERT
436 tty->print("missing MachConstantNode eval_constant function: ");
437 dump();
438 #endif
439 ShouldNotCallThis();
440 }
441
442 virtual const RegMask &in_RegMask(uint idx) const {
443 if (idx == mach_constant_base_node_input())
444 return MachConstantBaseNode::static_out_RegMask();
445 return MachNode::in_RegMask(idx);
446 }
447
448 // Input edge of MachConstantBaseNode.
449 uint mach_constant_base_node_input() const { return req() - 1; }
450 int constant_offset();
451 int constant_offset() const { return ((MachConstantNode*) this)->constant_offset(); }
452
453 protected:
454 void add_to_constant_table(BasicType type, jvalue value);
455 void add_to_constant_table(MachOper* oper);
456 void add_to_constant_table(jfloat f) {
457 jvalue value; value.f = f;
458 add_to_constant_table(T_FLOAT, value);
459 }
460 void add_to_constant_table(jdouble d) {
461 jvalue value; value.d = d;
462 add_to_constant_table(T_DOUBLE, value);
463 }
464
465 // Jump table
466 void allocate_jump_table_in_constant_table();
467 void fill_jump_table_in_constant_table(CodeBuffer& cb, GrowableArray<Label*> labels) const;
468 };
469
470 //------------------------------MachUEPNode-----------------------------------
471 // Machine Unvalidated Entry Point Node
472 class MachUEPNode : public MachIdealNode {
473 public:
474 MachUEPNode( ) {}
475 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
476 virtual uint size(PhaseRegAlloc *ra_) const;
477
478 #ifndef PRODUCT
479 virtual const char *Name() const { return "Unvalidated-Entry-Point"; }
480 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
481 #endif
482 };
483
484 //------------------------------MachPrologNode--------------------------------
485 // Machine function Prolog Node
486 class MachPrologNode : public MachIdealNode {
487 public:
488 MachPrologNode( ) {}
489 virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
|