From dc991f7cb6b7f9f7271f4e557cfdd3e59804d1d3 Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 21 Oct 2021 16:27:40 -0700 Subject: 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 --- .../slang-ir-specialize-dynamic-associatedtype-lookup.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp') 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(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; -- cgit v1.2.3