14 #define DEBUG_TYPE "asm-printer"
56 static const char *
const EHTimerName =
"DWARF Exception Writer";
58 STATISTIC(EmittedInsts,
"Number of machine instrs printed");
60 char AsmPrinter::ID = 0;
74 unsigned InBits = 0) {
98 TM(tm), MAI(tm.getMCAsmInfo()),
MII(tm.getInstrInfo()),
99 OutContext(Streamer.getContext()),
100 OutStreamer(Streamer),
101 LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) {
102 DD = 0; DE = 0;
MMI = 0; LI = 0;
MF = 0;
104 GCMetadataPrinters = 0;
109 assert(DD == 0 && DE == 0 &&
"Debug/EH info didn't get finalized");
111 if (GCMetadataPrinters != 0) {
117 GCMetadataPrinters = 0;
159 MMI = getAnalysisIfAvailable<MachineModuleInfo>();
181 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
184 MP->beginAssembly(*
this);
229 bool CanBeHidden =
false;
319 if (Size == 0) Size = 1;
320 unsigned Align = 1 << AlignLog;
369 if (Size == 0) Size = 1;
413 EmitLinkage(GV, GVSym);
432 EmitLinkage(GV, GVSym);
477 std::vector<MCSymbol*> DeadBlockSyms;
479 for (
unsigned i = 0, e = DeadBlockSyms.size(); i != e; ++i) {
508 "' label emitted multiple times to assembly file");
527 CommentOS << MMO->
getSize() <<
"-byte Reload\n";
531 CommentOS << MMO->
getSize() <<
"-byte Folded Reload\n";
535 CommentOS << MMO->
getSize() <<
"-byte Spill\n";
539 CommentOS << MMO->
getSize() <<
"-byte Folded Spill\n";
544 CommentOS <<
" Reload Reuse\n";
557 std::string Str =
"kill:";
560 assert(Op.
isReg() &&
"KILL instruction must have only register operands");
563 Str += (Op.
isDef() ?
"<def>" :
"<kill>");
637 OS <<
'+' << Offset <<
']';
678 bool FoundOne =
false;
680 for (std::vector<MCCFIInstruction>::const_iterator
I = Instrs.begin(),
681 E = Instrs.end();
I != E; ++
I) {
682 if (
I->getLabel() == Label) {
699 bool HasAnyRealCode =
false;
710 if (!II->isLabel() && !II->isImplicitDef() && !II->isKill() &&
711 !II->isDebugValue()) {
712 HasAnyRealCode =
true;
716 if (ShouldPrintDebugScopes) {
724 switch (II->getOpcode()) {
756 if (ShouldPrintDebugScopes) {
833 bool Indirect)
const {
897 EmitVisibility(Name, V,
false);
903 if (!ModuleFlags.
empty())
935 if (!
I->hasExternalWeakLinkage())
continue;
940 if (!
I->hasExternalWeakLinkage())
continue;
954 ": Target doesn't support aliases to declarations");
961 else if (
I->hasWeakLinkage() ||
I->hasLinkOnceLinkage())
964 assert(
I->hasLocalLinkage() &&
"Invalid alias linkage");
966 EmitVisibility(Name,
I->getVisibility());
975 assert(MI &&
"AsmPrinter didn't require GCModuleInfo?");
978 MP->finishAssembly(*
this);
986 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->
use_empty())
1010 LI = &getAnalysis<MachineLoopInfo>();
1019 SectionCPs(
const MCSection *s,
unsigned a) : S(s), Alignment(a) {}
1030 const std::vector<MachineConstantPoolEntry> &CP = MCP->
getConstants();
1031 if (CP.empty())
return;
1036 for (
unsigned i = 0, e = CP.size(); i != e; ++i) {
1061 unsigned SecIdx = CPSections.
size();
1062 while (SecIdx != 0) {
1063 if (CPSections[--SecIdx].S == S) {
1069 SecIdx = CPSections.
size();
1070 CPSections.
push_back(SectionCPs(S, Align));
1073 if (Align > CPSections[SecIdx].Alignment)
1074 CPSections[SecIdx].Alignment =
Align;
1079 for (
unsigned i = 0, e = CPSections.
size(); i != e; ++i) {
1083 unsigned Offset = 0;
1084 for (
unsigned j = 0, ee = CPSections[i].CPEs.
size(); j != ee; ++j) {
1085 unsigned CPI = CPSections[i].CPEs[j];
1090 unsigned NewOffset = (Offset + AlignMask) & ~AlignMask;
1110 if (MJTI == 0)
return;
1112 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
1113 if (JT.empty())
return;
1118 bool JTInDiffSection =
false;
1134 JTInDiffSection =
true;
1141 if (!JTInDiffSection)
1144 for (
unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
1145 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
1148 if (JTBBs.empty())
continue;
1158 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
1160 if (!EmittedSets.
insert(MBB))
continue;
1181 for (
unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
1182 EmitJumpTableEntry(MJTI, JTBBs[ii], JTI);
1184 if (!JTInDiffSection)
1192 unsigned UID)
const {
1193 assert(MBB && MBB->
getNumber() >= 0 &&
"Invalid basic block");
1251 assert(Value &&
"Unknown entry kind!");
1262 if (GV->
getName() ==
"llvm.used") {
1277 if (GV->
getName() ==
"llvm.global_ctors") {
1289 if (GV->
getName() ==
"llvm.global_dtors") {
1307 void AsmPrinter::EmitLLVMUsedList(
const ConstantArray *InitList) {
1309 for (
unsigned i = 0, e = InitList->
getNumOperands(); i != e; ++i) {
1319 void AsmPrinter::EmitXXStructorList(
const Constant *
List,
bool isCtor) {
1322 if (!isa<ConstantArray>(List))
return;
1326 if (!InitList)
return;
1333 typedef std::pair<unsigned, Constant *> Structor;
1335 for (
unsigned i = 0, e = InitList->
getNumOperands(); i != e; ++i) {
1341 if (!Priority)
continue;
1350 for (
unsigned i = 0, e = Structors.
size(); i != e; ++i) {
1362 void AsmPrinter::EmitModuleIdents(
Module &M) {
1367 for (
unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
1368 const MDNode *
N = NMD->getOperand(i);
1370 "llvm.ident metadata entry can have only one operand");
1403 unsigned Size)
const {
1455 unsigned Size,
bool IsSectionRelative)
1484 if (NumBits == 0)
return;
1504 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV))
1507 if (
const GlobalValue *GV = dyn_cast<GlobalValue>(CV))
1510 if (
const BlockAddress *BA = dyn_cast<BlockAddress>(CV))
1532 OS <<
"Unsupported expression in static initializer: ";
1537 case Instruction::GetElementPtr: {
1541 cast<GEPOperator>(CE)->accumulateConstantOffset(DL, OffsetAI);
1552 case Instruction::Trunc:
1558 case Instruction::BitCast:
1561 case Instruction::IntToPtr: {
1571 case Instruction::PtrToInt: {
1595 case Instruction::Add:
1596 case Instruction::Sub:
1597 case Instruction::Mul:
1598 case Instruction::SDiv:
1599 case Instruction::SRem:
1600 case Instruction::Shl:
1629 assert(!Data.
empty() &&
"Empty aggregates should be CAZ node");
1631 for (
unsigned i = 1, e = Data.
size(); i != e; ++i)
1632 if (Data[i] != C)
return -1;
1633 return static_cast<uint8_t
>(
C);
1642 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
1643 if (CI->getBitWidth() > 64)
return -1;
1646 uint64_t Value = CI->getZExtValue();
1652 if (CI->getBitWidth() < 8 || !
isPowerOf2_64(CI->getBitWidth()))
return -1;
1654 uint8_t Byte =
static_cast<uint8_t
>(Value);
1656 for (
unsigned i = 1; i < Size; ++i) {
1658 if (static_cast<uint8_t>(Value) != Byte)
return -1;
1665 assert(CA->getNumOperands() != 0 &&
"Should be a CAZ");
1667 if (Byte == -1)
return -1;
1669 for (
unsigned i = 1, e = CA->getNumOperands(); i != e; ++i) {
1671 if (ThisByte == -1)
return -1;
1672 if (Byte != ThisByte)
return -1;
1709 }
else if (ElementByteSize == 4) {
1743 if (
unsigned Padding = Size - EmittedSize)
1771 if (
unsigned Padding = Size - EmittedSize)
1780 uint64_t SizeSoFar = 0;
1788 SizeSoFar += FieldSize + PadSize;
1799 "Layout of constant struct may be incorrect!");
1819 unsigned TrailingBytes = NumBytes %
sizeof(uint64_t);
1830 for (; Chunk >= 0; --Chunk)
1834 for (Chunk = 0; Chunk < NumBytes /
sizeof(uint64_t); ++Chunk)
1854 uint64_t ExtraBits = 0;
1855 unsigned ExtraBitsSize = BitWidth & 63;
1857 if (ExtraBitsSize) {
1874 ExtraBits = Realigned.getRawData()[0] &
1875 (((uint64_t)-1) >> (64 - ExtraBitsSize));
1876 Realigned = Realigned.lshr(ExtraBitsSize);
1878 ExtraBits = Realigned.getRawData()[BitWidth / 64];
1884 const uint64_t *RawData = Realigned.getRawData();
1885 for (
unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
1886 uint64_t Val = DL->
isBigEndian() ? RawData[e - i - 1] : RawData[i];
1890 if (ExtraBitsSize) {
1895 Size -= (BitWidth / 64) * 8;
1896 assert(Size && Size * 8 >= ExtraBitsSize &&
1897 (ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
1898 == ExtraBits &&
"Directive too small for extra bits.");
1906 if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
1909 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
1917 CI->getZExtValue());
1926 if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
1929 if (isa<ConstantPointerNull>(CV)) {
1943 if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
1946 if (CE->getOpcode() == Instruction::BitCast)
1954 if (New && New != CE)
1986 OS <<
'+' << Offset;
1987 else if (Offset < 0)
2022 +
"_" +
Twine(CPID));
2043 bool ForcePrivate)
const {
2063 if (Loop == 0)
return;
2066 <<
"Parent Loop BB" << FunctionNumber <<
"_"
2078 OS.
indent((*CL)->getLoopDepth()*2)
2079 <<
"Child Loop BB" << FunctionNumber <<
"_"
2080 << (*CL)->getHeader()->getNumber() <<
" Depth " << (*CL)->getLoopDepth()
2092 if (Loop == 0)
return;
2095 assert(Header &&
"No header for loop");
2099 if (Header != &MBB) {
2144 for (
unsigned i = 0, e = Syms.size(); i != e; ++i)
2168 void AsmPrinter::EmitVisibility(
MCSymbol *Sym,
unsigned Visibility,
2169 bool IsDefinition)
const {
2172 switch (Visibility) {
2217 IE = Pred->
end(); II !=
IE; ++II) {
2247 if (GCPI != GCMap.
end())
2248 return GCPI->second;
2258 GCMap.
insert(std::make_pair(S, GMP));
static const MCBinaryExpr * CreateMod(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isPrologLabel() const
const MCSection * getTLSExtraDataSection() const
virtual void EmitGlobalVariable(const GlobalVariable *GV)
EmitGlobalVariable - Emit the specified global variable to the .s file.
MachineConstantPoolValue * MachineCPVal
int strcmp(const char *s1, const char *s2);
static SectionKind getReadOnlyWithRelLocal()
bool usesMetadata() const
void push_back(const T &Elt)
const MachineFunction * getParent() const
virtual void EmitStartOfAsmFile(Module &)
bool doesSupportDebugInformation() const
static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP)
LinkageTypes getLinkage() const
IntegerType * getType() const
mop_iterator operands_end()
The machine constant pool.
unsigned getAlignment() const
virtual const TargetLowering * getTargetLowering() const
static SectionKind getKindForGlobal(const GlobalValue *GV, const TargetMachine &TM)
MCSectionSubPair getPreviousSection() const
int getDwarfRegNum(unsigned RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number. Returns -1 if there is no equivalent va...
Like Private, but linker removes.
virtual void AddComment(const Twine &T)
std::vector< MCSymbol * > getAddrLabelSymbolToEmit(const BasicBlock *BB)
Special purpose, only applies to global arrays.
VisibilityTypes getVisibility() const
unsigned getPointerPrefAlignment(unsigned AS=0) const
static const MCBinaryExpr * CreateOr(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
static void emitBasicBlockLoopComments(const MachineBasicBlock &MBB, const MachineLoopInfo *LI, const AsmPrinter &AP)
emitBasicBlockLoopComments - Pretty-print comments for basic blocks.
uint32_t getCompactUnwindEncoding() const
bool hasIdentDirective() const
virtual bool hasStoreToStackSlot(const MachineInstr *MI, const MachineMemOperand *&MMO, int &FrameIndex) const
virtual void EndFunction()
EndFunction - Gather and emit post-function exception information.
void EmitRawText(const Twine &String)
MCSymbol * getSymbol(const GlobalValue *GV) const
bool isBranch(QueryType Type=AnyInBundle) const
static const MCBinaryExpr * CreateDiv(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
size_t size() const
size - Get the string size.
Reloc::Model getRelocationModel() const
virtual void emitModuleFlags(MCStreamer &, ArrayRef< Module::ModuleFlagEntry >, Mangler *, const TargetMachine &) const
emitModuleFlags - Emit the module flags that the platform cares about.
bool isSubprogram() const
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
.type _foo, STT_OBJECT # aka
static const fltSemantics IEEEdouble
const ConstantFP * getFPImm() const
MachineBasicBlock * getMBB() const
static const MCConstantExpr * Create(int64_t Value, MCContext &Ctx)
The main container class for the LLVM Intermediate Representation.
const DataLayout & getDataLayout() const
getDataLayout - Return information about data layout.
virtual void AddBlankLine()
AddBlankLine - Emit a blank line to a .s file to pretty it up.
void EmitInt8(int Value) const
unsigned getAlignment() const
Same, but only replaced by something equivalent.
void endFunction(const MachineFunction *MF)
Gather and emit post-function debug information.
void print(raw_ostream &OS, bool isSigned) const
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getBitWidth() const
getBitWidth - Return the bitwidth of this constant.
virtual bool hasLoadFromStackSlot(const MachineInstr *MI, const MachineMemOperand *&MMO, int &FrameIndex) const
unsigned getNumOperands() const
Available for inspection, not emission.
unsigned getNumOperands() const
getNumOperands - Return number of MDNode operands.
unsigned getPointerTypeSizeInBits(Type *) const
void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, unsigned Size, bool IsSectionRelative=false) const
iterator getFirstTerminator()
void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, bool isImplicitlyPrivate, bool UseGlobalPrefix=true)
void EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) const
static int isRepeatedByteSequence(const ConstantDataSequential *V)
Collects and handles dwarf debug information.
const char * getPrivateGlobalPrefix() const
virtual void EmitFileDirective(StringRef Filename)=0
bool hasAppendingLinkage() const
const MachineFunction * MF
The current machine function.
raw_ostream & indent(unsigned NumSpaces)
indent - Insert 'NumSpaces' spaces.
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol=0, uint64_t Size=0, unsigned ByteAlignment=0)=0
Like Internal, but omit from symbol table.
virtual const MCSection * getSectionForConstant(SectionKind Kind) const
const char * getLinkerPrivateGlobalPrefix() const
Externally visible function.
static SectionKind getMergeableConst8()
bool isDoubleTy() const
isDoubleTy - Return true if this is 'double', a 64-bit IEEE fp type.
bool hasAvailableExternallyLinkage() const
static SectionKind getMergeableConst16()
virtual bool hasRawTextSupport() const
static const char *const DWARFGroupName
virtual void EmitConstantPool()
virtual void EmitInstruction(const MCInst &Inst)=0
virtual void EmitDwarfRegOp(const MachineLocation &MLoc, bool Indirect) const
EmitDwarfRegOp - Emit dwarf register operation.
ExceptionHandling::ExceptionsType getExceptionHandlingType() const
LoopT * getParentLoop() const
unsigned getFunctionNumber() const
MDNode - a tuple of other values.
void EmitInt32(int Value) const
const Function * getFunction() const
const char * getWeakRefDirective() const
void endInstruction(const MachineInstr *MI)
Process end of an instruction.
LCOMM::LCOMMType getLCOMMDirectiveAlignmentType() const
const MDNode * getMetadata() const
unsigned getFunctionNumber() const
const Constant * getInitializer() const
static void emitKill(const MachineInstr *MI, AsmPrinter &AP)
unsigned getOpcode() const
getOpcode - Return the opcode at the root of this constant expression
const char * OperationEncodingString(unsigned Encoding)
void emitCFIInstruction(const MCCFIInstruction &Inst) const
Emit frame instruction to describe the layout of the frame.
static SectionKind getMergeableConst4()
BlockT * getHeader() const
virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI, int &FrameIndex) const
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)=0
virtual const MCSection * getNonexecutableStackSection(MCContext &Ctx) const
LoopInfoBase< BlockT, LoopT > * LI
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
MCSymbol * GetSymbolWithGlobalValueBase(const GlobalValue *GV, StringRef Suffix, bool ForcePrivate=true) const
MCSymbol * getAddrLabelSymbol(const BasicBlock *BB)
uint64_t getTypeAllocSizeInBits(Type *Ty) const
StringRef getName() const
bool hasMachoTBSSDirective() const
virtual void EmitGPRel32Value(const MCExpr *Value)
Value * getOperand(unsigned i) const LLVM_READONLY
getOperand - Return specified operand.
void print(raw_ostream &O) const
unsigned getRelocationInfo() const
unsigned getPointerTypeSize(Type *Ty) const
MCSymbolAttr getHiddenVisibilityAttr() const
void WriteAsOperand(raw_ostream &, const Value *, bool PrintTy=true, const Module *Context=0)
const std::vector< MachineJumpTableEntry > & getJumpTables() const
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
AnalysisUsage & addRequired()
MCSymbol * GetOrCreateSymbol(StringRef Name)
static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP)
static void Make(MCStreamer *MCOS, const MCSection *Section)
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
bool getAsmPrinterFlag(CommentFlag Flag) const
const MCSection * getTLSBSSSection() const
virtual void EmitGPRel64Value(const MCExpr *Value)
MCSymbol * CreateTempSymbol()
void takeDeletedSymbolsForFunction(const Function *F, std::vector< MCSymbol * > &Result)
virtual void EmitEndOfAsmFile(Module &)
const StructLayout * getStructLayout(StructType *Ty) const
const APInt & getValue() const
Return the constant's value.
void EmitBasicBlockStart(const MachineBasicBlock *MBB) const
virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI, int &FrameIndex) const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
MCSectionSubPair getCurrentSection() const
static const MCBinaryExpr * CreateXor(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
STATISTIC(EmittedInsts,"Number of machine instrs printed")
void getAnalysisUsage(AnalysisUsage &AU) const
virtual void EmitBytes(StringRef Data)=0
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc. to it.
double getElementAsDouble(unsigned i) const
MCSymbol * GetJTISymbol(unsigned JTID, bool isLinkerPrivate=false) const
GetJTISymbol - Return the symbol for the specified jump table entry.
Abstract Stack Frame Information.
bool hasMachoZeroFillDirective() const
bool hasSetDirective() const
virtual bool isVerboseAsm() const
bool hasDebugInfo() const
static void emitGlobalConstantVector(const ConstantVector *CV, AsmPrinter &AP)
ID
LLVM Calling Convention Representation.
StringRef getName() const
const std::string & getModuleIdentifier() const
static const MCBinaryExpr * CreateSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
unsigned getNumOperands() const
global_iterator global_begin()
format_object1< T > format(const char *Fmt, const T &Val)
void SwitchSection(const MCSection *Section, const MCExpr *Subsection=0)
DISubprogram - This is a wrapper for a subprogram (e.g. a function).
static void emitComments(const MachineInstr &MI, raw_ostream &CommentOS)
emitComments - Pretty-print comments for instructions.
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
virtual void getNoopForMachoTarget(MCInst &NopInst) const
getNoopForMachoTarget - Return the noop instruction to use for a noop.
Constant * ConstantFoldConstantExpression(const ConstantExpr *CE, const DataLayout *TD=0, const TargetLibraryInfo *TLI=0)
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Function to be imported from DLL.
list_type::const_iterator iterator
const std::string & getName() const
virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding)
const MCSection * getCurrentSection() const
getCurrentSection() - Return the current section we are emitting to.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
Get the constant's value with a saturation limit.
void EmitInt16(int Value) const
const MachineJumpTableInfo * getJumpTableInfo() const
double convertToDouble() const
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the current function's prologue. Used to construct frame maps for debug and exception handling comsumers.
SequentialType * getType() const
An entry in a MachineConstantPool.
virtual void emitImplicitDef(const MachineInstr *MI) const
unsigned getNumElements() const
Return the number of elements in the Vector type.
StringRef getTargetTriple() const
getTargetTriple - Return the target triple string.
virtual void EmitIntValue(uint64_t Value, unsigned Size)
bool isPPC_FP128Ty() const
isPPC_FP128Ty - Return true if this is powerpc long double.
Type * getElementType() const
virtual int getFrameIndexReference(const MachineFunction &MF, int FI, unsigned &FrameReg) const
void EmitValue(const MCExpr *Value, unsigned Size)
MachineModuleInfo * MMI
MMI - This is a pointer to the current MachineModuleInfo.
const BasicBlock * getBasicBlock() const
bool isMachineConstantPoolEntry() const
bool doInitialization(Module &M)
bool isSpillSlotObjectIndex(int ObjectIdx) const
bool getCommDirectiveSupportsAlignment() const
const MachineBasicBlock * getParent() const
Function * getFunction(StringRef Name) const
static const MCSymbolRefExpr * Create(const MCSymbol *Symbol, MCContext &Ctx)
const TargetLoweringObjectFile & getObjFileLowering() const
static bool isWeakForLinker(LinkageTypes Linkage)
uint64_t getElementOffset(unsigned Idx) const
const Constant * ConstVal
void append(in_iter S, in_iter E)
Append from an iterator pair.
virtual void BeginFunction(const MachineFunction *MF)
ExternalWeak linkage description.
unsigned getEntrySize(const DataLayout &TD) const
getEntrySize - Return the size of each entry in the jump table.
void emitPrologLabel(const MachineInstr &MI)
static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP)
bundle_iterator< MachineInstr, instr_iterator > iterator
MachineLoop * getLoopFor(const MachineBasicBlock *BB) const
bool needsDwarfSectionOffsetDirective() const
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
unsigned getEntryAlignment(const DataLayout &TD) const
getEntryAlignment - Return the alignment of each entry in the jump table.
virtual raw_ostream & GetCommentOS()
Same, but only replaced by something equivalent.
void AnalyzeModule(const Module &M)
virtual void EmitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros. This function properly handles data in virtual sections.
const MCSection * SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const
static const MCBinaryExpr * CreateAnd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
virtual void EmitFunctionBodyEnd()
MCSymbolAttr getHiddenDeclarationVisibilityAttr() const
void EmitFunctionHeader()
.weak_def_can_be_hidden (MachO)
alias_iterator alias_end()
virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)=0
MCSymbolAttr getProtectedVisibilityAttr() const
LLVM Basic Block Representation.
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue)
LLVM Constant Representation.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
getModuleFlagsMetadata - Returns the module flags in the provided vector.
static void emitGlobalConstantStruct(const ConstantStruct *CS, AsmPrinter &AP)
uint64_t getElementByteSize() const
getElementByteSize - Return the size in bytes of the elements in the data.
int64_t getSExtValue() const
Get sign extended value.
StringRef getAsString() const
bool isThreadData() const
const MachineOperand & getOperand(unsigned i) const
StringRef getRawDataValues() const
static void emitGlobalConstantArray(const ConstantArray *CA, AsmPrinter &AP)
void InitStreamer()
Initialize the streamer.
bool isFloatTy() const
isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type.
MCSymbol * GetJTSetSymbol(unsigned UID, unsigned MBBID) const
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static void emitGlobalConstantImpl(const Constant *C, AsmPrinter &AP)
bool isCImm() const
isCImm - Test if t his is a MO_CImmediate operand.
bool isIndirectBranch(QueryType Type=AnyInBundle) const
virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value)=0
virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute)=0
EmitSymbolAttribute - Add the given Attribute to Symbol.
virtual void EmitCOFFSecRel32(MCSymbol const *Symbol)
Type * getTypeAtIndex(const Value *V)
unsigned getBitWidth() const
Return the number of bits in the APInt.
void printOffset(int64_t Offset, raw_ostream &OS) const
printOffset - This is just convenient handler for printing offsets.
opStatus convert(const fltSemantics &, roundingMode, bool *)
virtual void Flush()
Flush - Causes any cached state to be written out.
Value * getOperand(unsigned i) const
static void PrintChildLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
void EmitLabelOffsetDifference(const MCSymbol *Hi, uint64_t Offset, const MCSymbol *Lo, unsigned Size) const
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Function to be accessible from DLL.
static bool analyzeGlobal(const Value *V, GlobalStatus &GS)
MachineConstantPool * getConstantPool()
virtual void EmitIdent(StringRef IdentString)
static const char *const EHTimerName
void Finish()
Finish - Finish emission of machine code.
uint64_t getElementAsInteger(unsigned i) const
const std::string & getSection() const
union llvm::MachineConstantPoolEntry::@29 Val
The constant itself.
virtual const TargetFrameLowering * getFrameLowering() const
pred_iterator pred_begin()
const char * getLinkOnceDirective() const
MCSymbol * getSymbol() const
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0)=0
bool isThreadLocal() const
static void PrintParentLoopComment(raw_ostream &OS, const MachineLoop *Loop, unsigned FunctionNumber)
PrintParentLoopComment - Print comments about parent loops of this one.
virtual void EmitDataRegion(MCDataRegionType Kind)
EmitDataRegion - Note in the output the specified region Kind.
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const
const std::string & getModuleInlineAsm() const
void EmitSLEB128(int64_t Value, const char *Desc=0) const
EmitSLEB128 - emit the specified signed leb128 value.
global_iterator global_end()
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
virtual const TargetInstrInfo * getInstrInfo() const
ArrayType * getType() const
Class for constant integers.
SectionKind getKind() const
virtual void EmitLabel(MCSymbol *Symbol)
uint64_t getTypeAllocSize(Type *Ty) const
void EmitGlobalConstant(const Constant *CV)
Print a general LLVM constant to the .s file.
virtual void EmitInstruction(const MachineInstr *)
EmitInstruction - Targets should implement this to emit instructions.
Keep one copy of function when linking (inline)
virtual const MCSection * getStaticDtorSection(unsigned Priority=65535) const
bool needsRelocationsForDwarfStringPool() const
virtual void EmitXXStructor(const Constant *CV)
static SectionKind getMergeableConst()
bool EmitSpecialLLVMGlobal(const GlobalVariable *GV)
static SectionKind getReadOnlyWithRel()
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0)=0
uint64_t getSizeInBytes() const
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
alias_iterator alias_begin()
BasicBlock * getBasicBlock() const
Value * stripPointerCasts()
Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value...
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
virtual const MCExpr * getPICJumpTableRelocBaseExpr(const MachineFunction *MF, unsigned JTI, MCContext &Ctx) const
MachineFrameInfo * getFrameInfo()
unsigned Log2_32(uint32_t Value)
static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &TD, unsigned InBits=0)
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
const ConstantInt * getCImm() const
MCSymbol * getJTISymbol(unsigned JTI, MCContext &Ctx, bool isLinkerPrivate=false) const
unsigned getOpcode() const
DIScope getContext() const
Class for arbitrary precision integers.
bool hasInitializer() const
virtual void EmitFunctionBodyStart()
StringRef str() const
Explicit conversion to StringRef.
LinkageTypes
An enumeration for the kinds of linkage for global values.
bool hasSingleParameterDotFile() const
StructType * getType() const
bool isPowerOf2_64(uint64_t Value)
const char * getWeakDefDirective() const
APInt bitcastToAPInt() const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
const StringRef getTargetTriple() const
FunctionNumber(functionNumber)
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
bool hasStaticCtorDtorReferenceInStaticMode() const
static const MCBinaryExpr * CreateAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Like LinkerPrivate, but weak.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
bool hasAddressTaken() const
PointerType * getType() const
getType - Global values are always pointers.
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3) const
NamedMDNode * getNamedMetadata(const Twine &Name) const
bool isLandingPad() const
bool hasNoDeadStrip() const
void SetupMachineFunction(MachineFunction &MF)
StringRef getName() const
getName - Get the symbol name.
const uint64_t * getRawData() const
void EmitULEB128(uint64_t Value, const char *Desc=0, unsigned PadTo=0) const
EmitULEB128 - emit the specified unsigned leb128 value.
bool IsCompared
True if the global's address is used in a comparison.
bool isDeclaration() const
float getElementAsFloat(unsigned i) const
DenseMap< GCStrategy *, GCMetadataPrinter * > gcp_map_type
static const MCExpr * lowerConstant(const Constant *CV, AsmPrinter &AP)
bool doFinalization(Module &M)
virtual void getAnalysisUsage(AnalysisUsage &AU) const
static const MCBinaryExpr * CreateShl(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
IMPLICIT_DEF - This is the MachineInstr-level equivalent of undef.
.type _foo, STT_FUNC # aka
virtual const DataLayout * getDataLayout() const
DBG_VALUE - a mapping of the llvm.dbg.value intrinsic.
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
void EmitAlignment(unsigned NumBits, const GlobalValue *GV=0) const
unsigned getNumElements() const
getNumElements - Return the number of elements in the array or vector.
MCSymbol * getMCSymbol() const
float convertToFloat() const
static gcp_map_type & getGCMap(void *&P)
const TargetMachine & getTarget() const
bool isString() const
isString - This method returns true if this is an array of i8.
bool hasPrefixData() const
Keep one copy of named function when linking (weak)
virtual const MCExpr * LowerCustomJumpTableEntry(const MachineJumpTableInfo *, const MachineBasicBlock *, unsigned, MCContext &) const
Rename collisions when linking (static functions).
virtual const TargetRegisterInfo * getRegisterInfo() const
uint64_t getTypeStoreSize(Type *Ty) const
Constant * getPrefixData() const
virtual void EmitFunctionEntryLabel()
JTEntryKind getEntryKind() const
MCSymbol * GetCPISymbol(unsigned CPID) const
GetCPISymbol - Return the symbol for the specified constant pool entry.
const APFloat & getValueAPF() const
CFIMoveType needsCFIMoves()
VectorType * getType() const
Type * getElementType() const
getElementType - Return the element type of the array/vector.
bool hasMCUseLoc() const
hasMCUseLoc - Check whether we should use dwarf's .loc directive.
unsigned getReg() const
getReg - Returns the register number.
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *) const
AsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
const TargetLoweringObjectFile & getObjFileLowering() const
getObjFileLowering - Return information about object file lowering.
virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment)=0
LLVM Value Representation.
bool hasUnnamedAddr() const
mop_iterator operands_begin()
bool hasSubsectionsViaSymbols() const
static const char *const DbgTimerName
void beginInstruction(const MachineInstr *MI)
Process beginning of an instruction.
virtual void EmitCodeAlignment(unsigned ByteAlignment, unsigned MaxBytesToEmit=0)=0
uint64_t getSize() const
getSize - Return the size in bytes of the memory reference.
virtual const MCSection * getStaticCtorSection(unsigned Priority=65535) const
MCSymbol * CurrentFnSymForSize
const char * getName(unsigned RegNo) const
Return the human-readable symbolic target-specific name for the specified physical register...
const std::vector< MachineConstantPoolEntry > & getConstants() const
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size)
static const MCBinaryExpr * CreateMul(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
bool isUndefined() const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
MachineModuleInfo & getMMI() const
MCSymbol * GetTempSymbol(StringRef Name, unsigned ID) const
std::vector< LoopT * >::const_iterator iterator
bool TimePassesIsEnabled
This is the storage for the -time-passes option.
unsigned getNumElements() const
Random access to the elements.
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
bool hasDotTypeDotSizeDirective() const
iterator find(const KeyT &Val)
unsigned getLoopDepth() const
static SectionKind getReadOnly()
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
const char * getCommentString() const
Function object to check whether the first component of a std::pair compares less than the first comp...
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD
bool doesDwarfUseRelocationsAcrossSections() const
MCSymbol * getSymbol(Mangler &M, const GlobalValue *GV) const
void beginFunction(const MachineFunction *MF)
Gather pre-function debug information.
void setSymbolSize(const MCSymbol *Sym, uint64_t Size)
For symbols that have a size designated (e.g. common symbols), this tracks that size.
bool empty() const
empty - Check if the string is empty.
void endModule()
Emit all Dwarf sections that should come after the content.
unsigned getAlignment() const
static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS, AsmPrinter &AP)
mmo_iterator memoperands_begin() const
Access to memory operands of the instruction.
unsigned getNumWords() const
Get the number of words.