< prev index next >

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

Print this page




1607         $bitstype$[] res = new $bitstype$[this.species().length()];
1608         for(int i = 0; i < this.species().length(); i++){
1609             res[i] = $Type$.$type$To$Bitstype$Bits(vec[i]);
1610         }
1611         return new $bitsvectortype$(res);
1612     }
1613 #end[FP]
1614 
1615 #if[intOrLong]
1616     $fpvectortype$ toFP() {
1617         $type$[] vec = getElements();
1618         $fptype$[] res = new $fptype$[this.species().length()];
1619         for(int i = 0; i < this.species().length(); i++){
1620             res[i] = $Boxfptype$.$bitstype$BitsTo$Fptype$(vec[i]);
1621         }
1622         return new $fpvectortype$(res);
1623     }
1624 #end[intOrLong]
1625 
1626     @Override

1627     public $vectortype$ rotateLanesLeft(int j) {
1628         $type$[] vec = getElements();
1629         $type$[] res = new $type$[length()];
1630         for (int i = 0; i < length(); i++){
1631             res[(j + i) % length()] = vec[i];



1632         }
1633         return new $vectortype$(res);
1634     }
1635 
1636     @Override

1637     public $vectortype$ rotateLanesRight(int j) {
1638         $type$[] vec = getElements();
1639         $type$[] res = new $type$[length()];
1640         for (int i = 0; i < length(); i++){
1641             int z = i - j;
1642             if(j < 0) {
1643                 res[length() + z] = vec[i];
1644             } else {
1645                 res[z] = vec[i];
1646             }

1647         }
1648         return new $vectortype$(res);
1649     }
1650 
1651     @Override


1652     public $vectortype$ shiftLanesLeft(int j) {
1653         $type$[] vec = getElements();
1654         $type$[] res = new $type$[length()];
1655         for (int i = 0; i < length() - j; i++) {
1656             res[i] = vec[i + j];






1657         }
1658         return new $vectortype$(res);
1659     }
1660 
1661     @Override


1662     public $vectortype$ shiftLanesRight(int j) {
1663         $type$[] vec = getElements();
1664         $type$[] res = new $type$[length()];
1665         for (int i = 0; i < length() - j; i++){
1666             res[i + j] = vec[i];






1667         }
1668         return new $vectortype$(res);
1669     }
1670 
1671     @Override
1672     @ForceInline
1673     public $vectortype$ rearrange(Vector<$Boxtype$> v,
1674                                   VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m) {
1675         return this.rearrange(s).blend(v.rearrange(s), m);
1676     }
1677 
1678     @Override
1679     @ForceInline
1680     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> o1) {
1681         Objects.requireNonNull(o1);
1682         $shuffletype$ s =  ($shuffletype$)o1;
1683 
1684         return VectorIntrinsics.rearrangeOp(
1685             $vectortype$.class, $shuffletype$.class, $type$.class, LENGTH,
1686             this, s,
1687             (v1, s_) -> v1.uOp((i, a) -> {
1688                 int ei = s_.lane(i);


1919             super(reorder);
1920         }
1921 
1922         public $shuffletype$(int[] reorder) {
1923             super(reorder);
1924         }
1925 
1926         public $shuffletype$(int[] reorder, int i) {
1927             super(reorder, i);
1928         }
1929 
1930         public $shuffletype$(IntUnaryOperator f) {
1931             super(f);
1932         }
1933 
1934         @Override
1935         public VectorSpecies<$Boxtype$> species() {
1936             return SPECIES;
1937         }
1938 
1939         @Override
1940         public $abstractvectortype$ toVector() {
1941             $type$[] va = new $type$[SPECIES.length()];
1942             for (int i = 0; i < va.length; i++) {
1943               va[i] = ($type$) lane(i);
1944             }
1945             return $abstractvectortype$.fromArray(SPECIES, va, 0);
1946         }
1947 
1948         @Override
1949         @ForceInline








1950         @SuppressWarnings("unchecked")
1951         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1952             if (length() != species.length())
1953                 throw new IllegalArgumentException("Shuffle length and species length differ");
1954             Class<?> stype = species.elementType();
1955             int [] shuffleArray = toArray();
1956             if (stype == byte.class) {
1957                 return (VectorShuffle<F>) new Byte$bits$Vector.Byte$bits$Shuffle(shuffleArray);
1958             } else if (stype == short.class) {
1959                 return (VectorShuffle<F>) new Short$bits$Vector.Short$bits$Shuffle(shuffleArray);
1960             } else if (stype == int.class) {
1961                 return (VectorShuffle<F>) new Int$bits$Vector.Int$bits$Shuffle(shuffleArray);
1962             } else if (stype == long.class) {
1963                 return (VectorShuffle<F>) new Long$bits$Vector.Long$bits$Shuffle(shuffleArray);
1964             } else if (stype == float.class) {
1965                 return (VectorShuffle<F>) new Float$bits$Vector.Float$bits$Shuffle(shuffleArray);
1966             } else if (stype == double.class) {
1967                 return (VectorShuffle<F>) new Double$bits$Vector.Double$bits$Shuffle(shuffleArray);
1968             } else {
1969                 throw new UnsupportedOperationException("Bad lane type for casting.");
1970             }
1971         }

1972 
1973         @Override
1974         public $shuffletype$ rearrange(VectorShuffle<$Boxtype$> o) {
1975             $shuffletype$ s = ($shuffletype$) o;
1976             byte[] r = new byte[reorder.length];
1977             for (int i = 0; i < reorder.length; i++) {
1978                 r[i] = reorder[s.reorder[i]];
1979             }
1980             return new $shuffletype$(r);
1981         }
1982     }
1983 
1984     // VectorSpecies
1985 
1986     @Override
1987     public VectorSpecies<$Boxtype$> species() {
1988         return SPECIES;
1989     }
1990 }


1607         $bitstype$[] res = new $bitstype$[this.species().length()];
1608         for(int i = 0; i < this.species().length(); i++){
1609             res[i] = $Type$.$type$To$Bitstype$Bits(vec[i]);
1610         }
1611         return new $bitsvectortype$(res);
1612     }
1613 #end[FP]
1614 
1615 #if[intOrLong]
1616     $fpvectortype$ toFP() {
1617         $type$[] vec = getElements();
1618         $fptype$[] res = new $fptype$[this.species().length()];
1619         for(int i = 0; i < this.species().length(); i++){
1620             res[i] = $Boxfptype$.$bitstype$BitsTo$Fptype$(vec[i]);
1621         }
1622         return new $fpvectortype$(res);
1623     }
1624 #end[intOrLong]
1625 
1626     @Override
1627     @ForceInline
1628     public $vectortype$ rotateLanesLeft(int j) {
1629       int L = length();
1630       if (j < 0) {
1631          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1632       } else {
1633         j = j & (L-1);
1634         VectorShuffle<$Boxtype$> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
1635         return this.rearrange(PermMask);
1636       }

1637     }
1638 
1639     @Override
1640     @ForceInline
1641     public $vectortype$ rotateLanesRight(int j) {
1642       int L = length();
1643       if (j < 0) {
1644          throw new IllegalArgumentException("Index " + j + " must be zero or positive");



1645       } else {
1646         j = j & (L-1);
1647         VectorShuffle<$Boxtype$> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
1648         return this.rearrange(PermMask);
1649       }

1650     }
1651 
1652     @Override
1653     @ForceInline
1654     @SuppressWarnings("unchecked")
1655     public $vectortype$ shiftLanesLeft(int j) {
1656        int L = length();
1657        if (j < 0) {
1658          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1659        } else if ( j >= L ) {
1660          return ZERO;
1661        } else {
1662          $shuffletype$     Iota    = ($shuffletype$)(VectorShuffle.shuffleIota(SPECIES, L-j));
1663          VectorMask<$Boxtype$> BlendMask = Iota.toVector().lessThan($vectortype$.broadcast(SPECIES, ($type$)(L-j)));
1664          Iota    = ($shuffletype$)(VectorShuffle.shuffleIota(SPECIES, L -j));
1665          return ZERO.blend(this.rearrange(Iota),BlendMask);
1666        }

1667     }
1668 
1669     @Override
1670     @ForceInline
1671     @SuppressWarnings("unchecked")
1672     public $vectortype$ shiftLanesRight(int j) {
1673        int L = length();
1674        if (j < 0) {
1675          throw new IllegalArgumentException("Index " + j + " must be zero or positive");
1676        } else if ( j >= L ) {
1677          return ZERO;
1678        } else {
1679          $shuffletype$     Iota    = ($shuffletype$)(VectorShuffle.shuffleIota(SPECIES, j));
1680          VectorMask<$Boxtype$> BlendMask = Iota.toVector().greaterThanEq($vectortype$.broadcast(SPECIES, ($type$)(j)));
1681          Iota    = ($shuffletype$)(VectorShuffle.shuffleIota(SPECIES, j));
1682          return ZERO.blend(this.rearrange(Iota),BlendMask);
1683        }

1684     }
1685 
1686     @Override
1687     @ForceInline
1688     public $vectortype$ rearrange(Vector<$Boxtype$> v,
1689                                   VectorShuffle<$Boxtype$> s, VectorMask<$Boxtype$> m) {
1690         return this.rearrange(s).blend(v.rearrange(s), m);
1691     }
1692 
1693     @Override
1694     @ForceInline
1695     public $vectortype$ rearrange(VectorShuffle<$Boxtype$> o1) {
1696         Objects.requireNonNull(o1);
1697         $shuffletype$ s =  ($shuffletype$)o1;
1698 
1699         return VectorIntrinsics.rearrangeOp(
1700             $vectortype$.class, $shuffletype$.class, $type$.class, LENGTH,
1701             this, s,
1702             (v1, s_) -> v1.uOp((i, a) -> {
1703                 int ei = s_.lane(i);


1934             super(reorder);
1935         }
1936 
1937         public $shuffletype$(int[] reorder) {
1938             super(reorder);
1939         }
1940 
1941         public $shuffletype$(int[] reorder, int i) {
1942             super(reorder, i);
1943         }
1944 
1945         public $shuffletype$(IntUnaryOperator f) {
1946             super(f);
1947         }
1948 
1949         @Override
1950         public VectorSpecies<$Boxtype$> species() {
1951             return SPECIES;
1952         }
1953 
1954         private $abstractvectortype$ toVector_helper() {

1955             $type$[] va = new $type$[SPECIES.length()];
1956             for (int i = 0; i < va.length; i++) {
1957               va[i] = ($type$) lane(i);
1958             }
1959             return $abstractvectortype$.fromArray(SPECIES, va, 0);
1960         }
1961 
1962         @Override
1963         @ForceInline
1964         public $abstractvectortype$ toVector() {
1965             return VectorIntrinsics.shuffleToVector($vectortype$.class, $type$.class, $shuffletype$.class, this,
1966                                                     SPECIES.length(), 
1967                                                     (s) -> ((($shuffletype$)(s)).toVector_helper()));
1968         }
1969 
1970         @Override
1971         @ForceInline
1972         @SuppressWarnings("unchecked")
1973         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
1974             if (length() != species.length())
1975                 throw new IllegalArgumentException("Shuffle length and species length differ");
1976             Class<?> stype = species.elementType();
1977             int [] shuffleArray = toArray();
1978             if (stype == byte.class) {
1979                 return (VectorShuffle<F>) new Byte$bits$Vector.Byte$bits$Shuffle(shuffleArray);
1980             } else if (stype == short.class) {
1981                 return (VectorShuffle<F>) new Short$bits$Vector.Short$bits$Shuffle(shuffleArray);
1982             } else if (stype == int.class) {
1983                 return (VectorShuffle<F>) new Int$bits$Vector.Int$bits$Shuffle(shuffleArray);
1984             } else if (stype == long.class) {
1985                 return (VectorShuffle<F>) new Long$bits$Vector.Long$bits$Shuffle(shuffleArray);
1986             } else if (stype == float.class) {
1987                 return (VectorShuffle<F>) new Float$bits$Vector.Float$bits$Shuffle(shuffleArray);
1988             } else if (stype == double.class) {
1989                 return (VectorShuffle<F>) new Double$bits$Vector.Double$bits$Shuffle(shuffleArray);
1990             } else {
1991                 throw new UnsupportedOperationException("Bad lane type for casting.");
1992             }
1993         }
1994 
1995 
1996         @Override
1997         public $shuffletype$ rearrange(VectorShuffle<$Boxtype$> o) {
1998             $shuffletype$ s = ($shuffletype$) o;
1999             byte[] r = new byte[reorder.length];
2000             for (int i = 0; i < reorder.length; i++) {
2001                 r[i] = reorder[s.reorder[i]];
2002             }
2003             return new $shuffletype$(r);
2004         }
2005     }
2006 
2007     // VectorSpecies
2008 
2009     @Override
2010     public VectorSpecies<$Boxtype$> species() {
2011         return SPECIES;
2012     }
2013 }
< prev index next >