LLVM  4.0.0
Macros | Typedefs | Functions | Variables
AsmPrinter.cpp File Reference
#include "llvm/CodeGen/AsmPrinter.h"
#include "CodeViewDebug.h"
#include "DwarfDebug.h"
#include "DwarfException.h"
#include "WinException.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/GCMetadataPrinter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineInstrBundle.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbolELF.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Timer.h"
#include "llvm/Target/TargetFrameLowering.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
Include dependency graph for AsmPrinter.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "asm-printer"
 

Typedefs

typedef DenseMap< GCStrategy
*, std::unique_ptr
< GCMetadataPrinter > > 
gcp_map_type
 

Functions

 STATISTIC (EmittedInsts,"Number of machine instrs printed")
 
static gcp_map_typegetGCMap (void *&P)
 
static unsigned getGVAlignmentLog2 (const GlobalValue *GV, const DataLayout &DL, unsigned InBits=0)
 getGVAlignmentLog2 - Return the alignment to use for the specified global value in log2 form. More...
 
static bool canBeHidden (const GlobalValue *GV, const MCAsmInfo &MAI)
 
static void emitComments (const MachineInstr &MI, raw_ostream &CommentOS)
 emitComments - Pretty-print comments for instructions. More...
 
static void emitKill (const MachineInstr *MI, AsmPrinter &AP)
 
static bool emitDebugValueComment (const MachineInstr *MI, AsmPrinter &AP)
 emitDebugValueComment - This method handles the target-independent form of DBG_VALUE, returning true if it was able to do so. More...
 
static unsigned getNumGlobalVariableUses (const Constant *C)
 Compute the number of Global Variables that uses a Constant. More...
 
static bool isGOTEquivalentCandidate (const GlobalVariable *GV, unsigned &NumGOTEquivUsers)
 Only consider global GOT equivalents if at least one user is a cstexpr inside an initializer of another global variables. More...
 
static void emitGlobalConstantImpl (const DataLayout &DL, const Constant *C, AsmPrinter &AP, const Constant *BaseCV=nullptr, uint64_t Offset=0)
 
static void emitGlobalConstantFP (const ConstantFP *CFP, AsmPrinter &AP)
 
static int isRepeatedByteSequence (const ConstantDataSequential *V)
 isRepeatedByteSequence - Determine whether the given value is composed of a repeated sequence of identical bytes and return the byte value. More...
 
static int isRepeatedByteSequence (const Value *V, const DataLayout &DL)
 isRepeatedByteSequence - Determine whether the given value is composed of a repeated sequence of identical bytes and return the byte value. More...
 
static void emitGlobalConstantDataSequential (const DataLayout &DL, const ConstantDataSequential *CDS, AsmPrinter &AP)
 
static void emitGlobalConstantArray (const DataLayout &DL, const ConstantArray *CA, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
 
static void emitGlobalConstantVector (const DataLayout &DL, const ConstantVector *CV, AsmPrinter &AP)
 
static void emitGlobalConstantStruct (const DataLayout &DL, const ConstantStruct *CS, AsmPrinter &AP, const Constant *BaseCV, uint64_t Offset)
 
static void emitGlobalConstantLargeInt (const ConstantInt *CI, AsmPrinter &AP)
 
static void handleIndirectSymViaGOTPCRel (AsmPrinter &AP, const MCExpr **ME, const Constant *BaseCst, uint64_t Offset)
 Transform a not absolute MCExpr containing a reference to a GOT equivalent global, by a target specific GOT pc relative access to the final symbol. More...
 
static void PrintParentLoopComment (raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
 PrintParentLoopComment - Print comments about parent loops of this one. More...
 
static void PrintChildLoopComment (raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
 PrintChildLoopComment - Print comments about child loops within the loop for this basic block, with nesting. More...
 
static void emitBasicBlockLoopComments (const MachineBasicBlock &MBB, const MachineLoopInfo *LI, const AsmPrinter &AP)
 emitBasicBlockLoopComments - Pretty-print comments for basic blocks. More...
 

Variables

static const char *const DWARFGroupName = "dwarf"
 
static const char *const DWARFGroupDescription = "DWARF Emission"
 
static const char *const DbgTimerName = "emit"
 
static const char *const DbgTimerDescription = "Debug Info Emission"
 
static const char *const EHTimerName = "write_exception"
 
static const char *const EHTimerDescription = "DWARF Exception Writer"
 
static const char *const CodeViewLineTablesGroupName = "linetables"
 
static const char *const CodeViewLineTablesGroupDescription
 

Macro Definition Documentation

#define DEBUG_TYPE   "asm-printer"

Definition at line 58 of file AsmPrinter.cpp.

Typedef Documentation

typedef DenseMap<GCStrategy*, std::unique_ptr<GCMetadataPrinter> > gcp_map_type

Definition at line 74 of file AsmPrinter.cpp.

Function Documentation

static bool canBeHidden ( const GlobalValue GV,
const MCAsmInfo MAI 
)
static
static void emitBasicBlockLoopComments ( const MachineBasicBlock MBB,
const MachineLoopInfo LI,
const AsmPrinter AP 
)
static
static void emitComments ( const MachineInstr MI,
raw_ostream CommentOS 
)
static
static bool emitDebugValueComment ( const MachineInstr MI,
AsmPrinter AP 
)
static

emitDebugValueComment - This method handles the target-independent form of DBG_VALUE, returning true if it was able to do so.

A false return means the target will need to handle MI in EmitInstruction.

Definition at line 731 of file AsmPrinter.cpp.

References llvm::lltok::APFloat, assert(), llvm::APFloat::convert(), llvm::APFloat::convertToDouble(), llvm::APFloat::convertToFloat(), llvm::dwarf::DW_OP_LLVM_fragment, llvm::StringRef::empty(), llvm::MachineOperand::getCImm(), llvm::MachineInstr::getDebugExpression(), llvm::MachineInstr::getDebugVariable(), llvm::DIExpression::getElement(), llvm::MachineOperand::getFPImm(), llvm::DIExpression::getFragmentInfo(), llvm::TargetFrameLowering::getFrameIndexReference(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::MachineOperand::getImm(), llvm::MachineOperand::getIndex(), llvm::DIVariable::getName(), llvm::DIExpression::getNumElements(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::DILocalVariable::getScope(), llvm::MachineFunction::getSubtarget(), llvm::Value::getType(), llvm::ConstantInt::getValue(), llvm::ConstantFP::getValueAPF(), i, llvm::APFloatBase::IEEEdouble(), llvm::MachineOperand::isCImm(), llvm::Type::isDoubleTy(), llvm::MachineOperand::isFI(), llvm::Type::isFloatTy(), llvm::MachineOperand::isFPImm(), llvm::MachineOperand::isImm(), llvm::MachineOperand::isReg(), llvm::AsmPrinter::MF, Offset, llvm::AsmPrinter::OutStreamer, llvm::APInt::print(), llvm::PrintReg(), llvm::APFloatBase::rmNearestTiesToEven, and llvm::raw_svector_ostream::str().

Referenced by llvm::AsmPrinter::EmitFunctionBody().

static void emitGlobalConstantArray ( const DataLayout DL,
const ConstantArray CA,
AsmPrinter AP,
const Constant BaseCV,
uint64_t  Offset 
)
static
static void emitGlobalConstantDataSequential ( const DataLayout DL,
const ConstantDataSequential CDS,
AsmPrinter AP 
)
static
static void emitGlobalConstantFP ( const ConstantFP CFP,
AsmPrinter AP 
)
static
static void emitGlobalConstantImpl ( const DataLayout DL,
const Constant C,
AsmPrinter AP,
const Constant BaseCV = nullptr,
uint64_t  Offset = 0 
)
static
static void emitGlobalConstantLargeInt ( const ConstantInt CI,
AsmPrinter AP 
)
static
static void emitGlobalConstantStruct ( const DataLayout DL,
const ConstantStruct CS,
AsmPrinter AP,
const Constant BaseCV,
uint64_t  Offset 
)
static
static void emitGlobalConstantVector ( const DataLayout DL,
const ConstantVector CV,
AsmPrinter AP 
)
static
static void emitKill ( const MachineInstr MI,
AsmPrinter AP 
)
static
static gcp_map_type& getGCMap ( void *&  P)
static

Definition at line 75 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::~AsmPrinter().

static unsigned getGVAlignmentLog2 ( const GlobalValue GV,
const DataLayout DL,
unsigned  InBits = 0 
)
static

getGVAlignmentLog2 - Return the alignment to use for the specified global value in log2 form.

This rounds up to the preferred alignment if possible and legal.

Definition at line 85 of file AsmPrinter.cpp.

References llvm::GlobalValue::getAlignment(), llvm::DataLayout::getPreferredAlignmentLog(), llvm::GlobalValue::hasSection(), and llvm::Log2_32().

Referenced by llvm::AsmPrinter::EmitAlignment(), and llvm::AsmPrinter::EmitGlobalVariable().

static unsigned getNumGlobalVariableUses ( const Constant C)
static

Compute the number of Global Variables that uses a Constant.

Definition at line 1022 of file AsmPrinter.cpp.

References llvm::Value::users().

Referenced by isGOTEquivalentCandidate().

static void handleIndirectSymViaGOTPCRel ( AsmPrinter AP,
const MCExpr **  ME,
const Constant BaseCst,
uint64_t  Offset 
)
static
static bool isGOTEquivalentCandidate ( const GlobalVariable GV,
unsigned NumGOTEquivUsers 
)
static

Only consider global GOT equivalents if at least one user is a cstexpr inside an initializer of another global variables.

Also, don't handle cstexpr inside instructions. During global variable emission, candidates are skipped and are emitted later in case at least one cstexpr isn't replaced by a PC relative GOT entry access.

Definition at line 1041 of file AsmPrinter.cpp.

References llvm::dyn_cast(), getNumGlobalVariableUses(), llvm::User::getOperand(), llvm::GlobalValue::hasGlobalUnnamedAddr(), llvm::GlobalVariable::hasInitializer(), llvm::GlobalVariable::isConstant(), llvm::GlobalValue::isDiscardableIfUnused(), and llvm::Value::users().

Referenced by llvm::AsmPrinter::computeGlobalGOTEquivs().

static int isRepeatedByteSequence ( const ConstantDataSequential V)
static

isRepeatedByteSequence - Determine whether the given value is composed of a repeated sequence of identical bytes and return the byte value.

If it is not a repeated sequence, return -1.

Definition at line 1925 of file AsmPrinter.cpp.

References assert(), C, llvm::StringRef::empty(), llvm::ConstantDataSequential::getRawDataValues(), i, and llvm::StringRef::size().

Referenced by emitGlobalConstantArray(), emitGlobalConstantDataSequential(), and isRepeatedByteSequence().

static int isRepeatedByteSequence ( const Value V,
const DataLayout DL 
)
static

isRepeatedByteSequence - Determine whether the given value is composed of a repeated sequence of identical bytes and return the byte value.

If it is not a repeated sequence, return -1.

Definition at line 1938 of file AsmPrinter.cpp.

References assert(), llvm::User::getOperand(), llvm::Value::getType(), llvm::DataLayout::getTypeAllocSizeInBits(), llvm::APInt::getZExtValue(), i, isRepeatedByteSequence(), llvm::APInt::isSplat(), llvm::APInt::zextOrSelf(), and llvm::APInt::zextOrTrunc().

static void PrintChildLoopComment ( raw_ostream OS,
const MachineLoop Loop,
unsigned  FunctionNumber 
)
static

PrintChildLoopComment - Print comments about child loops within the loop for this basic block, with nesting.

Definition at line 2439 of file AsmPrinter.cpp.

References llvm::raw_ostream::indent().

Referenced by emitBasicBlockLoopComments().

static void PrintParentLoopComment ( raw_ostream OS,
const MachineLoop Loop,
unsigned  FunctionNumber 
)
static

PrintParentLoopComment - Print comments about parent loops of this one.

Definition at line 2426 of file AsmPrinter.cpp.

References FunctionNumber(), llvm::LoopBase< N, M >::getHeader(), llvm::LoopBase< N, M >::getLoopDepth(), llvm::LoopBase< N, M >::getParentLoop(), and llvm::raw_ostream::indent().

Referenced by emitBasicBlockLoopComments().

STATISTIC ( EmittedInsts  ,
"Number of machine instrs printed"   
)

Variable Documentation

const char* const CodeViewLineTablesGroupDescription
static
Initial value:
=
"CodeView Line Tables"

Definition at line 67 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const CodeViewLineTablesGroupName = "linetables"
static

Definition at line 66 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const DbgTimerDescription = "Debug Info Emission"
static

Definition at line 63 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const DbgTimerName = "emit"
static

Definition at line 62 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const DWARFGroupDescription = "DWARF Emission"
static

Definition at line 61 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const DWARFGroupName = "dwarf"
static

Definition at line 60 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const EHTimerDescription = "DWARF Exception Writer"
static

Definition at line 65 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().

const char* const EHTimerName = "write_exception"
static

Definition at line 64 of file AsmPrinter.cpp.

Referenced by llvm::AsmPrinter::doInitialization().