LCOV - code coverage report
Current view: top level - lib/MC - MCAsmInfo.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 45 47 95.7 %
Date: 2017-09-14 15:23:50 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             : 
      21             : using namespace llvm;
      22             : 
      23       64178 : MCAsmInfo::MCAsmInfo() {
      24       32089 :   SeparatorString = ";";
      25       32089 :   CommentString = "#";
      26       32089 :   LabelSuffix = ":";
      27       32089 :   PrivateGlobalPrefix = "L";
      28       32089 :   PrivateLabelPrefix = PrivateGlobalPrefix;
      29       32089 :   LinkerPrivateGlobalPrefix = "";
      30       32089 :   InlineAsmStart = "APP";
      31       32089 :   InlineAsmEnd = "NO_APP";
      32       32089 :   Code16Directive = ".code16";
      33       32089 :   Code32Directive = ".code32";
      34       32089 :   Code64Directive = ".code64";
      35       32089 :   ZeroDirective = "\t.zero\t";
      36       32089 :   AsciiDirective = "\t.ascii\t";
      37       32089 :   AscizDirective = "\t.asciz\t";
      38       32089 :   Data8bitsDirective = "\t.byte\t";
      39       32089 :   Data16bitsDirective = "\t.short\t";
      40       32089 :   Data32bitsDirective = "\t.long\t";
      41       32089 :   Data64bitsDirective = "\t.quad\t";
      42       32089 :   GlobalDirective = "\t.globl\t";
      43       32089 :   WeakDirective = "\t.weak\t";
      44             : 
      45             :   // FIXME: Clang's logic should be synced with the logic used to initialize
      46             :   //        this member and the two implementations should be merged.
      47             :   // For reference:
      48             :   // - Solaris always enables the integrated assembler by default
      49             :   //   - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
      50             :   // - Windows always enables the integrated assembler by default
      51             :   //   - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
      52             :   // - MachO targets always enables the integrated assembler by default
      53             :   //   - MCAsmInfoDarwin is handling this case
      54             :   // - Generic_GCC toolchains enable the integrated assembler on a per
      55             :   //   architecture basis.
      56             :   //   - The target subclasses for AArch64, ARM, and X86 handle these cases
      57       32089 :   UseIntegratedAssembler = false;
      58       32089 :   PreserveAsmComments = true;
      59       32089 : }
      60             : 
      61             : MCAsmInfo::~MCAsmInfo() = default;
      62             : 
      63           0 : bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
      64           0 :   return false;
      65             : }
      66             : 
      67             : const MCExpr *
      68         121 : MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
      69             :                                        unsigned Encoding,
      70             :                                        MCStreamer &Streamer) const {
      71         121 :   return getExprForFDESymbol(Sym, Encoding, Streamer);
      72             : }
      73             : 
      74             : const MCExpr *
      75        9399 : MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
      76             :                                unsigned Encoding,
      77             :                                MCStreamer &Streamer) const {
      78        9399 :   if (!(Encoding & dwarf::DW_EH_PE_pcrel))
      79         770 :     return MCSymbolRefExpr::create(Sym, Streamer.getContext());
      80             : 
      81        9014 :   MCContext &Context = Streamer.getContext();
      82        9014 :   const MCExpr *Res = MCSymbolRefExpr::create(Sym, Context);
      83        9014 :   MCSymbol *PCSym = Context.createTempSymbol();
      84        9014 :   Streamer.EmitLabel(PCSym);
      85        9014 :   const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
      86        9014 :   return MCBinaryExpr::createSub(Res, PC, Context);
      87             : }
      88             : 
      89    14733110 : static bool isAcceptableChar(char C) {
      90    19418992 :   return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
      91    17000115 :          (C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
      92             : }
      93             : 
      94     1130820 : bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
      95     1130820 :   if (Name.empty())
      96             :     return false;
      97             : 
      98             :   // If any of the characters in the string is an unacceptable character, force
      99             :   // quotes.
     100    16992389 :   for (char C : Name) {
     101    14733110 :     if (!isAcceptableChar(C))
     102             :       return false;
     103             :   }
     104             : 
     105             :   return true;
     106             : }
     107             : 
     108      113772 : bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
     109             :   // FIXME: Does .section .bss/.data/.text work everywhere??
     110      180024 :   return SectionName == ".text" || SectionName == ".data" ||
     111       66175 :         (SectionName == ".bss" && !usesELFSectionDirectiveForBSS());
     112             : }

Generated by: LCOV version 1.13