From 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 16 Feb 2023 13:55:32 -0800 Subject: Overhaul global inst deduplication and cpp/cuda backend. (#2654) * Overhaul global inst deduplication and cpp/cuda backend. * Update IR documentation. --------- Co-authored-by: Yong He --- ...ir-specialize-dynamic-associatedtype-lookup.cpp | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) (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 39edaeb16..cfc9d9c76 100644 --- a/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp +++ b/source/slang/slang-ir-specialize-dynamic-associatedtype-lookup.cpp @@ -200,23 +200,22 @@ struct AssociatedTypeLookupSpecializationContext if (!seqId) return; // Insert code to pack sequential ID into an uint2 at all use sites. - IRUse* nextUse = nullptr; - for (auto use = inst->firstUse; use; use = nextUse) + traverseUses(inst, [&](IRUse* use) { - nextUse = use->nextUse; if (as(use->getUser())) - continue; + { + return; + } IRBuilder builder(sharedContext->sharedBuilderStorage); builder.setInsertBefore(use->getUser()); auto uint2Type = builder.getVectorType( builder.getUIntType(), builder.getIntValue(builder.getIntType(), 2)); IRInst* uint2Args[] = { seqId->getSequentialIDOperand(), - builder.getIntValue(builder.getUIntType(), 0)}; + builder.getIntValue(builder.getUIntType(), 0) }; auto uint2seqID = builder.emitMakeVector(uint2Type, 2, uint2Args); - use->set(uint2seqID); - use = nextUse; - } + builder.replaceOperand(use, uint2seqID); + }); } }); @@ -229,14 +228,12 @@ struct AssociatedTypeLookupSpecializationContext builder.setInsertBefore(globalInst); auto witnessTableIDType = builder.getWitnessTableIDType( (IRType*)cast(globalInst)->getConformanceType()); - IRUse* nextUse = nullptr; - for (auto use = globalInst->firstUse; use; use = nextUse) + traverseUses(globalInst, [&](IRUse* use) { - nextUse = use->nextUse; if (use->getUser()->getOp() == kIROp_WitnessTable) - continue; - use->set(witnessTableIDType); - } + return; + builder.replaceOperand(use, witnessTableIDType); + }); sharedContext->sharedBuilderStorage.deduplicateAndRebuildGlobalNumberingMap(); } } -- cgit v1.2.3