1 #!/bin/bash
  2 #
  3 # Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
  4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5 #
  6 # This code is free software; you can redistribute it and/or modify it
  7 # under the terms of the GNU General Public License version 2 only, as
  8 # published by the Free Software Foundation.  Oracle designates this
  9 # particular file as subject to the "Classpath" exception as provided
 10 # by Oracle in the LICENSE file that accompanied this code.
 11 #
 12 # This code is distributed in the hope that it will be useful, but WITHOUT
 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 14 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 15 # version 2 for more details (a copy is included in the LICENSE file that
 16 # accompanied this code).
 17 #
 18 # You should have received a copy of the GNU General Public License version
 19 # 2 along with this work; if not, write to the Free Software Foundation,
 20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 21 #
 22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 23 # or visit www.oracle.com if you need additional information or have any
 24 # questions.
 25 #
 26 
 27 generate_perf_tests=$1
 28 
 29 TEMPLATE_FOLDER="templates/"
 30 
 31 unit_output="unit_tests.template"
 32 perf_output="perf_tests.template"
 33 perf_scalar_output="perf_scalar_tests.template"
 34 
 35 unary="Unary-op"
 36 unary_masked="Unary-Masked-op"
 37 unary_scalar="Unary-Scalar-op"
 38 ternary="Ternary-op"
 39 ternary_masked="Ternary-Masked-op"
 40 ternary_broadcast="Ternary-Broadcast-op"
 41 ternary_broadcast_masked="Ternary-Broadcast-Masked-op"
 42 ternary_double_broadcast="Ternary-Double-Broadcast-op"
 43 ternary_double_broadcast_masked="Ternary-Double-Broadcast-Masked-op"
 44 ternary_scalar="Ternary-Scalar-op"
 45 binary="Binary-op"
 46 binary_masked="Binary-Masked-op"
 47 binary_broadcast="Binary-Broadcast-op"
 48 binary_broadcast_masked="Binary-Broadcast-Masked-op"
 49 binary_broadcast_long="Binary-Broadcast-Long-op"
 50 binary_broadcast_masked_long="Binary-Broadcast-Masked-Long-op"
 51 binary_scalar="Binary-Scalar-op"
 52 blend="Blend-op"
 53 test_template="Test"
 54 compare_template="Compare"
 55 compare_masked_template="Compare-Masked"
 56 compare_broadcast_template="Compare-Broadcast"
 57 reduction_scalar="Reduction-Scalar-op"
 58 reduction_scalar_func="Reduction-Scalar-op-func"
 59 reduction_scalar_masked="Reduction-Scalar-Masked-op"
 60 reduction_scalar_masked_func="Reduction-Scalar-Masked-op-func"
 61 reduction_op="Reduction-op"
 62 reduction_op_func="Reduction-op-func"
 63 reduction_op_masked="Reduction-Masked-op"
 64 reduction_op_masked_func="Reduction-Masked-op-func"
 65 unary_math_template="Unary-op-math"
 66 binary_math_template="Binary-op-math"
 67 binary_math_broadcast_template="Binary-Broadcast-op-math"
 68 bool_reduction_scalar="BoolReduction-Scalar-op"
 69 bool_reduction_template="BoolReduction-op"
 70 with_op_template="With-Op"
 71 shift_template="Shift-op"
 72 shift_masked_template="Shift-Masked-op"
 73 shift_const_template="Shift-Const-op"
 74 shift_masked_const_template="Shift-Masked-Const-op"
 75 get_template="Get-op"
 76 rearrange_template="Rearrange"
 77 compressexpand_template="CompressExpand"
 78 broadcast_template="Broadcast"
 79 zero_template="Zero"
 80 slice_template="Slice-op"
 81 slice1_template="Slice-bop"
 82 slice1_masked_template="Slice-Masked-bop"
 83 unslice_template="Unslice-op"
 84 unslice1_template="Unslice-bop"
 85 unslice1_masked_template="Unslice-Masked-bop"
 86 miscellaneous_template="Miscellaneous"
 87 
 88 function replace_variables {
 89   local filename=$1
 90   local output=$2
 91   local kernel=$3
 92   local test=$4
 93   local op=$5
 94   local init=$6
 95   local guard=$7
 96   local masked=$8
 97   local op_name=$9
 98   local kernel_smoke=${10}
 99 
100   if [ "x${kernel}" != "x" ]; then
101     local kernel_escaped=$(echo -e "$kernel" | tr '\n' '`')
102     sed "s/\[\[KERNEL\]\]/${kernel_escaped}/g" $filename > ${filename}.current1
103     cat ${filename}.current1 | tr '`' "\n" > ${filename}.current
104     rm -f "${filename}.current1"
105   else
106     cp $filename ${filename}.current
107   fi
108 
109   # Check if we need to do multiple replacements
110   # If you want to emit for an operation using lanewise(VectorOperator.**, ..) and also using dedicated instruction (e.g. add(..)), then
111   # pass the 'test' argument as "OPERATOR_NAME+func_Name" (e.g. "ADD+add")
112   # if there is a masked version available for the operation add "withMask" to 'test' argument (e.g. "ADD+add+withMask")
113   local test_func=""
114   local withMask=""
115   local tests=($(awk -F+ '{$1=$1} 1' <<< $test))
116   if [ "${tests[2]}" == "withMask" ]; then
117     test=${tests[0]}
118     test_func=${tests[1]}
119     withMask=${tests[2]}
120   elif [ "${tests[1]}" == "withMask" ]; then
121     test=""
122     test_func=${tests[0]}
123     withMask=${tests[1]}
124   elif [ "${tests[1]}" != "" ]; then
125     test=${tests[0]}
126     test_func=${tests[1]}
127   fi
128 
129   sed_prog="
130     s/\<OPTIONAL\>\(.*\)\<\\OPTIONAL\>/\1/g
131     s/\[\[TEST_TYPE\]\]/${masked}/g
132     s/\[\[TEST_OP\]\]/${op}/g
133     s/\[\[TEST_INIT\]\]/${init}/g
134     s/\[\[OP_NAME\]\]/${op_name}/g
135   "
136   sed_prog_2="$sed_prog
137     s/\[\[TEST\]\]/${test_func}/g
138     s/[.][^(]*(VectorOperators.$test_func, /.$test_func(/g
139     s/[.][^(]*(VectorOperators.$test_func,/.$test_func(/g
140     s/[.][^(]*(VectorOperators.$test_func/.$test_func(/g
141   "
142   sed_prog="
143     $sed_prog
144     s/\[\[TEST\]\]/${test}/g
145   "
146 
147   # Guard the test if necessary
148   if [ "$guard" != "" ]; then
149     echo -e "#if[${guard}]" >> $output
150   fi
151   if [ "$test" != "" ]; then
152     sed -e "$sed_prog" < ${filename}.current >> $output
153   fi
154   # If we also have a dedicated function for the operation then use 2nd sed expression
155   if [[ "$filename" == *"Unit"* ]] && [ "$test_func" != "" ]; then
156     if [ "$masked" == "" ] || [ "$withMask" != "" ]; then
157       if [ ! -z "$kernel_smoke" ]; then
158         local kernel_smoke_escaped=$(echo -e "$kernel_smoke" | tr '\n' '`')
159         sed "s/\[\[KERNEL\]\]/${kernel_smoke_escaped}/g" $filename > ${filename}.scurrent1
160         cat ${filename}.scurrent1 | tr '`' "\n" > ${filename}.scurrent
161         rm -f "${filename}.scurrent1"
162       else
163         cp $filename.current ${filename}.scurrent
164       fi
165       sed -e "$sed_prog_2" < ${filename}.scurrent >> $output
166       rm -f ${filename}.scurrent
167     fi
168   fi
169   if [ "$guard" != "" ]; then
170     echo -e "#end[${guard}]" >> $output
171   fi
172 
173   rm -f ${filename}.current
174 }
175 
176 function gen_op_tmpl {
177   local template=$1
178   local test=$2
179   local op=$3
180   local guard=""
181   local init=""
182   if [ $# -gt 3 ]; then
183     guard=$4
184   fi
185   if [ $# == 5 ]; then
186     init=$5
187   fi
188 
189   local masked=""
190   if [[ $template == *"Masked"* ]]; then
191     masked="Masked"
192   fi
193 
194   local op_name=""
195   if [[ $template == *"Shift"* ]]; then
196     op_name="Shift"
197   elif [[ $template == *"Get"* ]]; then
198     op_name="extract"
199   fi
200 
201   local kernel_filename="${TEMPLATE_FOLDER}/Kernel-${template}.template"
202   local kernel_smoke_filename="${TEMPLATE_FOLDER}/Kernel-${template}-smoke.template"
203   local unit_filename="${TEMPLATE_FOLDER}/Unit-${template}.template"
204   if [ ! -f $unit_filename ]; then
205     # Leverage general unit code snippet if no specialization exists
206     unit_filename="${TEMPLATE_FOLDER}/Unit-${template%_*}.template"
207     echo $unit_filename
208   fi
209 
210   local kernel=""
211   if [ -f $kernel_filename ]; then
212     kernel="$(cat $kernel_filename)"
213   fi
214 
215   local kernel_smoke=""
216   if [ -f $kernel_smoke_filename ]; then
217     kernel_smoke="$(cat $kernel_smoke_filename)"
218   else
219     kernel_smoke="$kernel"
220   fi
221 
222   # Replace template variables in unit test files (if any)
223   replace_variables $unit_filename $unit_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" "$kernel_smoke"
224 
225   local gen_perf_tests=$generate_perf_tests
226   if [[ $template == *"-Broadcast-"* ]] || [[ $template == "Miscellaneous" ]] ||
227      [[ $template == *"Compare-Masked"* ]] || [[ $template == *"Compare-Broadcast"* ]]; then
228     gen_perf_tests=false
229   fi
230   if [ $gen_perf_tests == true ]; then
231     # Replace template variables in performance test files (if any)
232     local perf_wrapper_filename="${TEMPLATE_FOLDER}/Perf-wrapper.template"
233     local perf_vector_filename="${TEMPLATE_FOLDER}/Perf-${template}.template"
234     local perf_scalar_filename="${TEMPLATE_FOLDER}/Perf-Scalar-${template}.template"
235 
236     if [ -f $perf_vector_filename ]; then
237       replace_variables $perf_vector_filename  $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
238     elif [ -f $kernel_filename ]; then
239       replace_variables $perf_wrapper_filename $perf_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
240     elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
241       echo "Warning: missing perf: $@"
242     fi
243 
244     if [ -f $perf_scalar_filename ]; then
245       replace_variables $perf_scalar_filename $perf_scalar_output "$kernel" "$test" "$op" "$init" "$guard" "$masked" "$op_name" ""
246     elif [[ $template != *"-Scalar-"* ]] && [[ $template != "Get-op" ]] && [[ $template != "With-Op" ]]; then
247       echo "Warning: Missing PERF SCALAR: $perf_scalar_filename"
248     fi
249   fi
250 }
251 
252 function gen_binary_alu_op {
253   echo "Generating binary op $1 ($2)..."
254   gen_op_tmpl $binary "$@"
255   gen_op_tmpl $binary_masked "$@"
256 }
257 
258 function gen_binary_alu_bcst_op {
259   echo "Generating binary broadcast op $1 ($2)..."
260   gen_op_tmpl $binary_broadcast "$@"
261   gen_op_tmpl $binary_broadcast_masked "$@"
262 }
263 
264 function gen_binary_alu_bcst_long_op {
265   echo "Generating binary broadcast long op $1 ($2)..."
266   gen_op_tmpl $binary_broadcast_long "$@"
267   gen_op_tmpl $binary_broadcast_masked_long "$@"
268 }
269 
270 function gen_shift_op {
271   echo "Generating Shift constant op $1 ($2)..."
272   gen_op_tmpl $shift_template "$@"
273   gen_op_tmpl $shift_masked_template "$@"
274 }
275 
276 function gen_shift_cst_op {
277   echo "Generating Shift constant op $1 ($2)..."
278   gen_op_tmpl $shift_const_template "$@"
279   gen_op_tmpl $shift_masked_const_template "$@"
280 }
281 
282 function gen_unary_alu_op {
283   echo "Generating unary op $1 ($2)..."
284   gen_op_tmpl $unary_scalar "$@"
285   gen_op_tmpl $unary "$@"
286   gen_op_tmpl $unary_masked "$@"
287 }
288 
289 function gen_ternary_alu_op {
290   echo "Generating ternary op $1 ($2)..."
291   gen_op_tmpl $ternary_scalar "$@"
292   gen_op_tmpl $ternary "$@"
293   gen_op_tmpl $ternary_masked "$@"
294 }
295 
296 function gen_ternary_alu_bcst_op {
297   echo "Generating ternary broadcast op $1 ($2)..."
298   gen_op_tmpl $ternary_broadcast "$@"
299   gen_op_tmpl $ternary_broadcast_masked "$@"
300 }
301 
302 function gen_ternary_alu_double_bcst_op {
303   echo "Generating ternary double broadcast op $1 ($2)..."
304   gen_op_tmpl $ternary_double_broadcast "$@"
305   gen_op_tmpl $ternary_double_broadcast_masked "$@"
306 }
307 
308 function gen_binary_op {
309   echo "Generating binary op $1 ($2)..."
310 #  gen_op_tmpl $binary_scalar "$@"
311   gen_op_tmpl $binary "$@"
312   gen_op_tmpl $binary_masked "$@"
313 }
314 
315 function gen_binary_op_no_masked {
316   echo "Generating binary op $1 ($2)..."
317 #  gen_op_tmpl $binary_scalar "$@"
318   gen_op_tmpl $binary "$@"
319 }
320 
321 function gen_binary_bcst_op_no_masked {
322   echo "Generating binary broadcast op $1 ($2)..."
323   gen_op_tmpl $binary_broadcast "$@"
324 }
325 
326 function gen_compare_op {
327   echo "Generating compare op $1 ($2)..."
328   gen_op_tmpl $compare_template "$@"
329   gen_op_tmpl $compare_masked_template "$@"
330 }
331 
332 function gen_compare_bcst_op {
333   echo "Generating compare broadcast op $1 ($2)..."
334   gen_op_tmpl $compare_broadcast_template "$@"
335 }
336 
337 function gen_reduction_op {
338   echo "Generating reduction op $1 ($2)..."
339   gen_op_tmpl $reduction_scalar "$@"
340   gen_op_tmpl $reduction_op "$@"
341   gen_op_tmpl $reduction_scalar_masked "$@"
342   gen_op_tmpl $reduction_op_masked "$@"
343 }
344 
345 function gen_reduction_op_func {
346   echo "Generating reduction op $1 ($2)..."
347   gen_op_tmpl $reduction_scalar_func "$@"
348   gen_op_tmpl $reduction_op_func "$@"
349   gen_op_tmpl $reduction_scalar_masked_func "$@"
350   gen_op_tmpl $reduction_op_masked_func "$@"
351 }
352 
353 function gen_bool_reduction_op {
354   echo "Generating boolean reduction op $1 ($2)..."
355   gen_op_tmpl $bool_reduction_scalar "$@"
356   gen_op_tmpl $bool_reduction_template "$@"
357 }
358 
359 function gen_with_op {
360   echo "Generating with op $1 ($2)..."
361   gen_op_tmpl $with_op_template "$@"
362 }
363 
364 function gen_get_op {
365   echo "Generating get op $1 ($2)..."
366   gen_op_tmpl $get_template "$@"
367 }
368 
369 function gen_unit_header {
370   cat $TEMPLATE_FOLDER/Unit-header.template > $1
371 }
372 
373 function gen_unit_footer {
374   cat $TEMPLATE_FOLDER/Unit-footer.template >> $1
375 }
376 
377 function gen_perf_header {
378   cat $TEMPLATE_FOLDER/Perf-header.template > $1
379 }
380 
381 function gen_perf_footer {
382   cat $TEMPLATE_FOLDER/Perf-footer.template >> $1
383 }
384 
385 function gen_perf_scalar_header {
386   cat $TEMPLATE_FOLDER/Perf-Scalar-header.template > $1
387 }
388 
389 function gen_perf_scalar_footer {
390   cat $TEMPLATE_FOLDER/Perf-Scalar-footer.template >> $1
391 }
392 
393 gen_unit_header $unit_output
394 
395 if [ $generate_perf_tests == true ]; then
396   gen_perf_header $perf_output
397   gen_perf_scalar_header $perf_scalar_output
398 fi
399 
400 # ALU binary ops.
401 # Here "ADD+add+withMask" says VectorOperator name is "ADD", and we have a dedicate method too named 'add', and add() is also available with mask variant.
402 gen_binary_alu_op "ADD+add+withMask" "a + b"
403 gen_binary_alu_op "SUB+sub+withMask" "a - b"
404 gen_binary_alu_op "MUL+mul+withMask" "a \* b"
405 gen_binary_alu_op "DIV+div+withMask" "a \/ b" "FP"
406 gen_op_tmpl "Binary-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE"
407 gen_op_tmpl "Binary-Masked-op_bitwise-div" "DIV+div+withMask" "a \/ b" "BITWISE"
408 gen_binary_alu_op "FIRST_NONZERO" "{#if[FP]?Double.doubleToLongBits}(a)!=0?a:b"
409 gen_binary_alu_op "AND+and"   "a \& b"  "BITWISE"
410 gen_binary_alu_op "AND_NOT" "a \& ~b" "BITWISE"
411 gen_binary_alu_op "OR+or"    "a | b"   "BITWISE"
412 # Missing:        "OR_UNCHECKED"
413 gen_binary_alu_op "XOR"   "a ^ b"   "BITWISE"
414 gen_binary_alu_op "COMPRESS_BITS" "\$Boxtype\$.compress(a, b)" "intOrLong"
415 gen_binary_alu_op "EXPAND_BITS" "\$Boxtype\$.expand(a, b)" "intOrLong"
416 # Generate the broadcast versions
417 gen_binary_alu_bcst_op "add+withMask" "a + b"
418 gen_binary_alu_bcst_op "sub+withMask" "a - b"
419 gen_binary_alu_bcst_op "mul+withMask" "a \* b"
420 gen_binary_alu_bcst_op "div+withMask" "a \/ b" "FP"
421 gen_op_tmpl "Binary-Broadcast-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE"
422 gen_op_tmpl "Binary-Broadcast-Masked-op_bitwise-div" "div+withMask" "a \/ b" "BITWISE"
423 gen_binary_alu_bcst_op "OR+or"    "a | b"   "BITWISE"
424 gen_binary_alu_bcst_op "AND+and"    "a \& b"   "BITWISE"
425 gen_binary_alu_bcst_long_op "OR"     "a | b"   "BITWISE"
426 gen_binary_alu_bcst_long_op "ADD"    "a + b"
427 
428 # Shifts
429 gen_binary_alu_op "LSHL" "(a << b)" "intOrLong"
430 gen_binary_alu_op "LSHL" "(a << (b \& 0x7))" "byte"
431 gen_binary_alu_op "LSHL" "(a << (b \& 0xF))" "short"
432 gen_binary_alu_op "ASHR" "(a >> b)" "intOrLong"
433 gen_binary_alu_op "ASHR" "(a >> (b \& 0x7))" "byte"
434 gen_binary_alu_op "ASHR" "(a >> (b \& 0xF))" "short"
435 gen_binary_alu_op "LSHR" "(a >>> b)" "intOrLong"
436 gen_binary_alu_op "LSHR" "((a \& 0xFF) >>> (b \& 0x7))" "byte"
437 gen_binary_alu_op "LSHR" "((a \& 0xFFFF) >>> (b \& 0xF))" "short"
438 gen_shift_op  "LSHL" "(a << b)" "intOrLong"
439 gen_shift_op  "LSHL" "(a << (b \& 7))" "byte"
440 gen_shift_op  "LSHL" "(a << (b \& 15))" "short"
441 gen_shift_op  "LSHR" "(a >>> b)" "intOrLong"
442 gen_shift_op  "LSHR" "((a \& 0xFF) >>> (b \& 7))" "byte"
443 gen_shift_op  "LSHR" "((a \& 0xFFFF) >>> (b \& 15))" "short"
444 gen_shift_op  "ASHR" "(a >> b)" "intOrLong"
445 gen_shift_op  "ASHR" "(a >> (b \& 7))" "byte"
446 gen_shift_op  "ASHR" "(a >> (b \& 15))" "short"
447 gen_binary_alu_op "ROR" "ROR_scalar(a,b)" "BITWISE"
448 gen_binary_alu_op "ROL" "ROL_scalar(a,b)" "BITWISE"
449 gen_shift_op  "ROR" "ROR_scalar(a, b)" "BITWISE"
450 gen_shift_op  "ROL" "ROL_scalar(a, b)" "BITWISE"
451 
452 # Constant Shifts
453 gen_shift_cst_op  "LSHR" "(a >>> CONST_SHIFT)" "intOrLong"
454 gen_shift_cst_op  "LSHR" "((a \& 0xFF) >>> CONST_SHIFT)" "byte"
455 gen_shift_cst_op  "LSHR" "((a \& 0xFFFF) >>> CONST_SHIFT)" "short"
456 gen_shift_cst_op  "LSHL" "(a << CONST_SHIFT)" "BITWISE"
457 gen_shift_cst_op  "ASHR" "(a >> CONST_SHIFT)" "BITWISE"
458 gen_shift_cst_op  "ROR" "ROR_scalar(a, CONST_SHIFT)" "BITWISE"
459 gen_shift_cst_op  "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE"
460 
461 # Masked reductions.
462 gen_binary_op_no_masked "MIN+min" "Math.min(a, b)"
463 gen_binary_op_no_masked "MAX+max" "Math.max(a, b)"
464 gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)"
465 gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)"
466 
467 # Reductions.
468 gen_reduction_op "AND" "\&" "BITWISE" "-1"
469 gen_reduction_op "OR" "|" "BITWISE" "0"
470 gen_reduction_op "XOR" "^" "BITWISE" "0"
471 gen_reduction_op "ADD" "+" "" "0"
472 gen_reduction_op "MUL" "*" "" "1"
473 gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "\$Wideboxtype\$.\$MaxValue\$"
474 gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "\$Wideboxtype\$.\$MinValue\$"
475 gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0"
476 
477 # Boolean reductions.
478 gen_bool_reduction_op "anyTrue" "|" "BITWISE" "false"
479 gen_bool_reduction_op "allTrue" "\&" "BITWISE" "true"
480 
481 #Insert
482 gen_with_op "withLane" "" "" ""
483 
484 # Tests
485 gen_op_tmpl $test_template "IS_DEFAULT" "bits(a)==0"
486 gen_op_tmpl $test_template "IS_NEGATIVE" "bits(a)<0"
487 gen_op_tmpl $test_template "IS_FINITE" "\$Boxtype\$.isFinite(a)" "FP"
488 gen_op_tmpl $test_template "IS_NAN" "\$Boxtype\$.isNaN(a)" "FP"
489 gen_op_tmpl $test_template "IS_INFINITE" "\$Boxtype\$.isInfinite(a)" "FP"
490 
491 # Compares
492 gen_compare_op "LT+lt" "lt"
493 gen_compare_op "GT" "gt"
494 gen_compare_op "EQ+eq" "eq"
495 gen_compare_op "NE" "neq"
496 gen_compare_op "LE" "le"
497 gen_compare_op "GE" "ge"
498 
499 gen_compare_op "UNSIGNED_LT" "ult" "BITWISE"
500 gen_compare_op "UNSIGNED_GT" "ugt" "BITWISE"
501 gen_compare_op "UNSIGNED_LE" "ule" "BITWISE"
502 gen_compare_op "UNSIGNED_GE" "uge" "BITWISE"
503 
504 
505 gen_compare_bcst_op "LT" "<"
506 gen_compare_bcst_op "EQ" "=="
507 
508 # Blend.
509 gen_op_tmpl $blend "blend" ""
510 
511 # Rearrange
512 gen_op_tmpl $rearrange_template "rearrange" ""
513 
514 # Compress/Expand
515 gen_op_tmpl $compressexpand_template "compress_expand" ""
516 
517 # Get
518 gen_get_op "lane" ""
519 
520 # Broadcast
521 gen_op_tmpl $broadcast_template "broadcast" ""
522 
523 # Zero
524 gen_op_tmpl $zero_template "zero" ""
525 
526 # Slice
527 gen_op_tmpl $slice_template "sliceUnary" ""
528 gen_op_tmpl $slice1_template "sliceBinary" ""
529 gen_op_tmpl $slice1_masked_template "slice" ""
530 
531 # Unslice
532 gen_op_tmpl $unslice_template "unsliceUnary" ""
533 gen_op_tmpl $unslice1_template "unsliceBinary" ""
534 gen_op_tmpl $unslice1_masked_template "unslice" ""
535 
536 # Math
537 gen_op_tmpl $unary_math_template "SIN" "Math.sin((double)a)" "FP"
538 gen_op_tmpl $unary_math_template "EXP" "Math.exp((double)a)" "FP"
539 gen_op_tmpl $unary_math_template "LOG1P" "Math.log1p((double)a)" "FP"
540 gen_op_tmpl $unary_math_template "LOG" "Math.log((double)a)" "FP"
541 gen_op_tmpl $unary_math_template "LOG10" "Math.log10((double)a)" "FP"
542 gen_op_tmpl $unary_math_template "EXPM1" "Math.expm1((double)a)" "FP"
543 gen_op_tmpl $unary_math_template "COS" "Math.cos((double)a)" "FP"
544 gen_op_tmpl $unary_math_template "TAN" "Math.tan((double)a)" "FP"
545 gen_op_tmpl $unary_math_template "SINH" "Math.sinh((double)a)" "FP"
546 gen_op_tmpl $unary_math_template "COSH" "Math.cosh((double)a)" "FP"
547 gen_op_tmpl $unary_math_template "TANH" "Math.tanh((double)a)" "FP"
548 gen_op_tmpl $unary_math_template "ASIN" "Math.asin((double)a)" "FP"
549 gen_op_tmpl $unary_math_template "ACOS" "Math.acos((double)a)" "FP"
550 gen_op_tmpl $unary_math_template "ATAN" "Math.atan((double)a)" "FP"
551 gen_op_tmpl $unary_math_template "CBRT" "Math.cbrt((double)a)" "FP"
552 gen_op_tmpl $binary_math_template "HYPOT" "Math.hypot((double)a, (double)b)" "FP"
553 gen_op_tmpl $binary_math_template "POW+pow" "Math.pow((double)a, (double)b)" "FP"
554 gen_op_tmpl $binary_math_template "ATAN2" "Math.atan2((double)a, (double)b)" "FP"
555 gen_op_tmpl $binary_math_broadcast_template "POW+pow" "Math.pow((double)a, (double)b)" "FP"
556 
557 # Ternary operations.
558 gen_ternary_alu_op "FMA+fma" "Math.fma(a, b, c)" "FP"
559 gen_ternary_alu_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE"
560 gen_ternary_alu_bcst_op "FMA" "Math.fma(a, b, c)" "FP"
561 gen_ternary_alu_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE"
562 gen_ternary_alu_double_bcst_op "FMA+fma" "Math.fma(a, b, c)" "FP"
563 gen_ternary_alu_double_bcst_op "BITWISE_BLEND+bitwiseBlend" "(a\&~(c))|(b\&c)" "BITWISE"
564 
565 # Unary operations.
566 gen_unary_alu_op "NEG+neg" "-((\$type\$)a)"
567 gen_unary_alu_op "ABS+abs" "Math.abs((\$type\$)a)"
568 gen_unary_alu_op "NOT+not" "~((\$type\$)a)" "BITWISE"
569 gen_unary_alu_op "ZOMO" "(a==0?0:-1)" "BITWISE"
570 gen_unary_alu_op "SQRT+sqrt" "Math.sqrt((double)a)" "FP"
571 gen_unary_alu_op "BIT_COUNT" "\$Boxtype\$.bitCount(a)" "intOrLong"
572 gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFF)" "byte"
573 gen_unary_alu_op "BIT_COUNT" "Integer.bitCount((int)a \& 0xFFFF)" "short"
574 gen_unary_alu_op "TRAILING_ZEROS_COUNT" "TRAILING_ZEROS_COUNT_scalar(a)" "BITWISE"
575 gen_unary_alu_op "LEADING_ZEROS_COUNT" "LEADING_ZEROS_COUNT_scalar(a)" "BITWISE"
576 gen_unary_alu_op "REVERSE" "REVERSE_scalar(a)" "BITWISE"
577 gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "intOrLong"
578 gen_unary_alu_op "REVERSE_BYTES" "\$Boxtype\$.reverseBytes(a)" "short"
579 gen_unary_alu_op "REVERSE_BYTES" "a" "byte"
580 
581 # Miscellaneous Smoke Tests
582 gen_op_tmpl $miscellaneous_template "MISC" "" ""
583 
584 gen_unit_footer $unit_output
585 
586 if [ $generate_perf_tests == true ]; then
587   gen_perf_footer $perf_output
588   gen_perf_scalar_footer $perf_scalar_output
589 fi
590 
591 rm -f templates/*.current*