Implement asin and acos in RP codegen.

The results were visually verified on the viewer runtime trig slide.

Change-Id: I3953e2839466719b3774043e7042e2b6a253a7fc
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/658020
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
diff --git a/src/core/SkRasterPipelineOpList.h b/src/core/SkRasterPipelineOpList.h
index 1dccd96..d1246b4 100644
--- a/src/core/SkRasterPipelineOpList.h
+++ b/src/core/SkRasterPipelineOpList.h
@@ -127,8 +127,9 @@
     M(abs_int)          M(abs_2_ints)          M(abs_3_ints)          M(abs_4_ints)           \
     M(floor_float)      M(floor_2_floats)      M(floor_3_floats)      M(floor_4_floats)       \
     M(ceil_float)       M(ceil_2_floats)       M(ceil_3_floats)       M(ceil_4_floats)        \
-    M(sin_float)        M(cos_float)           M(tan_float)           M(atan_float)           \
-    M(atan2_n_floats)   M(sqrt_float)          M(pow_n_floats)        M(exp_float)            \
+    M(sin_float)        M(cos_float)           M(tan_float)                                   \
+    M(asin_float)       M(acos_float)          M(atan_float)          M(atan2_n_floats)       \
+    M(sqrt_float)       M(pow_n_floats)        M(exp_float)                                   \
     M(copy_constant)    M(copy_2_constants)    M(copy_3_constants)    M(copy_4_constants)     \
     M(copy_slot_masked) M(copy_2_slots_masked) M(copy_3_slots_masked) M(copy_4_slots_masked)  \
     M(copy_from_indirect_unmasked) M(copy_from_indirect_uniform_unmasked)                     \
diff --git a/src/opts/SkRasterPipeline_opts.h b/src/opts/SkRasterPipeline_opts.h
index 31cca2c..3eaeed0 100644
--- a/src/opts/SkRasterPipeline_opts.h
+++ b/src/opts/SkRasterPipeline_opts.h
@@ -3714,6 +3714,8 @@
 STAGE_TAIL(sin_float, F* dst)  { *dst = sin_(*dst); }
 STAGE_TAIL(cos_float, F* dst)  { *dst = cos_(*dst); }
 STAGE_TAIL(tan_float, F* dst)  { *dst = tan_(*dst); }
+STAGE_TAIL(asin_float, F* dst) { *dst = asin_(*dst); }
+STAGE_TAIL(acos_float, F* dst) { *dst = acos_(*dst); }
 STAGE_TAIL(atan_float, F* dst) { *dst = atan_(*dst); }
 STAGE_TAIL(sqrt_float, F* dst) { *dst = sqrt_(*dst); }
 STAGE_TAIL(exp_float, F* dst)  { *dst = approx_exp(*dst); }
diff --git a/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp b/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp
index 45cdacd..395cb94 100644
--- a/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp
+++ b/src/sksl/codegen/SkSLRasterPipelineBuilder.cpp
@@ -37,7 +37,9 @@
 namespace RP {
 
 #define ALL_SINGLE_SLOT_UNARY_OP_CASES  \
-         BuilderOp::atan_float:         \
+         BuilderOp::acos_float:         \
+    case BuilderOp::asin_float:         \
+    case BuilderOp::atan_float:         \
     case BuilderOp::cos_float:          \
     case BuilderOp::exp_float:          \
     case BuilderOp::sin_float:          \
@@ -2037,6 +2039,8 @@
             case POp::cast_to_float_from_int: case POp::cast_to_float_from_uint:
             case POp::cast_to_int_from_float: case POp::cast_to_uint_from_float:
             case POp::abs_float:              case POp::abs_int:
+            case POp::acos_float:
+            case POp::asin_float:
             case POp::atan_float:
             case POp::ceil_float:
             case POp::cos_float:
@@ -2445,6 +2449,14 @@
                 opText = opArg1 + " = abs(" + opArg1 + ")";
                 break;
 
+            case POp::acos_float:
+                opText = opArg1 + " = acos(" + opArg1 + ")";
+                break;
+
+            case POp::asin_float:
+                opText = opArg1 + " = asin(" + opArg1 + ")";
+                break;
+
             case POp::atan_float:
                 opText = opArg1 + " = atan(" + opArg1 + ")";
                 break;
diff --git a/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp b/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp
index b1dc894..a8333db 100644
--- a/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp
+++ b/src/sksl/codegen/SkSLRasterPipelineCodeGenerator.cpp
@@ -2519,6 +2519,12 @@
             this->foldWithMultiOp(BuilderOp::bitwise_and_n_ints, arg0.type().slotCount());
             return true;
 
+        case IntrinsicKind::k_acos_IntrinsicKind:
+            return this->pushIntrinsic(BuilderOp::acos_float, arg0);
+
+        case IntrinsicKind::k_asin_IntrinsicKind:
+            return this->pushIntrinsic(BuilderOp::asin_float, arg0);
+
         case IntrinsicKind::k_atan_IntrinsicKind:
             return this->pushIntrinsic(BuilderOp::atan_float, arg0);
 
diff --git a/tests/sksl/intrinsics/Acos.skrp b/tests/sksl/intrinsics/Acos.skrp
index 3ef3d71..b64b843 100644
--- a/tests/sksl/intrinsics/Acos.skrp
+++ b/tests/sksl/intrinsics/Acos.skrp
@@ -1,4 +1,60 @@
-### Compilation failed:
-
-error: code is not supported
-1 error
+    1. store_src_rg                   coords = src.rg
+    2. init_lane_masks                CondMask = LoopMask = RetMask = true
+    3. copy_constant                  $4 = inputVal(0)
+    4. acos_float                     $4 = acos($4)
+    5. copy_constant                  $5 = expected(0)
+    6. cmpeq_float                    $4 = equal($4, $5)
+    7. copy_2_constants               $5..6 = inputVal(0..1)
+    8. acos_float                     $5 = acos($5)
+    9. acos_float                     $6 = acos($6)
+   10. copy_2_constants               $7..8 = expected(0..1)
+   11. cmpeq_2_floats                 $5..6 = equal($5..6, $7..8)
+   12. bitwise_and_int                $5 &= $6
+   13. bitwise_and_int                $4 &= $5
+   14. copy_3_constants               $5..7 = inputVal(0..2)
+   15. acos_float                     $5 = acos($5)
+   16. acos_float                     $6 = acos($6)
+   17. acos_float                     $7 = acos($7)
+   18. copy_3_constants               $8..10 = expected(0..2)
+   19. cmpeq_3_floats                 $5..7 = equal($5..7, $8..10)
+   20. bitwise_and_int                $6 &= $7
+   21. bitwise_and_int                $5 &= $6
+   22. bitwise_and_int                $4 &= $5
+   23. copy_4_constants               $5..8 = inputVal
+   24. acos_float                     $5 = acos($5)
+   25. acos_float                     $6 = acos($6)
+   26. acos_float                     $7 = acos($7)
+   27. acos_float                     $8 = acos($8)
+   28. copy_4_constants               $9..12 = expected
+   29. cmpeq_4_floats                 $5..8 = equal($5..8, $9..12)
+   30. bitwise_and_2_ints             $5..6 &= $7..8
+   31. bitwise_and_int                $5 &= $6
+   32. bitwise_and_int                $4 &= $5
+   33. zero_slot_unmasked             $5 = 0
+   34. copy_constant                  $6 = expected(0)
+   35. cmpeq_float                    $5 = equal($5, $6)
+   36. bitwise_and_int                $4 &= $5
+   37. zero_2_slots_unmasked          $5..6 = 0
+   38. copy_2_constants               $7..8 = expected(0..1)
+   39. cmpeq_2_floats                 $5..6 = equal($5..6, $7..8)
+   40. bitwise_and_int                $5 &= $6
+   41. bitwise_and_int                $4 &= $5
+   42. zero_3_slots_unmasked          $5..7 = 0
+   43. copy_3_constants               $8..10 = expected(0..2)
+   44. cmpeq_3_floats                 $5..7 = equal($5..7, $8..10)
+   45. bitwise_and_int                $6 &= $7
+   46. bitwise_and_int                $5 &= $6
+   47. bitwise_and_int                $4 &= $5
+   48. zero_4_slots_unmasked          $5..8 = 0
+   49. copy_4_constants               $9..12 = expected
+   50. cmpeq_4_floats                 $5..8 = equal($5..8, $9..12)
+   51. bitwise_and_2_ints             $5..6 &= $7..8
+   52. bitwise_and_int                $5 &= $6
+   53. bitwise_and_int                $4 &= $5
+   54. branch_if_no_active_lanes_eq   branch +3 (label 0 at #57) if no lanes of $4 == 0xFFFFFFFF
+   55. copy_4_constants               $0..3 = colorGreen
+   56. jump                           jump +3 (label 1 at #59)
+   57. label                          label 0x00000000
+   58. copy_4_constants               $0..3 = colorRed
+   59. label                          label 0x00000001
+   60. load_src                       src.rgba = $0..3
diff --git a/tests/sksl/intrinsics/Asin.skrp b/tests/sksl/intrinsics/Asin.skrp
index 3ef3d71..0c4bbe1 100644
--- a/tests/sksl/intrinsics/Asin.skrp
+++ b/tests/sksl/intrinsics/Asin.skrp
@@ -1,4 +1,60 @@
-### Compilation failed:
-
-error: code is not supported
-1 error
+    1. store_src_rg                   coords = src.rg
+    2. init_lane_masks                CondMask = LoopMask = RetMask = true
+    3. copy_constant                  $4 = inputVal(0)
+    4. asin_float                     $4 = asin($4)
+    5. copy_constant                  $5 = expected(0)
+    6. cmpeq_float                    $4 = equal($4, $5)
+    7. copy_2_constants               $5..6 = inputVal(0..1)
+    8. asin_float                     $5 = asin($5)
+    9. asin_float                     $6 = asin($6)
+   10. copy_2_constants               $7..8 = expected(0..1)
+   11. cmpeq_2_floats                 $5..6 = equal($5..6, $7..8)
+   12. bitwise_and_int                $5 &= $6
+   13. bitwise_and_int                $4 &= $5
+   14. copy_3_constants               $5..7 = inputVal(0..2)
+   15. asin_float                     $5 = asin($5)
+   16. asin_float                     $6 = asin($6)
+   17. asin_float                     $7 = asin($7)
+   18. copy_3_constants               $8..10 = expected(0..2)
+   19. cmpeq_3_floats                 $5..7 = equal($5..7, $8..10)
+   20. bitwise_and_int                $6 &= $7
+   21. bitwise_and_int                $5 &= $6
+   22. bitwise_and_int                $4 &= $5
+   23. copy_4_constants               $5..8 = inputVal
+   24. asin_float                     $5 = asin($5)
+   25. asin_float                     $6 = asin($6)
+   26. asin_float                     $7 = asin($7)
+   27. asin_float                     $8 = asin($8)
+   28. copy_4_constants               $9..12 = expected
+   29. cmpeq_4_floats                 $5..8 = equal($5..8, $9..12)
+   30. bitwise_and_2_ints             $5..6 &= $7..8
+   31. bitwise_and_int                $5 &= $6
+   32. bitwise_and_int                $4 &= $5
+   33. zero_slot_unmasked             $5 = 0
+   34. copy_constant                  $6 = expected(0)
+   35. cmpeq_float                    $5 = equal($5, $6)
+   36. bitwise_and_int                $4 &= $5
+   37. zero_2_slots_unmasked          $5..6 = 0
+   38. copy_2_constants               $7..8 = expected(0..1)
+   39. cmpeq_2_floats                 $5..6 = equal($5..6, $7..8)
+   40. bitwise_and_int                $5 &= $6
+   41. bitwise_and_int                $4 &= $5
+   42. zero_3_slots_unmasked          $5..7 = 0
+   43. copy_3_constants               $8..10 = expected(0..2)
+   44. cmpeq_3_floats                 $5..7 = equal($5..7, $8..10)
+   45. bitwise_and_int                $6 &= $7
+   46. bitwise_and_int                $5 &= $6
+   47. bitwise_and_int                $4 &= $5
+   48. zero_4_slots_unmasked          $5..8 = 0
+   49. copy_4_constants               $9..12 = expected
+   50. cmpeq_4_floats                 $5..8 = equal($5..8, $9..12)
+   51. bitwise_and_2_ints             $5..6 &= $7..8
+   52. bitwise_and_int                $5 &= $6
+   53. bitwise_and_int                $4 &= $5
+   54. branch_if_no_active_lanes_eq   branch +3 (label 0 at #57) if no lanes of $4 == 0xFFFFFFFF
+   55. copy_4_constants               $0..3 = colorGreen
+   56. jump                           jump +3 (label 1 at #59)
+   57. label                          label 0x00000000
+   58. copy_4_constants               $0..3 = colorRed
+   59. label                          label 0x00000001
+   60. load_src                       src.rgba = $0..3