summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-util.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-07-12 22:45:05 -0700
committerGitHub <noreply@github.com>2022-07-12 22:45:05 -0700
commit049aac1b80143753b4b3449e529024bafe2250be (patch)
treee6734ef240bf7016562a301009add1761caf06f6 /source/slang/slang-ir-util.cpp
parenta6775666c38ccaeb2a991921a08343afa09c659b (diff)
Support `class` types. (#2321)
* Support `class` types. * Ignore class-keyword test * Fix codereview comments and warnings. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
-rw-r--r--source/slang/slang-ir-util.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp
new file mode 100644
index 000000000..fda7b25cc
--- /dev/null
+++ b/source/slang/slang-ir-util.cpp
@@ -0,0 +1,29 @@
+#include "slang-ir-util.h"
+
+namespace Slang
+{
+
+bool isPointerOfType(IRInst* type, IROp opCode)
+{
+ if (auto ptrType = as<IRPtrTypeBase>(type))
+ {
+ return ptrType->getValueType() && ptrType->getValueType()->getOp() == opCode;
+ }
+ return false;
+}
+
+bool isPointerOfType(IRInst* type, IRInst* elementType)
+{
+ if (auto ptrType = as<IRPtrTypeBase>(type))
+ {
+ return ptrType->getValueType() && isTypeEqual(ptrType->getValueType(), (IRType*)elementType);
+ }
+ return false;
+}
+
+bool isPtrToClassType(IRInst* type)
+{
+ return isPointerOfType(type, kIROp_ClassType);
+}
+
+}