Beispiel #1
0
void fun_llvm_2_nts::process_instruction ( const llvm::Instruction & i, StateInfo & st )
{
	switch ( i.getOpcode() )
	{
		case Instruction::Alloca:
			return ctx.m_alloca.process ( bni, st, funmap, i );

		case Instruction::Call:
			return ctx.m_icall.process ( bni, st, funmap, i );

		case Instruction::Store:
		case Instruction::Load:
		case Instruction::Ret:
			return ctx.m_ils.process ( bni, st, funmap, i );

		case Instruction::Add:
			return ctx.m_ia.process ( bni, st, funmap, i );

		case Instruction::ICmp:
			return ctx.m_icmp.process ( bni, st, funmap, i );

		case Instruction::Br:
			return ctx.m_ibr.process ( bni, st, funmap, i );

		default:
		{
			string s ( "Instruction not implemented: " );
			throw std::domain_error ( ( s + i.getOpcodeName() ).c_str() );
		}

	}
}
unsigned 
InstructionCostEstimator::getInstructionCost(const llvm::Instruction &I) {
  switch (I.getOpcode()) {
    case llvm::Instruction::GetElementPtr:
      return Cost::Low;
    case llvm::Instruction::Ret:
    case llvm::Instruction::PHI:
    case llvm::Instruction::Br:
      return Cost::No;
    case llvm::Instruction::FRem:
    case llvm::Instruction::FAdd:
    case llvm::Instruction::FSub:
    case llvm::Instruction::FMul:
    case llvm::Instruction::FDiv:
      return Cost::Medium;
    case llvm::Instruction::Add:
    case llvm::Instruction::Sub:
    case llvm::Instruction::Mul:
    case llvm::Instruction::UDiv:
    case llvm::Instruction::SDiv:
    case llvm::Instruction::URem:
    case llvm::Instruction::SRem:
    case llvm::Instruction::Shl:
    case llvm::Instruction::LShr:
    case llvm::Instruction::AShr:
    case llvm::Instruction::And:
    case llvm::Instruction::Or:
    case llvm::Instruction::Xor:
      return Cost::Low;
    case llvm::Instruction::Select:
      return Cost::Low;
    case llvm::Instruction::ICmp:
    case llvm::Instruction::FCmp:
      return Cost::Low;
    case llvm::Instruction::Store:
      return Cost::Low;
    case llvm::Instruction::Load:
      return Cost::Low;
    case llvm::Instruction::ZExt:
    case llvm::Instruction::SExt:
    case llvm::Instruction::FPToUI:
    case llvm::Instruction::FPToSI:
    case llvm::Instruction::FPExt:
    case llvm::Instruction::PtrToInt:
    case llvm::Instruction::IntToPtr:
    case llvm::Instruction::SIToFP:
    case llvm::Instruction::UIToFP:
    case llvm::Instruction::Trunc:
    case llvm::Instruction::FPTrunc:
    case llvm::Instruction::BitCast:
    case llvm::Instruction::AddrSpaceCast:
      return Cost::No;
    case llvm::Instruction::ExtractElement:
      return Cost::Low;
    case llvm::Instruction::InsertElement:
      return Cost::Low;
    case llvm::Instruction::ShuffleVector:
      return Cost::Low;
    case llvm::Instruction::Call:
      return Cost::Low;
    default:
      return Cost::Low;
  }
}