summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-ir.cpp')
-rw-r--r--source/slang/slang-ir.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 3f10e3d3e..68b002153 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -7277,6 +7277,19 @@ namespace Slang
}
}
+ IROp getIntTypeOpFromInfo(const IntInfo info)
+ {
+ switch(info.width)
+ {
+ case 8: return info.isSigned ? kIROp_Int8Type : kIROp_UInt8Type;
+ case 16: return info.isSigned ? kIROp_Int16Type : kIROp_UInt16Type;
+ case 32: return info.isSigned ? kIROp_IntType : kIROp_UIntType;
+ case 64: return info.isSigned ? kIROp_Int64Type : kIROp_UInt64Type;
+ default:
+ SLANG_UNEXPECTED("Unhandled info passed to getIntTypeOpFromInfo");
+ }
+ }
+
FloatInfo getFloatingTypeInfo(const IRType* floatType)
{
switch(floatType->getOp())
@@ -7303,6 +7316,32 @@ namespace Slang
}
}
+ IRStructField* findStructField(IRInst* type, IRStructKey* key)
+ {
+ if (auto irStructType = as<IRStructType>(type))
+ {
+ for (auto field : irStructType->getFields())
+ {
+ if (field->getKey() == key)
+ {
+ return field;
+ }
+ }
+ }
+ else if (auto irSpecialize = as<IRSpecialize>(type))
+ {
+ if (auto irGeneric = as<IRGeneric>(irSpecialize->getBase()))
+ {
+ if (auto irGenericStructType = as<IRStructType>(findInnerMostGenericReturnVal(irGeneric)))
+ {
+ return findStructField(irGenericStructType, key);
+ }
+ }
+ }
+
+ return nullptr;
+ }
+
void findAllInstsBreadthFirst(IRInst* inst, List<IRInst*>& outInsts)
{
Index index = outInsts.getCount();