LLVM  4.0.0
Classes | Namespaces | Macros | Enumerations | Functions
AsmWriter.cpp File Reference
#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"
#include "llvm/IR/CFG.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ModuleSlotTracker.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/Statepoint.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"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cctype>
#include "llvm/IR/Metadata.def"
Include dependency graph for AsmWriter.cpp:

Go to the source code of this file.

Classes

class  llvm::SlotTracker
 This class provides computation of slot numbers for LLVM Assembly writing. More...
 

Namespaces

 llvm
 Compute iterated dominance frontiers using a linear time algorithm.
 

Macros

#define ST_DEBUG(X)
 
#define HANDLE_MDNODE_LEAF(CLASS)
 

Enumerations

enum  PrefixType {
  GlobalPrefix, ComdatPrefix, LabelPrefix, LocalPrefix,
  NoPrefix
}
 

Functions

static void orderValue (const Value *V, OrderMap &OM)
 
static OrderMap orderModule (const Module *M)
 
static void predictValueUseListOrderImpl (const Value *V, const Function *F, unsigned ID, const OrderMap &OM, UseListOrderStack &Stack)
 
static void predictValueUseListOrder (const Value *V, const Function *F, OrderMap &OM, UseListOrderStack &Stack)
 
static UseListOrderStack predictUseListOrder (const Module *M)
 
static const ModulegetModuleFromVal (const Value *V)
 
static void PrintCallingConv (unsigned cc, raw_ostream &Out)
 
static void PrintLLVMName (raw_ostream &OS, StringRef Name, PrefixType Prefix)
 Turn the specified name into an 'LLVM name', which is either prefixed with % (if the string only contains simple characters) or is surrounded with ""'s (if it has special chars in it). More...
 
static void PrintLLVMName (raw_ostream &OS, const Value *V)
 Turn the specified name into an 'LLVM name', which is either prefixed with % (if the string only contains simple characters) or is surrounded with ""'s (if it has special chars in it). More...
 
static SlotTrackercreateSlotTracker (const Value *V)
 
static void WriteAsOperandInternal (raw_ostream &Out, const Value *V, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void WriteAsOperandInternal (raw_ostream &Out, const Metadata *MD, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context, bool FromValue=false)
 
static void writeAtomicRMWOperation (raw_ostream &Out, AtomicRMWInst::BinOp Op)
 
static void WriteOptimizationInfo (raw_ostream &Out, const User *U)
 
static void WriteConstantInternal (raw_ostream &Out, const Constant *CV, TypePrinting &TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeMDTuple (raw_ostream &Out, const MDTuple *Node, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeMetadataAsOperand (raw_ostream &Out, const Metadata *MD, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeGenericDINode (raw_ostream &Out, const GenericDINode *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDILocation (raw_ostream &Out, const DILocation *DL, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDISubrange (raw_ostream &Out, const DISubrange *N, TypePrinting *, SlotTracker *, const Module *)
 
static void writeDIEnumerator (raw_ostream &Out, const DIEnumerator *N, TypePrinting *, SlotTracker *, const Module *)
 
static void writeDIBasicType (raw_ostream &Out, const DIBasicType *N, TypePrinting *, SlotTracker *, const Module *)
 
static void writeDIDerivedType (raw_ostream &Out, const DIDerivedType *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDICompositeType (raw_ostream &Out, const DICompositeType *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDISubroutineType (raw_ostream &Out, const DISubroutineType *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIFile (raw_ostream &Out, const DIFile *N, TypePrinting *, SlotTracker *, const Module *)
 
static void writeDICompileUnit (raw_ostream &Out, const DICompileUnit *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDISubprogram (raw_ostream &Out, const DISubprogram *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDILexicalBlock (raw_ostream &Out, const DILexicalBlock *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDILexicalBlockFile (raw_ostream &Out, const DILexicalBlockFile *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDINamespace (raw_ostream &Out, const DINamespace *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIMacro (raw_ostream &Out, const DIMacro *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIMacroFile (raw_ostream &Out, const DIMacroFile *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIModule (raw_ostream &Out, const DIModule *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDITemplateTypeParameter (raw_ostream &Out, const DITemplateTypeParameter *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDITemplateValueParameter (raw_ostream &Out, const DITemplateValueParameter *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIGlobalVariable (raw_ostream &Out, const DIGlobalVariable *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDILocalVariable (raw_ostream &Out, const DILocalVariable *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIExpression (raw_ostream &Out, const DIExpression *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIGlobalVariableExpression (raw_ostream &Out, const DIGlobalVariableExpression *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIObjCProperty (raw_ostream &Out, const DIObjCProperty *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void writeDIImportedEntity (raw_ostream &Out, const DIImportedEntity *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void WriteMDNodeBodyInternal (raw_ostream &Out, const MDNode *Node, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
 
static void printMetadataIdentifier (StringRef Name, formatted_raw_ostream &Out)
 
static const char * getLinkagePrintName (GlobalValue::LinkageTypes LT)
 
static void PrintVisibility (GlobalValue::VisibilityTypes Vis, formatted_raw_ostream &Out)
 
static void PrintDLLStorageClass (GlobalValue::DLLStorageClassTypes SCT, formatted_raw_ostream &Out)
 
static void PrintThreadLocalModel (GlobalVariable::ThreadLocalMode TLM, formatted_raw_ostream &Out)
 
static StringRef getUnnamedAddrEncoding (GlobalVariable::UnnamedAddr UA)
 
static void maybePrintComdat (formatted_raw_ostream &Out, const GlobalObject &GO)
 
static bool isReferencingMDNode (const Instruction &I)
 
static bool printWithoutType (const Value &V, raw_ostream &O, SlotTracker *Machine, const Module *M)
 Print without a type, skipping the TypePrinting object. More...
 
static void printAsOperandImpl (const Value &V, raw_ostream &O, bool PrintType, ModuleSlotTracker &MST)
 
static void printMetadataImpl (raw_ostream &ROS, const Metadata &MD, ModuleSlotTracker &MST, const Module *M, bool OnlyAsOperand)
 

Macro Definition Documentation

#define HANDLE_MDNODE_LEAF (   CLASS)
Value:
case Metadata::CLASS##Kind: \
write##CLASS(Out, cast<CLASS>(Node), TypePrinter, Machine, Context); \
break;
LLVMContext & Context
COFF::MachineTypes Machine
Definition: COFFYAML.cpp:303
static void write(bool isBE, void *P, T V)
const unsigned Kind
#define ST_DEBUG (   X)

Definition at line 768 of file AsmWriter.cpp.

Referenced by llvm::SlotTracker::purgeFunction().

Enumeration Type Documentation

enum PrefixType
Enumerator
GlobalPrefix 
ComdatPrefix 
LabelPrefix 
LocalPrefix 
NoPrefix 

Definition at line 351 of file AsmWriter.cpp.

Function Documentation

static SlotTracker* createSlotTracker ( const Value V)
static

Definition at line 739 of file AsmWriter.cpp.

static const char* getLinkagePrintName ( GlobalValue::LinkageTypes  LT)
static

Definition at line 2366 of file AsmWriter.cpp.

References llvm_unreachable.

static const Module* getModuleFromVal ( const Value V)
static
static StringRef getUnnamedAddrEncoding ( GlobalVariable::UnnamedAddr  UA)
static
static bool isReferencingMDNode ( const Instruction I)
static

Definition at line 3383 of file AsmWriter.cpp.

References llvm::Function::isIntrinsic(), and llvm::User::operands().

Referenced by llvm::Value::print().

static void maybePrintComdat ( formatted_raw_ostream Out,
const GlobalObject GO 
)
static
static OrderMap orderModule ( const Module M)
static
static void orderValue ( const Value V,
OrderMap &  OM 
)
static

Definition at line 75 of file AsmWriter.cpp.

References C.

Referenced by orderModule().

static UseListOrderStack predictUseListOrder ( const Module M)
static
static void predictValueUseListOrder ( const Value V,
const Function F,
OrderMap &  OM,
UseListOrderStack Stack 
)
static
static void predictValueUseListOrderImpl ( const Value V,
const Function F,
unsigned  ID,
const OrderMap &  OM,
UseListOrderStack Stack 
)
static
static void printAsOperandImpl ( const Value V,
raw_ostream O,
bool  PrintType,
ModuleSlotTracker MST 
)
static
static void PrintCallingConv ( unsigned  cc,
raw_ostream Out 
)
static
static void PrintDLLStorageClass ( GlobalValue::DLLStorageClassTypes  SCT,
formatted_raw_ostream Out 
)
static

Definition at line 2403 of file AsmWriter.cpp.

static void PrintLLVMName ( raw_ostream OS,
StringRef  Name,
PrefixType  Prefix 
)
static

Turn the specified name into an 'LLVM name', which is either prefixed with % (if the string only contains simple characters) or is surrounded with ""'s (if it has special chars in it).

Print it out.

Definition at line 395 of file AsmWriter.cpp.

References ComdatPrefix, GlobalPrefix, LabelPrefix, LocalPrefix, NoPrefix, and llvm::printLLVMNameWithoutPrefix().

Referenced by maybePrintComdat(), llvm::Comdat::print(), and PrintLLVMName().

static void PrintLLVMName ( raw_ostream OS,
const Value V 
)
static

Turn the specified name into an 'LLVM name', which is either prefixed with % (if the string only contains simple characters) or is surrounded with ""'s (if it has special chars in it).

Print it out.

Definition at line 417 of file AsmWriter.cpp.

References llvm::Value::getName(), GlobalPrefix, LocalPrefix, and PrintLLVMName().

static void printMetadataIdentifier ( StringRef  Name,
formatted_raw_ostream Out 
)
static

Definition at line 2329 of file AsmWriter.cpp.

References C, llvm::StringRef::empty(), llvm::hexdigit(), i, and llvm::StringRef::size().

static void printMetadataImpl ( raw_ostream ROS,
const Metadata MD,
ModuleSlotTracker MST,
const Module M,
bool  OnlyAsOperand 
)
static
static void PrintThreadLocalModel ( GlobalVariable::ThreadLocalMode  TLM,
formatted_raw_ostream Out 
)
static

Definition at line 2412 of file AsmWriter.cpp.

static void PrintVisibility ( GlobalValue::VisibilityTypes  Vis,
formatted_raw_ostream Out 
)
static

Definition at line 2394 of file AsmWriter.cpp.

static bool printWithoutType ( const Value V,
raw_ostream O,
SlotTracker Machine,
const Module M 
)
static

Print without a type, skipping the TypePrinting object.

Returns
true iff printing was successful.

Definition at line 3449 of file AsmWriter.cpp.

References llvm::Value::hasName(), and WriteAsOperandInternal().

Referenced by llvm::Value::printAsOperand().

static void WriteAsOperandInternal ( raw_ostream Out,
const Value V,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static
static void WriteAsOperandInternal ( raw_ostream Out,
const Metadata MD,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context,
bool  FromValue = false 
)
static
static void writeAtomicRMWOperation ( raw_ostream Out,
AtomicRMWInst::BinOp  Op 
)
static
static void WriteConstantInternal ( raw_ostream Out,
const Constant CV,
TypePrinting &  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static
static void writeDIBasicType ( raw_ostream Out,
const DIBasicType N,
TypePrinting *  ,
SlotTracker ,
const Module  
)
static

Definition at line 1586 of file AsmWriter.cpp.

static void writeDICompileUnit ( raw_ostream Out,
const DICompileUnit N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1669 of file AsmWriter.cpp.

static void writeDICompositeType ( raw_ostream Out,
const DICompositeType N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1620 of file AsmWriter.cpp.

static void writeDIDerivedType ( raw_ostream Out,
const DIDerivedType N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1600 of file AsmWriter.cpp.

static void writeDIEnumerator ( raw_ostream Out,
const DIEnumerator N,
TypePrinting *  ,
SlotTracker ,
const Module  
)
static

Definition at line 1577 of file AsmWriter.cpp.

static void writeDIExpression ( raw_ostream Out,
const DIExpression N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1861 of file AsmWriter.cpp.

static void writeDIFile ( raw_ostream Out,
const DIFile N,
TypePrinting *  ,
SlotTracker ,
const Module  
)
static

Definition at line 1656 of file AsmWriter.cpp.

static void writeDIGlobalVariable ( raw_ostream Out,
const DIGlobalVariable N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1827 of file AsmWriter.cpp.

static void writeDIGlobalVariableExpression ( raw_ostream Out,
const DIGlobalVariableExpression N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1882 of file AsmWriter.cpp.

static void writeDIImportedEntity ( raw_ostream Out,
const DIImportedEntity N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1909 of file AsmWriter.cpp.

static void writeDILexicalBlock ( raw_ostream Out,
const DILexicalBlock N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1724 of file AsmWriter.cpp.

static void writeDILexicalBlockFile ( raw_ostream Out,
const DILexicalBlockFile N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1736 of file AsmWriter.cpp.

static void writeDILocalVariable ( raw_ostream Out,
const DILocalVariable N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1845 of file AsmWriter.cpp.

static void writeDILocation ( raw_ostream Out,
const DILocation DL,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1555 of file AsmWriter.cpp.

static void writeDIMacro ( raw_ostream Out,
const DIMacro N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1763 of file AsmWriter.cpp.

static void writeDIMacroFile ( raw_ostream Out,
const DIMacroFile N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1775 of file AsmWriter.cpp.

static void writeDIModule ( raw_ostream Out,
const DIModule N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1786 of file AsmWriter.cpp.

static void writeDINamespace ( raw_ostream Out,
const DINamespace N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1750 of file AsmWriter.cpp.

static void writeDIObjCProperty ( raw_ostream Out,
const DIObjCProperty N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1894 of file AsmWriter.cpp.

static void writeDISubprogram ( raw_ostream Out,
const DISubprogram N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1694 of file AsmWriter.cpp.

static void writeDISubrange ( raw_ostream Out,
const DISubrange N,
TypePrinting *  ,
SlotTracker ,
const Module  
)
static

Definition at line 1568 of file AsmWriter.cpp.

static void writeDISubroutineType ( raw_ostream Out,
const DISubroutineType N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1644 of file AsmWriter.cpp.

static void writeDITemplateTypeParameter ( raw_ostream Out,
const DITemplateTypeParameter N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1800 of file AsmWriter.cpp.

static void writeDITemplateValueParameter ( raw_ostream Out,
const DITemplateValueParameter N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1812 of file AsmWriter.cpp.

static void writeGenericDINode ( raw_ostream Out,
const GenericDINode N,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1536 of file AsmWriter.cpp.

static void WriteMDNodeBodyInternal ( raw_ostream Out,
const MDNode Node,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1923 of file AsmWriter.cpp.

Referenced by printMetadataImpl().

static void writeMDTuple ( raw_ostream Out,
const MDTuple Node,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1360 of file AsmWriter.cpp.

static void writeMetadataAsOperand ( raw_ostream Out,
const Metadata MD,
TypePrinting *  TypePrinter,
SlotTracker Machine,
const Module Context 
)
static

Definition at line 1462 of file AsmWriter.cpp.

static void WriteOptimizationInfo ( raw_ostream Out,
const User U 
)
static

Definition at line 1062 of file AsmWriter.cpp.

References GEP.