diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-16 16:44:04 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-16 16:44:04 -0800 |
| commit | 245466d89cfe54b78da486f06d470bc6daaf4625 (patch) | |
| tree | 522e0af1a9d2756182e143cdc85031ea1bbc2aa0 /source/slang/slang-ir-specialize.cpp | |
| parent | 4c4826d47eeef4675daae4ae53ff76f4d5ebd84a (diff) | |
Remove `SharedIRBuilder`. (#2657)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-specialize.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/source/slang/slang-ir-specialize.cpp b/source/slang/slang-ir-specialize.cpp index 0044e5745..050c9bfc7 100644 --- a/source/slang/slang-ir-specialize.cpp +++ b/source/slang/slang-ir-specialize.cpp @@ -204,10 +204,6 @@ struct SpecializationContext typedef IRSimpleSpecializationKey Key; Dictionary<Key, IRInst*> genericSpecializations; - // We will also use some shared IR building state across - // all of our specialization/cloning steps. - // - SharedIRBuilder sharedBuilderStorage; // Now let's look at the task of finding or generation a // specialization of some generic `g`, given a specialization @@ -418,7 +414,7 @@ struct SpecializationContext for (UIndex ii = 0; ii < argCount; ii++) args.add(specInst->getArg(ii)); - IRBuilder builder(&sharedBuilderStorage); + IRBuilder builder(module); // Specialize the custom derivative function type with the original arguments. builder.setInsertInto(module); @@ -782,7 +778,7 @@ struct SpecializationContext template<typename TDict> void _writeSpecializationDictionaryImpl(TDict& dict, IROp dictOp, IRInst* moduleInst) { - IRBuilder builder(&sharedBuilderStorage); + IRBuilder builder(moduleInst); builder.setInsertInto(moduleInst); auto dictInst = builder.emitIntrinsicInst(nullptr, dictOp, 0, nullptr); builder.setInsertInto(dictInst); @@ -817,18 +813,10 @@ struct SpecializationContext // void processModule() { - // We start by initializing our shared IR building state, - // since we will re-use that state for any code we - // generate along the way. - // - SharedIRBuilder* sharedBuilder = &sharedBuilderStorage; - sharedBuilder->init(module); - // Read specialization dictionary from module if it is defined. // This prevents us from generating duplicated specializations // when this pass is invoked iteratively. readSpecializationDictionaries(); - sharedBuilder->deduplicateAndRebuildGlobalNumberingMap(); // The unspecialized IR we receive as input will have // `IRBindGlobalGenericParam` instructions that associate @@ -996,7 +984,7 @@ struct SpecializationContext { auto oldSpecialize = cast<IRSpecialize>(oldSpecializedCallee); SLANG_ASSERT(oldSpecialize->getArgCount() == 1); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(oldSpecializedCallee); auto calleeType = builder.getFuncType(1, &newContainerType, newElementType); auto newSpecialize = builder.emitSpecializeInst( @@ -1026,7 +1014,7 @@ struct SpecializationContext auto resultType = inst->getFullType(); auto elementType = sbType->getElementType(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(inst); List<IRInst*> args; @@ -1262,7 +1250,7 @@ struct SpecializationContext // Now that we've built up our argument list, it is simple enough // to construct a new `call` instruction. // - IRBuilder builderStorage(sharedBuilderStorage); + IRBuilder builderStorage(module); auto builder = &builderStorage; builder->setInsertBefore(inst); @@ -1421,7 +1409,7 @@ struct SpecializationContext // We also need some IR building state, for any // new instructions we will emit. // - IRBuilder builderStorage(sharedBuilderStorage); + IRBuilder builderStorage(module); auto builder = &builderStorage; // We will start out by determining what the parameters @@ -1561,7 +1549,7 @@ struct SpecializationContext // cloneInstDecorationsAndChildren( &cloneEnv, - builder->getSharedBuilder(), + builder->getModule(), oldFunc, newFunc); @@ -1740,7 +1728,7 @@ struct SpecializationContext // auto resultType = inst->getFullType(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(inst); // We'd *like* to replace this instruction with @@ -1844,7 +1832,7 @@ struct SpecializationContext // auto resultType = inst->getFullType(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(inst); // We'd *like* to replace this instruction with @@ -1931,7 +1919,7 @@ struct SpecializationContext // auto resultType = inst->getFullType(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(inst); // We'd *like* to replace this instruction with @@ -2018,7 +2006,7 @@ struct SpecializationContext auto val = wrapInst->getWrappedValue(); auto resultType = inst->getFullType(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(inst); auto elementType = cast<IRArrayTypeBase>(val->getDataType())->getElementType(); @@ -2061,7 +2049,7 @@ struct SpecializationContext auto resultType = inst->getFullType(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(inst); List<IRInst*> slotOperands; @@ -2135,7 +2123,7 @@ struct SpecializationContext auto baseType = type->getBaseType(); UInt slotOperandCount = type->getExistentialArgCount(); - IRBuilder builder(sharedBuilderStorage); + IRBuilder builder(module); builder.setInsertBefore(type); if( auto baseInterfaceType = as<IRInterfaceType>(baseType) ) @@ -2405,8 +2393,7 @@ IRInst* specializeGenericImpl( // into the global scope, at the same location // as the original generic. // - SharedIRBuilder sharedBuilderStorage(module); - IRBuilder builderStorage(sharedBuilderStorage); + IRBuilder builderStorage(module); IRBuilder* builder = &builderStorage; builder->setInsertBefore(genericVal); @@ -2440,7 +2427,7 @@ IRInst* specializeGenericImpl( // Clone decorations on the orignal `specialize` inst over to the newly specialized // value. cloneInstDecorationsAndChildren( - &env, &sharedBuilderStorage, specializeInst, specializedVal); + &env, module, specializeInst, specializedVal); return specializedVal; } |
