summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-ir-lower-existential.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-06-04 13:05:58 -0700
committerGitHub <noreply@github.com>2025-06-04 13:05:58 -0700
commit812e478989e27983b8dea7ab11964de751654ba2 (patch)
treee6db6def9c7896ee48c5fe42926856644e81c0e6 /source/slang/slang-ir-lower-existential.cpp
parentb9dc21d362f65f22bc707bede733a9537b80460a (diff)
Make interface types non c-style in Slang2026. (#7260)
* Make interface types non c-style. * Make Optional<T> work with autodiff and existential types. * Fix. * patch behind slang 2026. * Fix warnings. * cleanup. * Fix tests. * Fix. * Fix com interface lowering. * Add comment to test. * regenerate command line reference * Add test for passing `none` to autodiff function. * Fix recording of `getDynamicObjectRTTIBytes`. * Fix nested Optional types. --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source/slang/slang-ir-lower-existential.cpp')
-rw-r--r--source/slang/slang-ir-lower-existential.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/slang-ir-lower-existential.cpp b/source/slang/slang-ir-lower-existential.cpp
index c4ee6e6fc..076ed57bd 100644
--- a/source/slang/slang-ir-lower-existential.cpp
+++ b/source/slang/slang-ir-lower-existential.cpp
@@ -131,6 +131,19 @@ struct ExistentialLoweringContext
processExtractExistentialElement(inst, 2);
}
+ void processIsNullExistential(IRIsNullExistential* inst)
+ {
+ IRBuilder builder(sharedContext->module);
+ builder.setInsertBefore(inst);
+
+ auto rttiElement = extractTupleElement(&builder, inst->getOperand(0), 0);
+ auto isNull = builder.emitNeq(
+ builder.emitGetElement(builder.getUIntType(), rttiElement, 0),
+ builder.getIntValue(builder.getUIntType(), 0));
+ inst->replaceUsesWith(isNull);
+ inst->removeAndDeallocate();
+ }
+
void processExtractExistentialWitnessTable(IRExtractExistentialWitnessTable* inst)
{
processExtractExistentialElement(inst, 1);
@@ -261,6 +274,10 @@ struct ExistentialLoweringContext
{
processExtractExistentialWitnessTable(extractExistentialWitnessTable);
}
+ else if (auto isNullExistential = as<IRIsNullExistential>(inst))
+ {
+ processIsNullExistential(isNullExistential);
+ }
}
void processModule()