summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-10-21 16:27:40 -0700
committerGitHub <noreply@github.com>2021-10-21 16:27:40 -0700
commitdc991f7cb6b7f9f7271f4e557cfdd3e59804d1d3 (patch)
tree28d1a5974087e8d5c60645befe8808474332d3e5 /source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp
parent9304c2d04c9bfbae33cc328d404b24aba375aa4f (diff)
Passing associated type arguments to existential parameters + packing for `bool`. (#1987)
* Passing associated type arguments to existential parameters + packing for `bool`. * fix typo Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp')
-rw-r--r--source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp b/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp
index e2d321ed4..670202161 100644
--- a/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp
+++ b/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp
@@ -122,7 +122,18 @@ struct AssociatedTypeLookupSpecializationContext
{
// Ignore lookups for RTTI objects for now, since they are not used anywhere.
if (!as<IRWitnessTableType>(inst->getDataType()))
+ {
+ IRBuilder builder;
+ builder.sharedBuilder = &sharedContext->sharedBuilderStorage;
+ builder.setInsertBefore(inst);
+ auto uint2Type = builder.getVectorType(
+ builder.getUIntType(), builder.getIntValue(builder.getIntType(), 2));
+ auto zero = builder.getIntValue(builder.getUIntType(), 0);
+ IRInst* args[] = { zero, zero };
+ auto zeroUint2 = builder.emitMakeVector(uint2Type, 2, args);
+ inst->replaceUsesWith(zeroUint2);
return;
+ }
// Replace all witness table lookups with calls to specialized functions that directly
// returns the sequential ID of the resulting witness table, effectively getting rid
@@ -165,7 +176,7 @@ struct AssociatedTypeLookupSpecializationContext
{
// If the operand is a witness table, it is already replaced with a uint2
// at this point, where the first element in the uint2 is the id of the
- // witneess table.
+ // witness table.
auto vectorType = inst->getRTTIOperand()->getDataType();
IRBuilder builder;
builder.sharedBuilder = &sharedContext->sharedBuilderStorage;