LCOV - code coverage report
Current view: top level - lib/MC - MCAsmInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 44 46 95.7 %
Date: 2018-10-20 13:21:21 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===- MCAsmInfo.cpp - Asm Info -------------------------------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file defines target asm properties related what form asm statements
      11             : // should take.
      12             : //
      13             : //===----------------------------------------------------------------------===//
      14             : 
      15             : #include "llvm/MC/MCAsmInfo.h"
      16             : #include "llvm/BinaryFormat/Dwarf.h"
      17             : #include "llvm/MC/MCContext.h"
      18             : #include "llvm/MC/MCExpr.h"
      19             : #include "llvm/MC/MCStreamer.h"
      20             : #include "llvm/Support/CommandLine.h"
      21             : 
      22             : using namespace llvm;
      23             : 
      24             : enum DefaultOnOff { Default, Enable, Disable };
      25             : static cl::opt<DefaultOnOff> DwarfExtendedLoc(
      26             :     "dwarf-extended-loc", cl::Hidden,
      27             :     cl::desc("Disable emission of the extended flags in .loc directives."),
      28             :     cl::values(clEnumVal(Default, "Default for platform"),
      29             :                clEnumVal(Enable, "Enabled"), clEnumVal(Disable, "Disabled")),
      30             :     cl::init(Default));
      31             : 
      32       52316 : MCAsmInfo::MCAsmInfo() {
      33       52316 :   SeparatorString = ";";
      34       52316 :   CommentString = "#";
      35       52316 :   LabelSuffix = ":";
      36       52316 :   PrivateGlobalPrefix = "L";
      37       52316 :   PrivateLabelPrefix = PrivateGlobalPrefix;
      38       52316 :   LinkerPrivateGlobalPrefix = "";
      39       52316 :   InlineAsmStart = "APP";
      40       52316 :   InlineAsmEnd = "NO_APP";
      41       52316 :   Code16Directive = ".code16";
      42       52316 :   Code32Directive = ".code32";
      43       52316 :   Code64Directive = ".code64";
      44       52316 :   ZeroDirective = "\t.zero\t";
      45       52316 :   AsciiDirective = "\t.ascii\t";
      46       52316 :   AscizDirective = "\t.asciz\t";
      47       52316 :   Data8bitsDirective = "\t.byte\t";
      48       52316 :   Data16bitsDirective = "\t.short\t";
      49       52316 :   Data32bitsDirective = "\t.long\t";
      50       52316 :   Data64bitsDirective = "\t.quad\t";
      51       52316 :   GlobalDirective = "\t.globl\t";
      52       52316 :   WeakDirective = "\t.weak\t";
      53       52316 :   if (DwarfExtendedLoc != Default)
      54           2 :     SupportsExtendedDwarfLocDirective = DwarfExtendedLoc == Enable;
      55             : 
      56             :   // FIXME: Clang's logic should be synced with the logic used to initialize
      57             :   //        this member and the two implementations should be merged.
      58             :   // For reference:
      59             :   // - Solaris always enables the integrated assembler by default
      60             :   //   - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
      61             :   // - Windows always enables the integrated assembler by default
      62             :   //   - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
      63             :   // - MachO targets always enables the integrated assembler by default
      64             :   //   - MCAsmInfoDarwin is handling this case
      65             :   // - Generic_GCC toolchains enable the integrated assembler on a per
      66             :   //   architecture basis.
      67             :   //   - The target subclasses for AArch64, ARM, and X86 handle these cases
      68       52316 :   UseIntegratedAssembler = false;
      69       52316 :   PreserveAsmComments = true;
      70       52316 : }
      71             : 
      72             : MCAsmInfo::~MCAsmInfo() = default;
      73             : 
      74           0 : bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
      75           0 :   return false;
      76             : }
      77             : 
      78             : const MCExpr *
      79        3053 : MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
      80             :                                        unsigned Encoding,
      81             :                                        MCStreamer &Streamer) const {
      82        3053 :   return getExprForFDESymbol(Sym, Encoding, Streamer);
      83             : }
      84             : 
      85             : const MCExpr *
      86      257594 : MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
      87             :                                unsigned Encoding,
      88             :                                MCStreamer &Streamer) const {
      89      257594 :   if (!(Encoding & dwarf::DW_EH_PE_pcrel))
      90       46774 :     return MCSymbolRefExpr::create(Sym, Streamer.getContext());
      91             : 
      92      210820 :   MCContext &Context = Streamer.getContext();
      93             :   const MCExpr *Res = MCSymbolRefExpr::create(Sym, Context);
      94      210820 :   MCSymbol *PCSym = Context.createTempSymbol();
      95      210820 :   Streamer.EmitLabel(PCSym);
      96             :   const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
      97      210820 :   return MCBinaryExpr::createSub(Res, PC, Context);
      98             : }
      99             : 
     100    21817366 : static bool isAcceptableChar(char C) {
     101    28772269 :   return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
     102    21817366 :          (C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
     103             : }
     104             : 
     105     1556628 : bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
     106     1556628 :   if (Name.empty())
     107             :     return false;
     108             : 
     109             :   // If any of the characters in the string is an unacceptable character, force
     110             :   // quotes.
     111    23371105 :   for (char C : Name) {
     112    21817366 :     if (!isAcceptableChar(C))
     113             :       return false;
     114             :   }
     115             : 
     116             :   return true;
     117             : }
     118             : 
     119      152095 : bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
     120             :   // FIXME: Does .section .bss/.data/.text work everywhere??
     121             :   return SectionName == ".text" || SectionName == ".data" ||
     122        1777 :         (SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
     123             : }

Generated by: LCOV version 1.13