Comments in header
| 4492 | |
| 4493 | // Comments in header |
| 4494 | void Builder::makeSwitch(Id selector, SelectionControlMask control, int numSegments, const std::vector<int>& caseValues, |
| 4495 | const std::vector<int>& valueIndexToSegment, int defaultSegment, |
| 4496 | std::vector<Block*>& segmentBlocks) |
| 4497 | { |
| 4498 | Function& function = buildPoint->getParent(); |
| 4499 | |
| 4500 | // make all the blocks |
| 4501 | for (int s = 0; s < numSegments; ++s) |
| 4502 | segmentBlocks.push_back(new Block(getUniqueId(), function)); |
| 4503 | |
| 4504 | Block* mergeBlock = new Block(getUniqueId(), function); |
| 4505 | |
| 4506 | // make and insert the switch's selection-merge instruction |
| 4507 | createSelectionMerge(mergeBlock, control); |
| 4508 | |
| 4509 | // make the switch instruction |
| 4510 | Instruction* switchInst = new Instruction(NoResult, NoType, Op::OpSwitch); |
| 4511 | switchInst->reserveOperands((caseValues.size() * 2) + 2); |
| 4512 | switchInst->addIdOperand(selector); |
| 4513 | auto defaultOrMerge = (defaultSegment >= 0) ? segmentBlocks[defaultSegment] : mergeBlock; |
| 4514 | switchInst->addIdOperand(defaultOrMerge->getId()); |
| 4515 | defaultOrMerge->addPredecessor(buildPoint); |
| 4516 | for (int i = 0; i < (int)caseValues.size(); ++i) { |
| 4517 | switchInst->addImmediateOperand(caseValues[i]); |
| 4518 | switchInst->addIdOperand(segmentBlocks[valueIndexToSegment[i]]->getId()); |
| 4519 | segmentBlocks[valueIndexToSegment[i]]->addPredecessor(buildPoint); |
| 4520 | } |
| 4521 | addInstruction(std::unique_ptr<Instruction>(switchInst)); |
| 4522 | |
| 4523 | // push the merge block |
| 4524 | switchMerges.push(mergeBlock); |
| 4525 | } |
| 4526 | |
| 4527 | // Comments in header |
| 4528 | void Builder::addSwitchBreak(bool implicit) |
no test coverage detected