X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FIfConversion.cpp;h=fb53377b98ba0959468d0a9fca07bb1f77f003c0;hb=a9407f593778c3eff02dbb1fa11129865a59c6d3;hp=54069c6b94bca9750a782c8f78f952e250866498;hpb=4ee451de366474b9c228b4e5fa573795a715216d;p=oota-llvm.git diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp index 54069c6b94b..fb53377b98b 100644 --- a/lib/CodeGen/IfConversion.cpp +++ b/lib/CodeGen/IfConversion.cpp @@ -26,26 +26,24 @@ #include "llvm/ADT/STLExtras.h" using namespace llvm; -namespace { - // Hidden options for help debugging. - cl::opt IfCvtFnStart("ifcvt-fn-start", cl::init(-1), cl::Hidden); - cl::opt IfCvtFnStop("ifcvt-fn-stop", cl::init(-1), cl::Hidden); - cl::opt IfCvtLimit("ifcvt-limit", cl::init(-1), cl::Hidden); - cl::opt DisableSimple("disable-ifcvt-simple", - cl::init(false), cl::Hidden); - cl::opt DisableSimpleF("disable-ifcvt-simple-false", - cl::init(false), cl::Hidden); - cl::opt DisableTriangle("disable-ifcvt-triangle", - cl::init(false), cl::Hidden); - cl::opt DisableTriangleR("disable-ifcvt-triangle-rev", - cl::init(false), cl::Hidden); - cl::opt DisableTriangleF("disable-ifcvt-triangle-false", - cl::init(false), cl::Hidden); - cl::opt DisableTriangleFR("disable-ifcvt-triangle-false-rev", - cl::init(false), cl::Hidden); - cl::opt DisableDiamond("disable-ifcvt-diamond", - cl::init(false), cl::Hidden); -} +// Hidden options for help debugging. +static cl::opt IfCvtFnStart("ifcvt-fn-start", cl::init(-1), cl::Hidden); +static cl::opt IfCvtFnStop("ifcvt-fn-stop", cl::init(-1), cl::Hidden); +static cl::opt IfCvtLimit("ifcvt-limit", cl::init(-1), cl::Hidden); +static cl::opt DisableSimple("disable-ifcvt-simple", + cl::init(false), cl::Hidden); +static cl::opt DisableSimpleF("disable-ifcvt-simple-false", + cl::init(false), cl::Hidden); +static cl::opt DisableTriangle("disable-ifcvt-triangle", + cl::init(false), cl::Hidden); +static cl::opt DisableTriangleR("disable-ifcvt-triangle-rev", + cl::init(false), cl::Hidden); +static cl::opt DisableTriangleF("disable-ifcvt-triangle-false", + cl::init(false), cl::Hidden); +static cl::opt DisableTriangleFR("disable-ifcvt-triangle-false-rev", + cl::init(false), cl::Hidden); +static cl::opt DisableDiamond("disable-ifcvt-diamond", + cl::init(false), cl::Hidden); STATISTIC(NumSimple, "Number of simple if-conversions performed"); STATISTIC(NumSimpleFalse, "Number of simple (F) if-conversions performed"); @@ -239,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 Tokens; @@ -430,7 +428,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 { @@ -462,8 +460,7 @@ MachineBasicBlock::iterator firstNonBranchInst(MachineBasicBlock *BB, MachineBasicBlock::iterator I = BB->end(); while (I != BB->begin()) { --I; - const TargetInstrDescriptor *TID = I->getInstrDescriptor(); - if ((TID->Flags & M_BRANCH_FLAG) == 0) + if (!I->getDesc().isBranch()) break; } return I; @@ -522,7 +519,7 @@ bool IfConverter::ValidDiamond(BBInfo &TrueBBI, BBInfo &FalseBBI, /// ScanInstructions - Scan all the instructions in the block to determine if /// the block is predicable. In most cases, that means all the instructions -/// in the block has M_PREDICABLE flag. Also checks if the block contains any +/// in the block are isPredicable(). Also checks if the block contains any /// instruction which can clobber a predicate (e.g. condition code register). /// If so, the block is not predicable unless it's the last instruction. void IfConverter::ScanInstructions(BBInfo &BBI) { @@ -551,13 +548,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->getInstrDescriptor(); - if ((TID->Flags & M_NOT_DUPLICABLE) != 0) + const TargetInstrDesc &TID = I->getDesc(); + if (TID.isNotDuplicable()) BBI.CannotBeCopied = true; bool isPredicated = TII->isPredicated(I); - bool isCondBr = BBI.IsBrAnalyzable && - (TID->Flags & M_BRANCH_FLAG) != 0 && (TID->Flags & M_BARRIER_FLAG) == 0; + bool isCondBr = BBI.IsBrAnalyzable && TID.isConditionalBranch(); if (!isCondBr) { if (!isPredicated) @@ -594,7 +590,7 @@ void IfConverter::ScanInstructions(BBInfo &BBI) { if (TII->DefinesPredicate(I, PredDefs)) BBI.ClobbersPred = true; - if ((TID->Flags & M_PREDICABLE) == 0) { + if (!TID.isPredicable()) { BBI.IsUnpredicable = true; return; } @@ -650,7 +646,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; @@ -1136,10 +1132,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->getInstrDescriptor(); + const TargetInstrDesc &TID = I->getDesc(); bool isPredicated = TII->isPredicated(I); // Do not copy the end of the block branches. - if (IgnoreBr && !isPredicated && (TID->Flags & M_BRANCH_FLAG) != 0) + if (IgnoreBr && !isPredicated && TID.isBranch()) break; MachineInstr *MI = I->clone();