1 package jdk.internal.vm.vector;
2
3 import jdk.internal.HotSpotIntrinsicCandidate;
4 import jdk.internal.misc.Unsafe;
5 import jdk.internal.vm.annotation.ForceInline;
6
7 import java.nio.Buffer;
8 import java.nio.ByteBuffer;
9 import java.util.Objects;
10 import java.util.function.*;
11
12 public class VectorSupport {
13 static {
14 registerNatives();
15 }
16
17 private static final Unsafe U = Unsafe.getUnsafe();
18
19 // Unary
20 public static final int VECTOR_OP_ABS = 0;
21 public static final int VECTOR_OP_NEG = 1;
22 public static final int VECTOR_OP_SQRT = 2;
23 public static final int VECTOR_OP_NOT = 3;
24
25 // Binary
26 public static final int VECTOR_OP_ADD = 4;
27 public static final int VECTOR_OP_SUB = 5;
28 public static final int VECTOR_OP_MUL = 6;
29 public static final int VECTOR_OP_DIV = 7;
30 public static final int VECTOR_OP_MIN = 8;
31 public static final int VECTOR_OP_MAX = 9;
32
33 public static final int VECTOR_OP_AND = 10;
34 public static final int VECTOR_OP_OR = 11;
35 public static final int VECTOR_OP_XOR = 12;
36
37 // Ternary
38 public static final int VECTOR_OP_FMA = 13;
39
40 // Broadcast int
41 public static final int VECTOR_OP_LSHIFT = 14;
42 public static final int VECTOR_OP_RSHIFT = 15;
43 public static final int VECTOR_OP_URSHIFT = 16;
96 super(payload);
97 }
98 }
99
100 /* ============================================================================ */
101 public interface BroadcastOperation<VM, E, S extends VectorSpecies<E>> {
102 VM broadcast(long l, S s);
103 }
104
105 @HotSpotIntrinsicCandidate
106 public static
107 <VM, E, S extends VectorSpecies<E>>
108 VM broadcastCoerced(Class<? extends VM> vmClass, Class<E> E, int length,
109 long bits, S s,
110 BroadcastOperation<VM, E, S> defaultImpl) {
111 assert isNonCapturingLambda(defaultImpl) : defaultImpl;
112 return defaultImpl.broadcast(bits, s);
113 }
114
115 /* ============================================================================ */
116 public interface ShuffleIotaOperation<E> {
117 VectorShuffle<E> apply(int length, int start, int step);
118 }
119
120 @HotSpotIntrinsicCandidate
121 public static
122 <E>
123 VectorShuffle<E> shuffleIota(Class<?> E, Class<?> ShuffleClass, VectorSpecies<E> s, int length,
124 int start, int step, int wrap, ShuffleIotaOperation<E> defaultImpl) {
125 assert isNonCapturingLambda(defaultImpl) : defaultImpl;
126 return defaultImpl.apply(length, start, step);
127 }
128
129 public interface ShuffleToVectorOperation<VM, Sh, E> {
130 VM apply(Sh s);
131 }
132
133 @HotSpotIntrinsicCandidate
134 public static
135 <VM ,Sh extends VectorShuffle<E>, E>
136 VM shuffleToVector(Class<?> VM, Class<?>E , Class<?> ShuffleClass, Sh s, int length,
137 ShuffleToVectorOperation<VM,Sh,E> defaultImpl) {
138 assert isNonCapturingLambda(defaultImpl) : defaultImpl;
139 return defaultImpl.apply(s);
140 }
141
142 /* ============================================================================ */
143 public interface IndexOperation<V extends Vector<E>, E, S extends VectorSpecies<E>> {
144 V index(V v, int step, S s);
145 }
146
|
1 /*
2 * Copyright (c) 2020, 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 package jdk.internal.vm.vector;
25
26 import jdk.internal.HotSpotIntrinsicCandidate;
27 import jdk.internal.misc.Unsafe;
28 import jdk.internal.vm.annotation.ForceInline;
29
30 import java.nio.Buffer;
31 import java.nio.ByteBuffer;
32 import java.util.Objects;
33 import java.util.function.*;
34
35 public class VectorSupport {
36 static {
37 registerNatives();
38 }
39
40 private static final Unsafe U = Unsafe.getUnsafe();
41
42 // Unary
43 public static final int VECTOR_OP_ABS = 0;
44 public static final int VECTOR_OP_NEG = 1;
45 public static final int VECTOR_OP_SQRT = 2;
46
47 // Binary
48 public static final int VECTOR_OP_ADD = 4;
49 public static final int VECTOR_OP_SUB = 5;
50 public static final int VECTOR_OP_MUL = 6;
51 public static final int VECTOR_OP_DIV = 7;
52 public static final int VECTOR_OP_MIN = 8;
53 public static final int VECTOR_OP_MAX = 9;
54
55 public static final int VECTOR_OP_AND = 10;
56 public static final int VECTOR_OP_OR = 11;
57 public static final int VECTOR_OP_XOR = 12;
58
59 // Ternary
60 public static final int VECTOR_OP_FMA = 13;
61
62 // Broadcast int
63 public static final int VECTOR_OP_LSHIFT = 14;
64 public static final int VECTOR_OP_RSHIFT = 15;
65 public static final int VECTOR_OP_URSHIFT = 16;
118 super(payload);
119 }
120 }
121
122 /* ============================================================================ */
123 public interface BroadcastOperation<VM, E, S extends VectorSpecies<E>> {
124 VM broadcast(long l, S s);
125 }
126
127 @HotSpotIntrinsicCandidate
128 public static
129 <VM, E, S extends VectorSpecies<E>>
130 VM broadcastCoerced(Class<? extends VM> vmClass, Class<E> E, int length,
131 long bits, S s,
132 BroadcastOperation<VM, E, S> defaultImpl) {
133 assert isNonCapturingLambda(defaultImpl) : defaultImpl;
134 return defaultImpl.broadcast(bits, s);
135 }
136
137 /* ============================================================================ */
138 public interface ShuffleIotaOperation<E, S extends VectorSpecies<E>> {
139 VectorShuffle<E> apply(int length, int start, int step, S s);
140 }
141
142 @HotSpotIntrinsicCandidate
143 public static
144 <E, S extends VectorSpecies<E>>
145 VectorShuffle<E> shuffleIota(Class<?> E, Class<?> ShuffleClass, S s, int length,
146 int start, int step, int wrap, ShuffleIotaOperation<E, S> defaultImpl) {
147 assert isNonCapturingLambda(defaultImpl) : defaultImpl;
148 return defaultImpl.apply(length, start, step, s);
149 }
150
151 public interface ShuffleToVectorOperation<VM, Sh, E> {
152 VM apply(Sh s);
153 }
154
155 @HotSpotIntrinsicCandidate
156 public static
157 <VM ,Sh extends VectorShuffle<E>, E>
158 VM shuffleToVector(Class<?> VM, Class<?>E , Class<?> ShuffleClass, Sh s, int length,
159 ShuffleToVectorOperation<VM,Sh,E> defaultImpl) {
160 assert isNonCapturingLambda(defaultImpl) : defaultImpl;
161 return defaultImpl.apply(s);
162 }
163
164 /* ============================================================================ */
165 public interface IndexOperation<V extends Vector<E>, E, S extends VectorSpecies<E>> {
166 V index(V v, int step, S s);
167 }
168
|