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-09-23 13:06:45 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       53119 : MCAsmInfo::MCAsmInfo() {
      33       53119 :   SeparatorString = ";";
      34       53119 :   CommentString = "#";
      35       53119 :   LabelSuffix = ":";
      36       53119 :   PrivateGlobalPrefix = "L";
      37       53119 :   PrivateLabelPrefix = PrivateGlobalPrefix;
      38       53119 :   LinkerPrivateGlobalPrefix = "";
      39       53119 :   InlineAsmStart = "APP";
      40       53119 :   InlineAsmEnd = "NO_APP";
      41       53119 :   Code16Directive = ".code16";
      42       53119 :   Code32Directive = ".code32";
      43       53119 :   Code64Directive = ".code64";
      44       53119 :   ZeroDirective = "\t.zero\t";
      45       53119 :   AsciiDirective = "\t.ascii\t";
      46       53119 :   AscizDirective = "\t.asciz\t";
      47       53119 :   Data8bitsDirective = "\t.byte\t";
      48       53119 :   Data16bitsDirective = "\t.short\t";
      49       53119 :   Data32bitsDirective = "\t.long\t";
      50       53119 :   Data64bitsDirective = "\t.quad\t";
      51       53119 :   GlobalDirective = "\t.globl\t";
      52       53119 :   WeakDirective = "\t.weak\t";
      53       53119 :   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       53119 :   UseIntegratedAssembler = false;
      69       53119 :   PreserveAsmComments = true;
      70       53119 : }
      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        3430 : MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
      80             :                                        unsigned Encoding,
      81             :                                        MCStreamer &Streamer) const {
      82        3430 :   return getExprForFDESymbol(Sym, Encoding, Streamer);
      83             : }
      84             : 
      85             : const MCExpr *
      86      286296 : MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
      87             :                                unsigned Encoding,
      88             :                                MCStreamer &Streamer) const {
      89      286296 :   if (!(Encoding & dwarf::DW_EH_PE_pcrel))
      90       50087 :     return MCSymbolRefExpr::create(Sym, Streamer.getContext());
      91             : 
      92      236209 :   MCContext &Context = Streamer.getContext();
      93             :   const MCExpr *Res = MCSymbolRefExpr::create(Sym, Context);
      94      236209 :   MCSymbol *PCSym = Context.createTempSymbol();
      95      236209 :   Streamer.EmitLabel(PCSym);
      96             :   const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
      97      236209 :   return MCBinaryExpr::createSub(Res, PC, Context);
      98             : }
      99             : 
     100    21564490 : static bool isAcceptableChar(char C) {
     101    28433826 :   return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
     102    21564490 :          (C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
     103             : }
     104             : 
     105     1535623 : bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
     106     1535623 :   if (Name.empty())
     107             :     return false;
     108             : 
     109             :   // If any of the characters in the string is an unacceptable character, force
     110             :   // quotes.
     111    23097226 :   for (char C : Name) {
     112    21564490 :     if (!isAcceptableChar(C))
     113             :       return false;
     114             :   }
     115             : 
     116             :   return true;
     117             : }
     118             : 
     119      150107 : bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
     120             :   // FIXME: Does .section .bss/.data/.text work everywhere??
     121             :   return SectionName == ".text" || SectionName == ".data" ||
     122        1757 :         (SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
     123             : }

Generated by: LCOV version 1.13