本文整理汇总了C++中BlockSet类的典型用法代码示例。如果您正苦于以下问题:C++ BlockSet类的具体用法?C++ BlockSet怎么用?C++ BlockSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlockSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
bool run()
{
ASSERT(m_graph.m_form != SSA);
BlockSet blocksThatNeedInvalidationPoints;
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!block)
continue;
for (unsigned nodeIndex = 0; nodeIndex < block->size(); ++nodeIndex)
handle(nodeIndex, block->at(nodeIndex));
// Note: this assumes that control flow occurs at bytecode instruction boundaries.
if (m_originThatHadFire.isSet()) {
for (unsigned i = block->numSuccessors(); i--;)
blocksThatNeedInvalidationPoints.add(block->successor(i));
}
m_insertionSet.execute(block);
}
for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
BasicBlock* block = m_graph.block(blockIndex);
if (!blocksThatNeedInvalidationPoints.contains(block))
continue;
insertInvalidationCheck(0, block->at(0));
m_insertionSet.execute(block);
}
return true;
}
示例2: emit_frame
void ReplayAudioIngest::emit_frame(channel_entry &ch) {
BlockSet bset;
size_t i;
if (ch.fifo->fill_samples( ) < fft_size) {
throw std::runtime_error("cannot emit frame, not enough samples");
}
/* take FFT of ch.fifo->data( ) into ch.current_frame */
fft->compute(ch.current_frame, ch.fifo->data( ));
/* subtract phase of last_frame from phase of current_frame to get output_frame */
for (i = 0; i < fft_size; i++) {
output_frame[i] = std::polar(
std::abs(ch.current_frame[i]),
std::arg(ch.current_frame[i]) - std::arg(ch.last_frame[i])
);
}
/*
* swap last_frame and current_frame pointers
* (this makes current_frame the next last_frame)
*/
std::swap(ch.last_frame, ch.current_frame);
/* write output_frame to buffer */
bset.add_block(REPLAY_PVOC_BLOCK, output_frame, fft_size);
bset.add_block("Debug001", ch.fifo->data( ), fft_size);
ch.buffer->write_blockset(bset);
ch.fifo->pop_samples(fft_hop);
}
示例3: write_frame
timecode_t ReplayBuffer::write_frame(const ReplayFrameData &data) {
BlockSet blkset;
if (data.video_size == 0) {
throw std::runtime_error("Tried to write empty frame");
}
if (data.video_size > 0) {
blkset.add_block(
REPLAY_VIDEO_BLOCK,
data.video_data,
data.video_size
);
}
if (data.thumbnail_size > 0) {
blkset.add_block(
REPLAY_THUMBNAIL_BLOCK,
data.thumbnail_data,
data.thumbnail_size
);
}
if (data.audio != NULL) {
blkset.add_object(REPLAY_AUDIO_BLOCK, *(data.audio));
}
return write_blockset(blkset);
}
示例4: getBlocksWithCallsToFuctionsThatObserveSideEffects
static BlockSet getBlocksWithCallsToFuctionsThatObserveSideEffects(
ir::IRKernel& k)
{
BlockSet blocks;
report(" Getting functions that can observe side-effects");
for(auto block = k.cfg()->begin(); block != k.cfg()->end(); ++block)
{
for(auto instruction : block->instructions)
{
auto ptxInstruction = static_cast<ir::PTXInstruction*>(instruction);
// TODO: Check that the target can observe side effects
if(ptxInstruction->isCall())
{
report(" " << ptxInstruction->toString());
blocks.insert(block);
break;
}
}
}
return blocks;
}
示例5: getBlocksWithBranchesThatDependOn
static BlockSet getBlocksWithBranchesThatDependOn(
const BlockSet& blocksWithBackwardsBranches,
const InstructionSet& instructionsThatCanObserveSideEffects,
DependenceAnalysis* dependenceAnalysis,
ControlDependenceAnalysis* controlDependenceAnalysis)
{
BlockSet blocksWithDependentBranches;
report(" Getting blocks with branches that can observe side-effects");
for(auto blockWithBranch : blocksWithBackwardsBranches)
{
auto branch = getBranch(blockWithBranch);
if(branch == nullptr) continue;
auto controlDependentInstructions = getControlDependentInstructions(
branch, instructionsThatCanObserveSideEffects,
controlDependenceAnalysis);
for(auto instruction : controlDependentInstructions)
{
if(dependenceAnalysis->dependsOn(instruction, branch))
{
report(" " << blockWithBranch->label());
blocksWithDependentBranches.insert(blockWithBranch);
break;
}
}
}
return blocksWithDependentBranches;
}
示例6: getSubgraphConnectedToTheseOutputs
Layer Layer::getSubgraphConnectedToTheseOutputs(
const NeuronSet& outputs) const
{
typedef std::set<size_t> BlockSet;
BlockSet blocks;
// TODO: eliminate the reundant inserts
for(auto& output : outputs)
{
size_t block = (output / getOutputBlockingFactor()) % this->blocks();
blocks.insert(block);
}
Layer layer(blocks.size(), getInputBlockingFactor(),
getOutputBlockingFactor(), blockStep());
for(auto& block : blocks)
{
size_t blockIndex = block - *blocks.begin();
layer[blockIndex] = (*this)[block];
layer.at_bias(blockIndex) = at_bias(block);
}
return layer;
}
示例7: stateflowRegex
Udm::Object MatLabUdmChart::distinguish( Udm::Object udmParent ) {
SLSF::State state;
static boost::regex stateflowRegex( "stateflow", boost::regex_constants::perl | boost::regex_constants::icase );
boost::match_results<std::string::const_iterator> results;
SLSF::Subsystem subsystemParent = SLSF::Subsystem::Cast( udmParent );
BlockSet blockSet = subsystemParent.Block_kind_children();
Udm::Object chartParent = udmParent;
for( BlockSet::iterator blsItr = blockSet.begin() ; blsItr != blockSet.end() ; ++blsItr ) {
Block block = *blsItr;
std::string tag( block.Tag() );
if ( regex_search( tag, results, stateflowRegex ) ) {
chartParent = block;
break;
}
}
#if PARADIGM == CyberComposition_PARADIGM
state = SLSF::State::Create( chartParent );
#else
state = SLSF::State::Create( UdmEngine::get_singleton().getTopLevelState() );
SLSF::ConnectorRef connectorRef = SLSF::ConnectorRef::Create( chartParent );
connectorRef.ref() = state;
#endif
return state;
}
示例8: GetBestBlocks
BlockSet Drainer::GetBestBlocks() const
{
BlockSet set;
set.reserve(m_RootMacro->m_BestBlocks.size());
for (auto blk : m_RootMacro->m_BestBlocks)
set.push_back(m_Blocks[blk]);
return set;
}
示例9: report
ControlFlowGraph::BlockPointerVector
ControlFlowGraph::reverse_topological_sequence() {
typedef std::set<iterator, BlockSetCompare> BlockSet;
typedef std::queue<iterator> Queue;
report("Creating reverse topological order traversal");
BlockSet visited;
BlockPointerVector sequence;
Queue queue;
queue.push(get_exit_block());
while (sequence.size() != size()) {
if(queue.empty()) {
for (pointer_iterator block = sequence.begin();
block != sequence.end(); ++block) {
for (pointer_iterator pred = (*block)->predecessors.begin();
pred != (*block)->predecessors.end(); ++pred) {
if (visited.count(*pred) == 0) {
queue.push(*pred);
break;
}
}
if(!queue.empty()) {
break;
}
}
if(queue.empty()) break; // The remaining blocks are unreachable
}
iterator current = queue.front();
queue.pop();
if(!visited.insert(current).second) continue;
sequence.push_back(current);
report(" Adding block " << current->label());
for (pointer_iterator block = current->predecessors.begin();
block != current->predecessors.end(); ++block) {
bool noDependencies = true;
for (pointer_iterator successor = (*block)->successors.begin();
successor != (*block)->successors.end(); ++successor) {
if (visited.count(*successor) == 0) {
noDependencies = false;
break;
}
}
if(noDependencies) {
queue.push(*block);
}
}
}
return sequence;
}
示例10: Fill
void TotalGenerator::Fill(BlockSet &data)
{
std::vector<int_fast8_t> set(data.FullSize(), false);
for (auto i = 0; i < m_Total; i++)
set[i] = true;
std::shuffle(set.begin(), set.end(), m_Random);
for (auto i = 0; i < data.FullSize(); i++)
if (set[i])
data += i;
}
示例11: ASSERT
void TextAutosizer::FingerprintMapper::assertMapsAreConsistent()
{
// For each fingerprint -> block mapping in m_blocksForFingerprint we should have an associated
// map from block -> fingerprint in m_fingerprints.
ReverseFingerprintMap::iterator end = m_blocksForFingerprint.end();
for (ReverseFingerprintMap::iterator fingerprintIt = m_blocksForFingerprint.begin(); fingerprintIt != end; ++fingerprintIt) {
Fingerprint fingerprint = fingerprintIt->key;
BlockSet* blocks = fingerprintIt->value.get();
for (BlockSet::iterator blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt) {
const LayoutBlock* block = (*blockIt);
ASSERT(m_fingerprints.get(block) == fingerprint);
}
}
}
示例12: generateSideWalk
/**
* Generate side walks
*/
void VBOPmBlocks::generateSideWalk(VBORenderManager* renderManager, BlockSet& blocks) {
for (int i = 0; i < blocks.size(); ++i) {
if (!blocks[i].valid) continue;
BBox3D bbox;
blocks[i].sidewalkContour.getBBox3D(bbox.minPt, bbox.maxPt);
// If the block is too narrow, make it invalid.
if (blocks[i].sidewalkContour.isTooNarrow(8.0f, 18.0f) || blocks[i].sidewalkContour.isTooNarrow(1.0f, 3.0f)) {
blocks[i].valid = false;
continue;
}
// If the block is close or under waterlevel, or on a steep terain, make it invalid.
float min_z = std::numeric_limits<float>::max();
float max_z = 0.0f;
for (int pi = 0; pi < blocks[i].sidewalkContour.contour.size(); ++pi) {
int next_pi = (pi + 1) % blocks[i].sidewalkContour.contour.size();
for (int k = 0; k <= 20; ++k) {
QVector3D pt = blocks[i].sidewalkContour.contour[pi] * (float)(20 - k) * 0.05 + blocks[i].sidewalkContour.contour[next_pi] * (float)k * 0.05;
float z = renderManager->getTerrainHeight(pt.x(), pt.y());
min_z = std::min(min_z, z);
max_z = std::max(max_z, z);
}
//float z = renderManager->getTerrainHeight(blocks[i].sidewalkContour.contour[pi].x(), blocks[i].sidewalkContour.contour[pi].y());
//min_z = std::min(min_z, z);
//max_z = std::max(max_z, z);
}
if (min_z < 40.0f) {
blocks[i].valid = false;
continue;
} else if (max_z - min_z > 20.0f) {
blocks[i].isPark = true;
continue;
}
}
// Compute the block contour (the outer part becomes sidewalks)
for (int i = 0; i < blocks.size(); ++i) {
if (!blocks[i].valid) continue;
//if (blocks[i].isPark) continue;
Loop3D blockContourInset;
float sidewalk_width = G::getFloat("sidewalk_width");
blocks[i].sidewalkContour.computeInset(sidewalk_width, blockContourInset, false);
blocks[i].blockContour.contour = blockContourInset;
//blocks[i].blockContour.getBBox3D(blocks[i].bbox.minPt, blocks[i].bbox.maxPt);
}
}
示例13: get
SILValue
StackAllocationPromoter::getLiveOutValue(BlockSet &PhiBlocks,
SILBasicBlock *StartBB) {
DEBUG(llvm::dbgs() << "*** Searching for a value definition.\n");
// Walk the Dom tree in search of a defining value:
for (DomTreeNode *Node = DT->getNode(StartBB); Node; Node = Node->getIDom()) {
SILBasicBlock *BB = Node->getBlock();
// If there is a store (that must come after the phi), use its value.
BlockToInstMap::iterator it = LastStoreInBlock.find(BB);
if (it != LastStoreInBlock.end())
if (auto *St = dyn_cast_or_null<StoreInst>(it->second)) {
DEBUG(llvm::dbgs() << "*** Found Store def " << *St->getSrc());
return St->getSrc();
}
// If there is a Phi definition in this block:
if (PhiBlocks.count(BB)) {
// Return the dummy instruction that represents the new value that we will
// add to the basic block.
SILValue Phi = BB->getArgument(BB->getNumArguments() - 1);
DEBUG(llvm::dbgs() << "*** Found a dummy Phi def " << *Phi);
return Phi;
}
// Move to the next dominating block.
DEBUG(llvm::dbgs() << "*** Walking up the iDOM.\n");
}
DEBUG(llvm::dbgs() << "*** Could not find a Def. Using Undef.\n");
return SILUndef::get(ASI->getElementType(), ASI->getModule());
}
示例14: allPreviousDefinitionsDominateMove
static bool allPreviousDefinitionsDominateMove(instruction_iterator move,
block_iterator block, BlockSet& visited)
{
if(!visited.insert(block->id()).second) return true;
assert(move->d.size() == 1);
auto destination = *move->d.front().pointer;
// If the value is defined by a phi with multiple sources, then the
// previous definition does not dominate the move
for(auto phi = block->phis().begin(); phi != block->phis().end(); ++phi)
{
if(phi->d == destination)
{
return false;
}
}
// Check all predecessors with the value live out
for(auto predecessor = block->predecessors().begin();
predecessor != block->predecessors().end(); ++predecessor)
{
if((*predecessor)->aliveOut().count(destination) == 0) continue;
if(!allPreviousDefinitionsDominateMove(move, *predecessor, visited))
{
return false;
}
}
return true;
}
示例15: chaseDownPredecessors
static void chaseDownPredecessors(iterator node, Register value,
DataflowGraph* dfg,
dataflow_iterator block, NodeList& nodes,
InstructionToNodeMap& instructionToNodes, BlockSet& visited)
{
if(!visited.insert(block).second) return;
assert(block->aliveIn().count(value) != 0);
for(auto predecessor : block->predecessors())
{
if(predecessor->aliveOut().count(value) == 0) continue;
bool foundAnyDefinitions = false;
// check the body for a definition
for(auto instruction = predecessor->instructions().rbegin();
instruction != predecessor->instructions().rend(); ++instruction)
{
for(auto destination : instruction->d)
{
if(*destination.pointer == value)
{
auto producer = nodes.end();
auto ptx = static_cast<PTXInstruction*>(instruction->i);
auto existingNode = instructionToNodes.find(ptx);
if(existingNode == instructionToNodes.end())
{
producer = nodes.insert(nodes.end(), Node(ptx));
instructionToNodes.insert(
std::make_pair(ptx, producer));
}
else
{
producer = existingNode->second;
}
report(" " << producer->instruction->toString() << " -> "
<< node->instruction->toString());
node->predecessors.push_back(producer);
producer->successors.push_back(node);
foundAnyDefinitions = true;
break;
}
}
}
if(foundAnyDefinitions) continue;
// if no definitions were found, recurse through predecessors
chaseDownPredecessors(node, value, dfg, predecessor, nodes,
instructionToNodes, visited);
}
}