LLVM  8.0.1
X86MCAsmInfo.cpp
Go to the documentation of this file.
1 //===-- X86MCAsmInfo.cpp - X86 asm properties -----------------------------===//
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 contains the declarations of the X86MCAsmInfo properties.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "X86MCAsmInfo.h"
15 #include "llvm/ADT/Triple.h"
16 #include "llvm/MC/MCExpr.h"
17 #include "llvm/MC/MCStreamer.h"
19 using namespace llvm;
20 
22  // Note: This numbering has to match the GCC assembler dialects for inline
23  // asm alternatives to work right.
24  ATT = 0, Intel = 1
25 };
26 
28  "x86-asm-syntax", cl::init(ATT), cl::Hidden,
29  cl::desc("Choose style of code to emit from X86 backend:"),
30  cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
31  clEnumValN(Intel, "intel", "Emit Intel-style assembly")));
32 
33 static cl::opt<bool>
34 MarkedJTDataRegions("mark-data-regions", cl::init(true),
35  cl::desc("Mark code section jump table data regions."),
36  cl::Hidden);
37 
38 void X86MCAsmInfoDarwin::anchor() { }
39 
41  bool is64Bit = T.getArch() == Triple::x86_64;
42  if (is64Bit)
44 
46 
47  TextAlignFillValue = 0x90;
48 
49  if (!is64Bit)
50  Data64bitsDirective = nullptr; // we can't emit a 64-bit unit
51 
52  // Use ## as a comment string so that .s files generated by llvm can go
53  // through the GCC preprocessor without causing an error. This is needed
54  // because "clang foo.s" runs the C preprocessor, which is usually reserved
55  // for .S files on other systems. Perhaps this is because the file system
56  // wasn't always case preserving or something.
57  CommentString = "##";
58 
61 
62  // Exceptions handling
64 
65  // old assembler lacks some directives
66  // FIXME: this should really be a check on the assembler characteristics
67  // rather than OS version
68  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
70 
71  // Assume ld64 is new enough that the abs-ified FDE relocs may be used
72  // (actually, must, since otherwise the non-extern relocations we produce
73  // overwhelm ld64's tiny little mind and it fails).
75 
77 }
78 
80  : X86MCAsmInfoDarwin(Triple) {
81 }
82 
83 void X86ELFMCAsmInfo::anchor() { }
84 
86  bool is64Bit = T.getArch() == Triple::x86_64;
87  bool isX32 = T.getEnvironment() == Triple::GNUX32;
88 
89  // For ELF, x86-64 pointer size depends on the ABI.
90  // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
91  // with the x32 ABI, pointer size remains the default 4.
92  CodePointerSize = (is64Bit && !isX32) ? 8 : 4;
93 
94  // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
95  CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
96 
98 
99  TextAlignFillValue = 0x90;
100 
101  // Debug Information
103 
104  // Exceptions handling
106 
107  // Always enable the integrated assembler by default.
108  // Clang also enabled it when the OS is Solaris but that is redundant here.
109  UseIntegratedAssembler = true;
110 }
111 
112 const MCExpr *
114  unsigned Encoding,
115  MCStreamer &Streamer) const {
116  MCContext &Context = Streamer.getContext();
117  const MCExpr *Res =
119  const MCExpr *Four = MCConstantExpr::create(4, Context);
120  return MCBinaryExpr::createAdd(Res, Four, Context);
121 }
122 
123 void X86MCAsmInfoMicrosoft::anchor() { }
124 
126  if (Triple.getArch() == Triple::x86_64) {
127  PrivateGlobalPrefix = ".L";
128  PrivateLabelPrefix = ".L";
129  CodePointerSize = 8;
131  } else {
132  // 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
133  // a place holder that the Windows EHStreamer looks for to suppress CFI
134  // output. In particular, usesWindowsCFI() returns false.
136  }
137 
139 
141 
142  TextAlignFillValue = 0x90;
143 
144  AllowAtInName = true;
145 
146  UseIntegratedAssembler = true;
147 }
148 
149 void X86MCAsmInfoGNUCOFF::anchor() { }
150 
152  assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
153  if (Triple.getArch() == Triple::x86_64) {
154  PrivateGlobalPrefix = ".L";
155  PrivateLabelPrefix = ".L";
156  CodePointerSize = 8;
159  } else {
161  }
162 
164 
165  TextAlignFillValue = 0x90;
166 
167  UseIntegratedAssembler = true;
168 }
unsigned TextAlignFillValue
If non-zero, this is used to fill the executable space created as the result of a alignment directive...
Definition: MCAsmInfo.h:235
LLVMContext & Context
bool UseIntegratedAssembler
Should we use the integrated assembler? The integrated assembler should be enabled by default (by the...
Definition: MCAsmInfo.h:371
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:323
This class represents lattice values for constants.
Definition: AllocatorList.h:24
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:447
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:42
const char * Data64bitsDirective
Definition: MCAsmInfo.h:193
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:310
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:251
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:36
X86MCAsmInfoMicrosoft(const Triple &Triple)
Context object for machine code objects.
Definition: MCContext.h:63
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:290
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:461
AsmWriterFlavorTy
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:567
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:423
Streaming machine code generation interface.
Definition: MCStreamer.h:189
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:643
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:332
X86ELFMCAsmInfo(const Triple &Triple)
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition: MCAsmInfo.h:338
Windows x64, Windows Itanium (IA-64)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:308
bool DwarfFDESymbolsUseAbsDiff
True if DWARF FDE symbol reference relocations should be replaced by an absolute difference.
Definition: MCAsmInfo.h:346
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:618
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition: MCAsmInfo.h:335
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:432
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Windows CE ARM, PowerPC, SH3, SH4.
No exception support.
StringRef PrivateGlobalPrefix
This prefix is used for globals like constant pool entries that are completely private to the ...
Definition: MCAsmInfo.h:128
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:164