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