MCPcopy Create free account
hub / github.com/Inori/GPCS4 / emitControlFlowEndIf

Method emitControlFlowEndIf

GPCS4/Graphics/Gcn/GcnCompilerFlowControl.cpp:398–443  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

396 }
397
398 void GcnCompiler::emitControlFlowEndIf(const GcnToken& token)
399 {
400 if (m_controlFlowStack.size() == 0 ||
401 m_controlFlowStack.back().type != GcnCfgBlockType::If)
402 {
403 Logger::exception("GcnCompiler: 'EndIf' without 'If' found");
404 }
405
406 // Remove the block from the stack, it's closed
407 GcnCfgBlock block = m_controlFlowStack.back();
408 m_controlFlowStack.pop_back();
409
410 uint32_t labelMerge = m_blockTerminators.empty()
411 ? block.b_if.labelEnd
412 : m_blockTerminators.back();
413
414 // Write out the 'if' header
415 m_module.beginInsertion(block.b_if.headerPtr);
416
417 m_module.opSelectionMerge(
418 labelMerge,
419 spv::SelectionControlMaskNone);
420
421 m_module.opBranchConditional(
422 block.b_if.conditionId,
423 block.b_if.labelIf,
424 block.b_if.labelElse != 0
425 ? block.b_if.labelElse
426 : labelMerge);
427
428 m_module.endInsertion();
429
430 if (m_blockTerminators.empty())
431 {
432 // End the active 'if' or 'else' block
433 m_module.opBranch(labelMerge);
434 m_module.opLabel(labelMerge);
435 }
436 else
437 {
438 // if the block is already closed by other terminator instruction,
439 // then don't emit branch
440 // remove the terminator
441 m_blockTerminators.pop_back();
442 }
443 }
444
445 void GcnCompiler::emitControlFlowLoop(const GcnToken& token)
446 {

Callers 1

compileTokenEndMethod · 0.95

Calls 11

exceptionFunction · 0.85
backMethod · 0.80
opSelectionMergeMethod · 0.80
opBranchConditionalMethod · 0.80
opBranchMethod · 0.80
opLabelMethod · 0.80
sizeMethod · 0.45
pop_backMethod · 0.45
emptyMethod · 0.45
beginInsertionMethod · 0.45
endInsertionMethod · 0.45

Tested by

no test coverage detected