diff options
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 9680aa4bf52..cfe07ffba77 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/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!"); |

