< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template

Print this page

   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.incubator.vector;
  26 
  27 import java.nio.ByteBuffer;
  28 import java.util.Arrays;
  29 import java.util.Objects;
  30 import java.util.function.IntUnaryOperator;
  31 

  32 import jdk.internal.vm.annotation.ForceInline;
  33 import jdk.internal.vm.vector.VectorSupport;
  34 
  35 import static jdk.internal.vm.vector.VectorSupport.*;
  36 
  37 import static jdk.incubator.vector.VectorOperators.*;
  38 
  39 #warn This file is preprocessed before being compiled
  40 
  41 @SuppressWarnings("cast")  // warning: redundant cast
  42 final class $vectortype$ extends $abstractvectortype$ {
  43     static final $Type$Species VSPECIES =
  44         ($Type$Species) $Type$Vector.SPECIES_$BITS$;
  45 
  46     static final VectorShape VSHAPE =
  47         VSPECIES.vectorShape();
  48 
  49     static final Class<$vectortype$> VCLASS = $vectortype$.class;
  50 
  51     static final int VSIZE = VSPECIES.vectorBitSize();

 463     @ForceInline
 464     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> shuffle,
 465                                   VectorMask<$Boxtype$> m) {
 466         return ($vectortype$)
 467             super.rearrangeTemplate($shuffletype$.class,
 468                                     $masktype$.class,
 469                                     ($shuffletype$) shuffle,
 470                                     ($masktype$) m);  // specialize
 471     }
 472 
 473     @Override
 474     @ForceInline
 475     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> s,
 476                                   Vector<$Boxtype$> v) {
 477         return ($vectortype$)
 478             super.rearrangeTemplate($shuffletype$.class,
 479                                     ($shuffletype$) s,
 480                                     ($vectortype$) v);  // specialize
 481     }
 482 
















 483     @Override
 484     @ForceInline
 485     public $vectortype$ selectFrom(Vector<$Boxtype$> v) {
 486         return ($vectortype$)
 487             super.selectFromTemplate(($vectortype$) v);  // specialize
 488     }
 489 
 490     @Override
 491     @ForceInline
 492     public $vectortype$ selectFrom(Vector<$Boxtype$> v,
 493                                    VectorMask<$Boxtype$> m) {
 494         return ($vectortype$)
 495             super.selectFromTemplate(($vectortype$) v,
 496                                      ($masktype$) m);  // specialize
 497     }
 498 
 499 
 500 #if[FP]
 501     @ForceInline
 502     @Override

 903                 this, species,
 904                 (m, s) -> s.maskFactory(m.toArray()).check(s));
 905         }
 906 
 907         @Override
 908         @ForceInline
 909         public $masktype$ eq(VectorMask<$Boxtype$> mask) {
 910             Objects.requireNonNull(mask);
 911             $masktype$ m = ($masktype$)mask;
 912             return xor(m.not());
 913         }
 914 
 915         // Unary operations
 916 
 917         @Override
 918         @ForceInline
 919         public $masktype$ not() {
 920             return xor(maskAll(true));
 921         }
 922 









 923         // Binary operations
 924 
 925         @Override
 926         @ForceInline
 927         public $masktype$ and(VectorMask<$Boxtype$> mask) {
 928             Objects.requireNonNull(mask);
 929             $masktype$ m = ($masktype$)mask;
 930             return VectorSupport.binaryOp(VECTOR_OP_AND, $masktype$.class, null, $bitstype$.class, VLENGTH,
 931                                           this, m, null,
 932                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b));
 933         }
 934 
 935         @Override
 936         @ForceInline
 937         public $masktype$ or(VectorMask<$Boxtype$> mask) {
 938             Objects.requireNonNull(mask);
 939             $masktype$ m = ($masktype$)mask;
 940             return VectorSupport.binaryOp(VECTOR_OP_OR, $masktype$.class, null, $bitstype$.class, VLENGTH,
 941                                           this, m, null,
 942                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b));

1142 
1143 #if[byte]
1144     @ForceInline
1145     @Override
1146     final
1147     $abstractvectortype$ fromBooleanArray0(boolean[] a, int offset) {
1148         return super.fromBooleanArray0Template(a, offset);  // specialize
1149     }
1150 
1151     @ForceInline
1152     @Override
1153     final
1154     $abstractvectortype$ fromBooleanArray0(boolean[] a, int offset, VectorMask<$Boxtype$> m) {
1155         return super.fromBooleanArray0Template($masktype$.class, a, offset, ($masktype$) m);  // specialize
1156     }
1157 #end[byte]
1158 
1159     @ForceInline
1160     @Override
1161     final
1162     $abstractvectortype$ fromByteArray0(byte[] a, int offset) {
1163         return super.fromByteArray0Template(a, offset);  // specialize
1164     }
1165 
1166     @ForceInline
1167     @Override
1168     final
1169     $abstractvectortype$ fromByteArray0(byte[] a, int offset, VectorMask<$Boxtype$> m) {
1170         return super.fromByteArray0Template($masktype$.class, a, offset, ($masktype$) m);  // specialize
1171     }
1172 
1173     @ForceInline
1174     @Override
1175     final
1176     $abstractvectortype$ fromByteBuffer0(ByteBuffer bb, int offset) {
1177         return super.fromByteBuffer0Template(bb, offset);  // specialize
1178     }
1179 
1180     @ForceInline
1181     @Override
1182     final
1183     $abstractvectortype$ fromByteBuffer0(ByteBuffer bb, int offset, VectorMask<$Boxtype$> m) {
1184         return super.fromByteBuffer0Template($masktype$.class, bb, offset, ($masktype$) m);  // specialize
1185     }
1186 
1187     @ForceInline
1188     @Override
1189     final
1190     void intoArray0($type$[] a, int offset) {
1191         super.intoArray0Template(a, offset);  // specialize
1192     }
1193 
1194     @ForceInline
1195     @Override
1196     final
1197     void intoArray0($type$[] a, int offset, VectorMask<$Boxtype$> m) {
1198         super.intoArray0Template($masktype$.class, a, offset, ($masktype$) m);
1199     }
1200 
1201 #if[!byteOrShort]
1202     @ForceInline
1203     @Override
1204     final
1205     void intoArray0($type$[] a, int offset, int[] indexMap, int mapOffset, VectorMask<$Boxtype$> m) {
1206         super.intoArray0Template($masktype$.class, a, offset, indexMap, mapOffset, ($masktype$) m);
1207     }
1208 #end[!byteOrShort]
1209 
1210 #if[byte]
1211     @ForceInline
1212     @Override
1213     final
1214     void intoBooleanArray0(boolean[] a, int offset, VectorMask<$Boxtype$> m) {
1215         super.intoBooleanArray0Template($masktype$.class, a, offset, ($masktype$) m);
1216     }
1217 #end[byte]
1218 
1219     @ForceInline
1220     @Override
1221     final
1222     void intoByteArray0(byte[] a, int offset) {
1223         super.intoByteArray0Template(a, offset);  // specialize
1224     }
1225 
1226     @ForceInline
1227     @Override
1228     final
1229     void intoByteArray0(byte[] a, int offset, VectorMask<$Boxtype$> m) {
1230         super.intoByteArray0Template($masktype$.class, a, offset, ($masktype$) m);  // specialize
1231     }
1232 
1233     @ForceInline
1234     @Override
1235     final
1236     void intoByteBuffer0(ByteBuffer bb, int offset, VectorMask<$Boxtype$> m) {
1237         super.intoByteBuffer0Template($masktype$.class, bb, offset, ($masktype$) m);
1238     }
1239 
1240 #if[short]
1241     @ForceInline
1242     @Override
1243     final
1244     void intoCharArray0(char[] a, int offset, VectorMask<$Boxtype$> m) {
1245         super.intoCharArray0Template($masktype$.class, a, offset, ($masktype$) m);
1246     }
1247 #end[short]
1248 
1249     // End of specialized low-level memory operations.
1250 
1251     // ================================================
1252 
1253 }

   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package jdk.incubator.vector;
  26 

  27 import java.util.Arrays;
  28 import java.util.Objects;
  29 import java.util.function.IntUnaryOperator;
  30 
  31 import jdk.incubator.foreign.MemorySegment;
  32 import jdk.internal.vm.annotation.ForceInline;
  33 import jdk.internal.vm.vector.VectorSupport;
  34 
  35 import static jdk.internal.vm.vector.VectorSupport.*;
  36 
  37 import static jdk.incubator.vector.VectorOperators.*;
  38 
  39 #warn This file is preprocessed before being compiled
  40 
  41 @SuppressWarnings("cast")  // warning: redundant cast
  42 final class $vectortype$ extends $abstractvectortype$ {
  43     static final $Type$Species VSPECIES =
  44         ($Type$Species) $Type$Vector.SPECIES_$BITS$;
  45 
  46     static final VectorShape VSHAPE =
  47         VSPECIES.vectorShape();
  48 
  49     static final Class<$vectortype$> VCLASS = $vectortype$.class;
  50 
  51     static final int VSIZE = VSPECIES.vectorBitSize();

 463     @ForceInline
 464     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> shuffle,
 465                                   VectorMask<$Boxtype$> m) {
 466         return ($vectortype$)
 467             super.rearrangeTemplate($shuffletype$.class,
 468                                     $masktype$.class,
 469                                     ($shuffletype$) shuffle,
 470                                     ($masktype$) m);  // specialize
 471     }
 472 
 473     @Override
 474     @ForceInline
 475     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> s,
 476                                   Vector<$Boxtype$> v) {
 477         return ($vectortype$)
 478             super.rearrangeTemplate($shuffletype$.class,
 479                                     ($shuffletype$) s,
 480                                     ($vectortype$) v);  // specialize
 481     }
 482 
 483     @Override
 484     @ForceInline
 485     public $vectortype$ compress(VectorMask<$Boxtype$> m) {
 486         return ($vectortype$)
 487             super.compressTemplate($masktype$.class,
 488                                    ($masktype$) m);  // specialize
 489     }
 490 
 491     @Override
 492     @ForceInline
 493     public $vectortype$ expand(VectorMask<$Boxtype$> m) {
 494         return ($vectortype$)
 495             super.expandTemplate($masktype$.class,
 496                                    ($masktype$) m);  // specialize
 497     }
 498 
 499     @Override
 500     @ForceInline
 501     public $vectortype$ selectFrom(Vector<$Boxtype$> v) {
 502         return ($vectortype$)
 503             super.selectFromTemplate(($vectortype$) v);  // specialize
 504     }
 505 
 506     @Override
 507     @ForceInline
 508     public $vectortype$ selectFrom(Vector<$Boxtype$> v,
 509                                    VectorMask<$Boxtype$> m) {
 510         return ($vectortype$)
 511             super.selectFromTemplate(($vectortype$) v,
 512                                      ($masktype$) m);  // specialize
 513     }
 514 
 515 
 516 #if[FP]
 517     @ForceInline
 518     @Override

 919                 this, species,
 920                 (m, s) -> s.maskFactory(m.toArray()).check(s));
 921         }
 922 
 923         @Override
 924         @ForceInline
 925         public $masktype$ eq(VectorMask<$Boxtype$> mask) {
 926             Objects.requireNonNull(mask);
 927             $masktype$ m = ($masktype$)mask;
 928             return xor(m.not());
 929         }
 930 
 931         // Unary operations
 932 
 933         @Override
 934         @ForceInline
 935         public $masktype$ not() {
 936             return xor(maskAll(true));
 937         }
 938 
 939         @Override
 940         @ForceInline
 941         public $masktype$ compress() {
 942             return ($masktype$)VectorSupport.comExpOp(VectorSupport.VECTOR_OP_MASK_COMPRESS,
 943                 $vectortype$.class, $masktype$.class, ETYPE, VLENGTH, null, this,
 944                 (v1, m1) -> VSPECIES.iota().compare(VectorOperators.LT, m1.trueCount()));
 945         }
 946 
 947 
 948         // Binary operations
 949 
 950         @Override
 951         @ForceInline
 952         public $masktype$ and(VectorMask<$Boxtype$> mask) {
 953             Objects.requireNonNull(mask);
 954             $masktype$ m = ($masktype$)mask;
 955             return VectorSupport.binaryOp(VECTOR_OP_AND, $masktype$.class, null, $bitstype$.class, VLENGTH,
 956                                           this, m, null,
 957                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a & b));
 958         }
 959 
 960         @Override
 961         @ForceInline
 962         public $masktype$ or(VectorMask<$Boxtype$> mask) {
 963             Objects.requireNonNull(mask);
 964             $masktype$ m = ($masktype$)mask;
 965             return VectorSupport.binaryOp(VECTOR_OP_OR, $masktype$.class, null, $bitstype$.class, VLENGTH,
 966                                           this, m, null,
 967                                           (m1, m2, vm) -> m1.bOp(m2, (i, a, b) -> a | b));

1167 
1168 #if[byte]
1169     @ForceInline
1170     @Override
1171     final
1172     $abstractvectortype$ fromBooleanArray0(boolean[] a, int offset) {
1173         return super.fromBooleanArray0Template(a, offset);  // specialize
1174     }
1175 
1176     @ForceInline
1177     @Override
1178     final
1179     $abstractvectortype$ fromBooleanArray0(boolean[] a, int offset, VectorMask<$Boxtype$> m) {
1180         return super.fromBooleanArray0Template($masktype$.class, a, offset, ($masktype$) m);  // specialize
1181     }
1182 #end[byte]
1183 
1184     @ForceInline
1185     @Override
1186     final
1187     $abstractvectortype$ fromMemorySegment0(MemorySegment ms, long offset) {
1188         return super.fromMemorySegment0Template(ms, offset);  // specialize
1189     }
1190 
1191     @ForceInline
1192     @Override
1193     final
1194     $abstractvectortype$ fromMemorySegment0(MemorySegment ms, long offset, VectorMask<$Boxtype$> m) {
1195         return super.fromMemorySegment0Template($masktype$.class, ms, offset, ($masktype$) m);  // specialize














1196     }
1197 
1198     @ForceInline
1199     @Override
1200     final
1201     void intoArray0($type$[] a, int offset) {
1202         super.intoArray0Template(a, offset);  // specialize
1203     }
1204 
1205     @ForceInline
1206     @Override
1207     final
1208     void intoArray0($type$[] a, int offset, VectorMask<$Boxtype$> m) {
1209         super.intoArray0Template($masktype$.class, a, offset, ($masktype$) m);
1210     }
1211 
1212 #if[!byteOrShort]
1213     @ForceInline
1214     @Override
1215     final
1216     void intoArray0($type$[] a, int offset, int[] indexMap, int mapOffset, VectorMask<$Boxtype$> m) {
1217         super.intoArray0Template($masktype$.class, a, offset, indexMap, mapOffset, ($masktype$) m);
1218     }
1219 #end[!byteOrShort]
1220 
1221 #if[byte]
1222     @ForceInline
1223     @Override
1224     final
1225     void intoBooleanArray0(boolean[] a, int offset, VectorMask<$Boxtype$> m) {
1226         super.intoBooleanArray0Template($masktype$.class, a, offset, ($masktype$) m);
1227     }
1228 #end[byte]
1229 
1230     @ForceInline
1231     @Override
1232     final
1233     void intoMemorySegment0(MemorySegment ms, long offset, VectorMask<$Boxtype$> m) {
1234         super.intoMemorySegment0Template($masktype$.class, ms, offset, ($masktype$) m);














1235     }
1236 
1237 #if[short]
1238     @ForceInline
1239     @Override
1240     final
1241     void intoCharArray0(char[] a, int offset, VectorMask<$Boxtype$> m) {
1242         super.intoCharArray0Template($masktype$.class, a, offset, ($masktype$) m);
1243     }
1244 #end[short]
1245 
1246     // End of specialized low-level memory operations.
1247 
1248     // ================================================
1249 
1250 }
< prev index next >