135 virtual relocInfo::relocType disp_reloc() const;
136 virtual int constant_disp() const; // usu. 0, may return Type::OffsetBot
137 virtual int base_position() const; // base edge position, or -1
138 virtual int index_position() const; // index edge position, or -1
139
140 // Access the TypeKlassPtr of operands with a base==RegI and disp==RegP
141 // Only returns non-null value for i486.ad's indOffset32X
142 virtual const TypePtr *disp_as_type() const { return NULL; }
143
144 // Return the label
145 virtual Label *label() const;
146
147 // Return the method's address
148 virtual intptr_t method() const;
149
150 // Hash and compare over operands are currently identical
151 virtual uint hash() const;
152 virtual uint cmp( const MachOper &oper ) const;
153
154 // Virtual clone, since I do not know how big the MachOper is.
155 virtual MachOper *clone(Compile* C) const = 0;
156
157 // Return ideal Type from simple operands. Fail for complex operands.
158 virtual const Type *type() const;
159
160 // Set an integer offset if we have one, or error otherwise
161 virtual void set_con( jint c0 ) { ShouldNotReachHere(); }
162
163 #ifndef PRODUCT
164 // Return name of operand
165 virtual const char *Name() const { return "???";}
166
167 // Methods to output the text version of the operand
168 virtual void int_format(PhaseRegAlloc *,const MachNode *node, outputStream *st) const = 0;
169 virtual void ext_format(PhaseRegAlloc *,const MachNode *node,int idx, outputStream *st) const=0;
170
171 virtual void dump_spec(outputStream *st) const; // Print per-operand info
172
173 // Check whether o is a valid oper.
174 static bool notAnOper(const MachOper *o) {
175 if (o == NULL) return true;
185 // ADLC inherit from this class.
186 class MachNode : public Node {
187 public:
188 MachNode() : Node((uint)0), _num_opnds(0), _opnds(NULL) {
189 init_class_id(Class_Mach);
190 }
191 // Required boilerplate
192 virtual uint size_of() const { return sizeof(MachNode); }
193 virtual int Opcode() const; // Always equal to MachNode
194 virtual uint rule() const = 0; // Machine-specific opcode
195 // Number of inputs which come before the first operand.
196 // Generally at least 1, to skip the Control input
197 virtual uint oper_input_base() const { return 1; }
198 // Position of constant base node in node's inputs. -1 if
199 // no constant base node input.
200 virtual uint mach_constant_base_node_input() const { return (uint)-1; }
201
202 // Copy inputs and operands to new node of instruction.
203 // Called from cisc_version() and short_branch_version().
204 // !!!! The method's body is defined in ad_<arch>.cpp file.
205 void fill_new_machnode(MachNode *n, Compile* C) const;
206
207 // Return an equivalent instruction using memory for cisc_operand position
208 virtual MachNode *cisc_version(int offset, Compile* C);
209 // Modify this instruction's register mask to use stack version for cisc_operand
210 virtual void use_cisc_RegMask();
211
212 // Support for short branches
213 bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; }
214
215 // Avoid back to back some instructions on some CPUs.
216 enum AvoidBackToBackFlag { AVOID_NONE = 0,
217 AVOID_BEFORE = Flag_avoid_back_to_back_before,
218 AVOID_AFTER = Flag_avoid_back_to_back_after,
219 AVOID_BEFORE_AND_AFTER = AVOID_BEFORE | AVOID_AFTER };
220
221 bool avoid_back_to_back(AvoidBackToBackFlag flag_value) const {
222 return (flags() & flag_value) == flag_value;
223 }
224
225 // instruction implemented with a call
226 bool has_call() const { return (flags() & Flag_has_call) != 0; }
227
228 // First index in _in[] corresponding to operand, or -1 if there is none
300 #define TYPE_PTR_SENTINAL ((const TypePtr*)-1)
301 // Passing TYPE_PTR_SENTINAL as adr_type asks for computation of the adr_type if possible
302 const Node* get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const;
303
304 // Helper for get_base_and_disp: find the base and index input nodes.
305 // Returns the MachOper as determined by memory_operand(), for use, if
306 // needed by the caller. If (MachOper *)-1 is returned, base and index
307 // are set to NodeSentinel. If (MachOper *) NULL is returned, base and
308 // index are set to NULL.
309 const MachOper* memory_inputs(Node* &base, Node* &index) const;
310
311 // Helper for memory_inputs: Which operand carries the necessary info?
312 // By default, returns NULL, which means there is no such operand.
313 // If it returns (MachOper*)-1, this means there are multiple memories.
314 virtual const MachOper* memory_operand() const { return NULL; }
315
316 // Call "get_base_and_disp" to decide which category of memory is used here.
317 virtual const class TypePtr *adr_type() const;
318
319 // Apply peephole rule(s) to this instruction
320 virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C );
321
322 // Top-level ideal Opcode matched
323 virtual int ideal_Opcode() const { return Op_Node; }
324
325 // Adds the label for the case
326 virtual void add_case_label( int switch_val, Label* blockLabel);
327
328 // Set the absolute address for methods
329 virtual void method_set( intptr_t addr );
330
331 // Should we clone rather than spill this instruction?
332 bool rematerialize() const;
333
334 // Get the pipeline info
335 static const Pipeline *pipeline_class();
336 virtual const Pipeline *pipeline() const;
337
338 // Returns true if this node is a check that can be implemented with a trap.
339 virtual bool is_TrapBasedCheckNode() const { return false; }
340
610 assert(false, "Must have valid spill type");
611 return "MachSpillCopy";
612 }
613 }
614
615 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
616 #endif
617 };
618
619 //------------------------------MachBranchNode--------------------------------
620 // Abstract machine branch Node
621 class MachBranchNode : public MachIdealNode {
622 public:
623 MachBranchNode() : MachIdealNode() {
624 init_class_id(Class_MachBranch);
625 }
626 virtual void label_set(Label* label, uint block_num) = 0;
627 virtual void save_label(Label** label, uint* block_num) = 0;
628
629 // Support for short branches
630 virtual MachNode *short_branch_version(Compile* C) { return NULL; }
631
632 virtual bool pinned() const { return true; };
633 };
634
635 //------------------------------MachNullChkNode--------------------------------
636 // Machine-dependent null-pointer-check Node. Points a real MachNode that is
637 // also some kind of memory op. Turns the indicated MachNode into a
638 // conditional branch with good latency on the ptr-not-null path and awful
639 // latency on the pointer-is-null path.
640
641 class MachNullCheckNode : public MachBranchNode {
642 public:
643 const uint _vidx; // Index of memop being tested
644 MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachBranchNode(), _vidx(vidx) {
645 init_class_id(Class_MachNullCheck);
646 add_req(ctrl);
647 add_req(memop);
648 }
649 virtual uint size_of() const { return sizeof(*this); }
650
968
969
970
971 //------------------------------labelOper--------------------------------------
972 // Machine-independent version of label operand
973 class labelOper : public MachOper {
974 private:
975 virtual uint num_edges() const { return 0; }
976 public:
977 // Supported for fixed size branches
978 Label* _label; // Label for branch(es)
979
980 uint _block_num;
981
982 labelOper() : _block_num(0), _label(0) {}
983
984 labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {}
985
986 labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {}
987
988 virtual MachOper *clone(Compile* C) const;
989
990 virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; }
991
992 virtual uint opcode() const;
993
994 virtual uint hash() const;
995 virtual uint cmp( const MachOper &oper ) const;
996 #ifndef PRODUCT
997 virtual const char *Name() const { return "Label";}
998
999 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
1000 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
1001 #endif
1002 };
1003
1004
1005 //------------------------------methodOper--------------------------------------
1006 // Machine-independent version of method operand
1007 class methodOper : public MachOper {
1008 private:
1009 virtual uint num_edges() const { return 0; }
1010 public:
1011 intptr_t _method; // Address of method
1012 methodOper() : _method(0) {}
1013 methodOper(intptr_t method) : _method(method) {}
1014
1015 virtual MachOper *clone(Compile* C) const;
1016
1017 virtual intptr_t method() const { return _method; }
1018
1019 virtual uint opcode() const;
1020
1021 virtual uint hash() const;
1022 virtual uint cmp( const MachOper &oper ) const;
1023 #ifndef PRODUCT
1024 virtual const char *Name() const { return "Method";}
1025
1026 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
1027 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
1028 #endif
1029 };
1030
1031 #endif // SHARE_VM_OPTO_MACHNODE_HPP
|
135 virtual relocInfo::relocType disp_reloc() const;
136 virtual int constant_disp() const; // usu. 0, may return Type::OffsetBot
137 virtual int base_position() const; // base edge position, or -1
138 virtual int index_position() const; // index edge position, or -1
139
140 // Access the TypeKlassPtr of operands with a base==RegI and disp==RegP
141 // Only returns non-null value for i486.ad's indOffset32X
142 virtual const TypePtr *disp_as_type() const { return NULL; }
143
144 // Return the label
145 virtual Label *label() const;
146
147 // Return the method's address
148 virtual intptr_t method() const;
149
150 // Hash and compare over operands are currently identical
151 virtual uint hash() const;
152 virtual uint cmp( const MachOper &oper ) const;
153
154 // Virtual clone, since I do not know how big the MachOper is.
155 virtual MachOper *clone() const = 0;
156
157 // Return ideal Type from simple operands. Fail for complex operands.
158 virtual const Type *type() const;
159
160 // Set an integer offset if we have one, or error otherwise
161 virtual void set_con( jint c0 ) { ShouldNotReachHere(); }
162
163 #ifndef PRODUCT
164 // Return name of operand
165 virtual const char *Name() const { return "???";}
166
167 // Methods to output the text version of the operand
168 virtual void int_format(PhaseRegAlloc *,const MachNode *node, outputStream *st) const = 0;
169 virtual void ext_format(PhaseRegAlloc *,const MachNode *node,int idx, outputStream *st) const=0;
170
171 virtual void dump_spec(outputStream *st) const; // Print per-operand info
172
173 // Check whether o is a valid oper.
174 static bool notAnOper(const MachOper *o) {
175 if (o == NULL) return true;
185 // ADLC inherit from this class.
186 class MachNode : public Node {
187 public:
188 MachNode() : Node((uint)0), _num_opnds(0), _opnds(NULL) {
189 init_class_id(Class_Mach);
190 }
191 // Required boilerplate
192 virtual uint size_of() const { return sizeof(MachNode); }
193 virtual int Opcode() const; // Always equal to MachNode
194 virtual uint rule() const = 0; // Machine-specific opcode
195 // Number of inputs which come before the first operand.
196 // Generally at least 1, to skip the Control input
197 virtual uint oper_input_base() const { return 1; }
198 // Position of constant base node in node's inputs. -1 if
199 // no constant base node input.
200 virtual uint mach_constant_base_node_input() const { return (uint)-1; }
201
202 // Copy inputs and operands to new node of instruction.
203 // Called from cisc_version() and short_branch_version().
204 // !!!! The method's body is defined in ad_<arch>.cpp file.
205 void fill_new_machnode(MachNode *n) const;
206
207 // Return an equivalent instruction using memory for cisc_operand position
208 virtual MachNode *cisc_version(int offset);
209 // Modify this instruction's register mask to use stack version for cisc_operand
210 virtual void use_cisc_RegMask();
211
212 // Support for short branches
213 bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; }
214
215 // Avoid back to back some instructions on some CPUs.
216 enum AvoidBackToBackFlag { AVOID_NONE = 0,
217 AVOID_BEFORE = Flag_avoid_back_to_back_before,
218 AVOID_AFTER = Flag_avoid_back_to_back_after,
219 AVOID_BEFORE_AND_AFTER = AVOID_BEFORE | AVOID_AFTER };
220
221 bool avoid_back_to_back(AvoidBackToBackFlag flag_value) const {
222 return (flags() & flag_value) == flag_value;
223 }
224
225 // instruction implemented with a call
226 bool has_call() const { return (flags() & Flag_has_call) != 0; }
227
228 // First index in _in[] corresponding to operand, or -1 if there is none
300 #define TYPE_PTR_SENTINAL ((const TypePtr*)-1)
301 // Passing TYPE_PTR_SENTINAL as adr_type asks for computation of the adr_type if possible
302 const Node* get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const;
303
304 // Helper for get_base_and_disp: find the base and index input nodes.
305 // Returns the MachOper as determined by memory_operand(), for use, if
306 // needed by the caller. If (MachOper *)-1 is returned, base and index
307 // are set to NodeSentinel. If (MachOper *) NULL is returned, base and
308 // index are set to NULL.
309 const MachOper* memory_inputs(Node* &base, Node* &index) const;
310
311 // Helper for memory_inputs: Which operand carries the necessary info?
312 // By default, returns NULL, which means there is no such operand.
313 // If it returns (MachOper*)-1, this means there are multiple memories.
314 virtual const MachOper* memory_operand() const { return NULL; }
315
316 // Call "get_base_and_disp" to decide which category of memory is used here.
317 virtual const class TypePtr *adr_type() const;
318
319 // Apply peephole rule(s) to this instruction
320 virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted);
321
322 // Top-level ideal Opcode matched
323 virtual int ideal_Opcode() const { return Op_Node; }
324
325 // Adds the label for the case
326 virtual void add_case_label( int switch_val, Label* blockLabel);
327
328 // Set the absolute address for methods
329 virtual void method_set( intptr_t addr );
330
331 // Should we clone rather than spill this instruction?
332 bool rematerialize() const;
333
334 // Get the pipeline info
335 static const Pipeline *pipeline_class();
336 virtual const Pipeline *pipeline() const;
337
338 // Returns true if this node is a check that can be implemented with a trap.
339 virtual bool is_TrapBasedCheckNode() const { return false; }
340
610 assert(false, "Must have valid spill type");
611 return "MachSpillCopy";
612 }
613 }
614
615 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
616 #endif
617 };
618
619 //------------------------------MachBranchNode--------------------------------
620 // Abstract machine branch Node
621 class MachBranchNode : public MachIdealNode {
622 public:
623 MachBranchNode() : MachIdealNode() {
624 init_class_id(Class_MachBranch);
625 }
626 virtual void label_set(Label* label, uint block_num) = 0;
627 virtual void save_label(Label** label, uint* block_num) = 0;
628
629 // Support for short branches
630 virtual MachNode *short_branch_version() { return NULL; }
631
632 virtual bool pinned() const { return true; };
633 };
634
635 //------------------------------MachNullChkNode--------------------------------
636 // Machine-dependent null-pointer-check Node. Points a real MachNode that is
637 // also some kind of memory op. Turns the indicated MachNode into a
638 // conditional branch with good latency on the ptr-not-null path and awful
639 // latency on the pointer-is-null path.
640
641 class MachNullCheckNode : public MachBranchNode {
642 public:
643 const uint _vidx; // Index of memop being tested
644 MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachBranchNode(), _vidx(vidx) {
645 init_class_id(Class_MachNullCheck);
646 add_req(ctrl);
647 add_req(memop);
648 }
649 virtual uint size_of() const { return sizeof(*this); }
650
968
969
970
971 //------------------------------labelOper--------------------------------------
972 // Machine-independent version of label operand
973 class labelOper : public MachOper {
974 private:
975 virtual uint num_edges() const { return 0; }
976 public:
977 // Supported for fixed size branches
978 Label* _label; // Label for branch(es)
979
980 uint _block_num;
981
982 labelOper() : _block_num(0), _label(0) {}
983
984 labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {}
985
986 labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {}
987
988 virtual MachOper *clone() const;
989
990 virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; }
991
992 virtual uint opcode() const;
993
994 virtual uint hash() const;
995 virtual uint cmp( const MachOper &oper ) const;
996 #ifndef PRODUCT
997 virtual const char *Name() const { return "Label";}
998
999 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
1000 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
1001 #endif
1002 };
1003
1004
1005 //------------------------------methodOper--------------------------------------
1006 // Machine-independent version of method operand
1007 class methodOper : public MachOper {
1008 private:
1009 virtual uint num_edges() const { return 0; }
1010 public:
1011 intptr_t _method; // Address of method
1012 methodOper() : _method(0) {}
1013 methodOper(intptr_t method) : _method(method) {}
1014
1015 virtual MachOper *clone() const;
1016
1017 virtual intptr_t method() const { return _method; }
1018
1019 virtual uint opcode() const;
1020
1021 virtual uint hash() const;
1022 virtual uint cmp( const MachOper &oper ) const;
1023 #ifndef PRODUCT
1024 virtual const char *Name() const { return "Method";}
1025
1026 virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
1027 virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
1028 #endif
1029 };
1030
1031 #endif // SHARE_VM_OPTO_MACHNODE_HPP
|