LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AsmWriter.h
Go to the documentation of this file.
1 //===-- llvm/IR/AsmWriter.h - Printing LLVM IR as an assembly file - C++ --===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This files defines the interface for the AssemblyWriter class used to print
11 // LLVM IR and various helper classes that are used in printing.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_ASSEMBLYWRITER_H
16 #define LLVM_IR_ASSEMBLYWRITER_H
17 
18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/OwningPtr.h"
20 #include "llvm/IR/Attributes.h"
21 #include "llvm/IR/Instructions.h"
22 #include "llvm/IR/TypeFinder.h"
24 
25 namespace llvm {
26 
27 class BasicBlock;
28 class Function;
29 class GlobalValue;
30 class Module;
31 class NamedMDNode;
32 class Value;
33 class SlotTracker;
34 
35 /// Create a new SlotTracker for a Module
36 SlotTracker *createSlotTracker(const Module *M);
37 
38 //===----------------------------------------------------------------------===//
39 // TypePrinting Class: Type printing machinery
40 //===----------------------------------------------------------------------===//
41 
42 class TypePrinting {
44  void operator=(const TypePrinting&) LLVM_DELETED_FUNCTION;
45 public:
46 
47  /// NamedTypes - The named types that are used by the current module.
49 
50  /// NumberedTypes - The numbered types, along with their value.
52 
53 
56 
57  void incorporateTypes(const Module &M);
58 
59  void print(Type *Ty, raw_ostream &OS);
60 
61  void printStructBody(StructType *Ty, raw_ostream &OS);
62 };
63 
65 protected:
67  const Module *TheModule;
68 
69 private:
70  OwningPtr<SlotTracker> ModuleSlotTracker;
71  SlotTracker &Machine;
72  TypePrinting TypePrinter;
73  AssemblyAnnotationWriter *AnnotationWriter;
74 
75 public:
76  /// Construct an AssemblyWriter with an external SlotTracker
78  const Module *M, AssemblyAnnotationWriter *AAW);
79 
80  /// Construct an AssemblyWriter with an internally allocated SlotTracker
83 
84  virtual ~AssemblyWriter();
85 
86  void printMDNodeBody(const MDNode *MD);
87  void printNamedMDNode(const NamedMDNode *NMD);
88 
89  void printModule(const Module *M);
90 
91  void writeOperand(const Value *Op, bool PrintType);
92  void writeParamOperand(const Value *Operand, AttributeSet Attrs,unsigned Idx);
93  void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope);
94 
95  void writeAllMDNodes();
96  void writeMDNode(unsigned Slot, const MDNode *Node);
98 
99  void printTypeIdentities();
100  void printGlobal(const GlobalVariable *GV);
101  void printAlias(const GlobalAlias *GV);
102  void printFunction(const Function *F);
103  void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx);
104  void printBasicBlock(const BasicBlock *BB);
105  void printInstructionLine(const Instruction &I);
106  void printInstruction(const Instruction &I);
107 
108 private:
109  void init();
110 
111  // printInfoComment - Print a little comment after the instruction indicating
112  // which slot it occupies.
113  void printInfoComment(const Value &V);
114 };
115 
116 } // namespace llvm
117 
118 #endif //LLVM_IR_ASMWRITER_H
void printStructBody(StructType *Ty, raw_ostream &OS)
Definition: AsmWriter.cpp:270
void printInstructionLine(const Instruction &I)
printInstructionLine - Print an instruction and a newline character.
Definition: AsmWriter.cpp:1736
formatted_raw_ostream & Out
Definition: AsmWriter.h:66
void printArgument(const Argument *FA, AttributeSet Attrs, unsigned Idx)
Definition: AsmWriter.cpp:1670
LLVM Argument representation.
Definition: Argument.h:35
Various leaf nodes.
Definition: ISDOpcodes.h:60
The main container class for the LLVM Intermediate Representation.
Definition: Module.h:112
MDNode - a tuple of other values.
Definition: Metadata.h:69
F(f)
AssemblyWriter(formatted_raw_ostream &o, SlotTracker &Mac, const Module *M, AssemblyAnnotationWriter *AAW)
Construct an AssemblyWriter with an external SlotTracker.
Definition: AsmWriter.cpp:1210
void printBasicBlock(const BasicBlock *BB)
Definition: AsmWriter.cpp:1688
void writeAllAttributeGroups()
Definition: AsmWriter.cpp:2112
void print(Type *Ty, raw_ostream &OS)
Definition: AsmWriter.cpp:193
This file contains the simple types necessary to represent the attributes associated with functions a...
SynchronizationScope
Definition: Instructions.h:47
void writeMDNode(unsigned Slot, const MDNode *Node)
Definition: AsmWriter.cpp:2089
AtomicOrdering
Definition: Instructions.h:36
void printGlobal(const GlobalVariable *GV)
Definition: AsmWriter.cpp:1442
void writeOperand(const Value *Op, bool PrintType)
Definition: AsmWriter.cpp:1226
DenseMap< StructType *, unsigned > NumberedTypes
NumberedTypes - The numbered types, along with their value.
Definition: AsmWriter.h:51
LLVM Basic Block Representation.
Definition: BasicBlock.h:72
TypeFinder NamedTypes
NamedTypes - The named types that are used by the current module.
Definition: AsmWriter.h:48
void printInstruction(const Instruction &I)
Definition: AsmWriter.cpp:1750
void printFunction(const Function *F)
Definition: AsmWriter.cpp:1549
void incorporateTypes(const Module &M)
Definition: AsmWriter.cpp:166
SlotTracker * createSlotTracker(const Module *M)
Create a new SlotTracker for a Module.
Definition: AsmWriter.cpp:396
void printMDNodeBody(const MDNode *MD)
Definition: AsmWriter.cpp:2106
void writeParamOperand(const Value *Operand, AttributeSet Attrs, unsigned Idx)
Definition: AsmWriter.cpp:1259
#define LLVM_DELETED_FUNCTION
Definition: Compiler.h:137
const Module * TheModule
Definition: AsmWriter.h:67
void printNamedMDNode(const NamedMDNode *NMD)
Definition: AsmWriter.cpp:1353
#define I(x, y, z)
Definition: MD5.cpp:54
virtual ~AssemblyWriter()
Definition: AsmWriter.cpp:1224
LLVM Value Representation.
Definition: Value.h:66
void writeAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope)
Definition: AsmWriter.cpp:1238
void printAlias(const GlobalAlias *GV)
Definition: AsmWriter.cpp:1479
void printModule(const Module *M)
Definition: AsmWriter.cpp:1276