< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java

Print this page

   1 /*
   2  * Copyright (c) 2019, 2021, 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.  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

 433         VO_KIND_CAST               = 0x000,
 434         VO_KIND_BITWISE            = 0x100;
 435 
 436     private static final HashMap<Integer, String> OPC_NAME
 437         = new HashMap<>();
 438     private static final HashMap<Integer, String> CMP_OPC_NAME
 439         = new HashMap<>();
 440     private static final HashMap<Integer, String> CONV_OPC_NAME
 441         = new HashMap<>();
 442 
 443     // Unary operators
 444 
 445     /** Produce {@code ~a}.  Integral only. */
 446     public static final /*bitwise*/ Unary NOT = unary("NOT", "~", -1 /*VectorSupport.VECTOR_OP_NOT*/, VO_NOFP | VO_SPECIAL);
 447     /** Produce {@code a==0?0:-1} (zero or minus one).  Integral only. */
 448     public static final /*bitwise*/ Unary ZOMO = unary("ZOMO", "a==0?0:-1", -1 /*VectorSupport.VECTOR_OP_ZOMO*/, VO_NOFP);
 449     /** Produce {@code abs(a)}. */
 450     public static final Unary ABS = unary("ABS", "abs", VectorSupport.VECTOR_OP_ABS, VO_ALL);
 451     /** Produce {@code -a}. */
 452     public static final Unary NEG = unary("NEG", "-a", VectorSupport.VECTOR_OP_NEG, VO_ALL|VO_SPECIAL);




















 453 
 454     /** Produce {@code sin(a)}.  Floating only.
 455      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 456      */
 457     public static final /*float*/ Unary SIN = unary("SIN", "sin", VectorSupport.VECTOR_OP_SIN, VO_ONLYFP);
 458     /** Produce {@code cos(a)}.  Floating only.
 459      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 460      */
 461     public static final /*float*/ Unary COS = unary("COS", "cos", VectorSupport.VECTOR_OP_COS, VO_ONLYFP);
 462     /** Produce {@code tan(a)}.  Floating only.
 463      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 464      */
 465     public static final /*float*/ Unary TAN = unary("TAN", "tan", VectorSupport.VECTOR_OP_TAN, VO_ONLYFP);
 466     /** Produce {@code asin(a)}.  Floating only.
 467      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 468      */
 469     public static final /*float*/ Unary ASIN = unary("ASIN", "asin", VectorSupport.VECTOR_OP_ASIN, VO_ONLYFP);
 470     /** Produce {@code acos(a)}.  Floating only.
 471      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 472      */

 537     public static final Associative AND = assoc("AND", "&", VectorSupport.VECTOR_OP_AND, VO_NOFP+VO_ASSOC);
 538     /** Produce {@code a&~b}.  Integral only. */
 539     public static final /*bitwise*/ Binary AND_NOT = binary("AND_NOT", "&~", -1 /*VectorSupport.VECTOR_OP_AND_NOT*/, VO_NOFP); // FIXME
 540     /** Produce {@code a|b}.  Integral only. */
 541     public static final /*bitwise*/ Associative OR = assoc("OR", "|", VectorSupport.VECTOR_OP_OR, VO_NOFP+VO_ASSOC);
 542     /*package-private*/ /** Version of OR which works on float and double too. */
 543     static final Associative OR_UNCHECKED = assoc("OR_UNCHECKED", "|", VectorSupport.VECTOR_OP_OR, VO_ASSOC+VO_PRIVATE);
 544     /** Produce {@code a^b}.  Integral only. */
 545     public static final /*bitwise*/ Associative XOR = assoc("XOR", "^", VectorSupport.VECTOR_OP_XOR, VO_NOFP+VO_ASSOC);
 546 
 547     /** Produce {@code a<<(n&(ESIZE*8-1))}.  Integral only. */
 548     public static final /*bitwise*/ Binary LSHL = binary("LSHL", "<<", VectorSupport.VECTOR_OP_LSHIFT, VO_SHIFT);
 549     /** Produce {@code a>>(n&(ESIZE*8-1))}.  Integral only. */
 550     public static final /*bitwise*/ Binary ASHR = binary("ASHR", ">>", VectorSupport.VECTOR_OP_RSHIFT, VO_SHIFT);
 551     /** Produce {@code a>>>(n&(ESIZE*8-1))}.  Integral only. */
 552     public static final /*bitwise*/ Binary LSHR = binary("LSHR", ">>>", VectorSupport.VECTOR_OP_URSHIFT, VO_SHIFT);
 553     /** Produce {@code rotateLeft(a,n)}.  Integral only. */
 554     public static final /*bitwise*/ Binary ROL = binary("ROL", "rotateLeft", VectorSupport.VECTOR_OP_LROTATE, VO_SHIFT);
 555     /** Produce {@code rotateRight(a,n)}.  Integral only. */
 556     public static final /*bitwise*/ Binary ROR = binary("ROR", "rotateRight", VectorSupport.VECTOR_OP_RROTATE, VO_SHIFT);








 557 
 558     /** Produce {@code atan2(a,b)}. See  Floating only.
 559      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 560      */
 561     public static final /*float*/ Binary ATAN2 = binary("ATAN2", "atan2", VectorSupport.VECTOR_OP_ATAN2, VO_ONLYFP);
 562     /** Produce {@code pow(a,b)}.  Floating only.
 563      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 564      */
 565     public static final /*float*/ Binary POW = binary("POW", "pow", VectorSupport.VECTOR_OP_POW, VO_ONLYFP);
 566     /** Produce {@code hypot(a,b)}.  Floating only.
 567      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 568      */
 569     public static final /*float*/ Binary HYPOT = binary("HYPOT", "hypot", VectorSupport.VECTOR_OP_HYPOT, VO_ONLYFP);
 570 
 571     // Ternary operators
 572 
 573     /** Produce {@code a^((a^b)&c)}.  (Bitwise {@code (c(i)?b(i):a(i))}.)  Integral only. */
 574     public static final /*float*/ Ternary BITWISE_BLEND = ternary("BITWISE_BLEND", "a^((a^b)&c)", -1 /*VectorSupport.VECTOR_OP_BITWISE_BLEND*/, VO_NOFP);
 575     /** Produce {@code fma(a,b,c)}.  Floating only. */
 576     public static final /*float*/ Ternary FMA = ternary("FMA", "fma", VectorSupport.VECTOR_OP_FMA, VO_ONLYFP);

   1 /*
   2  * Copyright (c) 2019, 2022, 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.  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

 433         VO_KIND_CAST               = 0x000,
 434         VO_KIND_BITWISE            = 0x100;
 435 
 436     private static final HashMap<Integer, String> OPC_NAME
 437         = new HashMap<>();
 438     private static final HashMap<Integer, String> CMP_OPC_NAME
 439         = new HashMap<>();
 440     private static final HashMap<Integer, String> CONV_OPC_NAME
 441         = new HashMap<>();
 442 
 443     // Unary operators
 444 
 445     /** Produce {@code ~a}.  Integral only. */
 446     public static final /*bitwise*/ Unary NOT = unary("NOT", "~", -1 /*VectorSupport.VECTOR_OP_NOT*/, VO_NOFP | VO_SPECIAL);
 447     /** Produce {@code a==0?0:-1} (zero or minus one).  Integral only. */
 448     public static final /*bitwise*/ Unary ZOMO = unary("ZOMO", "a==0?0:-1", -1 /*VectorSupport.VECTOR_OP_ZOMO*/, VO_NOFP);
 449     /** Produce {@code abs(a)}. */
 450     public static final Unary ABS = unary("ABS", "abs", VectorSupport.VECTOR_OP_ABS, VO_ALL);
 451     /** Produce {@code -a}. */
 452     public static final Unary NEG = unary("NEG", "-a", VectorSupport.VECTOR_OP_NEG, VO_ALL|VO_SPECIAL);
 453     /** Produce {@code bitCount(a)}
 454      * @since 19
 455      */
 456     public static final Unary BIT_COUNT = unary("BIT_COUNT", "bitCount", VectorSupport.VECTOR_OP_BIT_COUNT, VO_NOFP);
 457     /** Produce {@code numberOfTrailingZeros(a)}
 458      * @since 19
 459      */
 460     public static final Unary TRAILING_ZEROS_COUNT = unary("TRAILING_ZEROS_COUNT", "numberOfTrailingZeros", VectorSupport.VECTOR_OP_TZ_COUNT, VO_NOFP);
 461     /** Produce {@code numberOfLeadingZeros(a)}
 462      * @since 19
 463      */
 464     public static final Unary LEADING_ZEROS_COUNT = unary("LEADING_ZEROS_COUNT", "numberOfLeadingZeros", VectorSupport.VECTOR_OP_LZ_COUNT, VO_NOFP);
 465     /** Produce {@code reverse(a)}
 466      * @since 19
 467      */
 468     public static final Unary REVERSE = unary("REVERSE", "reverse", VectorSupport.VECTOR_OP_REVERSE, VO_NOFP);
 469     /** Produce {@code reverseBytes(a)}
 470      * @since 19
 471      */
 472     public static final Unary REVERSE_BYTES = unary("REVERSE_BYTES", "reverseBytes", VectorSupport.VECTOR_OP_REVERSE_BYTES, VO_NOFP);
 473 
 474     /** Produce {@code sin(a)}.  Floating only.
 475      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 476      */
 477     public static final /*float*/ Unary SIN = unary("SIN", "sin", VectorSupport.VECTOR_OP_SIN, VO_ONLYFP);
 478     /** Produce {@code cos(a)}.  Floating only.
 479      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 480      */
 481     public static final /*float*/ Unary COS = unary("COS", "cos", VectorSupport.VECTOR_OP_COS, VO_ONLYFP);
 482     /** Produce {@code tan(a)}.  Floating only.
 483      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 484      */
 485     public static final /*float*/ Unary TAN = unary("TAN", "tan", VectorSupport.VECTOR_OP_TAN, VO_ONLYFP);
 486     /** Produce {@code asin(a)}.  Floating only.
 487      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 488      */
 489     public static final /*float*/ Unary ASIN = unary("ASIN", "asin", VectorSupport.VECTOR_OP_ASIN, VO_ONLYFP);
 490     /** Produce {@code acos(a)}.  Floating only.
 491      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 492      */

 557     public static final Associative AND = assoc("AND", "&", VectorSupport.VECTOR_OP_AND, VO_NOFP+VO_ASSOC);
 558     /** Produce {@code a&~b}.  Integral only. */
 559     public static final /*bitwise*/ Binary AND_NOT = binary("AND_NOT", "&~", -1 /*VectorSupport.VECTOR_OP_AND_NOT*/, VO_NOFP); // FIXME
 560     /** Produce {@code a|b}.  Integral only. */
 561     public static final /*bitwise*/ Associative OR = assoc("OR", "|", VectorSupport.VECTOR_OP_OR, VO_NOFP+VO_ASSOC);
 562     /*package-private*/ /** Version of OR which works on float and double too. */
 563     static final Associative OR_UNCHECKED = assoc("OR_UNCHECKED", "|", VectorSupport.VECTOR_OP_OR, VO_ASSOC+VO_PRIVATE);
 564     /** Produce {@code a^b}.  Integral only. */
 565     public static final /*bitwise*/ Associative XOR = assoc("XOR", "^", VectorSupport.VECTOR_OP_XOR, VO_NOFP+VO_ASSOC);
 566 
 567     /** Produce {@code a<<(n&(ESIZE*8-1))}.  Integral only. */
 568     public static final /*bitwise*/ Binary LSHL = binary("LSHL", "<<", VectorSupport.VECTOR_OP_LSHIFT, VO_SHIFT);
 569     /** Produce {@code a>>(n&(ESIZE*8-1))}.  Integral only. */
 570     public static final /*bitwise*/ Binary ASHR = binary("ASHR", ">>", VectorSupport.VECTOR_OP_RSHIFT, VO_SHIFT);
 571     /** Produce {@code a>>>(n&(ESIZE*8-1))}.  Integral only. */
 572     public static final /*bitwise*/ Binary LSHR = binary("LSHR", ">>>", VectorSupport.VECTOR_OP_URSHIFT, VO_SHIFT);
 573     /** Produce {@code rotateLeft(a,n)}.  Integral only. */
 574     public static final /*bitwise*/ Binary ROL = binary("ROL", "rotateLeft", VectorSupport.VECTOR_OP_LROTATE, VO_SHIFT);
 575     /** Produce {@code rotateRight(a,n)}.  Integral only. */
 576     public static final /*bitwise*/ Binary ROR = binary("ROR", "rotateRight", VectorSupport.VECTOR_OP_RROTATE, VO_SHIFT);
 577     /** Produce {@code compress(a,n)}. Integral, {@code int} and {@code long}, only.
 578      * @since 19
 579      */
 580     public static final /*bitwise*/ Binary COMPRESS_BITS = binary("COMPRESS_BITS", "compressBits", VectorSupport.VECTOR_OP_COMPRESS_BITS, VO_NOFP);
 581     /** Produce {@code expand(a,n)}. Integral, {@code int} and {@code long}, only.
 582      * @since 19
 583      */
 584     public static final /*bitwise*/ Binary EXPAND_BITS = binary("EXPAND_BITS", "expandBits", VectorSupport.VECTOR_OP_EXPAND_BITS, VO_NOFP);
 585 
 586     /** Produce {@code atan2(a,b)}. See  Floating only.
 587      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 588      */
 589     public static final /*float*/ Binary ATAN2 = binary("ATAN2", "atan2", VectorSupport.VECTOR_OP_ATAN2, VO_ONLYFP);
 590     /** Produce {@code pow(a,b)}.  Floating only.
 591      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 592      */
 593     public static final /*float*/ Binary POW = binary("POW", "pow", VectorSupport.VECTOR_OP_POW, VO_ONLYFP);
 594     /** Produce {@code hypot(a,b)}.  Floating only.
 595      *  Not guaranteed to be semi-monotonic. See section "Operations on floating point vectors" above
 596      */
 597     public static final /*float*/ Binary HYPOT = binary("HYPOT", "hypot", VectorSupport.VECTOR_OP_HYPOT, VO_ONLYFP);
 598 
 599     // Ternary operators
 600 
 601     /** Produce {@code a^((a^b)&c)}.  (Bitwise {@code (c(i)?b(i):a(i))}.)  Integral only. */
 602     public static final /*float*/ Ternary BITWISE_BLEND = ternary("BITWISE_BLEND", "a^((a^b)&c)", -1 /*VectorSupport.VECTOR_OP_BITWISE_BLEND*/, VO_NOFP);
 603     /** Produce {@code fma(a,b,c)}.  Floating only. */
 604     public static final /*float*/ Ternary FMA = ternary("FMA", "fma", VectorSupport.VECTOR_OP_FMA, VO_ONLYFP);
< prev index next >