LLVM API Documentation
00001 //===-- MCAsmInfo.cpp - Asm Info -------------------------------------------==// 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 file defines target asm properties related what form asm statements 00011 // should take. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "llvm/MC/MCAsmInfo.h" 00016 #include "llvm/MC/MCContext.h" 00017 #include "llvm/MC/MCExpr.h" 00018 #include "llvm/MC/MCStreamer.h" 00019 #include "llvm/Support/DataTypes.h" 00020 #include "llvm/Support/Dwarf.h" 00021 #include <cctype> 00022 #include <cstring> 00023 using namespace llvm; 00024 00025 MCAsmInfo::MCAsmInfo() { 00026 PointerSize = 4; 00027 CalleeSaveStackSlotSize = 4; 00028 00029 IsLittleEndian = true; 00030 StackGrowsUp = false; 00031 HasSubsectionsViaSymbols = false; 00032 HasMachoZeroFillDirective = false; 00033 HasMachoTBSSDirective = false; 00034 HasStaticCtorDtorReferenceInStaticMode = false; 00035 LinkerRequiresNonEmptyDwarfLines = false; 00036 MaxInstLength = 4; 00037 MinInstAlignment = 1; 00038 DollarIsPC = false; 00039 SeparatorString = ";"; 00040 CommentString = "#"; 00041 LabelSuffix = ":"; 00042 UseAssignmentForEHBegin = false; 00043 PrivateGlobalPrefix = "L"; 00044 LinkerPrivateGlobalPrefix = ""; 00045 InlineAsmStart = "APP"; 00046 InlineAsmEnd = "NO_APP"; 00047 Code16Directive = ".code16"; 00048 Code32Directive = ".code32"; 00049 Code64Directive = ".code64"; 00050 AssemblerDialect = 0; 00051 AllowAtInName = false; 00052 UseDataRegionDirectives = false; 00053 ZeroDirective = "\t.zero\t"; 00054 AsciiDirective = "\t.ascii\t"; 00055 AscizDirective = "\t.asciz\t"; 00056 Data8bitsDirective = "\t.byte\t"; 00057 Data16bitsDirective = "\t.short\t"; 00058 Data32bitsDirective = "\t.long\t"; 00059 Data64bitsDirective = "\t.quad\t"; 00060 SunStyleELFSectionSwitchSyntax = false; 00061 UsesELFSectionDirectiveForBSS = false; 00062 AlignmentIsInBytes = true; 00063 TextAlignFillValue = 0; 00064 GPRel64Directive = nullptr; 00065 GPRel32Directive = nullptr; 00066 GlobalDirective = "\t.globl\t"; 00067 HasSetDirective = true; 00068 HasAggressiveSymbolFolding = true; 00069 COMMDirectiveAlignmentIsInBytes = true; 00070 LCOMMDirectiveAlignmentType = LCOMM::NoAlignment; 00071 HasDotTypeDotSizeDirective = true; 00072 HasSingleParameterDotFile = true; 00073 HasIdentDirective = false; 00074 HasNoDeadStrip = false; 00075 WeakRefDirective = nullptr; 00076 HasWeakDefDirective = false; 00077 HasWeakDefCanBeHiddenDirective = false; 00078 HasLinkOnceDirective = false; 00079 HiddenVisibilityAttr = MCSA_Hidden; 00080 HiddenDeclarationVisibilityAttr = MCSA_Hidden; 00081 ProtectedVisibilityAttr = MCSA_Protected; 00082 SupportsDebugInformation = false; 00083 ExceptionsType = ExceptionHandling::None; 00084 WinEHEncodingType = WinEH::EncodingType::Invalid; 00085 DwarfUsesRelocationsAcrossSections = true; 00086 DwarfFDESymbolsUseAbsDiff = false; 00087 DwarfRegNumForCFI = false; 00088 NeedsDwarfSectionOffsetDirective = false; 00089 UseParensForSymbolVariant = false; 00090 00091 // FIXME: Clang's logic should be synced with the logic used to initialize 00092 // this member and the two implementations should be merged. 00093 // For reference: 00094 // - Solaris always enables the integrated assembler by default 00095 // - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case 00096 // - Windows always enables the integrated assembler by default 00097 // - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft? 00098 // - MachO targets always enables the integrated assembler by default 00099 // - MCAsmInfoDarwin is handling this case 00100 // - Generic_GCC toolchains enable the integrated assembler on a per 00101 // architecture basis. 00102 // - The target subclasses for AArch64, ARM, and X86 handle these cases 00103 UseIntegratedAssembler = false; 00104 00105 CompressDebugSections = false; 00106 } 00107 00108 MCAsmInfo::~MCAsmInfo() { 00109 } 00110 00111 const MCExpr * 00112 MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, 00113 unsigned Encoding, 00114 MCStreamer &Streamer) const { 00115 return getExprForFDESymbol(Sym, Encoding, Streamer); 00116 } 00117 00118 const MCExpr * 00119 MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, 00120 unsigned Encoding, 00121 MCStreamer &Streamer) const { 00122 if (!(Encoding & dwarf::DW_EH_PE_pcrel)) 00123 return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); 00124 00125 MCContext &Context = Streamer.getContext(); 00126 const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); 00127 MCSymbol *PCSym = Context.CreateTempSymbol(); 00128 Streamer.EmitLabel(PCSym); 00129 const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context); 00130 return MCBinaryExpr::CreateSub(Res, PC, Context); 00131 }