1 /*
  2  * Copyright (c) 2021, 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.
  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.utils;
 25 
 26 import java.util.List;
 27 import java.util.stream.Stream;
 28 
 29 import static compiler.vectorapi.reshape.utils.VectorReshapeHelper.*;
 30 import static compiler.vectorapi.reshape.utils.VectorSpeciesPair.makePair;
 31 
 32 /**
 33  * The cast intrinsics implemented on each platform.
 34  */
 35 public class TestCastMethods {
 36     public static final List<VectorSpeciesPair> AVX1_CAST_TESTS = List.of(
 37             makePair(BSPEC64, SSPEC64),
 38             makePair(BSPEC64, SSPEC128),
 39             makePair(BSPEC64, ISPEC128),
 40             makePair(BSPEC64, FSPEC128),
 41             makePair(BSPEC64, DSPEC256),
 42             makePair(SSPEC64, BSPEC64),
 43             makePair(SSPEC128, BSPEC64),
 44             makePair(SSPEC64, ISPEC64),
 45             makePair(SSPEC64, ISPEC128),
 46             makePair(SSPEC64, LSPEC128),
 47             makePair(SSPEC64, FSPEC64),
 48             makePair(SSPEC64, FSPEC128),
 49             makePair(SSPEC64, DSPEC128),
 50             makePair(SSPEC64, DSPEC256),
 51             makePair(ISPEC128, BSPEC64),
 52             makePair(ISPEC64, SSPEC64),
 53             makePair(ISPEC128, SSPEC64),
 54             makePair(ISPEC64, LSPEC128),
 55             makePair(ISPEC64, FSPEC64),
 56             makePair(ISPEC128, FSPEC128),
 57             makePair(ISPEC64, DSPEC128),
 58             makePair(ISPEC128, DSPEC256),
 59             makePair(LSPEC128, SSPEC64),
 60             makePair(LSPEC128, ISPEC64),
 61             makePair(FSPEC64, ISPEC64),
 62             makePair(FSPEC128, ISPEC128),
 63             makePair(FSPEC64, DSPEC128),
 64             makePair(FSPEC128, DSPEC256),
 65             makePair(FSPEC128, SSPEC64),
 66             makePair(DSPEC128, FSPEC64),
 67             makePair(DSPEC256, FSPEC128),
 68             makePair(DSPEC128, ISPEC64),
 69             makePair(BSPEC64, SSPEC64, true),
 70             makePair(BSPEC64, SSPEC128, true),
 71             makePair(BSPEC64, ISPEC128, true),
 72             makePair(SSPEC64, ISPEC64, true),
 73             makePair(SSPEC64, ISPEC128, true),
 74             makePair(SSPEC64, LSPEC128, true),
 75             makePair(ISPEC64, LSPEC128, true)
 76     );
 77 
 78     public static final List<VectorSpeciesPair> AVX2_CAST_TESTS = Stream.concat(AVX1_CAST_TESTS.stream(), Stream.of(
 79             makePair(DSPEC256, ISPEC128),
 80             makePair(DSPEC256, SSPEC64),
 81             makePair(FSPEC256, ISPEC256),
 82             makePair(FSPEC256, SSPEC128),
 83             makePair(FSPEC256, BSPEC64),
 84             makePair(BSPEC128, SSPEC256),
 85             makePair(BSPEC64, ISPEC256),
 86             makePair(BSPEC64, LSPEC256),
 87             makePair(BSPEC64, FSPEC256),
 88             makePair(SSPEC256, BSPEC128),
 89             makePair(SSPEC128, ISPEC256),
 90             makePair(SSPEC64, LSPEC256),
 91             makePair(SSPEC128, FSPEC256),
 92             makePair(ISPEC256, BSPEC64),
 93             makePair(ISPEC256, SSPEC128),
 94             makePair(ISPEC128, LSPEC256),
 95             makePair(ISPEC256, FSPEC256),
 96             makePair(LSPEC256, BSPEC64),
 97             makePair(LSPEC256, SSPEC64),
 98             makePair(LSPEC256, ISPEC128),
 99             makePair(BSPEC128, SSPEC256, true),
100             makePair(BSPEC64, ISPEC256, true),
101             makePair(BSPEC64, LSPEC256, true),
102             makePair(SSPEC128, ISPEC256, true),
103             makePair(SSPEC64, LSPEC256, true),
104             makePair(ISPEC128, LSPEC256, true)
105     )).toList();
106 
107     public static final List<VectorSpeciesPair> AVX512_CAST_TESTS = Stream.concat(AVX2_CAST_TESTS.stream(), Stream.of(
108             makePair(BSPEC128, ISPEC512),
109             makePair(BSPEC64, LSPEC512),
110             makePair(BSPEC128, FSPEC512),
111             makePair(BSPEC64, DSPEC512),
112             makePair(SSPEC256, ISPEC512),
113             makePair(SSPEC128, LSPEC512),
114             makePair(SSPEC256, FSPEC512),
115             makePair(SSPEC128, DSPEC512),
116             makePair(ISPEC512, BSPEC128),
117             makePair(ISPEC512, SSPEC256),
118             makePair(ISPEC256, LSPEC512),
119             makePair(ISPEC512, FSPEC512),
120             makePair(ISPEC256, DSPEC512),
121             makePair(LSPEC512, BSPEC64),
122             makePair(LSPEC512, SSPEC128),
123             makePair(LSPEC512, ISPEC256),
124             makePair(FSPEC256, DSPEC512),
125             makePair(DSPEC512, FSPEC256),
126             makePair(DSPEC512, ISPEC256),
127             makePair(DSPEC512, SSPEC128),
128             makePair(DSPEC512, BSPEC64),
129             makePair(FSPEC512, ISPEC512),
130             makePair(FSPEC512, SSPEC256),
131             makePair(FSPEC512, BSPEC128),
132             makePair(BSPEC128, ISPEC512, true),
133             makePair(BSPEC64, LSPEC512, true),
134             makePair(SSPEC256, ISPEC512, true),
135             makePair(SSPEC128, LSPEC512, true),
136             makePair(ISPEC256, LSPEC512, true)
137     )).toList();
138 
139     public static final List<VectorSpeciesPair> AVX512BW_CAST_TESTS = Stream.concat(AVX512_CAST_TESTS.stream(), Stream.of(
140             makePair(BSPEC256, SSPEC512),
141             makePair(SSPEC512, BSPEC256),
142             makePair(BSPEC256, SSPEC512, true)
143     )).toList();
144 
145     public static final List<VectorSpeciesPair> AVX512DQ_CAST_TESTS = Stream.concat(AVX512_CAST_TESTS.stream(), Stream.of(
146             makePair(LSPEC128, DSPEC128),
147             makePair(LSPEC256, DSPEC256),
148             makePair(LSPEC512, DSPEC512),
149             makePair(DSPEC128, LSPEC128),
150             makePair(DSPEC256, LSPEC256),
151             makePair(DSPEC512, LSPEC512)
152     )).toList();
153 
154     public static final List<VectorSpeciesPair> SVE_CAST_TESTS = List.of(
155             makePair(BSPEC64, SSPEC128),
156             makePair(BSPEC128, SSPEC256),
157             makePair(BSPEC256, SSPEC512),
158             makePair(BSPEC64, ISPEC256),
159             makePair(BSPEC128, ISPEC512),
160             makePair(BSPEC64, LSPEC512),
161             makePair(BSPEC64, FSPEC256),
162             makePair(BSPEC128, FSPEC512),
163             makePair(BSPEC64, DSPEC512),
164             makePair(SSPEC128, BSPEC64),
165             makePair(SSPEC256, BSPEC128),
166             makePair(SSPEC512, BSPEC256),
167             makePair(SSPEC64, ISPEC128),
168             makePair(SSPEC128, ISPEC256),
169             makePair(SSPEC256, ISPEC512),
170             makePair(SSPEC64, LSPEC256),
171             makePair(SSPEC128, LSPEC512),
172             makePair(SSPEC64, FSPEC128),
173             makePair(SSPEC128, FSPEC256),
174             makePair(SSPEC256, FSPEC512),
175             makePair(SSPEC64, DSPEC256),
176             makePair(SSPEC128, DSPEC512),
177             makePair(ISPEC256, BSPEC64),
178             makePair(ISPEC512, BSPEC128),
179             makePair(ISPEC128, SSPEC64),
180             makePair(ISPEC256, SSPEC128),
181             makePair(ISPEC512, SSPEC256),
182             makePair(ISPEC64, LSPEC128),
183             makePair(ISPEC128, LSPEC256),
184             makePair(ISPEC256, LSPEC512),
185             makePair(ISPEC64, FSPEC64),
186             makePair(ISPEC128, FSPEC128),
187             makePair(ISPEC256, FSPEC256),
188             makePair(ISPEC512, FSPEC512),
189             makePair(ISPEC64, DSPEC128),
190             makePair(ISPEC128, DSPEC256),
191             makePair(ISPEC256, DSPEC512),
192             makePair(LSPEC512, BSPEC64),
193             makePair(LSPEC256, SSPEC64),
194             makePair(LSPEC512, SSPEC128),
195             makePair(LSPEC128, ISPEC64),
196             makePair(LSPEC256, ISPEC128),
197             makePair(LSPEC512, ISPEC256),
198             makePair(LSPEC128, FSPEC64),
199             makePair(LSPEC256, FSPEC128),
200             makePair(LSPEC512, FSPEC256),
201             makePair(LSPEC128, DSPEC128),
202             makePair(LSPEC256, DSPEC256),
203             makePair(LSPEC512, DSPEC512),
204             makePair(FSPEC256, BSPEC64),
205             makePair(FSPEC512, BSPEC128),
206             makePair(FSPEC128, SSPEC64),
207             makePair(FSPEC256, SSPEC128),
208             makePair(FSPEC512, SSPEC256),
209             makePair(FSPEC64, ISPEC64),
210             makePair(FSPEC128, ISPEC128),
211             makePair(FSPEC256, ISPEC256),
212             makePair(FSPEC512, ISPEC512),
213             makePair(FSPEC64, LSPEC128),
214             makePair(FSPEC128, LSPEC256),
215             makePair(FSPEC256, LSPEC512),
216             makePair(FSPEC64, DSPEC128),
217             makePair(FSPEC128, DSPEC256),
218             makePair(FSPEC256, DSPEC512),
219             makePair(DSPEC512, BSPEC64),
220             makePair(DSPEC256, SSPEC64),
221             makePair(DSPEC512, SSPEC128),
222             makePair(DSPEC128, ISPEC64),
223             makePair(DSPEC256, ISPEC128),
224             makePair(DSPEC512, ISPEC256),
225             makePair(DSPEC128, LSPEC128),
226             makePair(DSPEC256, LSPEC256),
227             makePair(DSPEC512, LSPEC512),
228             makePair(DSPEC128, FSPEC64),
229             makePair(DSPEC256, FSPEC128),
230             makePair(DSPEC512, FSPEC256)
231     );
232 
233     public static final List<VectorSpeciesPair> NEON_CAST_TESTS = List.of(
234             makePair(BSPEC64, SSPEC64),
235             makePair(BSPEC64, SSPEC128),
236             makePair(BSPEC64, ISPEC128),
237             makePair(BSPEC64, FSPEC128),
238             makePair(SSPEC64, BSPEC64),
239             makePair(SSPEC128, BSPEC64),
240             makePair(SSPEC64, ISPEC128),
241             makePair(SSPEC64, FSPEC128),
242             makePair(ISPEC128, BSPEC64),
243             makePair(ISPEC128, SSPEC64),
244             makePair(ISPEC64, LSPEC128),
245             makePair(ISPEC64, FSPEC64),
246             makePair(ISPEC128, FSPEC128),
247             makePair(ISPEC64, DSPEC128),
248             makePair(LSPEC128, ISPEC64),
249             makePair(LSPEC128, FSPEC64),
250             makePair(LSPEC128, DSPEC128),
251             makePair(FSPEC128, BSPEC64),
252             makePair(FSPEC128, SSPEC64),
253             makePair(FSPEC64, ISPEC64),
254             makePair(FSPEC128, ISPEC128),
255             makePair(FSPEC64, LSPEC128),
256             makePair(FSPEC64, DSPEC128),
257             makePair(DSPEC128, ISPEC64),
258             makePair(DSPEC128, LSPEC128),
259             makePair(DSPEC128, FSPEC64)
260     );
261 }