Esempio n. 1
0
void MakeDispatcherPass::ConvertSwitch( Function& function )
{
  BasicBlock* entryBB = &function.getEntryBlock();

  std::cout << ":Processing " << function.getName().str() << std::endl;

  for( Function::iterator i = function.begin(); i != function.end(); i++ )
    {
      BasicBlock* basicBlock = &*i;
      Instruction* inst;

      TerminatorInst* terminator = basicBlock->getTerminator();
      assert( terminator && "Basic block is not well formed and has no terminator!" );

      if( isa< BranchInst >( terminator ) )
        {
	  // std::cout << "Branch Instruction !!!" << std::endl;
	  BranchInst* branchInst = dynamic_cast< BranchInst *>
	    (
	     basicBlock->getTerminator()
	     );
	  std::cout << "Branch Instruction, Opcode = " <<
	    branchInst->getOpcodeName();
	  if (branchInst->isConditional())
	    {
	      inst = dynamic_cast<Instruction *>(basicBlock->getTerminator());
	      std::cout << ", Is Conditional ";
	      // i->eraseFromParent();
	    }
	  else
	    {
	      std::cout << ", Is not conditionnal ";
	    }

	  // if (valbranch) // && !valbranch->getName().empty())
	  //   {
	  //     valbranch->getType()->dump();
	  //     std::cout << valbranch->getName().str();
	  //   }
	  // branchInst->eraseFromParent();


	  std::cout << std::endl;

	  // std::cout << branchInst->getCondition()->getName.str() << std::endl;
        }
    }
}