diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-03-01 01:50:19 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-01 01:50:19 +0800 |
| commit | d979b5048009c3909cfc13476a78a12ae5f4d61b (patch) | |
| tree | 550815d37916be845fb0aa1dcc6131960c2bf517 /source/slang/slang-ir.cpp | |
| parent | 21f86773771c26da8bf3c458642e51b1728d419c (diff) | |
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
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 39 |
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(); |
