From d979b5048009c3909cfc13476a78a12ae5f4d61b Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Fri, 1 Mar 2024 01:50:19 +0800 Subject: Add support for bitfields (#3639) * Add support for bitfields Closes https://github.com/shader-slang/slang/issues/3559 * Set scopes for syntsized bitfield accessors * Simplify generated code for bitfield accessors * spelling * regenerate vs project * warnings --- source/slang/slang-ir.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'source/slang/slang-ir.cpp') 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(type)) + { + for (auto field : irStructType->getFields()) + { + if (field->getKey() == key) + { + return field; + } + } + } + else if (auto irSpecialize = as(type)) + { + if (auto irGeneric = as(irSpecialize->getBase())) + { + if (auto irGenericStructType = as(findInnerMostGenericReturnVal(irGeneric))) + { + return findStructField(irGenericStructType, key); + } + } + } + + return nullptr; + } + void findAllInstsBreadthFirst(IRInst* inst, List& outInsts) { Index index = outInsts.getCount(); -- cgit v1.2.3