示例#1
0
bool Aa::get_loop_pipelining_info(llvm::BasicBlock& BB,int& pipelining_depth, int& buffering, bool& full_rate_flag)
{
	bool opt_fn_found = false;

	for(llvm::BasicBlock::iterator iiter = BB.begin(),fiter = BB.end(); 
			iiter != fiter;  ++iiter)
	{
		if(isa<CallInst>(*iiter))
		{
			llvm::CallInst& C = static_cast<CallInst&>(*iiter);
			llvm::Function* f  = C.getCalledFunction();

			if(f == NULL)
				return(false);

			if(f->isDeclaration())
			{
				StringRef name = f->getName();
				if(name.equals("__loop_pipelining_on__"))
				{
					opt_fn_found = true;
					if(C.getNumArgOperands() > 0)
					{
						llvm::Value* v = C.getArgOperand(0);	
						if(isa<Constant>(v))
						{
							int pd = get_uint32(dyn_cast<Constant>(v));
							if(pd > 0)
								pipelining_depth = pd;
						}	
						if(C.getNumArgOperands() > 1)
						{
							v = C.getArgOperand(1);	
							if(isa<Constant>(v))
							{
								int bd = get_uint32(dyn_cast<Constant>(v));
								if(bd > 0)
									buffering = bd;
							}
						}
						if(C.getNumArgOperands() > 2)
						{
							v = C.getArgOperand(2);	
							if(isa<Constant>(v))
							{
								int bd = get_uint32(dyn_cast<Constant>(v));
								if(bd > 0)
									full_rate_flag = true;
							}
						}
					}
					break;
				}
			}
		}
	}
	return(opt_fn_found);
}
示例#2
0
    //------------------------------------------------------------------
    /// Scan a basic block to see if any instructions are interesting
    ///
    /// @param[in] bb
    ///     The basic block to be inspected.
    ///
    /// @return
    ///     False if there was an error scanning; true otherwise.
    //------------------------------------------------------------------
    virtual bool InspectBasicBlock(llvm::BasicBlock &bb)
    {
        for (llvm::BasicBlock::iterator ii = bb.begin(), last_ii = bb.end();
             ii != last_ii;
             ++ii)
        {
            if (!InspectInstruction(*ii))
                return false;
        }

        return true;
    }
示例#3
0
bool Aa::is_marked_as_a_do_while_loop(llvm::BasicBlock& BB, int& pipelining_depth, int& buffering, bool& full_rate_flag)
{
        full_rate_flag = false;
	pipelining_depth = 1;
	buffering = 1;
	llvm::TerminatorInst* T = BB.getTerminator();

	if(isa<llvm::ReturnInst>(T))
		return(false);

	if(isa<llvm::SwitchInst>(T))
		return(false);

	if(T->getNumSuccessors() == 0)
		return(false);


	// optimize function must be called here in order
	// to pipeline this loop.
	bool opt_fn_found = get_loop_pipelining_info(BB,pipelining_depth, buffering, full_rate_flag); 
	return(opt_fn_found);
}