diff options
Diffstat (limited to 'source/slang/slang-ir-ssa.cpp')
| -rw-r--r-- | source/slang/slang-ir-ssa.cpp | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index b195af2cc..d8246edae 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -83,8 +83,7 @@ struct ConstructSSAContext // Information about each basic block Dictionary<IRBlock*, RefPtr<SSABlockInfo>> blockInfos; - // IR building state to use during the operation - SharedIRBuilder* sharedBuilder; + IRModule* module; // Instructions to remove during cleanup List<IRInst*> instsToRemove; @@ -923,23 +922,15 @@ IRBlock* IREdge::getSuccessor() const return cast<IRBlock>(getUse()->get()); } -void SharedIRBuilder::init(IRModule* module) -{ - m_module = module; - m_session = module->getSession(); - - m_globalValueNumberingMap.Clear(); - m_constantMap.Clear(); -} - -void SharedIRBuilder::insertBlockAlongEdge( +void IRBuilder::insertBlockAlongEdge( + IRModule* module, IREdge const& edge) { auto pred = edge.getPredecessor(); auto succ = edge.getSuccessor(); auto edgeUse = edge.getUse(); - IRBuilder builder(this); + IRBuilder builder(module); builder.setInsertInto(pred); // Create a new block that will sit "along" the edge @@ -1052,7 +1043,7 @@ static void breakCriticalEdges( for (auto edge : criticalEdges) { - context->sharedBuilder->insertBlockAlongEdge(edge); + IRBuilder::insertBlockAlongEdge(context->module, edge); } } @@ -1082,7 +1073,7 @@ bool constructSSA(ConstructSSAContext* context) auto blockInfo = new SSABlockInfo(); blockInfo->block = bb; - blockInfo->builder.init(context->sharedBuilder); + blockInfo->builder = IRBuilder(context->module); blockInfo->builder.setInsertBefore(bb->getLastInst()); context->blockInfos.Add(bb, blockInfo); @@ -1208,34 +1199,16 @@ bool constructSSA(ConstructSSAContext* context) return true; } -// Construct SSA form for a global value with code -bool constructSSA(IRModule* module, IRGlobalValueWithCode* globalVal) -{ - ConstructSSAContext context; - context.globalVal = globalVal; - - SharedIRBuilder sharedBuilder(module); - context.sharedBuilder = &sharedBuilder; - - context.builder.init(context.sharedBuilder); - context.builder.setInsertInto(module); - - return constructSSA(&context); -} - // Construct SSA form for a global value with code and reuse // an existing sharedBuilder // -bool constructSSA(SharedIRBuilder* sharedBuilder, IRGlobalValueWithCode* globalVal) +bool constructSSA(IRModule* module, IRGlobalValueWithCode* globalVal) { ConstructSSAContext context; context.globalVal = globalVal; - - context.sharedBuilder = sharedBuilder; - - context.builder.init(sharedBuilder); - context.builder.setInsertInto(sharedBuilder->getModule()); - + context.module = module; + context.builder = IRBuilder(module); + context.builder.setInsertInto(module); return constructSSA(&context); } |
