Ejemplo n.º 1
0
void RemoveBarrierPass::_removeBarrier( analysis::DataflowGraph::iterator block, 
	unsigned int id )
{
	typedef analysis::DataflowGraph::RegisterSet RegisterSet;
	
	analysis::DataflowGraph::InstructionVector::const_iterator 
		_instruction( block->instructions().begin() );
	std::advance( _instruction, id );
	analysis::DataflowGraph::iterator exitBlock( _dfg().end() );
	std::advance( exitBlock, -1 );

	ir::PTXInstruction& instruction = static_cast< ir::PTXInstruction& >( 
		*_instruction->i );

	bool isBarrier = instruction.opcode == ir::PTXInstruction::Bar;

	if( isBarrier )
	{
		report( "  Converting instruction " << instruction.toString() );
		instruction.opcode = ir::PTXInstruction::Call;
		instruction.tailCall = true;
		instruction.branchTargetInstruction = -1;
		instruction.a = ir::PTXOperand(
			ir::PTXOperand::FunctionName, "_ZOcelotBarrierKernel");
		instruction.d.addressMode = ir::PTXOperand::Invalid;

		report( "   Converted to " << instruction.toString() );		
	}
	
	RegisterSet alive = block->alive( _instruction );
	
	analysis::DataflowGraph::iterator bottom = _dfg().split( block, 
		id + 1, false );

	_addSpillCode( block, bottom, alive, isBarrier );
	_addRestoreCode( bottom, alive );
	
	_dfg().redirect( block, bottom, exitBlock );
	
	if( !isBarrier && instruction.pg.condition != ir::PTXOperand::PT )
	{
		_dfg().target( block, bottom, true );
	}
	
	_addEntryPoint( bottom );
}
Ejemplo n.º 2
0
/* statement */
static int _statement(State * state)
	/* ( function | [ space [ instruction ] ] ) newline */
{
	int ret;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s()\n", __func__);
#endif
	if(_parser_in_set(state, TS_FUNCTION))
		/* function */
		ret = _function(state);
	else if(_parser_in_set(state, TS_SPACE))
	{
		/* space [ instruction ] */
		ret = _space(state);
		if(_parser_in_set(state, TS_INSTRUCTION))
			ret |= _instruction(state);
	}
	else if(!_parser_in_set(state, TS_NEWLINE))
		return _parser_recover(state, AS_CODE_NEWLINE, "Statement");
	ret |= _newline(state);
	return ret;
}