1 // Copyright 2020 The Tint Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef SRC_AST_INTRINSIC_H_ 16 #define SRC_AST_INTRINSIC_H_ 17 18 #include <ostream> 19 #include <string> 20 21 namespace tint { 22 namespace ast { 23 24 enum class Intrinsic { 25 kNone = -1, 26 27 kAbs, 28 kAcos, 29 kAll, 30 kAny, 31 kArrayLength, 32 kAsin, 33 kAtan, 34 kAtan2, 35 kCeil, 36 kClamp, 37 kCos, 38 kCosh, 39 kCountOneBits, 40 kCross, 41 kDeterminant, 42 kDistance, 43 kDot, 44 kDpdx, 45 kDpdxCoarse, 46 kDpdxFine, 47 kDpdy, 48 kDpdyCoarse, 49 kDpdyFine, 50 kExp, 51 kExp2, 52 kFaceForward, 53 kFloor, 54 kFma, 55 kFract, 56 kFrexp, 57 kFwidth, 58 kFwidthCoarse, 59 kFwidthFine, 60 kInverseSqrt, 61 kIsFinite, 62 kIsInf, 63 kIsNan, 64 kIsNormal, 65 kLdexp, 66 kLength, 67 kLog, 68 kLog2, 69 kMax, 70 kMin, 71 kMix, 72 kModf, 73 kNormalize, 74 kOuterProduct, 75 kPow, 76 kReflect, 77 kReverseBits, 78 kRound, 79 kSelect, 80 kSign, 81 kSin, 82 kSinh, 83 kSmoothStep, 84 kSqrt, 85 kStep, 86 kTan, 87 kTanh, 88 kTextureLoad, 89 kTextureSample, 90 kTextureSampleBias, 91 kTextureSampleCompare, 92 kTextureSampleLevel, 93 kTrunc 94 }; 95 96 /// Emits the name of the intrinsic function. The spelling, 97 /// including case, matches the name in the WGSL spec. 98 std::ostream& operator<<(std::ostream& out, Intrinsic i); 99 100 namespace intrinsic { 101 102 /// Determines if the given |name| is a coarse derivative 103 /// @param i the intrinsic 104 /// @returns true if the given derivative is coarse. 105 bool IsCoarseDerivative(ast::Intrinsic i); 106 107 /// Determines if the given |name| is a fine derivative 108 /// @param i the intrinsic 109 /// @returns true if the given derivative is fine. 110 bool IsFineDerivative(ast::Intrinsic i); 111 112 /// Determine if the given |name| is a derivative intrinsic 113 /// @param i the intrinsic 114 /// @returns true if the given |name| is a derivative intrinsic 115 bool IsDerivative(ast::Intrinsic i); 116 117 /// Determines if the given |name| is a float classification intrinsic 118 /// @param i the intrinsic 119 /// @returns true if the given |name| is a float intrinsic 120 bool IsFloatClassificationIntrinsic(ast::Intrinsic i); 121 122 /// Determines if the given |name| is a texture operation intrinsic 123 /// @param i the intrinsic 124 /// @returns true if the given |name| is a texture operation intrinsic 125 bool IsTextureIntrinsic(ast::Intrinsic i); 126 127 } // namespace intrinsic 128 } // namespace ast 129 } // namespace tint 130 131 #endif // SRC_AST_INTRINSIC_H_ 132