1 /*
  2  * Copyright (c) 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.
  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 compiler.vectorapi.reshape.tests;
 25 
 26 import compiler.lib.ir_framework.IR;
 27 import compiler.lib.ir_framework.Run;
 28 import compiler.lib.ir_framework.Test;
 29 
 30 import static compiler.vectorapi.reshape.utils.VectorReshapeHelper.*;
 31 
 32 /**
 33  *  This class contains method to ensure a resizing reinterpretation operations work as
 34  *  intended.
 35  *
 36  *  In each test, the ReinterpretNode is expected to appear exactly once.
 37  */
 38 public class TestVectorExpandShrink {
 39     @Test
 40     @IR(counts = {REINTERPRET_NODE, "1"})
 41     public static void testB64toB128(byte[] input, byte[] output) {
 42         vectorExpandShrink(BSPEC64, BSPEC128, input, output);
 43     }
 44 
 45     @Run(test = "testB64toB128")
 46     public static void runB64toB128() throws Throwable {
 47         runExpandShrinkHelper(BSPEC64, BSPEC128);
 48     }
 49 
 50     @Test
 51     @IR(counts = {REINTERPRET_NODE, "1"})
 52     public static void testB64toB256(byte[] input, byte[] output) {
 53         vectorExpandShrink(BSPEC64, BSPEC256, input, output);
 54     }
 55 
 56     @Run(test = "testB64toB256")
 57     public static void runB64toB256() throws Throwable {
 58         runExpandShrinkHelper(BSPEC64, BSPEC256);
 59     }
 60 
 61     @Test
 62     @IR(counts = {REINTERPRET_NODE, "1"})
 63     public static void testB64toB512(byte[] input, byte[] output) {
 64         vectorExpandShrink(BSPEC64, BSPEC512, input, output);
 65     }
 66 
 67     @Run(test = "testB64toB512")
 68     public static void runB64toB512() throws Throwable {
 69         runExpandShrinkHelper(BSPEC64, BSPEC512);
 70     }
 71 
 72     @Test
 73     @IR(counts = {REINTERPRET_NODE, "1"})
 74     public static void testB128toB64(byte[] input, byte[] output) {
 75         vectorExpandShrink(BSPEC128, BSPEC64, input, output);
 76     }
 77 
 78     @Run(test = "testB128toB64")
 79     public static void runB128toB64() throws Throwable {
 80         runExpandShrinkHelper(BSPEC128, BSPEC64);
 81     }
 82 
 83     @Test
 84     @IR(counts = {REINTERPRET_NODE, "1"})
 85     public static void testB128toB256(byte[] input, byte[] output) {
 86         vectorExpandShrink(BSPEC128, BSPEC256, input, output);
 87     }
 88 
 89     @Run(test = "testB128toB256")
 90     public static void runB128toB256() throws Throwable {
 91         runExpandShrinkHelper(BSPEC128, BSPEC256);
 92     }
 93 
 94     @Test
 95     @IR(counts = {REINTERPRET_NODE, "1"})
 96     public static void testB128toB512(byte[] input, byte[] output) {
 97         vectorExpandShrink(BSPEC128, BSPEC512, input, output);
 98     }
 99 
100     @Run(test = "testB128toB512")
101     public static void runB128toB512() throws Throwable {
102         runExpandShrinkHelper(BSPEC128, BSPEC512);
103     }
104 
105     @Test
106     @IR(counts = {REINTERPRET_NODE, "1"})
107     public static void testB256toB64(byte[] input, byte[] output) {
108         vectorExpandShrink(BSPEC256, BSPEC64, input, output);
109     }
110 
111     @Run(test = "testB256toB64")
112     public static void runB256toB64() throws Throwable {
113         runExpandShrinkHelper(BSPEC256, BSPEC64);
114     }
115 
116     @Test
117     @IR(counts = {REINTERPRET_NODE, "1"})
118     public static void testB256toB128(byte[] input, byte[] output) {
119         vectorExpandShrink(BSPEC256, BSPEC128, input, output);
120     }
121 
122     @Run(test = "testB256toB128")
123     public static void runB256toB128() throws Throwable {
124         runExpandShrinkHelper(BSPEC256, BSPEC128);
125     }
126 
127     @Test
128     @IR(counts = {REINTERPRET_NODE, "1"})
129     public static void testB256toB512(byte[] input, byte[] output) {
130         vectorExpandShrink(BSPEC256, BSPEC512, input, output);
131     }
132 
133     @Run(test = "testB256toB512")
134     public static void runB256toB512() throws Throwable {
135         runExpandShrinkHelper(BSPEC256, BSPEC512);
136     }
137 
138     @Test
139     @IR(counts = {REINTERPRET_NODE, "1"})
140     public static void testB512toB64(byte[] input, byte[] output) {
141         vectorExpandShrink(BSPEC512, BSPEC64, input, output);
142     }
143 
144     @Run(test = "testB512toB64")
145     public static void runB512toB64() throws Throwable {
146         runExpandShrinkHelper(BSPEC512, BSPEC64);
147     }
148 
149     @Test
150     @IR(counts = {REINTERPRET_NODE, "1"})
151     public static void testB512toB128(byte[] input, byte[] output) {
152         vectorExpandShrink(BSPEC512, BSPEC128, input, output);
153     }
154 
155     @Run(test = "testB512toB128")
156     public static void runB512toB128() throws Throwable {
157         runExpandShrinkHelper(BSPEC512, BSPEC128);
158     }
159 
160     @Test
161     @IR(counts = {REINTERPRET_NODE, "1"})
162     public static void testB512toB256(byte[] input, byte[] output) {
163         vectorExpandShrink(BSPEC512, BSPEC256, input, output);
164     }
165 
166     @Run(test = "testB512toB256")
167     public static void runB512toB256() throws Throwable {
168         runExpandShrinkHelper(BSPEC512, BSPEC256);
169     }
170 }