2020-06-04 17:05:35 +00:00
|
|
|
// Copyright 2020 The Tint Authors.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-02-03 21:02:25 +00:00
|
|
|
#include "src/semantic/intrinsic.h"
|
2020-06-04 17:05:35 +00:00
|
|
|
|
2021-03-02 20:51:18 +00:00
|
|
|
TINT_INSTANTIATE_TYPEINFO(tint::semantic::Intrinsic);
|
2021-02-08 22:31:44 +00:00
|
|
|
|
2020-06-04 17:05:35 +00:00
|
|
|
namespace tint {
|
2021-02-03 21:02:25 +00:00
|
|
|
namespace semantic {
|
2020-06-04 17:05:35 +00:00
|
|
|
|
2021-02-08 19:53:42 +00:00
|
|
|
std::ostream& operator<<(std::ostream& out, IntrinsicType i) {
|
2021-02-08 22:31:44 +00:00
|
|
|
out << str(i);
|
2021-02-03 21:02:25 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2021-02-08 22:31:44 +00:00
|
|
|
const char* Intrinsic::str() const {
|
|
|
|
return semantic::str(type_);
|
|
|
|
}
|
2021-02-03 21:02:25 +00:00
|
|
|
|
2021-03-04 23:00:46 +00:00
|
|
|
IntrinsicType ParseIntrinsicType(const std::string& name) {
|
|
|
|
if (name == "abs") {
|
|
|
|
return IntrinsicType::kAbs;
|
|
|
|
} else if (name == "acos") {
|
|
|
|
return IntrinsicType::kAcos;
|
|
|
|
} else if (name == "all") {
|
|
|
|
return IntrinsicType::kAll;
|
|
|
|
} else if (name == "any") {
|
|
|
|
return IntrinsicType::kAny;
|
|
|
|
} else if (name == "arrayLength") {
|
|
|
|
return IntrinsicType::kArrayLength;
|
|
|
|
} else if (name == "asin") {
|
|
|
|
return IntrinsicType::kAsin;
|
|
|
|
} else if (name == "atan") {
|
|
|
|
return IntrinsicType::kAtan;
|
|
|
|
} else if (name == "atan2") {
|
|
|
|
return IntrinsicType::kAtan2;
|
|
|
|
} else if (name == "ceil") {
|
|
|
|
return IntrinsicType::kCeil;
|
|
|
|
} else if (name == "clamp") {
|
|
|
|
return IntrinsicType::kClamp;
|
|
|
|
} else if (name == "cos") {
|
|
|
|
return IntrinsicType::kCos;
|
|
|
|
} else if (name == "cosh") {
|
|
|
|
return IntrinsicType::kCosh;
|
|
|
|
} else if (name == "countOneBits") {
|
|
|
|
return IntrinsicType::kCountOneBits;
|
|
|
|
} else if (name == "cross") {
|
|
|
|
return IntrinsicType::kCross;
|
|
|
|
} else if (name == "determinant") {
|
|
|
|
return IntrinsicType::kDeterminant;
|
|
|
|
} else if (name == "distance") {
|
|
|
|
return IntrinsicType::kDistance;
|
|
|
|
} else if (name == "dot") {
|
|
|
|
return IntrinsicType::kDot;
|
|
|
|
} else if (name == "dpdx") {
|
|
|
|
return IntrinsicType::kDpdx;
|
|
|
|
} else if (name == "dpdxCoarse") {
|
|
|
|
return IntrinsicType::kDpdxCoarse;
|
|
|
|
} else if (name == "dpdxFine") {
|
|
|
|
return IntrinsicType::kDpdxFine;
|
|
|
|
} else if (name == "dpdy") {
|
|
|
|
return IntrinsicType::kDpdy;
|
|
|
|
} else if (name == "dpdyCoarse") {
|
|
|
|
return IntrinsicType::kDpdyCoarse;
|
|
|
|
} else if (name == "dpdyFine") {
|
|
|
|
return IntrinsicType::kDpdyFine;
|
|
|
|
} else if (name == "exp") {
|
|
|
|
return IntrinsicType::kExp;
|
|
|
|
} else if (name == "exp2") {
|
|
|
|
return IntrinsicType::kExp2;
|
|
|
|
} else if (name == "faceForward") {
|
|
|
|
return IntrinsicType::kFaceForward;
|
|
|
|
} else if (name == "floor") {
|
|
|
|
return IntrinsicType::kFloor;
|
|
|
|
} else if (name == "fma") {
|
|
|
|
return IntrinsicType::kFma;
|
|
|
|
} else if (name == "fract") {
|
|
|
|
return IntrinsicType::kFract;
|
|
|
|
} else if (name == "frexp") {
|
|
|
|
return IntrinsicType::kFrexp;
|
|
|
|
} else if (name == "fwidth") {
|
|
|
|
return IntrinsicType::kFwidth;
|
|
|
|
} else if (name == "fwidthCoarse") {
|
|
|
|
return IntrinsicType::kFwidthCoarse;
|
|
|
|
} else if (name == "fwidthFine") {
|
|
|
|
return IntrinsicType::kFwidthFine;
|
|
|
|
} else if (name == "inverseSqrt") {
|
|
|
|
return IntrinsicType::kInverseSqrt;
|
|
|
|
} else if (name == "isFinite") {
|
|
|
|
return IntrinsicType::kIsFinite;
|
|
|
|
} else if (name == "isInf") {
|
|
|
|
return IntrinsicType::kIsInf;
|
|
|
|
} else if (name == "isNan") {
|
|
|
|
return IntrinsicType::kIsNan;
|
|
|
|
} else if (name == "isNormal") {
|
|
|
|
return IntrinsicType::kIsNormal;
|
|
|
|
} else if (name == "ldexp") {
|
|
|
|
return IntrinsicType::kLdexp;
|
|
|
|
} else if (name == "length") {
|
|
|
|
return IntrinsicType::kLength;
|
|
|
|
} else if (name == "log") {
|
|
|
|
return IntrinsicType::kLog;
|
|
|
|
} else if (name == "log2") {
|
|
|
|
return IntrinsicType::kLog2;
|
|
|
|
} else if (name == "max") {
|
|
|
|
return IntrinsicType::kMax;
|
|
|
|
} else if (name == "min") {
|
|
|
|
return IntrinsicType::kMin;
|
|
|
|
} else if (name == "mix") {
|
|
|
|
return IntrinsicType::kMix;
|
|
|
|
} else if (name == "modf") {
|
|
|
|
return IntrinsicType::kModf;
|
|
|
|
} else if (name == "normalize") {
|
|
|
|
return IntrinsicType::kNormalize;
|
|
|
|
} else if (name == "pack4x8snorm") {
|
|
|
|
return IntrinsicType::kPack4x8Snorm;
|
|
|
|
} else if (name == "pack4x8unorm") {
|
|
|
|
return IntrinsicType::kPack4x8Unorm;
|
|
|
|
} else if (name == "pack2x16snorm") {
|
|
|
|
return IntrinsicType::kPack2x16Snorm;
|
|
|
|
} else if (name == "pack2x16unorm") {
|
|
|
|
return IntrinsicType::kPack2x16Unorm;
|
|
|
|
} else if (name == "pack2x16float") {
|
|
|
|
return IntrinsicType::kPack2x16Float;
|
|
|
|
} else if (name == "pow") {
|
|
|
|
return IntrinsicType::kPow;
|
|
|
|
} else if (name == "reflect") {
|
|
|
|
return IntrinsicType::kReflect;
|
|
|
|
} else if (name == "reverseBits") {
|
|
|
|
return IntrinsicType::kReverseBits;
|
|
|
|
} else if (name == "round") {
|
|
|
|
return IntrinsicType::kRound;
|
|
|
|
} else if (name == "select") {
|
|
|
|
return IntrinsicType::kSelect;
|
|
|
|
} else if (name == "sign") {
|
|
|
|
return IntrinsicType::kSign;
|
|
|
|
} else if (name == "sin") {
|
|
|
|
return IntrinsicType::kSin;
|
|
|
|
} else if (name == "sinh") {
|
|
|
|
return IntrinsicType::kSinh;
|
|
|
|
} else if (name == "smoothStep") {
|
|
|
|
return IntrinsicType::kSmoothStep;
|
|
|
|
} else if (name == "sqrt") {
|
|
|
|
return IntrinsicType::kSqrt;
|
|
|
|
} else if (name == "step") {
|
|
|
|
return IntrinsicType::kStep;
|
|
|
|
} else if (name == "tan") {
|
|
|
|
return IntrinsicType::kTan;
|
|
|
|
} else if (name == "tanh") {
|
|
|
|
return IntrinsicType::kTanh;
|
|
|
|
} else if (name == "textureDimensions") {
|
|
|
|
return IntrinsicType::kTextureDimensions;
|
|
|
|
} else if (name == "textureNumLayers") {
|
|
|
|
return IntrinsicType::kTextureNumLayers;
|
|
|
|
} else if (name == "textureNumLevels") {
|
|
|
|
return IntrinsicType::kTextureNumLevels;
|
|
|
|
} else if (name == "textureNumSamples") {
|
|
|
|
return IntrinsicType::kTextureNumSamples;
|
|
|
|
} else if (name == "textureLoad") {
|
|
|
|
return IntrinsicType::kTextureLoad;
|
|
|
|
} else if (name == "textureStore") {
|
|
|
|
return IntrinsicType::kTextureStore;
|
|
|
|
} else if (name == "textureSample") {
|
|
|
|
return IntrinsicType::kTextureSample;
|
|
|
|
} else if (name == "textureSampleBias") {
|
|
|
|
return IntrinsicType::kTextureSampleBias;
|
|
|
|
} else if (name == "textureSampleCompare") {
|
|
|
|
return IntrinsicType::kTextureSampleCompare;
|
|
|
|
} else if (name == "textureSampleGrad") {
|
|
|
|
return IntrinsicType::kTextureSampleGrad;
|
|
|
|
} else if (name == "textureSampleLevel") {
|
|
|
|
return IntrinsicType::kTextureSampleLevel;
|
|
|
|
} else if (name == "trunc") {
|
|
|
|
return IntrinsicType::kTrunc;
|
|
|
|
} else if (name == "unpack4x8snorm") {
|
|
|
|
return IntrinsicType::kUnpack4x8Snorm;
|
|
|
|
} else if (name == "unpack4x8unorm") {
|
|
|
|
return IntrinsicType::kUnpack4x8Unorm;
|
|
|
|
} else if (name == "unpack2x16snorm") {
|
|
|
|
return IntrinsicType::kUnpack2x16Snorm;
|
|
|
|
} else if (name == "unpack2x16unorm") {
|
|
|
|
return IntrinsicType::kUnpack2x16Unorm;
|
|
|
|
} else if (name == "unpack2x16float") {
|
|
|
|
return IntrinsicType::kUnpack2x16Float;
|
|
|
|
}
|
|
|
|
return IntrinsicType::kNone;
|
|
|
|
}
|
|
|
|
|
2021-02-08 19:53:42 +00:00
|
|
|
const char* str(IntrinsicType i) {
|
2020-11-11 14:30:25 +00:00
|
|
|
/// The emitted name matches the spelling in the WGSL spec.
|
|
|
|
/// including case.
|
2020-09-22 19:42:13 +00:00
|
|
|
switch (i) {
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kNone:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "<not-an-intrinsic>";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAbs:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "abs";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAcos:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "acos";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAll:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "all";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAny:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "any";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kArrayLength:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "arrayLength";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAsin:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "asin";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAtan:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "atan";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kAtan2:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "atan2";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kCeil:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "ceil";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kClamp:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "clamp";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kCos:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "cos";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kCosh:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "cosh";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kCountOneBits:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "countOneBits";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kCross:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "cross";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDeterminant:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "determinant";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDistance:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "distance";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDot:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dot";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDpdx:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dpdx";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDpdxCoarse:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dpdxCoarse";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDpdxFine:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dpdxFine";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDpdy:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dpdy";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDpdyCoarse:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dpdyCoarse";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kDpdyFine:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "dpdyFine";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kExp:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "exp";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kExp2:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "exp2";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFaceForward:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "faceForward";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFloor:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "floor";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFma:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "fma";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFract:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "fract";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFrexp:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "frexp";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFwidth:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "fwidth";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFwidthCoarse:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "fwidthCoarse";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kFwidthFine:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "fwidthFine";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kInverseSqrt:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "inverseSqrt";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kIsFinite:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "isFinite";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kIsInf:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "isInf";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kIsNan:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "isNan";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kIsNormal:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "isNormal";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kLdexp:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "ldexp";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kLength:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "length";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kLog:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "log";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kLog2:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "log2";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kMax:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "max";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kMin:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "min";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kMix:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "mix";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kModf:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "modf";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kNormalize:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "normalize";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kPack4x8Snorm:
|
2021-02-04 16:17:49 +00:00
|
|
|
return "pack4x8snorm";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kPack4x8Unorm:
|
2021-02-04 16:17:49 +00:00
|
|
|
return "pack4x8unorm";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kPack2x16Snorm:
|
2021-02-04 16:17:49 +00:00
|
|
|
return "pack2x16snorm";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kPack2x16Unorm:
|
2021-02-04 16:17:49 +00:00
|
|
|
return "pack2x16unorm";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kPack2x16Float:
|
2021-02-04 16:17:49 +00:00
|
|
|
return "pack2x16float";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kPow:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "pow";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kReflect:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "reflect";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kReverseBits:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "reverseBits";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kRound:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "round";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kSelect:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "select";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kSign:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "sign";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kSin:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "sin";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kSinh:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "sinh";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kSmoothStep:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "smoothStep";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kSqrt:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "sqrt";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kStep:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "step";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTan:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "tan";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTanh:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "tanh";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureDimensions:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureDimensions";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureLoad:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureLoad";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureNumLayers:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureNumLayers";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureNumLevels:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureNumLevels";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureNumSamples:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureNumSamples";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureSample:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureSample";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureSampleBias:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureSampleBias";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureSampleCompare:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureSampleCompare";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureSampleGrad:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureSampleGrad";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureSampleLevel:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureSampleLevel";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTextureStore:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "textureStore";
|
2021-02-08 19:53:42 +00:00
|
|
|
case IntrinsicType::kTrunc:
|
2021-02-03 21:02:25 +00:00
|
|
|
return "trunc";
|
2021-02-09 21:23:00 +00:00
|
|
|
case IntrinsicType::kUnpack4x8Snorm:
|
|
|
|
return "unpack4x8snorm";
|
|
|
|
case IntrinsicType::kUnpack4x8Unorm:
|
|
|
|
return "unpack4x8unorm";
|
|
|
|
case IntrinsicType::kUnpack2x16Snorm:
|
|
|
|
return "unpack2x16snorm";
|
|
|
|
case IntrinsicType::kUnpack2x16Unorm:
|
|
|
|
return "unpack2x16unorm";
|
|
|
|
case IntrinsicType::kUnpack2x16Float:
|
|
|
|
return "unpack2x16float";
|
2020-09-22 19:42:13 +00:00
|
|
|
}
|
2021-02-03 21:02:25 +00:00
|
|
|
return "<unknown>";
|
2020-06-04 17:14:43 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 22:31:44 +00:00
|
|
|
bool IsCoarseDerivativeIntrinsic(IntrinsicType i) {
|
2021-02-08 19:53:42 +00:00
|
|
|
return i == IntrinsicType::kDpdxCoarse || i == IntrinsicType::kDpdyCoarse ||
|
|
|
|
i == IntrinsicType::kFwidthCoarse;
|
2020-06-04 17:14:43 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 22:31:44 +00:00
|
|
|
bool IsFineDerivativeIntrinsic(IntrinsicType i) {
|
2021-02-08 19:53:42 +00:00
|
|
|
return i == IntrinsicType::kDpdxFine || i == IntrinsicType::kDpdyFine ||
|
|
|
|
i == IntrinsicType::kFwidthFine;
|
2020-06-04 17:05:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 22:31:44 +00:00
|
|
|
bool IsDerivativeIntrinsic(IntrinsicType i) {
|
2021-02-08 19:53:42 +00:00
|
|
|
return i == IntrinsicType::kDpdx || i == IntrinsicType::kDpdy ||
|
2021-02-08 22:31:44 +00:00
|
|
|
i == IntrinsicType::kFwidth || IsCoarseDerivativeIntrinsic(i) ||
|
|
|
|
IsFineDerivativeIntrinsic(i);
|
2020-06-04 17:05:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 19:53:42 +00:00
|
|
|
bool IsFloatClassificationIntrinsic(IntrinsicType i) {
|
|
|
|
return i == IntrinsicType::kIsFinite || i == IntrinsicType::kIsInf ||
|
|
|
|
i == IntrinsicType::kIsNan || i == IntrinsicType::kIsNormal;
|
2020-08-31 15:24:54 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 19:53:42 +00:00
|
|
|
bool IsTextureIntrinsic(IntrinsicType i) {
|
|
|
|
return IsImageQueryIntrinsic(i) || i == IntrinsicType::kTextureLoad ||
|
|
|
|
i == IntrinsicType::kTextureSample ||
|
|
|
|
i == IntrinsicType::kTextureSampleLevel ||
|
|
|
|
i == IntrinsicType::kTextureSampleBias ||
|
|
|
|
i == IntrinsicType::kTextureSampleCompare ||
|
|
|
|
i == IntrinsicType::kTextureSampleGrad ||
|
|
|
|
i == IntrinsicType::kTextureStore;
|
2020-06-04 17:05:35 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 19:53:42 +00:00
|
|
|
bool IsImageQueryIntrinsic(IntrinsicType i) {
|
2021-02-08 22:31:44 +00:00
|
|
|
return i == IntrinsicType::kTextureDimensions ||
|
2021-02-08 19:53:42 +00:00
|
|
|
i == IntrinsicType::kTextureNumLayers ||
|
|
|
|
i == IntrinsicType::kTextureNumLevels ||
|
|
|
|
i == IntrinsicType::kTextureNumSamples;
|
2021-01-11 21:07:32 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 19:53:42 +00:00
|
|
|
bool IsDataPackingIntrinsic(IntrinsicType i) {
|
|
|
|
return i == IntrinsicType::kPack4x8Snorm ||
|
|
|
|
i == IntrinsicType::kPack4x8Unorm ||
|
|
|
|
i == IntrinsicType::kPack2x16Snorm ||
|
|
|
|
i == IntrinsicType::kPack2x16Unorm ||
|
|
|
|
i == IntrinsicType::kPack2x16Float;
|
2021-02-04 16:17:49 +00:00
|
|
|
}
|
|
|
|
|
2021-02-09 21:23:00 +00:00
|
|
|
bool IsDataUnpackingIntrinsic(IntrinsicType i) {
|
|
|
|
return i == IntrinsicType::kUnpack4x8Snorm ||
|
|
|
|
i == IntrinsicType::kUnpack4x8Unorm ||
|
|
|
|
i == IntrinsicType::kUnpack2x16Snorm ||
|
|
|
|
i == IntrinsicType::kUnpack2x16Unorm ||
|
|
|
|
i == IntrinsicType::kUnpack2x16Float;
|
|
|
|
}
|
|
|
|
|
2021-02-08 22:31:44 +00:00
|
|
|
Intrinsic::Intrinsic(IntrinsicType type,
|
|
|
|
type::Type* return_type,
|
2021-02-09 15:37:44 +00:00
|
|
|
const ParameterList& parameters)
|
2021-02-08 22:31:44 +00:00
|
|
|
: Base(return_type, parameters), type_(type) {}
|
|
|
|
|
|
|
|
Intrinsic::~Intrinsic() = default;
|
|
|
|
|
|
|
|
bool Intrinsic::IsCoarseDerivative() const {
|
|
|
|
return IsCoarseDerivativeIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Intrinsic::IsFineDerivative() const {
|
|
|
|
return IsFineDerivativeIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Intrinsic::IsDerivative() const {
|
|
|
|
return IsDerivativeIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Intrinsic::IsFloatClassification() const {
|
|
|
|
return IsFloatClassificationIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Intrinsic::IsTexture() const {
|
|
|
|
return IsTextureIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Intrinsic::IsImageQuery() const {
|
|
|
|
return IsImageQueryIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Intrinsic::IsDataPacking() const {
|
|
|
|
return IsDataPackingIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
2021-02-09 21:23:00 +00:00
|
|
|
bool Intrinsic::IsDataUnpacking() const {
|
|
|
|
return IsDataUnpackingIntrinsic(type_);
|
|
|
|
}
|
|
|
|
|
2021-02-03 21:02:25 +00:00
|
|
|
} // namespace semantic
|
2020-06-04 17:05:35 +00:00
|
|
|
} // namespace tint
|