51436
|
1 |
/*
|
52910
|
2 |
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
|
51436
|
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 |
package org.graalvm.compiler.replacements.amd64;
|
|
26 |
|
52578
|
27 |
import jdk.vm.ci.meta.JavaKind;
|
|
28 |
import jdk.vm.ci.meta.Value;
|
51436
|
29 |
import org.graalvm.compiler.core.common.type.StampFactory;
|
|
30 |
import org.graalvm.compiler.graph.NodeClass;
|
52578
|
31 |
import org.graalvm.compiler.graph.NodeInputList;
|
51436
|
32 |
import org.graalvm.compiler.nodeinfo.InputType;
|
|
33 |
import org.graalvm.compiler.nodeinfo.NodeCycles;
|
|
34 |
import org.graalvm.compiler.nodeinfo.NodeInfo;
|
|
35 |
import org.graalvm.compiler.nodes.FixedWithNextNode;
|
|
36 |
import org.graalvm.compiler.nodes.NamedLocationIdentity;
|
|
37 |
import org.graalvm.compiler.nodes.ValueNode;
|
|
38 |
import org.graalvm.compiler.nodes.ValueNodeUtil;
|
|
39 |
import org.graalvm.compiler.nodes.memory.MemoryAccess;
|
|
40 |
import org.graalvm.compiler.nodes.memory.MemoryNode;
|
|
41 |
import org.graalvm.compiler.nodes.spi.LIRLowerable;
|
|
42 |
import org.graalvm.compiler.nodes.spi.NodeLIRBuilderTool;
|
|
43 |
import jdk.internal.vm.compiler.word.LocationIdentity;
|
|
44 |
import jdk.internal.vm.compiler.word.Pointer;
|
|
45 |
|
52578
|
46 |
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_512;
|
51436
|
47 |
|
|
48 |
@NodeInfo(size = SIZE_512, cycles = NodeCycles.CYCLES_UNKNOWN)
|
|
49 |
public class AMD64ArrayIndexOfNode extends FixedWithNextNode implements LIRLowerable, MemoryAccess {
|
|
50 |
|
|
51 |
public static final NodeClass<AMD64ArrayIndexOfNode> TYPE = NodeClass.create(AMD64ArrayIndexOfNode.class);
|
|
52 |
|
|
53 |
private final JavaKind kind;
|
52578
|
54 |
private final boolean findTwoConsecutive;
|
51436
|
55 |
|
|
56 |
@Input private ValueNode arrayPointer;
|
|
57 |
@Input private ValueNode arrayLength;
|
52578
|
58 |
@Input private NodeInputList<ValueNode> searchValues;
|
51436
|
59 |
|
|
60 |
@OptionalInput(InputType.Memory) private MemoryNode lastLocationAccess;
|
|
61 |
|
52578
|
62 |
public AMD64ArrayIndexOfNode(@ConstantNodeParameter JavaKind kind, @ConstantNodeParameter boolean findTwoConsecutive,
|
|
63 |
ValueNode arrayPointer, ValueNode arrayLength, ValueNode... searchValues) {
|
51436
|
64 |
super(TYPE, StampFactory.forKind(JavaKind.Int));
|
|
65 |
this.kind = kind;
|
52578
|
66 |
this.findTwoConsecutive = findTwoConsecutive;
|
51436
|
67 |
this.arrayPointer = arrayPointer;
|
|
68 |
this.arrayLength = arrayLength;
|
52578
|
69 |
this.searchValues = new NodeInputList<>(this, searchValues);
|
|
70 |
}
|
|
71 |
|
|
72 |
public AMD64ArrayIndexOfNode(@ConstantNodeParameter JavaKind kind, ValueNode arrayPointer, ValueNode arrayLength, ValueNode... searchValues) {
|
|
73 |
this(kind, false, arrayPointer, arrayLength, searchValues);
|
51436
|
74 |
}
|
|
75 |
|
|
76 |
@Override
|
|
77 |
public LocationIdentity getLocationIdentity() {
|
|
78 |
return NamedLocationIdentity.getArrayLocation(kind);
|
|
79 |
}
|
|
80 |
|
|
81 |
@Override
|
|
82 |
public void generate(NodeLIRBuilderTool gen) {
|
52578
|
83 |
Value[] searchValueOperands = new Value[searchValues.size()];
|
|
84 |
for (int i = 0; i < searchValues.size(); i++) {
|
|
85 |
searchValueOperands[i] = gen.operand(searchValues.get(i));
|
|
86 |
}
|
|
87 |
Value result = gen.getLIRGeneratorTool().emitArrayIndexOf(kind, findTwoConsecutive, gen.operand(arrayPointer), gen.operand(arrayLength), searchValueOperands);
|
51436
|
88 |
gen.setResult(this, result);
|
|
89 |
}
|
|
90 |
|
|
91 |
@Override
|
|
92 |
public MemoryNode getLastLocationAccess() {
|
|
93 |
return lastLocationAccess;
|
|
94 |
}
|
|
95 |
|
|
96 |
@Override
|
|
97 |
public void setLastLocationAccess(MemoryNode lla) {
|
|
98 |
updateUsages(ValueNodeUtil.asNode(lastLocationAccess), ValueNodeUtil.asNode(lla));
|
|
99 |
lastLocationAccess = lla;
|
|
100 |
}
|
|
101 |
|
|
102 |
@NodeIntrinsic
|
52578
|
103 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, @ConstantNodeParameter boolean findTwoConsecutive,
|
|
104 |
Pointer arrayPointer, int arrayLength, int searchValue);
|
|
105 |
|
|
106 |
@NodeIntrinsic
|
|
107 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, char c1);
|
|
108 |
|
|
109 |
@NodeIntrinsic
|
|
110 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, char c1, char c2);
|
|
111 |
|
|
112 |
@NodeIntrinsic
|
|
113 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, char c1, char c2, char c3);
|
|
114 |
|
|
115 |
@NodeIntrinsic
|
|
116 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, char c1, char c2, char c3, char c4);
|
|
117 |
|
|
118 |
@NodeIntrinsic
|
|
119 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, byte c1);
|
|
120 |
|
|
121 |
@NodeIntrinsic
|
|
122 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, byte c1, byte c2);
|
|
123 |
|
|
124 |
@NodeIntrinsic
|
|
125 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, byte c1, byte c2, byte c3);
|
|
126 |
|
|
127 |
@NodeIntrinsic
|
|
128 |
public static native int optimizedArrayIndexOf(@ConstantNodeParameter JavaKind kind, Pointer arrayPointer, int arrayLength, byte c1, byte c2, byte c3, byte c4);
|
51436
|
129 |
}
|