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 */
24
25 #ifndef SHARE_OPTO_CFGNODE_HPP
26 #define SHARE_OPTO_CFGNODE_HPP
27
28 #include "opto/multnode.hpp"
29 #include "opto/node.hpp"
30 #include "opto/opcodes.hpp"
31 #include "opto/predicates_enums.hpp"
32 #include "opto/type.hpp"
33
34 // Portions of code courtesy of Clifford Click
35
36 // Optimization - Graph Style
37
38 class Matcher;
39 class Node;
40 class RegionNode;
41 class TypeNode;
42 class PhiNode;
43 class GotoNode;
44 class MultiNode;
45 class MultiBranchNode;
46 class IfNode;
47 class PCTableNode;
48 class JumpNode;
49 class CatchNode;
50 class NeverBranchNode;
51 class BlackholeNode;
52 class ProjNode;
214 PhiNode* slice_memory(const TypePtr* adr_type) const;
215 PhiNode* split_out_instance(const TypePtr* at, PhaseIterGVN *igvn) const;
216 // like make(r, x), but does not initialize the in edges to x
217 static PhiNode* make_blank( Node* r, Node* x );
218
219 // Accessors
220 RegionNode* region() const { Node* r = in(Region); assert(!r || r->is_Region(), ""); return (RegionNode*)r; }
221
222 bool is_tripcount(BasicType bt) const;
223
224 // Determine a unique non-trivial input, if any.
225 // Ignore casts if it helps. Return null on failure.
226 Node* unique_input(PhaseValues* phase, bool uncast);
227 Node* unique_input(PhaseValues* phase) {
228 Node* uin = unique_input(phase, false);
229 if (uin == nullptr) {
230 uin = unique_input(phase, true);
231 }
232 return uin;
233 }
234
235 // Check for a simple dead loop.
236 enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
237 LoopSafety simple_data_loop_check(Node *in) const;
238 // Is it unsafe data loop? It becomes a dead loop if this phi node removed.
239 bool is_unsafe_data_reference(Node *in) const;
240 int is_diamond_phi() const;
241 bool try_clean_memory_phi(PhaseIterGVN* igvn);
242 virtual int Opcode() const;
243 virtual bool pinned() const { return in(0) != nullptr; }
244 virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
245
246 void set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; }
247 int inst_mem_id() const { return _inst_mem_id; }
248 int inst_id() const { return _inst_id; }
249 int inst_index() const { return _inst_index; }
250 int inst_offset() const { return _inst_offset; }
251 bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) {
252 return type()->basic_type() == tp->basic_type() &&
253 inst_mem_id() == mem_id &&
254 inst_id() == id &&
255 inst_index() == index &&
256 inst_offset() == offset &&
257 type()->higher_equal(tp);
258 }
259
260 virtual const Type* Value(PhaseGVN* phase) const;
261 virtual Node* Identity(PhaseGVN* phase);
262 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
263 virtual const RegMask &out_RegMask() const;
264 virtual const RegMask &in_RegMask(uint) const;
265 #ifndef PRODUCT
266 virtual void dump_spec(outputStream *st) const;
267 #endif
268 #ifdef ASSERT
269 void verify_adr_type(VectorSet& visited, const TypePtr* at) const;
270 void verify_adr_type(bool recursive = false) const;
271 #else //ASSERT
272 void verify_adr_type(bool recursive = false) const {}
273 #endif //ASSERT
274
275 const TypeTuple* collect_types(PhaseGVN* phase) const;
276 bool can_be_replaced_by(const PhiNode* other) const;
277 };
278
279 //------------------------------GotoNode---------------------------------------
451 }
452
453 virtual int Opcode() const;
454 virtual bool pinned() const { return true; }
455 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
456 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
457 virtual const Type* Value(PhaseGVN* phase) const;
458 virtual uint required_outcnt() const { return 2; }
459 virtual const RegMask &out_RegMask() const;
460 Node* fold_compares(PhaseIterGVN* phase);
461 static Node* up_one_dom(Node* curr, bool linear_only = false);
462 bool is_zero_trip_guard() const;
463 Node* dominated_by(Node* prev_dom, PhaseIterGVN* igvn, bool prev_dom_not_imply_this);
464 ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call, Deoptimization::DeoptReason reason = Deoptimization::Reason_none) const;
465
466 // Takes the type of val and filters it through the test represented
467 // by if_proj and returns a more refined type if one is produced.
468 // Returns null is it couldn't improve the type.
469 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
470
471 AssertionPredicateType assertion_predicate_type() const {
472 return _assertion_predicate_type;
473 }
474
475 #ifndef PRODUCT
476 virtual void dump_spec(outputStream *st) const;
477 #endif
478
479 bool same_condition(const Node* dom, PhaseIterGVN* igvn) const;
480 void mark_projections_unsafe_for_fold_compare() const;
481 };
482
483 class RangeCheckNode : public IfNode {
484 private:
485 int is_range_check(Node*& range, Node*& index, jint& offset);
486
487 public:
488 RangeCheckNode(Node* control, Node* bol, float p, float fcnt) : IfNode(control, bol, p, fcnt) {
489 init_class_id(Class_RangeCheck);
490 }
740 virtual int Opcode() const;
741 virtual bool pinned() const { return true; };
742 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
743 virtual const Type* Value(PhaseGVN* phase) const;
744 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
745 virtual uint required_outcnt() const { return 2; }
746 virtual void emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const { }
747 virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
748 #ifndef PRODUCT
749 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
750 #endif
751 };
752
753 //------------------------------BlackholeNode----------------------------
754 // Blackhole all arguments. This node would survive through the compiler
755 // the effects on its arguments, and would be finally matched to nothing.
756 class BlackholeNode : public MultiNode {
757 public:
758 BlackholeNode(Node* ctrl) : MultiNode(1) {
759 init_req(TypeFunc::Control, ctrl);
760 }
761 virtual int Opcode() const;
762 virtual uint ideal_reg() const { return 0; } // not matched in the AD file
763 virtual const Type* bottom_type() const { return TypeTuple::MEMBAR; }
764 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
765
766 const RegMask &in_RegMask(uint idx) const {
767 // Fake the incoming arguments mask for blackholes: accept all registers
768 // and all stack slots. This would avoid any redundant register moves
769 // for blackhole inputs.
770 return RegMask::ALL;
771 }
772 #ifndef PRODUCT
773 virtual void format(PhaseRegAlloc* ra, outputStream* st) const;
774 #endif
775 };
776
777
778 #endif // SHARE_OPTO_CFGNODE_HPP
|
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 */
24
25 #ifndef SHARE_OPTO_CFGNODE_HPP
26 #define SHARE_OPTO_CFGNODE_HPP
27
28 #include "opto/multnode.hpp"
29 #include "opto/node.hpp"
30 #include "opto/opcodes.hpp"
31 #include "opto/predicates_enums.hpp"
32 #include "opto/type.hpp"
33 #include "runtime/arguments.hpp"
34
35 // Portions of code courtesy of Clifford Click
36
37 // Optimization - Graph Style
38
39 class Matcher;
40 class Node;
41 class RegionNode;
42 class TypeNode;
43 class PhiNode;
44 class GotoNode;
45 class MultiNode;
46 class MultiBranchNode;
47 class IfNode;
48 class PCTableNode;
49 class JumpNode;
50 class CatchNode;
51 class NeverBranchNode;
52 class BlackholeNode;
53 class ProjNode;
215 PhiNode* slice_memory(const TypePtr* adr_type) const;
216 PhiNode* split_out_instance(const TypePtr* at, PhaseIterGVN *igvn) const;
217 // like make(r, x), but does not initialize the in edges to x
218 static PhiNode* make_blank( Node* r, Node* x );
219
220 // Accessors
221 RegionNode* region() const { Node* r = in(Region); assert(!r || r->is_Region(), ""); return (RegionNode*)r; }
222
223 bool is_tripcount(BasicType bt) const;
224
225 // Determine a unique non-trivial input, if any.
226 // Ignore casts if it helps. Return null on failure.
227 Node* unique_input(PhaseValues* phase, bool uncast);
228 Node* unique_input(PhaseValues* phase) {
229 Node* uin = unique_input(phase, false);
230 if (uin == nullptr) {
231 uin = unique_input(phase, true);
232 }
233 return uin;
234 }
235 Node* unique_constant_input_recursive(PhaseGVN* phase);
236
237 // Check for a simple dead loop.
238 enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };
239 LoopSafety simple_data_loop_check(Node *in) const;
240 // Is it unsafe data loop? It becomes a dead loop if this phi node removed.
241 bool is_unsafe_data_reference(Node *in) const;
242 int is_diamond_phi() const;
243 bool try_clean_memory_phi(PhaseIterGVN* igvn);
244 virtual int Opcode() const;
245 virtual bool pinned() const { return in(0) != nullptr; }
246 virtual const TypePtr *adr_type() const { verify_adr_type(true); return _adr_type; }
247
248 void set_inst_mem_id(int inst_mem_id) { _inst_mem_id = inst_mem_id; }
249 int inst_mem_id() const { return _inst_mem_id; }
250 int inst_id() const { return _inst_id; }
251 int inst_index() const { return _inst_index; }
252 int inst_offset() const { return _inst_offset; }
253 bool is_same_inst_field(const Type* tp, int mem_id, int id, int index, int offset) {
254 return type()->basic_type() == tp->basic_type() &&
255 inst_mem_id() == mem_id &&
256 inst_id() == id &&
257 inst_index() == index &&
258 inst_offset() == offset &&
259 type()->higher_equal(tp);
260 }
261
262 bool can_be_inline_type() const {
263 return Arguments::is_valhalla_enabled() && _type->isa_instptr() && _type->is_instptr()->can_be_inline_type();
264 }
265
266 Node* try_push_inline_types_down(PhaseGVN* phase, bool can_reshape);
267 DEBUG_ONLY(bool can_push_inline_types_down(PhaseGVN* phase);)
268
269 virtual const Type* Value(PhaseGVN* phase) const;
270 virtual Node* Identity(PhaseGVN* phase);
271 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
272 virtual const RegMask &out_RegMask() const;
273 virtual const RegMask &in_RegMask(uint) const;
274 #ifndef PRODUCT
275 virtual void dump_spec(outputStream *st) const;
276 #endif
277 #ifdef ASSERT
278 void verify_adr_type(VectorSet& visited, const TypePtr* at) const;
279 void verify_adr_type(bool recursive = false) const;
280 #else //ASSERT
281 void verify_adr_type(bool recursive = false) const {}
282 #endif //ASSERT
283
284 const TypeTuple* collect_types(PhaseGVN* phase) const;
285 bool can_be_replaced_by(const PhiNode* other) const;
286 };
287
288 //------------------------------GotoNode---------------------------------------
460 }
461
462 virtual int Opcode() const;
463 virtual bool pinned() const { return true; }
464 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
465 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
466 virtual const Type* Value(PhaseGVN* phase) const;
467 virtual uint required_outcnt() const { return 2; }
468 virtual const RegMask &out_RegMask() const;
469 Node* fold_compares(PhaseIterGVN* phase);
470 static Node* up_one_dom(Node* curr, bool linear_only = false);
471 bool is_zero_trip_guard() const;
472 Node* dominated_by(Node* prev_dom, PhaseIterGVN* igvn, bool prev_dom_not_imply_this);
473 ProjNode* uncommon_trap_proj(CallStaticJavaNode*& call, Deoptimization::DeoptReason reason = Deoptimization::Reason_none) const;
474
475 // Takes the type of val and filters it through the test represented
476 // by if_proj and returns a more refined type if one is produced.
477 // Returns null is it couldn't improve the type.
478 static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj);
479
480 bool is_flat_array_check(PhaseTransform* phase, Node** array = nullptr);
481
482 AssertionPredicateType assertion_predicate_type() const {
483 return _assertion_predicate_type;
484 }
485
486 #ifndef PRODUCT
487 virtual void dump_spec(outputStream *st) const;
488 #endif
489
490 bool same_condition(const Node* dom, PhaseIterGVN* igvn) const;
491 void mark_projections_unsafe_for_fold_compare() const;
492 };
493
494 class RangeCheckNode : public IfNode {
495 private:
496 int is_range_check(Node*& range, Node*& index, jint& offset);
497
498 public:
499 RangeCheckNode(Node* control, Node* bol, float p, float fcnt) : IfNode(control, bol, p, fcnt) {
500 init_class_id(Class_RangeCheck);
501 }
751 virtual int Opcode() const;
752 virtual bool pinned() const { return true; };
753 virtual const Type *bottom_type() const { return TypeTuple::IFBOTH; }
754 virtual const Type* Value(PhaseGVN* phase) const;
755 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
756 virtual uint required_outcnt() const { return 2; }
757 virtual void emit(C2_MacroAssembler *masm, PhaseRegAlloc *ra_) const { }
758 virtual uint size(PhaseRegAlloc *ra_) const { return 0; }
759 #ifndef PRODUCT
760 virtual void format( PhaseRegAlloc *, outputStream *st ) const;
761 #endif
762 };
763
764 //------------------------------BlackholeNode----------------------------
765 // Blackhole all arguments. This node would survive through the compiler
766 // the effects on its arguments, and would be finally matched to nothing.
767 class BlackholeNode : public MultiNode {
768 public:
769 BlackholeNode(Node* ctrl) : MultiNode(1) {
770 init_req(TypeFunc::Control, ctrl);
771 init_class_id(Class_Blackhole);
772 }
773 virtual int Opcode() const;
774 virtual uint ideal_reg() const { return 0; } // not matched in the AD file
775 virtual const Type* bottom_type() const { return TypeTuple::MEMBAR; }
776 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
777
778 const RegMask &in_RegMask(uint idx) const {
779 // Fake the incoming arguments mask for blackholes: accept all registers
780 // and all stack slots. This would avoid any redundant register moves
781 // for blackhole inputs.
782 return RegMask::ALL;
783 }
784 #ifndef PRODUCT
785 virtual void format(PhaseRegAlloc* ra, outputStream* st) const;
786 #endif
787 };
788
789
790 #endif // SHARE_OPTO_CFGNODE_HPP
|