LLVM API Documentation
00001 //===-- llvm/Assembly/Writer.h - Printer for LLVM assembly files --*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This functionality is implemented by lib/VMCore/AsmWriter.cpp. 00011 // This library is used to print LLVM assembly language files to an iostream. It 00012 // can print LLVM code at a variety of granularities, including Modules, 00013 // BasicBlocks, and Instructions. This makes it useful for debugging. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #ifndef LLVM_ASSEMBLY_WRITER_H 00018 #define LLVM_ASSEMBLY_WRITER_H 00019 00020 #include <iosfwd> 00021 #include <string> 00022 00023 namespace llvm { 00024 00025 class Type; 00026 class Module; 00027 class Value; 00028 class raw_ostream; 00029 template <typename T> class SmallVectorImpl; 00030 00031 /// TypePrinting - Type printing machinery. 00032 class TypePrinting { 00033 void *TypeNames; // A map to remember type names. 00034 TypePrinting(const TypePrinting &); // DO NOT IMPLEMENT 00035 void operator=(const TypePrinting&); // DO NOT IMPLEMENT 00036 public: 00037 TypePrinting(); 00038 ~TypePrinting(); 00039 00040 void clear(); 00041 00042 void print(const Type *Ty, raw_ostream &OS, bool IgnoreTopLevelName = false); 00043 00044 void printAtLeastOneLevel(const Type *Ty, raw_ostream &OS) { 00045 print(Ty, OS, true); 00046 } 00047 00048 /// hasTypeName - Return true if the type has a name in TypeNames, false 00049 /// otherwise. 00050 bool hasTypeName(const Type *Ty) const; 00051 00052 /// addTypeName - Add a name for the specified type if it doesn't already have 00053 /// one. This name will be printed instead of the structural version of the 00054 /// type in order to make the output more concise. 00055 void addTypeName(const Type *Ty, const std::string &N); 00056 00057 private: 00058 void CalcTypeName(const Type *Ty, SmallVectorImpl<const Type *> &TypeStack, 00059 raw_ostream &OS, bool IgnoreTopLevelName = false); 00060 }; 00061 00062 // WriteTypeSymbolic - This attempts to write the specified type as a symbolic 00063 // type, if there is an entry in the Module's symbol table for the specified 00064 // type or one of its component types. 00065 // 00066 void WriteTypeSymbolic(raw_ostream &, const Type *, const Module *M); 00067 00068 // WriteAsOperand - Write the name of the specified value out to the specified 00069 // ostream. This can be useful when you just want to print int %reg126, not the 00070 // whole instruction that generated it. If you specify a Module for context, 00071 // then even constants get pretty-printed; for example, the type of a null 00072 // pointer is printed symbolically. 00073 // 00074 void WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, 00075 const Module *Context = 0); 00076 void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy = true, 00077 const Module *Context = 0); 00078 00079 } // End llvm namespace 00080 00081 #endif