summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2014-01-09 02:29:41 +0000
committerChandler Carruth <chandlerc@gmail.com>2014-01-09 02:29:41 +0000
commit560e3955c3c4fe0a3ae88fd91a1b7780b8fe7810 (patch)
tree77aed3e451050c08fe443b73e42ccac2fc13d366
parent58691befda948d2a69f93e91d4aeedc0e7c38501 (diff)
downloadllvm-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
-rw-r--r--include/llvm/Analysis/CFGPrinter.h5
-rw-r--r--include/llvm/Analysis/Dominators.h2
-rw-r--r--include/llvm/Analysis/LoopInfoImpl.h2
-rw-r--r--include/llvm/CodeGen/MachineBasicBlock.h5
-rw-r--r--include/llvm/IR/Value.h8
-rw-r--r--include/llvm/IR/Writer.h37
-rw-r--r--lib/Analysis/AliasAnalysisCounter.cpp7
-rw-r--r--lib/Analysis/AliasAnalysisEvaluator.cpp7
-rw-r--r--lib/Analysis/AliasSetTracker.cpp5
-rw-r--r--lib/Analysis/DominanceFrontier.cpp5
-rw-r--r--lib/Analysis/IPA/FindUsedTypes.cpp1
-rw-r--r--lib/Analysis/IVUsers.cpp7
-rw-r--r--lib/Analysis/Lint.cpp3
-rw-r--r--lib/Analysis/LoopInfo.cpp1
-rw-r--r--lib/Analysis/MemDepPrinter.cpp3
-rw-r--r--lib/Analysis/ModuleDebugInfoPrinter.cpp1
-rw-r--r--lib/Analysis/PostDominators.cpp1
-rw-r--r--lib/Analysis/RegionInfo.cpp5
-rw-r--r--lib/Analysis/ScalarEvolution.cpp17
-rw-r--r--lib/Analysis/Trace.cpp3
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp7
-rw-r--r--lib/CodeGen/MachineBasicBlock.cpp13
-rw-r--r--lib/CodeGen/MachineFunction.cpp3
-rw-r--r--lib/CodeGen/MachineInstr.cpp11
-rw-r--r--lib/CodeGen/ScheduleDAGPrinter.cpp1
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp1
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp7
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp1
-rw-r--r--lib/IR/AsmWriter.cpp61
-rw-r--r--lib/IR/Dominators.cpp1
-rw-r--r--lib/IR/LegacyPassManager.cpp3
-rw-r--r--lib/IR/Verifier.cpp5
-rw-r--r--lib/Target/ARM/ARMAsmPrinter.cpp1
-rw-r--r--lib/Target/Hexagon/HexagonAsmPrinter.cpp1
-rw-r--r--lib/Target/MSP430/MSP430AsmPrinter.cpp1
-rw-r--r--lib/Target/NVPTX/NVPTXAsmPrinter.cpp3
-rw-r--r--lib/Target/PowerPC/PPCAsmPrinter.cpp1
-rw-r--r--lib/Target/X86/X86AsmPrinter.cpp1
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp7
-rw-r--r--lib/Transforms/Scalar/GVN.cpp7
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp13
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp3
-rw-r--r--lib/Transforms/Scalar/Sink.cpp5
-rw-r--r--tools/bugpoint/ExtractFunction.cpp5
44 files changed, 106 insertions, 181 deletions
diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h
index b28621528b..8208b63368 100644
--- a/include/llvm/Analysis/CFGPrinter.h
+++ b/include/llvm/Analysis/CFGPrinter.h
@@ -18,7 +18,6 @@
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/GraphWriter.h"
@@ -40,7 +39,7 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
std::string Str;
raw_string_ostream OS(Str);
- WriteAsOperand(OS, Node, false);
+ Node->printAsOperand(OS, false);
return OS.str();
}
@@ -51,7 +50,7 @@ struct DOTGraphTraits<const Function*> : public DefaultDOTGraphTraits {
raw_string_ostream OS(Str);
if (Node->getName().empty()) {
- WriteAsOperand(OS, Node, false);
+ Node->printAsOperand(OS, false);
OS << ":";
}
diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h
index 896664c1c1..2d8009d59f 100644
--- a/include/llvm/Analysis/Dominators.h
+++ b/include/llvm/Analysis/Dominators.h
@@ -155,7 +155,7 @@ template<class NodeT>
inline raw_ostream &operator<<(raw_ostream &o,
const DomTreeNodeBase<NodeT> *Node) {
if (Node->getBlock())
- WriteAsOperand(o, Node->getBlock(), false);
+ Node->getBlock()->printAsOperand(o, false);
else
o << " <<exit node>>";
diff --git a/include/llvm/Analysis/LoopInfoImpl.h b/include/llvm/Analysis/LoopInfoImpl.h
index 934f7cf9a0..fe08d631db 100644
--- a/include/llvm/Analysis/LoopInfoImpl.h
+++ b/include/llvm/Analysis/LoopInfoImpl.h
@@ -324,7 +324,7 @@ void LoopBase<BlockT, LoopT>::print(raw_ostream &OS, unsigned Depth) const {
for (unsigned i = 0; i < getBlocks().size(); ++i) {
if (i) OS << ",";
BlockT *BB = getBlocks()[i];
- WriteAsOperand(OS, BB, false);
+ BB->printAsOperand(OS, false);
if (BB == getHeader()) OS << "<header>";
if (BB == getLoopLatch()) OS << "<latch>";
if (isLoopExiting(BB)) OS << "<exiting>";
diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h
index 7717809e0d..e196419e90 100644
--- a/include/llvm/CodeGen/MachineBasicBlock.h
+++ b/include/llvm/CodeGen/MachineBasicBlock.h
@@ -608,6 +608,9 @@ public:
void dump() const;
void print(raw_ostream &OS, SlotIndexes* = 0) const;
+ // Printing method used by LoopInfo.
+ void printAsOperand(raw_ostream &OS, bool PrintType = true);
+
/// getNumber - MachineBasicBlocks are uniquely numbered at the function
/// level, unless they're not in a MachineFunction yet, in which case this
/// will return -1.
@@ -655,8 +658,6 @@ private:
raw_ostream& operator<<(raw_ostream &OS, const MachineBasicBlock &MBB);
-void WriteAsOperand(raw_ostream &, const MachineBasicBlock*, bool t);
-
// This is useful when building IndexedMaps keyed on basic block pointers.
struct MBB2NumberFunctor :
public std::unary_function<const MachineBasicBlock*, unsigned> {
diff --git a/include/llvm/IR/Value.h b/include/llvm/IR/Value.h
index c6734695e4..858c6e3f4f 100644
--- a/include/llvm/IR/Value.h
+++ b/include/llvm/IR/Value.h
@@ -36,6 +36,7 @@ class InlineAsm;
class Instruction;
class LLVMContext;
class MDNode;
+class Module;
class StringRef;
class Twine;
class Type;
@@ -106,6 +107,13 @@ public:
///
void print(raw_ostream &O, AssemblyAnnotationWriter *AAW = 0) const;
+ /// \brief Print the name of this Value out to the specified raw_ostream.
+ /// This is useful when you just want to print 'int %reg126', not the
+ /// instruction that generated it. If you specify a Module for context, then
+ /// even constanst get pretty-printed; for example, the type of a null
+ /// pointer is printed symbolically.
+ void printAsOperand(raw_ostream &O, bool PrintType = true, const Module *M = 0) const;
+
/// All values are typed, get the type of this value.
///
Type *getType() const { return VTy; }
diff --git a/include/llvm/IR/Writer.h b/include/llvm/IR/Writer.h
deleted file mode 100644
index d1685e96dc..0000000000
--- a/include/llvm/IR/Writer.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//===-- Writer.h - Printer for LLVM IR assembly files -------------*- C++ -*-=//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This functionality is implemented by lib/IR/AsmWriter.cpp.
-// This library is used to print LLVM assembly language files to an iostream. It
-// can print LLVM code at a variety of granularities, including Modules,
-// BasicBlocks, and Instructions. This makes it useful for debugging.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_IR_WRITER_H
-#define LLVM_IR_WRITER_H
-
-namespace llvm {
-
-class Module;
-class Value;
-class raw_ostream;
-
-// WriteAsOperand - Write the name of the specified value out to the specified
-// ostream. This can be useful when you just want to print int %reg126, not the
-// whole instruction that generated it. If you specify a Module for context,
-// then even constants get pretty-printed; for example, the type of a null
-// pointer is printed symbolically.
-//
-void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy = true,
- const Module *Context = 0);
-
-} // End llvm namespace
-
-#endif
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;
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 8719701eb7..dc2fa8c104 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -30,7 +30,6 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
@@ -291,7 +290,7 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
return;
if (isVerbose()) {
- WriteAsOperand(OutStreamer.GetCommentOS(), GV,
+ GV->printAsOperand(OutStreamer.GetCommentOS(),
/*PrintType=*/false, GV->getParent());
OutStreamer.GetCommentOS() << '\n';
}
@@ -470,7 +469,7 @@ void AsmPrinter::EmitFunctionHeader() {
OutStreamer.EmitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
if (isVerbose()) {
- WriteAsOperand(OutStreamer.GetCommentOS(), F,
+ F->printAsOperand(OutStreamer.GetCommentOS(),
/*PrintType=*/false, F->getParent());
OutStreamer.GetCommentOS() << '\n';
}
@@ -1529,7 +1528,7 @@ static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP) {
std::string S;
raw_string_ostream OS(S);
OS << "Unsupported expression in static initializer: ";
- WriteAsOperand(OS, CE, /*PrintType=*/false,
+ CE->printAsOperand(OS, /*PrintType=*/false,
!AP.MF ? 0 : AP.MF->getFunction()->getParent());
report_fatal_error(OS.str());
}
diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp
index 08145ca4bd..5bd47c2f1d 100644
--- a/lib/CodeGen/MachineBasicBlock.cpp
+++ b/lib/CodeGen/MachineBasicBlock.cpp
@@ -24,7 +24,6 @@
#include "llvm/CodeGen/SlotIndexes.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/Support/Debug.h"
@@ -278,7 +277,7 @@ void MachineBasicBlock::print(raw_ostream &OS, SlotIndexes *Indexes) const {
const char *Comma = "";
if (const BasicBlock *LBB = getBasicBlock()) {
OS << Comma << "derived from LLVM BB ";
- WriteAsOperand(OS, LBB, /*PrintType=*/false);
+ LBB->printAsOperand(OS, /*PrintType=*/false);
Comma = ", ";
}
if (isLandingPad()) { OS << Comma << "EH LANDING PAD"; Comma = ", "; }
@@ -331,6 +330,10 @@ void MachineBasicBlock::print(raw_ostream &OS, SlotIndexes *Indexes) const {
}
}
+void MachineBasicBlock::printAsOperand(raw_ostream &OS, bool /*PrintType*/) {
+ OS << "BB#" << getNumber();
+}
+
void MachineBasicBlock::removeLiveIn(unsigned Reg) {
std::vector<unsigned>::iterator I =
std::find(LiveIns.begin(), LiveIns.end(), Reg);
@@ -1216,9 +1219,3 @@ MachineBasicBlock::computeRegisterLiveness(const TargetRegisterInfo *TRI,
// At this point we have no idea of the liveness of the register.
return LQR_Unknown;
}
-
-void llvm::WriteAsOperand(raw_ostream &OS, const MachineBasicBlock *MBB,
- bool t) {
- OS << "BB#" << MBB->getNumber();
-}
-
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 5a9065cd04..d9b0cca963 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -28,7 +28,6 @@
#include "llvm/DebugInfo.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/Support/Debug.h"
@@ -918,7 +917,7 @@ void MachineConstantPool::print(raw_ostream &OS) const {
if (Constants[i].isMachineConstantPoolEntry())
Constants[i].Val.MachineCPVal->print(OS);
else
- WriteAsOperand(OS, Constants[i].Val.ConstVal, /*PrintType=*/false);
+ Constants[i].Val.ConstVal->printAsOperand(OS, /*PrintType=*/false);
OS << ", align=" << Constants[i].getAlignment();
OS << "\n";
}
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index 1c382d3d82..ddb8595e04 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -30,7 +30,6 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCInstrDesc.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Debug.h"
@@ -352,7 +351,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
break;
case MachineOperand::MO_GlobalAddress:
OS << "<ga:";
- WriteAsOperand(OS, getGlobal(), /*PrintType=*/false);
+ getGlobal()->printAsOperand(OS, /*PrintType=*/false);
if (getOffset()) OS << "+" << getOffset();
OS << '>';
break;
@@ -363,7 +362,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
break;
case MachineOperand::MO_BlockAddress:
OS << '<';
- WriteAsOperand(OS, getBlockAddress(), /*PrintType=*/false);
+ getBlockAddress()->printAsOperand(OS, /*PrintType=*/false);
if (getOffset()) OS << "+" << getOffset();
OS << '>';
break;
@@ -375,7 +374,7 @@ void MachineOperand::print(raw_ostream &OS, const TargetMachine *TM) const {
break;
case MachineOperand::MO_Metadata:
OS << '<';
- WriteAsOperand(OS, getMetadata(), /*PrintType=*/false);
+ getMetadata()->printAsOperand(OS, /*PrintType=*/false);
OS << '>';
break;
case MachineOperand::MO_MCSymbol:
@@ -484,7 +483,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineMemOperand &MMO) {
if (!MMO.getValue())
OS << "<unknown>";
else
- WriteAsOperand(OS, MMO.getValue(), /*PrintType=*/false);
+ MMO.getValue()->printAsOperand(OS, /*PrintType=*/false);
unsigned AS = MMO.getAddrSpace();
if (AS != 0)
@@ -509,7 +508,7 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineMemOperand &MMO) {
if (const MDNode *TBAAInfo = MMO.getTBAAInfo()) {
OS << "(tbaa=";
if (TBAAInfo->getNumOperands() > 0)
- WriteAsOperand(OS, TBAAInfo->getOperand(0), /*PrintType=*/false);
+ TBAAInfo->getOperand(0)->printAsOperand(OS, /*PrintType=*/false);
else
OS << "<unknown>";
OS << ")";
diff --git a/lib/CodeGen/ScheduleDAGPrinter.cpp b/lib/CodeGen/ScheduleDAGPrinter.cpp
index 8088d59bfa..f59c6cfd82 100644
--- a/lib/CodeGen/ScheduleDAGPrinter.cpp
+++ b/lib/CodeGen/ScheduleDAGPrinter.cpp
@@ -18,7 +18,6 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/Constants.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index dacfa1ecd4..8a1dfdc39e 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -33,7 +33,6 @@
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Intrinsics.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
index b3946d9e62..79377f7424 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -20,7 +20,6 @@
#include "llvm/DebugInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Intrinsics.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
@@ -385,7 +384,7 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
dyn_cast<GlobalAddressSDNode>(this)) {
int64_t offset = GADN->getOffset();
OS << '<';
- WriteAsOperand(OS, GADN->getGlobal());
+ GADN->getGlobal()->printAsOperand(OS);
OS << '>';
if (offset > 0)
OS << " + " << offset;
@@ -476,9 +475,9 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
dyn_cast<BlockAddressSDNode>(this)) {
int64_t offset = BA->getOffset();
OS << "<";
- WriteAsOperand(OS, BA->getBlockAddress()->getFunction(), false);
+ BA->getBlockAddress()->getFunction()->printAsOperand(OS, false);
OS << ", ";
- WriteAsOperand(OS, BA->getBlockAddress()->getBasicBlock(), false);
+ BA->getBlockAddress()->getBasicBlock()->printAsOperand(OS, false);
OS << ">";
if (offset > 0)
OS << " + " << offset;
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
index 59449017dd..d70bc90095 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp
@@ -20,7 +20,6 @@
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/DebugInfo.h"
#include "llvm/IR/Constants.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp
index 9680aa4bf5..cfe07ffba7 100644
--- a/lib/IR/AsmWriter.cpp
+++ b/lib/IR/AsmWriter.cpp
@@ -32,7 +32,6 @@
#include "llvm/IR/PrintModulePass.h"
#include "llvm/IR/TypeFinder.h"
#include "llvm/IR/ValueSymbolTable.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h"
@@ -675,8 +674,6 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
SlotTracker *Machine,
const Module *Context);
-
-
static const char *getPredicateText(unsigned predicate) {
const char * pred = "unknown";
switch (predicate) {
@@ -1063,11 +1060,8 @@ static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
Out << "}";
}
-
-/// WriteAsOperand - Write the name of the specified value out to the specified
-/// ostream. This can be useful when you just want to print int %reg126, not
-/// the whole instruction that generated it.
-///
+// Full implementation of printing a Value as an operand with support for
+// TypePrinting, etc.
static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
TypePrinting *TypePrinter,
SlotTracker *Machine,
@@ -1174,31 +1168,6 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
Out << "<badref>";
}
-void WriteAsOperand(raw_ostream &Out, const Value *V,
- bool PrintType, const Module *Context) {
-
- // Fast path: Don't construct and populate a TypePrinting object if we
- // won't be needing any types printed.
- if (!PrintType &&
- ((!isa<Constant>(V) && !isa<MDNode>(V)) ||
- V->hasName() || isa<GlobalValue>(V))) {
- WriteAsOperandInternal(Out, V, 0, 0, Context);
- return;
- }
-
- if (Context == 0) Context = getModuleFromVal(V);
-
- TypePrinting TypePrinter;
- if (Context)
- TypePrinter.incorporateTypes(*Context);
- if (PrintType) {
- TypePrinter.print(V->getType(), Out);
- Out << ' ';
- }
-
- WriteAsOperandInternal(Out, V, &TypePrinter, 0, Context);
-}
-
void AssemblyWriter::init() {
if (TheModule)
TypePrinter.incorporateTypes(*TheModule);
@@ -2193,7 +2162,7 @@ void Value::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
WriteConstantInternal(OS, C, TypePrinter, 0, 0);
} else if (isa<InlineAsm>(this) || isa<MDString>(this) ||
isa<Argument>(this)) {
- WriteAsOperand(OS, this, true, 0);
+ this->printAsOperand(OS);
} else {
// Otherwise we don't know what it is. Call the virtual function to
// allow a subclass to print itself.
@@ -2201,6 +2170,30 @@ void Value::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
}
}
+void Value::printAsOperand(raw_ostream &O, bool PrintType, const Module *M) const {
+ // Fast path: Don't construct and populate a TypePrinting object if we
+ // won't be needing any types printed.
+ if (!PrintType &&
+ ((!isa<Constant>(this) && !isa<MDNode>(this)) ||
+ hasName() || isa<GlobalValue>(this))) {
+ WriteAsOperandInternal(O, this, 0, 0, M);
+ return;
+ }
+
+ if (!M)
+ M = getModuleFromVal(this);
+
+ TypePrinting TypePrinter;
+ if (M)
+ TypePrinter.incorporateTypes(*M);
+ if (PrintType) {
+ TypePrinter.print(getType(), O);
+ O << ' ';
+ }
+
+ WriteAsOperandInternal(O, this, &TypePrinter, 0, M);
+}
+
// Value::printCustom - subclasses should override this to implement printing.
void Value::printCustom(raw_ostream &OS) const {
llvm_unreachable("Unknown value to print out!");
diff --git a/lib/IR/Dominators.cpp b/lib/IR/Dominators.cpp
index fd0ef4badb..c11c87391a 100644
--- a/lib/IR/Dominators.cpp
+++ b/lib/IR/Dominators.cpp
@@ -20,7 +20,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/DominatorInternals.h"
#include "llvm/IR/Instructions.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
diff --git a/lib/IR/LegacyPassManager.cpp b/lib/IR/LegacyPassManager.cpp
index 211856bb1b..85e50f753f 100644
--- a/lib/IR/LegacyPassManager.cpp
+++ b/lib/IR/LegacyPassManager.cpp
@@ -16,7 +16,6 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/LegacyPassManagers.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -144,7 +143,7 @@ void PassManagerPrettyStackEntry::print(raw_ostream &OS) const {
OS << "value";
OS << " '";
- WriteAsOperand(OS, V, /*PrintTy=*/false, M);
+ V->printAsOperand(OS, /*PrintTy=*/false, M);
OS << "'\n";
}
diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp
index 650e34af82..8324d924ca 100644
--- a/lib/IR/Verifier.cpp
+++ b/lib/IR/Verifier.cpp
@@ -62,7 +62,6 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/Writer.h"
#include "llvm/InstVisitor.h"
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
@@ -101,7 +100,7 @@ namespace { // Anonymous namespace for class
if (I->empty() || !I->back().isTerminator()) {
dbgs() << "Basic Block in function '" << F.getName()
<< "' does not have terminator!\n";
- WriteAsOperand(dbgs(), I, true);
+ I->printAsOperand(dbgs(), true);
dbgs() << "\n";
Broken = true;
}
@@ -348,7 +347,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/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp
index 1c3b530cbd..84d1476d04 100644
--- a/lib/Target/ARM/ARMAsmPrinter.cpp
+++ b/lib/Target/ARM/ARMAsmPrinter.cpp
@@ -35,7 +35,6 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
diff --git a/lib/Target/Hexagon/HexagonAsmPrinter.cpp b/lib/Target/Hexagon/HexagonAsmPrinter.cpp
index 3504854823..7757394c8f 100644
--- a/lib/Target/Hexagon/HexagonAsmPrinter.cpp
+++ b/lib/Target/Hexagon/HexagonAsmPrinter.cpp
@@ -35,7 +35,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp
index d308cee78e..92d8649785 100644
--- a/lib/Target/MSP430/MSP430AsmPrinter.cpp
+++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp
@@ -27,7 +27,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCStreamer.h"
diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index 0e00874617..2c8e7e70f6 100644
--- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -35,7 +35,6 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/CommandLine.h"
@@ -149,7 +148,7 @@ const MCExpr *nvptx::LowerConstant(const Constant *CV, AsmPrinter &AP) {
std::string S;
raw_string_ostream OS(S);
OS << "Unsupported expression in static initializer: ";
- WriteAsOperand(OS, CE, /*PrintType=*/ false,
+ CE->printAsOperand(OS, /*PrintType=*/ false,
!AP.MF ? 0 : AP.MF->getFunction()->getParent());
report_fatal_error(OS.str());
}
diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp
index eac68f1674..98c6417a1a 100644
--- a/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -38,7 +38,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp
index 70f9e179d6..a2c3f770d3 100644
--- a/lib/Target/X86/X86AsmPrinter.cpp
+++ b/lib/Target/X86/X86AsmPrinter.cpp
@@ -28,7 +28,6 @@
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
-#include "llvm/IR/Writer.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index a94d191285..ed12b2e753 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -30,7 +30,6 @@
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Pass.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CommandLine.h"
@@ -845,7 +844,7 @@ void ExtAddrMode::print(raw_ostream &OS) const {
if (BaseGV) {
OS << (NeedPlus ? " + " : "")
<< "GV:";
- WriteAsOperand(OS, BaseGV, /*PrintType=*/false);
+ BaseGV->printAsOperand(OS, /*PrintType=*/false);
NeedPlus = true;
}
@@ -855,13 +854,13 @@ void ExtAddrMode::print(raw_ostream &OS) const {
if (BaseReg) {
OS << (NeedPlus ? " + " : "")
<< "Base:";
- WriteAsOperand(OS, BaseReg, /*PrintType=*/false);
+ BaseReg->printAsOperand(OS, /*PrintType=*/false);
NeedPlus = true;
}
if (Scale) {
OS << (NeedPlus ? " + " : "")
<< Scale << "*";
- WriteAsOperand(OS, ScaledReg, /*PrintType=*/false);
+ ScaledReg->printAsOperand(OS, /*PrintType=*/false);
}
OS << ']';
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 967c916eaa..8ed387c9dc 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -39,7 +39,6 @@
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
@@ -1712,7 +1711,7 @@ bool GVN::processNonLocalLoad(LoadInst *LI) {
!Deps[0].getResult().isDef() && !Deps[0].getResult().isClobber()) {
DEBUG(
dbgs() << "GVN: non-local load ";
- WriteAsOperand(dbgs(), LI);
+ LI->printAsOperand(dbgs());
dbgs() << " has unknown dependencies\n";
);
return false;
@@ -1890,7 +1889,7 @@ bool GVN::processLoad(LoadInst *L) {
DEBUG(
// fast print dep, using operator<< on instruction is too slow.
dbgs() << "GVN: load ";
- WriteAsOperand(dbgs(), L);
+ L->printAsOperand(dbgs());
Instruction *I = Dep.getInst();
dbgs() << " is clobbered by " << *I << '\n';
);
@@ -1905,7 +1904,7 @@ bool GVN::processLoad(LoadInst *L) {
DEBUG(
// fast print dep, using operator<< on instruction is too slow.
dbgs() << "GVN: load ";
- WriteAsOperand(dbgs(), L);
+ L->printAsOperand(dbgs());
dbgs() << " has unknown dependence\n";
);
return false;
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index fa5a35e599..777504726e 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -68,7 +68,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ValueHandle.h"
@@ -394,7 +393,7 @@ void Formula::print(raw_ostream &OS) const {
bool First = true;
if (BaseGV) {
if (!First) OS << " + "; else First = false;
- WriteAsOperand(OS, BaseGV, /*PrintType=*/false);
+ BaseGV->printAsOperand(OS, /*PrintType=*/false);
}
if (BaseOffset != 0) {
if (!First) OS << " + "; else First = false;
@@ -1080,19 +1079,19 @@ void LSRFixup::print(raw_ostream &OS) const {
// Store is common and interesting enough to be worth special-casing.
if (StoreInst *Store = dyn_cast<StoreInst>(UserInst)) {
OS << "store ";
- WriteAsOperand(OS, Store->getOperand(0), /*PrintType=*/false);
+ Store->getOperand(0)->printAsOperand(OS, /*PrintType=*/false);
} else if (UserInst->getType()->isVoidTy())
OS << UserInst->getOpcodeName();
else
- WriteAsOperand(OS, UserInst, /*PrintType=*/false);
+ UserInst->printAsOperand(OS, /*PrintType=*/false);
OS << ", OperandValToReplace=";
- WriteAsOperand(OS, OperandValToReplace, /*PrintType=*/false);
+ OperandValToReplace->printAsOperand(OS, /*PrintType=*/false);
for (PostIncLoopSet::const_iterator I = PostIncLoops.begin(),
E = PostIncLoops.end(); I != E; ++I) {
OS << ", PostIncLoop=";
- WriteAsOperand(OS, (*I)->getHeader(), /*PrintType=*/false);
+ (*I)->getHeader()->printAsOperand(OS, /*PrintType=*/false);
}
if (LUIdx != ~size_t(0))
@@ -4734,7 +4733,7 @@ LSRInstance::LSRInstance(Loop *L, Pass *P)
#endif // DEBUG
DEBUG(dbgs() << "\nLSR on loop ";
- WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
+ L->getHeader()->printAsOperand(dbgs(), /*PrintType=*/false);
dbgs() << ":\n");
// First, perform some low-level loop optimizations.
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp
index eb9a26c98f..7d31de4d74 100644
--- a/lib/Transforms/Scalar/Reassociate.cpp
+++ b/lib/Transforms/Scalar/Reassociate.cpp
@@ -33,7 +33,6 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Pass.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
@@ -67,7 +66,7 @@ static void PrintOps(Instruction *I, const SmallVectorImpl<ValueEntry> &Ops) {
<< *Ops[0].Op->getType() << '\t';
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
dbgs() << "[ ";
- WriteAsOperand(dbgs(), Ops[i].Op, false, M);
+ Ops[i].Op->printAsOperand(dbgs(), false, M);
dbgs() << ", #" << Ops[i].Rank << "] ";
}
}
diff --git a/lib/Transforms/Scalar/Sink.cpp b/lib/Transforms/Scalar/Sink.cpp
index cf8e5b75ab..a5096da46a 100644
--- a/lib/Transforms/Scalar/Sink.cpp
+++ b/lib/Transforms/Scalar/Sink.cpp
@@ -20,7 +20,6 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
@@ -259,9 +258,9 @@ bool Sinking::SinkInstruction(Instruction *Inst,
return false;
DEBUG(dbgs() << "Sink" << *Inst << " (";
- WriteAsOperand(dbgs(), Inst->getParent(), false);
+ Inst->getParent()->printAsOperand(dbgs(), false);
dbgs() << " -> ";
- WriteAsOperand(dbgs(), SuccToSinkTo, false);
+ SuccToSinkTo->printAsOperand(dbgs(), false);
dbgs() << ")\n");
// Move the instruction.
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index fb2edf6844..369c904709 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -19,7 +19,6 @@
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/Writer.h"
#include "llvm/Pass.h"
#include "llvm/PassManager.h"
#include "llvm/Support/CommandLine.h"
@@ -309,7 +308,7 @@ llvm::SplitFunctionsOutOfModule(Module *M,
for (unsigned i = 0, e = F.size(); i != e; ++i) {
Function *TNOF = cast<Function>(VMap[F[i]]);
DEBUG(errs() << "Removing function ");
- DEBUG(WriteAsOperand(errs(), TNOF, false));
+ DEBUG(TNOF->printAsOperand(errs(), false));
DEBUG(errs() << "\n");
TestFunctions.insert(cast<Function>(NewVMap[TNOF]));
DeleteFunctionBody(TNOF); // Function is now external in this module!
@@ -330,7 +329,7 @@ llvm::SplitFunctionsOutOfModule(Module *M,
if (Function *SafeFn = globalInitUsesExternalBA(GV)) {
errs() << "*** Error: when reducing functions, encountered "
"the global '";
- WriteAsOperand(errs(), GV, false);
+ GV->printAsOperand(errs(), false);
errs() << "' with an initializer that references blockaddresses "
"from safe function '" << SafeFn->getName()
<< "' and from test function '" << TestFn->getName() << "'.\n";