Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file contains the declarations of the X86MCAsmInfo properties.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "X86MCAsmInfo.h"
14
#include "llvm/ADT/Triple.h"
15
#include "llvm/MC/MCExpr.h"
16
#include "llvm/MC/MCStreamer.h"
17
#include "llvm/Support/CommandLine.h"
18
using namespace llvm;
19
20
enum AsmWriterFlavorTy {
21
  // Note: This numbering has to match the GCC assembler dialects for inline
22
  // asm alternatives to work right.
23
  ATT = 0, Intel = 1
24
};
25
26
static cl::opt<AsmWriterFlavorTy> AsmWriterFlavor(
27
    "x86-asm-syntax", cl::init(ATT), cl::Hidden,
28
    cl::desc("Choose style of code to emit from X86 backend:"),
29
    cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
30
               clEnumValN(Intel, "intel", "Emit Intel-style assembly")));
31
32
static cl::opt<bool>
33
MarkedJTDataRegions("mark-data-regions", cl::init(true),
34
  cl::desc("Mark code section jump table data regions."),
35
  cl::Hidden);
36
37
0
void X86MCAsmInfoDarwin::anchor() { }
38
39
10.0k
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
40
10.0k
  bool is64Bit = T.getArch() == Triple::x86_64;
41
10.0k
  if (is64Bit)
42
8.47k
    CodePointerSize = CalleeSaveStackSlotSize = 8;
43
10.0k
44
10.0k
  AssemblerDialect = AsmWriterFlavor;
45
10.0k
46
10.0k
  TextAlignFillValue = 0x90;
47
10.0k
48
10.0k
  if (!is64Bit)
49
1.56k
    Data64bitsDirective = nullptr;       // we can't emit a 64-bit unit
50
10.0k
51
10.0k
  // Use ## as a comment string so that .s files generated by llvm can go
52
10.0k
  // through the GCC preprocessor without causing an error.  This is needed
53
10.0k
  // because "clang foo.s" runs the C preprocessor, which is usually reserved
54
10.0k
  // for .S files on other systems.  Perhaps this is because the file system
55
10.0k
  // wasn't always case preserving or something.
56
10.0k
  CommentString = "##";
57
10.0k
58
10.0k
  SupportsDebugInformation = true;
59
10.0k
  UseDataRegionDirectives = MarkedJTDataRegions;
60
10.0k
61
10.0k
  // Exceptions handling
62
10.0k
  ExceptionsType = ExceptionHandling::DwarfCFI;
63
10.0k
64
10.0k
  // old assembler lacks some directives
65
10.0k
  // FIXME: this should really be a check on the assembler characteristics
66
10.0k
  // rather than OS version
67
10.0k
  if (T.isMacOSX() && 
T.isMacOSXVersionLT(10, 6)9.13k
)
68
3.01k
    HasWeakDefCanBeHiddenDirective = false;
69
10.0k
70
10.0k
  // Assume ld64 is new enough that the abs-ified FDE relocs may be used
71
10.0k
  // (actually, must, since otherwise the non-extern relocations we produce
72
10.0k
  // overwhelm ld64's tiny little mind and it fails).
73
10.0k
  DwarfFDESymbolsUseAbsDiff = true;
74
10.0k
75
10.0k
  UseIntegratedAssembler = true;
76
10.0k
}
77
78
X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
79
8.47k
  : X86MCAsmInfoDarwin(Triple) {
80
8.47k
}
81
82
0
void X86ELFMCAsmInfo::anchor() { }
83
84
15.5k
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
85
15.5k
  bool is64Bit = T.getArch() == Triple::x86_64;
86
15.5k
  bool isX32 = T.getEnvironment() == Triple::GNUX32;
87
15.5k
88
15.5k
  // For ELF, x86-64 pointer size depends on the ABI.
89
15.5k
  // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
90
15.5k
  // with the x32 ABI, pointer size remains the default 4.
91
15.5k
  CodePointerSize = (is64Bit && 
!isX3211.4k
) ?
811.4k
:
44.09k
;
92
15.5k
93
15.5k
  // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
94
15.5k
  CalleeSaveStackSlotSize = is64Bit ? 
811.4k
:
44.02k
;
95
15.5k
96
15.5k
  AssemblerDialect = AsmWriterFlavor;
97
15.5k
98
15.5k
  TextAlignFillValue = 0x90;
99
15.5k
100
15.5k
  // Debug Information
101
15.5k
  SupportsDebugInformation = true;
102
15.5k
103
15.5k
  // Exceptions handling
104
15.5k
  ExceptionsType = ExceptionHandling::DwarfCFI;
105
15.5k
106
15.5k
  // Always enable the integrated assembler by default.
107
15.5k
  // Clang also enabled it when the OS is Solaris but that is redundant here.
108
15.5k
  UseIntegratedAssembler = true;
109
15.5k
}
110
111
const MCExpr *
112
X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym,
113
                                                   unsigned Encoding,
114
12
                                                   MCStreamer &Streamer) const {
115
12
  MCContext &Context = Streamer.getContext();
116
12
  const MCExpr *Res =
117
12
    MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context);
118
12
  const MCExpr *Four = MCConstantExpr::create(4, Context);
119
12
  return MCBinaryExpr::createAdd(Res, Four, Context);
120
12
}
121
122
0
void X86MCAsmInfoMicrosoft::anchor() { }
123
124
1.65k
X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) {
125
1.65k
  if (Triple.getArch() == Triple::x86_64) {
126
956
    PrivateGlobalPrefix = ".L";
127
956
    PrivateLabelPrefix = ".L";
128
956
    CodePointerSize = 8;
129
956
    WinEHEncodingType = WinEH::EncodingType::Itanium;
130
956
  } else {
131
697
    // 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
132
697
    // a place holder that the Windows EHStreamer looks for to suppress CFI
133
697
    // output. In particular, usesWindowsCFI() returns false.
134
697
    WinEHEncodingType = WinEH::EncodingType::X86;
135
697
  }
136
1.65k
137
1.65k
  ExceptionsType = ExceptionHandling::WinEH;
138
1.65k
139
1.65k
  AssemblerDialect = AsmWriterFlavor;
140
1.65k
141
1.65k
  TextAlignFillValue = 0x90;
142
1.65k
143
1.65k
  AllowAtInName = true;
144
1.65k
145
1.65k
  UseIntegratedAssembler = true;
146
1.65k
}
147
148
0
void X86MCAsmInfoGNUCOFF::anchor() { }
149
150
315
X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) {
151
315
  assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
152
315
  if (Triple.getArch() == Triple::x86_64) {
153
131
    PrivateGlobalPrefix = ".L";
154
131
    PrivateLabelPrefix = ".L";
155
131
    CodePointerSize = 8;
156
131
    WinEHEncodingType = WinEH::EncodingType::Itanium;
157
131
    ExceptionsType = ExceptionHandling::WinEH;
158
184
  } else {
159
184
    ExceptionsType = ExceptionHandling::DwarfCFI;
160
184
  }
161
315
162
315
  AssemblerDialect = AsmWriterFlavor;
163
315
164
315
  TextAlignFillValue = 0x90;
165
315
166
315
  UseIntegratedAssembler = true;
167
315
}