LLVM  10.0.0svn
X86MCAsmInfo.cpp
Go to the documentation of this file.
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"
18 using namespace llvm;
19 
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 
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 void X86MCAsmInfoDarwin::anchor() { }
38 
40  bool is64Bit = T.getArch() == Triple::x86_64;
41  if (is64Bit)
43 
45 
46  TextAlignFillValue = 0x90;
47 
48  if (!is64Bit)
49  Data64bitsDirective = nullptr; // we can't emit a 64-bit unit
50 
51  // Use ## as a comment string so that .s files generated by llvm can go
52  // through the GCC preprocessor without causing an error. This is needed
53  // because "clang foo.s" runs the C preprocessor, which is usually reserved
54  // for .S files on other systems. Perhaps this is because the file system
55  // wasn't always case preserving or something.
56  CommentString = "##";
57 
60 
61  // Exceptions handling
63 
64  // old assembler lacks some directives
65  // FIXME: this should really be a check on the assembler characteristics
66  // rather than OS version
67  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
69 
70  // Assume ld64 is new enough that the abs-ified FDE relocs may be used
71  // (actually, must, since otherwise the non-extern relocations we produce
72  // overwhelm ld64's tiny little mind and it fails).
74 
76 }
77 
79  : X86MCAsmInfoDarwin(Triple) {
80 }
81 
82 void X86ELFMCAsmInfo::anchor() { }
83 
85  bool is64Bit = T.getArch() == Triple::x86_64;
86  bool isX32 = T.getEnvironment() == Triple::GNUX32;
87 
88  // For ELF, x86-64 pointer size depends on the ABI.
89  // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
90  // with the x32 ABI, pointer size remains the default 4.
91  CodePointerSize = (is64Bit && !isX32) ? 8 : 4;
92 
93  // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
94  CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
95 
97 
98  TextAlignFillValue = 0x90;
99 
100  // Debug Information
102 
103  // Exceptions handling
105 
106  // Always enable the integrated assembler by default.
107  // Clang also enabled it when the OS is Solaris but that is redundant here.
108  UseIntegratedAssembler = true;
109 }
110 
111 const MCExpr *
113  unsigned Encoding,
114  MCStreamer &Streamer) const {
115  MCContext &Context = Streamer.getContext();
116  const MCExpr *Res =
118  const MCExpr *Four = MCConstantExpr::create(4, Context);
119  return MCBinaryExpr::createAdd(Res, Four, Context);
120 }
121 
122 void X86MCAsmInfoMicrosoft::anchor() { }
123 
125  if (Triple.getArch() == Triple::x86_64) {
126  PrivateGlobalPrefix = ".L";
127  PrivateLabelPrefix = ".L";
128  CodePointerSize = 8;
130  } else {
131  // 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
132  // a place holder that the Windows EHStreamer looks for to suppress CFI
133  // output. In particular, usesWindowsCFI() returns false.
135  }
136 
138 
140 
141  TextAlignFillValue = 0x90;
142 
143  AllowAtInName = true;
144 
145  UseIntegratedAssembler = true;
146 }
147 
148 void X86MCAsmInfoGNUCOFF::anchor() { }
149 
151  assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
152  if (Triple.getArch() == Triple::x86_64) {
153  PrivateGlobalPrefix = ".L";
154  PrivateLabelPrefix = ".L";
155  CodePointerSize = 8;
158  } else {
160  }
161 
163 
164  TextAlignFillValue = 0x90;
165 
166  AllowAtInName = true;
167 
168  UseIntegratedAssembler = true;
169 }
unsigned TextAlignFillValue
If non-zero, this is used to fill the executable space created as the result of a alignment directive...
Definition: MCAsmInfo.h:239
LLVMContext & Context
bool UseIntegratedAssembler
Should we use the integrated assembler? The integrated assembler should be enabled by default (by the...
Definition: MCAsmInfo.h:379
StringRef PrivateLabelPrefix
This prefix is used for labels for basic blocks.
Definition: MCAsmInfo.h:132
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:329
This class represents lattice values for constants.
Definition: AllocatorList.h:23
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:453
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
const char * Data64bitsDirective
Definition: MCAsmInfo.h:197
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
Definition: MCAsmInfo.h:67
unsigned AssemblerDialect
Which dialect of an assembler variant to use. Defaults to 0.
Definition: MCAsmInfo.h:153
bool HasWeakDefCanBeHiddenDirective
True if we have a directive to declare a global as being a weak defined symbol that can be hidden (un...
Definition: MCAsmInfo.h:314
const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding, MCStreamer &Streamer) const override
static cl::opt< bool > MarkedJTDataRegions("mark-data-regions", cl::init(true), cl::desc("Mark code section jump table data regions."), cl::Hidden)
static cl::opt< AsmWriterFlavorTy > AsmWriterFlavor("x86-asm-syntax", cl::init(ATT), cl::Hidden, cl::desc("Choose style of code to emit from X86 backend:"), cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"), clEnumValN(Intel, "intel", "Emit Intel-style assembly")))
X86_64MCAsmInfoDarwin(const Triple &Triple)
MCContext & getContext() const
Definition: MCStreamer.h:252
StringRef CommentString
This indicates the comment character used by the assembler.
Definition: MCAsmInfo.h:114
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
X86MCAsmInfoMicrosoft(const Triple &Triple)
Context object for machine code objects.
Definition: MCContext.h:65
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:296
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:467
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
Definition: MCExpr.cpp:169
AsmWriterFlavorTy
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:538
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
Streaming machine code generation interface.
Definition: MCStreamer.h:190
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:652
static bool is64Bit(const char *name)
bool AllowAtInName
This is true if the assembler allows @ characters in symbol names.
Definition: MCAsmInfo.h:157
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition: MCAsmInfo.h:340
X86ELFMCAsmInfo(const Triple &Triple)
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition: MCAsmInfo.h:346
Windows x64, Windows Itanium (IA-64)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:314
bool DwarfFDESymbolsUseAbsDiff
True if DWARF FDE symbol reference relocations should be replaced by an absolute difference.
Definition: MCAsmInfo.h:354
unsigned CodePointerSize
Code pointer size in bytes. Default is 4.
Definition: MCAsmInfo.h:63
X86MCAsmInfoDarwin(const Triple &Triple)
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:627
Windows Exception Handling.
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition: MCAsmInfo.h:343
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives...
Definition: MCAsmInfo.h:166
X86MCAsmInfoGNUCOFF(const Triple &Triple)
bool isMacOSXVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isMacOSXVersionLT - Comparison function for checking OS X version compatibility, which handles suppor...
Definition: Triple.h:438
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Windows CE ARM, PowerPC, SH3, SH4.
DWARF-like instruction based exceptions.
StringRef PrivateGlobalPrefix
This prefix is used for globals like constant pool entries that are completely private to the ...
Definition: MCAsmInfo.h:128