Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/MC/MCAsmInfo.cpp
Line
Count
Source (jump to first uncovered line)
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
49.4k
MCAsmInfo::MCAsmInfo() {
24
49.4k
  SeparatorString = ";";
25
49.4k
  CommentString = "#";
26
49.4k
  LabelSuffix = ":";
27
49.4k
  PrivateGlobalPrefix = "L";
28
49.4k
  PrivateLabelPrefix = PrivateGlobalPrefix;
29
49.4k
  LinkerPrivateGlobalPrefix = "";
30
49.4k
  InlineAsmStart = "APP";
31
49.4k
  InlineAsmEnd = "NO_APP";
32
49.4k
  Code16Directive = ".code16";
33
49.4k
  Code32Directive = ".code32";
34
49.4k
  Code64Directive = ".code64";
35
49.4k
  ZeroDirective = "\t.zero\t";
36
49.4k
  AsciiDirective = "\t.ascii\t";
37
49.4k
  AscizDirective = "\t.asciz\t";
38
49.4k
  Data8bitsDirective = "\t.byte\t";
39
49.4k
  Data16bitsDirective = "\t.short\t";
40
49.4k
  Data32bitsDirective = "\t.long\t";
41
49.4k
  Data64bitsDirective = "\t.quad\t";
42
49.4k
  GlobalDirective = "\t.globl\t";
43
49.4k
  WeakDirective = "\t.weak\t";
44
49.4k
45
49.4k
  // FIXME: Clang's logic should be synced with the logic used to initialize
46
49.4k
  //        this member and the two implementations should be merged.
47
49.4k
  // For reference:
48
49.4k
  // - Solaris always enables the integrated assembler by default
49
49.4k
  //   - SparcELFMCAsmInfo and X86ELFMCAsmInfo are handling this case
50
49.4k
  // - Windows always enables the integrated assembler by default
51
49.4k
  //   - MCAsmInfoCOFF is handling this case, should it be MCAsmInfoMicrosoft?
52
49.4k
  // - MachO targets always enables the integrated assembler by default
53
49.4k
  //   - MCAsmInfoDarwin is handling this case
54
49.4k
  // - Generic_GCC toolchains enable the integrated assembler on a per
55
49.4k
  //   architecture basis.
56
49.4k
  //   - The target subclasses for AArch64, ARM, and X86 handle these cases
57
49.4k
  UseIntegratedAssembler = false;
58
49.4k
  PreserveAsmComments = true;
59
49.4k
}
60
61
32.1k
MCAsmInfo::~MCAsmInfo() = default;
62
63
0
bool MCAsmInfo::isSectionAtomizableBySymbols(const MCSection &Section) const {
64
0
  return false;
65
0
}
66
67
const MCExpr *
68
MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym,
69
                                       unsigned Encoding,
70
50
                                       MCStreamer &Streamer) const {
71
50
  return getExprForFDESymbol(Sym, Encoding, Streamer);
72
50
}
73
74
const MCExpr *
75
MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
76
                               unsigned Encoding,
77
11.5k
                               MCStreamer &Streamer) const {
78
11.5k
  if (!(Encoding & dwarf::DW_EH_PE_pcrel))
79
271
    return MCSymbolRefExpr::create(Sym, Streamer.getContext());
80
11.2k
81
11.2k
  MCContext &Context = Streamer.getContext();
82
11.2k
  const MCExpr *Res = MCSymbolRefExpr::create(Sym, Context);
83
11.2k
  MCSymbol *PCSym = Context.createTempSymbol();
84
11.2k
  Streamer.EmitLabel(PCSym);
85
11.2k
  const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
86
11.2k
  return MCBinaryExpr::createSub(Res, PC, Context);
87
11.2k
}
88
89
14.8M
static bool isAcceptableChar(char C) {
90
14.8M
  return (C >= 'a' && 
C <= 'z'9.34M
) ||
(C >= 'A' && 5.49M
C <= 'Z'2.67M
) ||
91
14.8M
         
(C >= '0' && 4.71M
C <= '9'4.32M
) ||
C == '_'2.28M
||
C == '$'394k
||
C == '.'365k
||
C == '@'3.84k
;
92
14.8M
}
93
94
1.13M
bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
95
1.13M
  if (Name.empty())
96
0
    return false;
97
1.13M
98
1.13M
  // If any of the characters in the string is an unacceptable character, force
99
1.13M
  // quotes.
100
1.13M
  
for (char C : Name) 1.13M
{
101
14.8M
    if (!isAcceptableChar(C))
102
2.31k
      return false;
103
1.12M
  }
104
1.12M
105
1.12M
  return true;
106
1.12M
}
107
108
114k
bool MCAsmInfo::shouldOmitSectionDirective(StringRef SectionName) const {
109
114k
  // FIXME: Does .section .bss/.data/.text work everywhere??
110
66.7k
  return SectionName == ".text" || SectionName == ".data" ||
111
65.1k
        
(SectionName == ".bss" && 65.1k
!usesELFSectionDirectiveForBSS()1.64k
);
112
114k
}