summaryrefslogtreecommitdiff
path: root/include
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 /include
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
Diffstat (limited to 'include')
-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
6 files changed, 15 insertions, 44 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