| 331 | } |
| 332 | |
| 333 | void GcnTokenListBuilder::popScopes(GcnCfgVertex vtx) |
| 334 | { |
| 335 | // Check if we need to close some scopes |
| 336 | while (!m_scopeStack.empty()) |
| 337 | { |
| 338 | auto& scope = m_scopeStack.back(); |
| 339 | switch (scope.m_kind) |
| 340 | { |
| 341 | case Scope::If: |
| 342 | case Scope::Direct: |
| 343 | { |
| 344 | if (scope.m_nested && m_domTree.dominates(scope.m_vertex, vtx)) |
| 345 | { |
| 346 | return; |
| 347 | } |
| 348 | |
| 349 | // If the scope is not nested, add the branch token |
| 350 | if (!scope.m_nested) |
| 351 | { |
| 352 | auto iter = m_loopHeaders.find(scope.m_vertex); |
| 353 | GcnToken* branch = iter == m_loopHeaders.end() |
| 354 | ? m_factory.createBranch(nullptr) |
| 355 | : m_factory.createBranch(iter->second); |
| 356 | |
| 357 | m_blockScopes[scope.m_vertex].push_back(branch); |
| 358 | m_insertPtr = m_tokens->insertAfter(m_insertPtr, branch); |
| 359 | } |
| 360 | } |
| 361 | break; |
| 362 | case Scope::Loop: |
| 363 | { |
| 364 | const auto loop = m_loopInfo.getLoop(scope.m_vertex); |
| 365 | auto iter = m_loopCounts.find(loop); |
| 366 | LOG_ASSERT(iter != m_loopCounts.end(), "can't find loop."); |
| 367 | uint32_t countLeft = iter->second; |
| 368 | if (countLeft > 0) |
| 369 | { |
| 370 | return; |
| 371 | } |
| 372 | } |
| 373 | break; |
| 374 | } |
| 375 | |
| 376 | if (scope.m_endPtr != m_tokens->end()) |
| 377 | { |
| 378 | m_insertPtr = scope.m_endPtr; |
| 379 | } |
| 380 | |
| 381 | m_scopeStack.pop_back(); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | GcnToken* GcnTokenListBuilder::makeCode(GcnCfgVertex vtx) |
| 386 | { |
nothing calls this directly
no test coverage detected