all but CAS working on x86
[oota-llvm.git] / lib / CodeGen / IfConversion.cpp
index a98347b486ed759f1dc70291e3c13e7952d213cf..a77ccb766ff60737b03d03706d8ce50cebfddd0b 100644 (file)
@@ -56,7 +56,7 @@ STATISTIC(NumIfConvBBs,    "Number of if-converted blocks");
 STATISTIC(NumDupBBs,       "Number of duplicated blocks");
 
 namespace {
-  class IfConverter : public MachineFunctionPass {
+  class VISIBILITY_HIDDEN IfConverter : public MachineFunctionPass {
     enum IfcvtKind {
       ICNotClassfied,  // BB data valid, but not classified.
       ICSimpleFalse,   // Same as ICSimple, but on the false path.
@@ -237,7 +237,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
 
   // Look for root nodes, i.e. blocks without successors.
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
-    if (I->succ_size() == 0)
+    if (I->succ_empty())
       Roots.push_back(I);
 
   std::vector<IfcvtToken*> Tokens;
@@ -278,9 +278,10 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
                  : BBI.TrueBB->getNumber()) << ") ";
         RetVal = IfConvertSimple(BBI, Kind);
         DOUT << (RetVal ? "succeeded!" : "failed!") << "\n";
-        if (RetVal)
+        if (RetVal) {
           if (isFalse) NumSimpleFalse++;
           else         NumSimple++;
+        }
        break;
       }
       case ICTriangle:
@@ -428,7 +429,7 @@ bool IfConverter::ValidTriangle(BBInfo &TrueBBI, BBInfo &FalseBBI,
 
     unsigned Size = TrueBBI.NonPredSize;
     if (TrueBBI.IsBrAnalyzable) {
-      if (TrueBBI.TrueBB && TrueBBI.BrCond.size() == 0)
+      if (TrueBBI.TrueBB && TrueBBI.BrCond.empty())
         // End with an unconditional branch. It will be removed.
         --Size;
       else {
@@ -460,7 +461,7 @@ MachineBasicBlock::iterator firstNonBranchInst(MachineBasicBlock *BB,
   MachineBasicBlock::iterator I = BB->end();
   while (I != BB->begin()) {
     --I;
-    if (!I->getDesc()->isBranch())
+    if (!I->getDesc().isBranch())
       break;
   }
   return I;
@@ -548,12 +549,12 @@ void IfConverter::ScanInstructions(BBInfo &BBI) {
   bool SeenCondBr = false;
   for (MachineBasicBlock::iterator I = BBI.BB->begin(), E = BBI.BB->end();
        I != E; ++I) {
-    const TargetInstrDescriptor *TID = I->getDesc();
-    if (TID->isNotDuplicable())
+    const TargetInstrDesc &TID = I->getDesc();
+    if (TID.isNotDuplicable())
       BBI.CannotBeCopied = true;
 
     bool isPredicated = TII->isPredicated(I);
-    bool isCondBr = BBI.IsBrAnalyzable && TID->isConditionalBranch();
+    bool isCondBr = BBI.IsBrAnalyzable && TID.isConditionalBranch();
 
     if (!isCondBr) {
       if (!isPredicated)
@@ -590,7 +591,7 @@ void IfConverter::ScanInstructions(BBInfo &BBI) {
     if (TII->DefinesPredicate(I, PredDefs))
       BBI.ClobbersPred = true;
 
-    if (!TID->isPredicable()) {
+    if (!TID.isPredicable()) {
       BBI.IsUnpredicable = true;
       return;
     }
@@ -646,7 +647,7 @@ IfConverter::BBInfo &IfConverter::AnalyzeBlock(MachineBasicBlock *BB,
   ScanInstructions(BBI);
 
   // Unanalyable or ends with fallthrough or unconditional branch.
-  if (!BBI.IsBrAnalyzable || BBI.BrCond.size() == 0) {
+  if (!BBI.IsBrAnalyzable || BBI.BrCond.empty()) {
     BBI.IsBeingAnalyzed = false;
     BBI.IsAnalyzed = true;
     return BBI;
@@ -1132,10 +1133,10 @@ void IfConverter::CopyAndPredicateBlock(BBInfo &ToBBI, BBInfo &FromBBI,
                                         bool IgnoreBr) {
   for (MachineBasicBlock::iterator I = FromBBI.BB->begin(),
          E = FromBBI.BB->end(); I != E; ++I) {
-    const TargetInstrDescriptor *TID = I->getDesc();
+    const TargetInstrDesc &TID = I->getDesc();
     bool isPredicated = TII->isPredicated(I);
     // Do not copy the end of the block branches.
-    if (IgnoreBr && !isPredicated && TID->isBranch())
+    if (IgnoreBr && !isPredicated && TID.isBranch())
       break;
 
     MachineInstr *MI = I->clone();