LLVM  4.0.0
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/MCContext.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/MC/MCSectionELF.h"
19 #include "llvm/MC/MCStreamer.h"
21 #include "llvm/Support/ELF.h"
22 using namespace llvm;
23 
25  // Note: This numbering has to match the GCC assembler dialects for inline
26  // asm alternatives to work right.
27  ATT = 0, Intel = 1
28 };
29 
31 AsmWriterFlavor("x86-asm-syntax", cl::init(ATT),
32  cl::desc("Choose style of code to emit from X86 backend:"),
33  cl::values(clEnumValN(ATT, "att", "Emit AT&T-style assembly"),
34  clEnumValN(Intel, "intel", "Emit Intel-style assembly")));
35 
36 static cl::opt<bool>
37 MarkedJTDataRegions("mark-data-regions", cl::init(true),
38  cl::desc("Mark code section jump table data regions."),
39  cl::Hidden);
40 
41 void X86MCAsmInfoDarwin::anchor() { }
42 
44  bool is64Bit = T.getArch() == Triple::x86_64;
45  if (is64Bit)
47 
49 
50  TextAlignFillValue = 0x90;
51 
52  if (!is64Bit)
53  Data64bitsDirective = nullptr; // we can't emit a 64-bit unit
54 
55  // Use ## as a comment string so that .s files generated by llvm can go
56  // through the GCC preprocessor without causing an error. This is needed
57  // because "clang foo.s" runs the C preprocessor, which is usually reserved
58  // for .S files on other systems. Perhaps this is because the file system
59  // wasn't always case preserving or something.
60  CommentString = "##";
61 
64 
65  // Exceptions handling
67 
68  // old assembler lacks some directives
69  // FIXME: this should really be a check on the assembler characteristics
70  // rather than OS version
71  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
73 
74  // Assume ld64 is new enough that the abs-ified FDE relocs may be used
75  // (actually, must, since otherwise the non-extern relocations we produce
76  // overwhelm ld64's tiny little mind and it fails).
78 
80 }
81 
83  : X86MCAsmInfoDarwin(Triple) {
84 }
85 
86 void X86ELFMCAsmInfo::anchor() { }
87 
89  bool is64Bit = T.getArch() == Triple::x86_64;
90  bool isX32 = T.getEnvironment() == Triple::GNUX32;
91 
92  // For ELF, x86-64 pointer size depends on the ABI.
93  // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
94  // with the x32 ABI, pointer size remains the default 4.
95  PointerSize = (is64Bit && !isX32) ? 8 : 4;
96 
97  // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
98  CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
99 
101 
102  TextAlignFillValue = 0x90;
103 
104  // Debug Information
106 
107  // Exceptions handling
109 
110  // Always enable the integrated assembler by default.
111  // Clang also enabled it when the OS is Solaris but that is redundant here.
112  UseIntegratedAssembler = true;
113 }
114 
115 const MCExpr *
117  unsigned Encoding,
118  MCStreamer &Streamer) const {
119  MCContext &Context = Streamer.getContext();
120  const MCExpr *Res =
122  const MCExpr *Four = MCConstantExpr::create(4, Context);
123  return MCBinaryExpr::createAdd(Res, Four, Context);
124 }
125 
126 void X86MCAsmInfoMicrosoft::anchor() { }
127 
129  if (Triple.getArch() == Triple::x86_64) {
130  PrivateGlobalPrefix = ".L";
131  PrivateLabelPrefix = ".L";
132  PointerSize = 8;
134  } else {
135  // 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
136  // a place holder that the Windows EHStreamer looks for to suppress CFI
137  // output. In particular, usesWindowsCFI() returns false.
139  }
140 
142 
144 
145  TextAlignFillValue = 0x90;
146 
147  AllowAtInName = true;
148 
149  UseIntegratedAssembler = true;
150 }
151 
152 void X86MCAsmInfoGNUCOFF::anchor() { }
153 
155  assert(Triple.isOSWindows() && "Windows is the only supported COFF target");
156  if (Triple.getArch() == Triple::x86_64) {
157  PrivateGlobalPrefix = ".L";
158  PrivateLabelPrefix = ".L";
159  PointerSize = 8;
162  } else {
164  }
165 
167 
168  TextAlignFillValue = 0x90;
169 
170  UseIntegratedAssembler = true;
171 }
unsigned TextAlignFillValue
If non-zero, this is used to fill the executable space created as the result of a alignment directive...
Definition: MCAsmInfo.h:226
LLVMContext & Context
bool UseIntegratedAssembler
Should we use the integrated assembler? The integrated assembler should be enabled by default (by the...
Definition: MCAsmInfo.h:358
StringRef PrivateLabelPrefix
This prefix is used for labels for basic blocks.
Definition: MCAsmInfo.h:124
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:298
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
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:412
const char * Data64bitsDirective
Definition: MCAsmInfo.h:184
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
Definition: MCAsmInfo.h:68
unsigned AssemblerDialect
Which dialect of an assembler variant to use. Defaults to 0.
Definition: MCAsmInfo.h:145
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:301
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)
bool isOSWindows() const
Tests whether the OS is Windows.
Definition: Triple.h:540
X86_64MCAsmInfoDarwin(const Triple &Triple)
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:427
StringRef CommentString
This indicates the comment character used by the assembler.
Definition: MCAsmInfo.h:106
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
X86MCAsmInfoMicrosoft(const Triple &Triple)
MCContext & getContext() const
Definition: MCStreamer.h:221
Context object for machine code objects.
Definition: MCContext.h:51
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Definition: Triple.h:270
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition: MCExpr.h:429
AsmWriterFlavorTy
ValuesClass values(OptsTy...Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:615
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:395
Streaming machine code generation interface.
Definition: MCStreamer.h:161
unsigned PointerSize
Pointer size in bytes. Default is 4.
Definition: MCAsmInfo.h:64
static bool is64Bit(const char *name)
bool AllowAtInName
This is true if the assembler allows @ characters in symbol names.
Definition: MCAsmInfo.h:149
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition: MCAsmInfo.h:323
X86ELFMCAsmInfo(const Triple &Triple)
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition: MCAsmInfo.h:329
Windows x64, Windows Itanium (IA-64)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
static cl::opt< AsmWriterFlavorTy > AsmWriterFlavor("x86-asm-syntax", cl::init(ATT), 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")))
bool DwarfFDESymbolsUseAbsDiff
True if DWARF FDE symbol reference relocations should be replaced by an absolute difference.
Definition: MCAsmInfo.h:337
X86MCAsmInfoDarwin(const Triple &Triple)
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:590
ExceptionHandling ExceptionsType
Exception handling format for the target. Defaults to None.
Definition: MCAsmInfo.h:326
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives...
Definition: MCAsmInfo.h:158
X86MCAsmInfoGNUCOFF(const Triple &Triple)
EnvironmentType getEnvironment() const
getEnvironment - Get the parsed environment type of this triple.
Definition: Triple.h:288
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:120
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
Definition: MCExpr.cpp:149