Example #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);
}
Example #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;
    }