[llvm] r232532 - Internalize llvm::AssemblyWriter. It's not used outside of AsmWriter.cpp.
Benjamin Kramer
benny.kra at googlemail.com
Tue Mar 17 12:53:41 PDT 2015
Author: d0k
Date: Tue Mar 17 14:53:41 2015
New Revision: 232532
URL: http://llvm.org/viewvc/llvm-project?rev=232532&view=rev
Log:
Internalize llvm::AssemblyWriter. It's not used outside of AsmWriter.cpp.
This is an artifact of an implementation detail of DebugIR that has been
long refactored away. NFC.
Removed:
llvm/trunk/lib/IR/AsmWriter.h
Modified:
llvm/trunk/lib/IR/AsmWriter.cpp
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=232532&r1=232531&r2=232532&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Tue Mar 17 14:53:41 2015
@@ -14,9 +14,9 @@
//
//===----------------------------------------------------------------------===//
-#include "AsmWriter.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/AssemblyAnnotationWriter.h"
@@ -32,6 +32,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/TypeFinder.h"
+#include "llvm/IR/UseListOrder.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Dwarf.h"
@@ -387,7 +388,29 @@ static void PrintLLVMName(raw_ostream &O
}
-namespace llvm {
+namespace {
+class TypePrinting {
+ TypePrinting(const TypePrinting &) = delete;
+ void operator=(const TypePrinting&) = delete;
+public:
+
+ /// NamedTypes - The named types that are used by the current module.
+ TypeFinder NamedTypes;
+
+ /// NumberedTypes - The numbered types, along with their value.
+ DenseMap<StructType*, unsigned> NumberedTypes;
+
+
+ TypePrinting() {}
+ ~TypePrinting() {}
+
+ void incorporateTypes(const Module &M);
+
+ void print(Type *Ty, raw_ostream &OS);
+
+ void printStructBody(StructType *Ty, raw_ostream &OS);
+};
+} // namespace
void TypePrinting::incorporateTypes(const Module &M) {
NamedTypes.run(M, false);
@@ -517,6 +540,7 @@ void TypePrinting::printStructBody(Struc
OS << '>';
}
+namespace {
//===----------------------------------------------------------------------===//
// SlotTracker Class: Enumerate slot numbers for unnamed values
//===----------------------------------------------------------------------===//
@@ -635,8 +659,9 @@ private:
SlotTracker(const SlotTracker &) = delete;
void operator=(const SlotTracker &) = delete;
};
+} // namespace
-SlotTracker *createSlotTracker(const Module *M) {
+static SlotTracker *createSlotTracker(const Module *M) {
return new SlotTracker(M);
}
@@ -2046,6 +2071,64 @@ static void WriteAsOperandInternal(raw_o
WriteAsOperandInternal(Out, V->getValue(), TypePrinter, Machine, Context);
}
+namespace {
+class AssemblyWriter {
+ formatted_raw_ostream &Out;
+ const Module *TheModule;
+ std::unique_ptr<SlotTracker> ModuleSlotTracker;
+ SlotTracker &Machine;
+ TypePrinting TypePrinter;
+ AssemblyAnnotationWriter *AnnotationWriter;
+ SetVector<const Comdat *> Comdats;
+ UseListOrderStack UseListOrders;
+
+public:
+ /// Construct an AssemblyWriter with an external SlotTracker
+ AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
+ const Module *M, AssemblyAnnotationWriter *AAW);
+
+ /// Construct an AssemblyWriter with an internally allocated SlotTracker
+ AssemblyWriter(formatted_raw_ostream &o, const Module *M,
+ AssemblyAnnotationWriter *AAW);
+
+ void printMDNodeBody(const MDNode *MD);
+ void printNamedMDNode(const NamedMDNode *NMD);
+
+ void printModule(const Module *M);
+
+ void writeOperand(const Value *Op, bool PrintType);
+ void writeParamOperand(const Value *Operand, AttributeSet Attrs,unsigned Idx);
+ void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope);
+ void writeAtomicCmpXchg(AtomicOrdering SuccessOrdering,
+ AtomicOrdering FailureOrdering,
+ SynchronizationScope SynchScope);
+
+ void writeAllMDNodes();
+ void writeMDNode(unsigned Slot, const MDNode *Node);
+ void writeAllAttributeGroups();
+
+ void printTypeIdentities();
+ void printGlobal(const GlobalVariable *GV);
+ void printAlias(const GlobalAlias *GV);
+ void printComdat(const Comdat *C);
+ void printFunction(const Function *F);
+ void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx);
+ void printBasicBlock(const BasicBlock *BB);
+ void printInstructionLine(const Instruction &I);
+ void printInstruction(const Instruction &I);
+
+ void printUseListOrder(const UseListOrder &Order);
+ void printUseLists(const Function *F);
+
+private:
+ void init();
+
+ // printInfoComment - Print a little comment after the instruction indicating
+ // which slot it occupies.
+ void printInfoComment(const Value &V);
+};
+} // namespace
+
void AssemblyWriter::init() {
if (!TheModule)
return;
@@ -2073,8 +2156,6 @@ AssemblyWriter::AssemblyWriter(formatted
init();
}
-AssemblyWriter::~AssemblyWriter() { }
-
void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType) {
if (!Operand) {
Out << "<null operand!>";
@@ -3073,8 +3154,6 @@ void AssemblyWriter::writeAllAttributeGr
<< I->first.getAsString(AttributeSet::FunctionIndex, true) << " }\n";
}
-} // namespace llvm
-
void AssemblyWriter::printUseListOrder(const UseListOrder &Order) {
bool IsInFunction = Machine.getFunction();
if (IsInFunction)
Removed: llvm/trunk/lib/IR/AsmWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.h?rev=232531&view=auto
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.h (original)
+++ llvm/trunk/lib/IR/AsmWriter.h (removed)
@@ -1,129 +0,0 @@
-//===-- llvm/IR/AsmWriter.h - Printing LLVM IR as an assembly file - C++ --===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This files defines the interface for the AssemblyWriter class used to print
-// LLVM IR and various helper classes that are used in printing.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_IR_ASMWRITER_H
-#define LLVM_LIB_IR_ASMWRITER_H
-
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SetVector.h"
-#include "llvm/IR/Attributes.h"
-#include "llvm/IR/Instructions.h"
-#include "llvm/IR/TypeFinder.h"
-#include "llvm/IR/UseListOrder.h"
-#include "llvm/Support/FormattedStream.h"
-
-namespace llvm {
-
-class BasicBlock;
-class Function;
-class GlobalValue;
-class Comdat;
-class Module;
-class NamedMDNode;
-class Value;
-class SlotTracker;
-
-/// Create a new SlotTracker for a Module
-SlotTracker *createSlotTracker(const Module *M);
-
-//===----------------------------------------------------------------------===//
-// TypePrinting Class: Type printing machinery
-//===----------------------------------------------------------------------===//
-
-class TypePrinting {
- TypePrinting(const TypePrinting &) = delete;
- void operator=(const TypePrinting&) = delete;
-public:
-
- /// NamedTypes - The named types that are used by the current module.
- TypeFinder NamedTypes;
-
- /// NumberedTypes - The numbered types, along with their value.
- DenseMap<StructType*, unsigned> NumberedTypes;
-
-
- TypePrinting() {}
- ~TypePrinting() {}
-
- void incorporateTypes(const Module &M);
-
- void print(Type *Ty, raw_ostream &OS);
-
- void printStructBody(StructType *Ty, raw_ostream &OS);
-};
-
-class AssemblyWriter {
-protected:
- formatted_raw_ostream &Out;
- const Module *TheModule;
-
-private:
- std::unique_ptr<SlotTracker> ModuleSlotTracker;
- SlotTracker &Machine;
- TypePrinting TypePrinter;
- AssemblyAnnotationWriter *AnnotationWriter;
- SetVector<const Comdat *> Comdats;
- UseListOrderStack UseListOrders;
-
-public:
- /// Construct an AssemblyWriter with an external SlotTracker
- AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac,
- const Module *M, AssemblyAnnotationWriter *AAW);
-
- /// Construct an AssemblyWriter with an internally allocated SlotTracker
- AssemblyWriter(formatted_raw_ostream &o, const Module *M,
- AssemblyAnnotationWriter *AAW);
-
- virtual ~AssemblyWriter();
-
- void printMDNodeBody(const MDNode *MD);
- void printNamedMDNode(const NamedMDNode *NMD);
-
- void printModule(const Module *M);
-
- void writeOperand(const Value *Op, bool PrintType);
- void writeParamOperand(const Value *Operand, AttributeSet Attrs,unsigned Idx);
- void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope);
- void writeAtomicCmpXchg(AtomicOrdering SuccessOrdering,
- AtomicOrdering FailureOrdering,
- SynchronizationScope SynchScope);
-
- void writeAllMDNodes();
- void writeMDNode(unsigned Slot, const MDNode *Node);
- void writeAllAttributeGroups();
-
- void printTypeIdentities();
- void printGlobal(const GlobalVariable *GV);
- void printAlias(const GlobalAlias *GV);
- void printComdat(const Comdat *C);
- void printFunction(const Function *F);
- void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx);
- void printBasicBlock(const BasicBlock *BB);
- void printInstructionLine(const Instruction &I);
- void printInstruction(const Instruction &I);
-
- void printUseListOrder(const UseListOrder &Order);
- void printUseLists(const Function *F);
-
-private:
- void init();
-
- // printInfoComment - Print a little comment after the instruction indicating
- // which slot it occupies.
- void printInfoComment(const Value &V);
-};
-
-} // namespace llvm
-
-#endif
More information about the llvm-commits
mailing list