1/*
2 * Copyright (c) 2015, 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 */
24
25#include "precompiled.hpp"
26#include "opto/intrinsicnode.hpp"
27#include "opto/memnode.hpp"
28#include "opto/phaseX.hpp"
29
30//=============================================================================
31// Do not match memory edge.
32uint StrIntrinsicNode::match_edge(uint idx) const {
33 return idx == 2 || idx == 3;
34}
35
36//------------------------------Ideal------------------------------------------
37// Return a node which is more "ideal" than the current node. Strip out
38// control copies
39Node* StrIntrinsicNode::Ideal(PhaseGVN* phase, bool can_reshape) {
40 if (remove_dead_region(phase, can_reshape)) return this;
41 // Don't bother trying to transform a dead node
42 if (in(0) && in(0)->is_top()) return NULL;
43
44 if (can_reshape) {
45 Node* mem = phase->transform(in(MemNode::Memory));
46 // If transformed to a MergeMem, get the desired slice
47 uint alias_idx = phase->C->get_alias_index(adr_type());
48 mem = mem->is_MergeMem() ? mem->as_MergeMem()->memory_at(alias_idx) : mem;
49 if (mem != in(MemNode::Memory)) {
50 set_req(MemNode::Memory, mem);
51 return this;
52 }
53 }
54 return NULL;
55}
56
57//------------------------------Value------------------------------------------
58const Type* StrIntrinsicNode::Value(PhaseGVN* phase) const {
59 if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP;
60 return bottom_type();
61}
62
63uint StrIntrinsicNode::size_of() const { return sizeof(*this); }
64
65//=============================================================================
66//------------------------------Ideal------------------------------------------
67// Return a node which is more "ideal" than the current node. Strip out
68// control copies
69Node* StrCompressedCopyNode::Ideal(PhaseGVN* phase, bool can_reshape) {
70 return remove_dead_region(phase, can_reshape) ? this : NULL;
71}
72
73//=============================================================================
74//------------------------------Ideal------------------------------------------
75// Return a node which is more "ideal" than the current node. Strip out
76// control copies
77Node* StrInflatedCopyNode::Ideal(PhaseGVN* phase, bool can_reshape) {
78 return remove_dead_region(phase, can_reshape) ? this : NULL;
79}
80
81//=============================================================================
82//------------------------------match_edge-------------------------------------
83// Do not match memory edge
84uint EncodeISOArrayNode::match_edge(uint idx) const {
85 return idx == 2 || idx == 3; // EncodeISOArray src (Binary dst len)
86}
87
88//------------------------------Ideal------------------------------------------
89// Return a node which is more "ideal" than the current node. Strip out
90// control copies
91Node* EncodeISOArrayNode::Ideal(PhaseGVN* phase, bool can_reshape) {
92 return remove_dead_region(phase, can_reshape) ? this : NULL;
93}
94
95//------------------------------Value------------------------------------------
96const Type* EncodeISOArrayNode::Value(PhaseGVN* phase) const {
97 if (in(0) && phase->type(in(0)) == Type::TOP) return Type::TOP;
98 return bottom_type();
99}
100
101