diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2014-01-09 02:29:41 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2014-01-09 02:29:41 +0000 |
commit | 560e3955c3c4fe0a3ae88fd91a1b7780b8fe7810 (patch) | |
tree | 77aed3e451050c08fe443b73e42ccac2fc13d366 /lib/Analysis | |
parent | 58691befda948d2a69f93e91d4aeedc0e7c38501 (diff) | |
download | llvm-560e3955c3c4fe0a3ae88fd91a1b7780b8fe7810.tar.gz llvm-560e3955c3c4fe0a3ae88fd91a1b7780b8fe7810.tar.bz2 llvm-560e3955c3c4fe0a3ae88fd91a1b7780b8fe7810.tar.xz |
Put the functionality for printing a value to a raw_ostream as an
operand into the Value interface just like the core print method is.
That gives a more conistent organization to the IR printing interfaces
-- they are all attached to the IR objects themselves. Also, update all
the users.
This removes the 'Writer.h' header which contained only a single function
declaration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198836 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/AliasAnalysisCounter.cpp | 7 | ||||
-rw-r--r-- | lib/Analysis/AliasAnalysisEvaluator.cpp | 7 | ||||
-rw-r--r-- | lib/Analysis/AliasSetTracker.cpp | 5 | ||||
-rw-r--r-- | lib/Analysis/DominanceFrontier.cpp | 5 | ||||
-rw-r--r-- | lib/Analysis/IPA/FindUsedTypes.cpp | 1 | ||||
-rw-r--r-- | lib/Analysis/IVUsers.cpp | 7 | ||||
-rw-r--r-- | lib/Analysis/Lint.cpp | 3 | ||||
-rw-r--r-- | lib/Analysis/LoopInfo.cpp | 1 | ||||
-rw-r--r-- | lib/Analysis/MemDepPrinter.cpp | 3 | ||||
-rw-r--r-- | lib/Analysis/ModuleDebugInfoPrinter.cpp | 1 | ||||
-rw-r--r-- | lib/Analysis/PostDominators.cpp | 1 | ||||
-rw-r--r-- | lib/Analysis/RegionInfo.cpp | 5 | ||||
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 17 | ||||
-rw-r--r-- | lib/Analysis/Trace.cpp | 3 |
14 files changed, 26 insertions, 40 deletions
diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 2649836f57..0211be19ab 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -14,7 +14,6 @@ #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/IR/Writer.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -138,10 +137,10 @@ AliasAnalysisCounter::alias(const Location &LocA, const Location &LocB) { if (PrintAll || (PrintAllFailures && R == MayAlias)) { errs() << AliasString << ":\t"; errs() << "[" << LocA.Size << "B] "; - WriteAsOperand(errs(), LocA.Ptr, true, M); + LocA.Ptr->printAsOperand(errs(), true, M); errs() << ", "; errs() << "[" << LocB.Size << "B] "; - WriteAsOperand(errs(), LocB.Ptr, true, M); + LocB.Ptr->printAsOperand(errs(), true, M); errs() << "\n"; } @@ -164,7 +163,7 @@ AliasAnalysisCounter::getModRefInfo(ImmutableCallSite CS, if (PrintAll || (PrintAllFailures && R == ModRef)) { errs() << MRString << ": Ptr: "; errs() << "[" << Loc.Size << "B] "; - WriteAsOperand(errs(), Loc.Ptr, true, M); + Loc.Ptr->printAsOperand(errs(), true, M); errs() << "\t<->" << *CS.getInstruction() << '\n'; } return R; diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index 15bf9732b5..482119d303 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -24,7 +24,6 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/Writer.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -94,8 +93,8 @@ static void PrintResults(const char *Msg, bool P, const Value *V1, std::string o1, o2; { raw_string_ostream os1(o1), os2(o2); - WriteAsOperand(os1, V1, true, M); - WriteAsOperand(os2, V2, true, M); + V1->printAsOperand(os1, true, M); + V2->printAsOperand(os2, true, M); } if (o2 < o1) @@ -111,7 +110,7 @@ PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, Module *M) { if (P) { errs() << " " << Msg << ": Ptr: "; - WriteAsOperand(errs(), Ptr, true, M); + Ptr->printAsOperand(errs(), true, M); errs() << "\t<->" << *I << '\n'; } } diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index 76693bed3e..035d16e4e4 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -18,7 +18,6 @@ #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Type.h" -#include "llvm/IR/Writer.h" #include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -566,7 +565,7 @@ void AliasSet::print(raw_ostream &OS) const { OS << "Pointers: "; for (iterator I = begin(), E = end(); I != E; ++I) { if (I != begin()) OS << ", "; - WriteAsOperand(OS << "(", I.getPointer()); + I.getPointer()->printAsOperand(OS << "("); OS << ", " << I.getSize() << ")"; } } @@ -574,7 +573,7 @@ void AliasSet::print(raw_ostream &OS) const { OS << "\n " << UnknownInsts.size() << " Unknown instructions: "; for (unsigned i = 0, e = UnknownInsts.size(); i != e; ++i) { if (i) OS << ", "; - WriteAsOperand(OS, UnknownInsts[i]); + UnknownInsts[i]->printAsOperand(OS); } } OS << "\n"; diff --git a/lib/Analysis/DominanceFrontier.cpp b/lib/Analysis/DominanceFrontier.cpp index bd94641224..74cd15815f 100644 --- a/lib/Analysis/DominanceFrontier.cpp +++ b/lib/Analysis/DominanceFrontier.cpp @@ -9,7 +9,6 @@ #include "llvm/Analysis/DominanceFrontier.h" #include "llvm/ADT/SmallPtrSet.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -114,7 +113,7 @@ void DominanceFrontierBase::print(raw_ostream &OS, const Module* ) const { for (const_iterator I = begin(), E = end(); I != E; ++I) { OS << " DomFrontier for BB "; if (I->first) - WriteAsOperand(OS, I->first, false); + I->first->printAsOperand(OS, false); else OS << " <<exit node>>"; OS << " is:\t"; @@ -125,7 +124,7 @@ void DominanceFrontierBase::print(raw_ostream &OS, const Module* ) const { I != E; ++I) { OS << ' '; if (*I) - WriteAsOperand(OS, *I, false); + (*I)->printAsOperand(OS, false); else OS << "<<exit node>>"; } diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 704fa9ac7e..d94ce686e3 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -17,7 +17,6 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Module.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp index 9a8ff2235c..f56196f7ff 100644 --- a/lib/Analysis/IVUsers.cpp +++ b/lib/Analysis/IVUsers.cpp @@ -24,7 +24,6 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Type.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -248,7 +247,7 @@ bool IVUsers::runOnLoop(Loop *l, LPPassManager &LPM) { void IVUsers::print(raw_ostream &OS, const Module *M) const { OS << "IV Users for loop "; - WriteAsOperand(OS, L->getHeader(), false); + L->getHeader()->printAsOperand(OS, false); if (SE->hasLoopInvariantBackedgeTakenCount(L)) { OS << " with backedge-taken count " << *SE->getBackedgeTakenCount(L); @@ -258,13 +257,13 @@ void IVUsers::print(raw_ostream &OS, const Module *M) const { for (ilist<IVStrideUse>::const_iterator UI = IVUses.begin(), E = IVUses.end(); UI != E; ++UI) { OS << " "; - WriteAsOperand(OS, UI->getOperandValToReplace(), false); + UI->getOperandValToReplace()->printAsOperand(OS, false); OS << " = " << *getReplacementExpr(*UI); for (PostIncLoopSet::const_iterator I = UI->PostIncLoops.begin(), E = UI->PostIncLoops.end(); I != E; ++I) { OS << " (post-inc with loop "; - WriteAsOperand(OS, (*I)->getHeader(), false); + (*I)->getHeader()->printAsOperand(OS, false); OS << ")"; } OS << " in "; diff --git a/lib/Analysis/Lint.cpp b/lib/Analysis/Lint.cpp index 693ea2d48b..0e94df4a6a 100644 --- a/lib/Analysis/Lint.cpp +++ b/lib/Analysis/Lint.cpp @@ -46,7 +46,6 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Function.h" #include "llvm/IR/IntrinsicInst.h" -#include "llvm/IR/Writer.h" #include "llvm/InstVisitor.h" #include "llvm/Pass.h" #include "llvm/PassManager.h" @@ -129,7 +128,7 @@ namespace { if (isa<Instruction>(V)) { MessagesStr << *V << '\n'; } else { - WriteAsOperand(MessagesStr, V, true, Mod); + V->printAsOperand(MessagesStr, true, Mod); MessagesStr << '\n'; } } diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index e64b3fcb68..e406546e68 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -24,7 +24,6 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Metadata.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/CFG.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" diff --git a/lib/Analysis/MemDepPrinter.cpp b/lib/Analysis/MemDepPrinter.cpp index 06c498fa36..55dea6ad5e 100644 --- a/lib/Analysis/MemDepPrinter.cpp +++ b/lib/Analysis/MemDepPrinter.cpp @@ -14,7 +14,6 @@ #include "llvm/ADT/SetVector.h" #include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/IR/LLVMContext.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/InstIterator.h" @@ -177,7 +176,7 @@ void MemDepPrinter::print(raw_ostream &OS, const Module *M) const { OS << DepTypeStr[type]; if (DepBB) { OS << " in block "; - WriteAsOperand(OS, DepBB, /*PrintType=*/false, M); + DepBB->printAsOperand(OS, /*PrintType=*/false, M); } if (DepInst) { OS << " from: "; diff --git a/lib/Analysis/ModuleDebugInfoPrinter.cpp b/lib/Analysis/ModuleDebugInfoPrinter.cpp index 88bb17c401..38498aa5d2 100644 --- a/lib/Analysis/ModuleDebugInfoPrinter.cpp +++ b/lib/Analysis/ModuleDebugInfoPrinter.cpp @@ -19,7 +19,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/DebugInfo.h" #include "llvm/IR/Function.h" -#include "llvm/IR/Writer.h" #include "llvm/Pass.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 0b672693a6..2bcfed11cc 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -18,7 +18,6 @@ #include "llvm/ADT/SetOperations.h" #include "llvm/Analysis/DominatorInternals.h" #include "llvm/IR/Instructions.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Debug.h" using namespace llvm; diff --git a/lib/Analysis/RegionInfo.cpp b/lib/Analysis/RegionInfo.cpp index 8470d316f7..f732ffdde0 100644 --- a/lib/Analysis/RegionInfo.cpp +++ b/lib/Analysis/RegionInfo.cpp @@ -15,7 +15,6 @@ #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/RegionIterator.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -215,7 +214,7 @@ std::string Region::getNameStr() const { if (getEntry()->getName().empty()) { raw_string_ostream OS(entryName); - WriteAsOperand(OS, getEntry(), false); + getEntry()->printAsOperand(OS, false); } else entryName = getEntry()->getName(); @@ -223,7 +222,7 @@ std::string Region::getNameStr() const { if (getExit()->getName().empty()) { raw_string_ostream OS(exitName); - WriteAsOperand(OS, getExit(), false); + getExit()->printAsOperand(OS, false); } else exitName = getExit()->getName(); } else diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 6c2400c490..86f6784eec 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -77,7 +77,6 @@ #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Operator.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/Debug.h" @@ -138,7 +137,7 @@ void SCEV::dump() const { void SCEV::print(raw_ostream &OS) const { switch (getSCEVType()) { case scConstant: - WriteAsOperand(OS, cast<SCEVConstant>(this)->getValue(), false); + cast<SCEVConstant>(this)->getValue()->printAsOperand(OS, false); return; case scTruncate: { const SCEVTruncateExpr *Trunc = cast<SCEVTruncateExpr>(this); @@ -174,7 +173,7 @@ void SCEV::print(raw_ostream &OS) const { if (AR->getNoWrapFlags(FlagNW) && !AR->getNoWrapFlags((NoWrapFlags)(FlagNUW | FlagNSW))) OS << "nw><"; - WriteAsOperand(OS, AR->getLoop()->getHeader(), /*PrintType=*/false); + AR->getLoop()->getHeader()->printAsOperand(OS, /*PrintType=*/false); OS << ">"; return; } @@ -229,13 +228,13 @@ void SCEV::print(raw_ostream &OS) const { Constant *FieldNo; if (U->isOffsetOf(CTy, FieldNo)) { OS << "offsetof(" << *CTy << ", "; - WriteAsOperand(OS, FieldNo, false); + FieldNo->printAsOperand(OS, false); OS << ")"; return; } // Otherwise just print it normally. - WriteAsOperand(OS, U->getValue(), false); + U->getValue()->printAsOperand(OS, false); return; } case scCouldNotCompute: @@ -7321,7 +7320,7 @@ static void PrintLoopInfo(raw_ostream &OS, ScalarEvolution *SE, PrintLoopInfo(OS, SE, *I); OS << "Loop "; - WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false); + L->getHeader()->printAsOperand(OS, /*PrintType=*/false); OS << ": "; SmallVector<BasicBlock *, 8> ExitBlocks; @@ -7337,7 +7336,7 @@ static void PrintLoopInfo(raw_ostream &OS, ScalarEvolution *SE, OS << "\n" "Loop "; - WriteAsOperand(OS, L->getHeader(), /*PrintType=*/false); + L->getHeader()->printAsOperand(OS, /*PrintType=*/false); OS << ": "; if (!isa<SCEVCouldNotCompute>(SE->getMaxBackedgeTakenCount(L))) { @@ -7359,7 +7358,7 @@ void ScalarEvolution::print(raw_ostream &OS, const Module *) const { ScalarEvolution &SE = *const_cast<ScalarEvolution *>(this); OS << "Classifying expressions for: "; - WriteAsOperand(OS, F, /*PrintType=*/false); + F->printAsOperand(OS, /*PrintType=*/false); OS << "\n"; for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) if (isSCEVable(I->getType()) && !isa<CmpInst>(*I)) { @@ -7390,7 +7389,7 @@ void ScalarEvolution::print(raw_ostream &OS, const Module *) const { } OS << "Determining loop execution counts for: "; - WriteAsOperand(OS, F, /*PrintType=*/false); + F->printAsOperand(OS, /*PrintType=*/false); OS << "\n"; for (LoopInfo::iterator I = LI->begin(), E = LI->end(); I != E; ++I) PrintLoopInfo(OS, &SE, *I); diff --git a/lib/Analysis/Trace.cpp b/lib/Analysis/Trace.cpp index 3b3bacd6d0..5a1acc00fb 100644 --- a/lib/Analysis/Trace.cpp +++ b/lib/Analysis/Trace.cpp @@ -17,7 +17,6 @@ #include "llvm/Analysis/Trace.h" #include "llvm/IR/Function.h" -#include "llvm/IR/Writer.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -37,7 +36,7 @@ void Trace::print(raw_ostream &O) const { O << "; Trace from function " << F->getName() << ", blocks:\n"; for (const_iterator i = begin(), e = end(); i != e; ++i) { O << "; "; - WriteAsOperand(O, *i, true, getModule()); + (*i)->printAsOperand(O, true, getModule()); O << "\n"; } O << "; Trace parent function: \n" << *F; |