LLVM 24.0.0git
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 "X86MCOptions.h"
15#include "llvm/ADT/Enum.h"
16#include "llvm/MC/MCExpr.h"
17#include "llvm/MC/MCStreamer.h"
19using namespace llvm;
20
22 {{"ABS8"}, X86::S_ABS8},
23 {{"DTPOFF"}, X86::S_DTPOFF},
24 {{"DTPREL"}, X86::S_DTPREL},
25 {{"GOT"}, X86::S_GOT},
26 {{"GOTENT"}, X86::S_GOTENT},
27 {{"GOTNTPOFF"}, X86::S_GOTNTPOFF},
28 {{"GOTOFF"}, X86::S_GOTOFF},
29 {{"GOTPCREL"}, X86::S_GOTPCREL},
30 {{"GOTPCREL_NORELAX"}, X86::S_GOTPCREL_NORELAX},
31 {{"GOTREL"}, X86::S_GOTREL},
32 {{"GOTTPOFF"}, X86::S_GOTTPOFF},
33 {{"INDNTPOFF"}, X86::S_INDNTPOFF},
35 {{"NTPOFF"}, X86::S_NTPOFF},
36 {{"PCREL"}, X86::S_PCREL},
37 {{"PLT"}, X86::S_PLT},
38 {{"PLTOFF"}, X86::S_PLTOFF},
39 {{"SECREL32"}, X86::S_COFF_SECREL},
40 {{"SIZE"}, X86::S_SIZE},
41 {{"tlscall"}, X86::S_TLSCALL},
42 {{"tlsdesc"}, X86::S_TLSDESC},
43 {{"TLSGD"}, X86::S_TLSGD},
44 {{"TLSLD"}, X86::S_TLSLD},
45 {{"TLSLDM"}, X86::S_TLSLDM},
46 {{"TLVP"}, X86::S_TLVP},
47 {{"TLVPPAGE"}, X86::S_TLVPPAGE},
48 {{"TLVPPAGEOFF"}, X86::S_TLVPPAGEOFF},
49 {{"TPOFF"}, X86::S_TPOFF},
50};
52
56 bool is64Bit = T.isX86_64();
57 if (is64Bit)
59
61
62 if (!is64Bit)
63 Data64bitsDirective = nullptr; // we can't emit a 64-bit unit
64
65 // Use ## as a comment string so that .s files generated by llvm can go
66 // through the GCC preprocessor without causing an error. This is needed
67 // because "clang foo.s" runs the C preprocessor, which is usually reserved
68 // for .S files on other systems. Perhaps this is because the file system
69 // wasn't always case preserving or something.
70 CommentString = "##";
71
74
75 // old assembler lacks some directives
76 // FIXME: this should really be a check on the assembler characteristics
77 // rather than OS version
78 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
80
81 // Assume ld64 is new enough that the abs-ified FDE relocs may be used
82 // (actually, must, since otherwise the non-extern relocations we produce
83 // overwhelm ld64's tiny little mind and it fails).
85
87}
88
95
99 bool is64Bit = T.isX86_64();
100 bool isX32 = T.isX32();
101
102 // For ELF, x86-64 pointer size depends on the ABI.
103 // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
104 // with the x32 ABI, pointer size remains the default 4.
105 CodePointerSize = (is64Bit && !isX32) ? 8 : 4;
106
107 // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
109
111
112 // Debug Information
114
116
117 // .bss is supported without .section.
118 SectionDirectives.insert(".bss");
119}
120
124 if (Triple.isX86_64()) {
125 InternalSymbolPrefix = ".L";
126 CodePointerSize = 8;
127 WinEHEncodingType = WinEH::EncodingType::Itanium;
128 } else {
129 // 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just
130 // a place holder that the Windows EHStreamer looks for to suppress CFI
131 // output. In particular, usesWindowsCFI() returns false.
132 WinEHEncodingType = WinEH::EncodingType::X86;
133 }
134
136
137 AllowAtInName = true;
138
140}
141
153
158 "Windows and UEFI are the only supported COFF targets");
159 if (Triple.isX86_64()) {
161 CodePointerSize = 8;
163 }
164
166
167 AllowAtInName = true;
168
170}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
constexpr EnumStringDef< MCAsmInfo::AtSpecifierKind > AtSpecifierDefs[]
constexpr auto atSpecifiers
#define BUILD_ENUM_STRINGS(Tab)
Definition Enum.h:120
static LVOptions Options
Definition LVOptions.cpp:25
#define T
static bool is64Bit(const char *name)
MCAsmInfoDarwin(const MCTargetOptions &Options)
MCAsmInfoELF(const Triple &TT, const MCTargetOptions &Options)
MCAsmInfoGNUCOFF(const MCTargetOptions &Options)
MCAsmInfoMicrosoft(const MCTargetOptions &Options)
StringRef InternalSymbolPrefix
For internal use by compiler and assembler, not meant to be visible externally.
Definition MCAsmInfo.h:169
bool AllowAdditionalComments
This indicates whether to allow additional "comment strings" to be lexed as a comment.
Definition MCAsmInfo.h:152
bool AllowQuestionAtStartOfIdentifier
This is true if the assembler allows the "?" character at the start of of a string to be lexed as an ...
Definition MCAsmInfo.h:194
const char * Data64bitsDirective
Definition MCAsmInfo.h:264
bool DollarIsPC
The '$' token, when not referencing an identifier or constant, refers to the current PC.
Definition MCAsmInfo.h:136
bool AllowDollarAtStartOfIdentifier
This is true if the assembler allows the "$" character at the start of of a string to be lexed as an ...
Definition MCAsmInfo.h:201
bool DwarfFDESymbolsUseAbsDiff
True if DWARF FDE symbol reference relocations should be replaced by an absolute difference.
Definition MCAsmInfo.h:397
bool AllowAtAtStartOfIdentifier
This is true if the assembler allows the "@" character at the start of a string to be lexed as an Asm...
Definition MCAsmInfo.h:208
WinEH::EncodingType WinEHEncodingType
Windows exception handling data (.pdata) encoding. Defaults to Invalid.
Definition MCAsmInfo.h:380
SmallDenseSet< StringRef, 8 > SectionDirectives
Sections whose name also is supported as a directive without an explicit ".section" directive.
Definition MCAsmInfo.h:475
bool AllowAtInName
This is true if the assembler allows @ characters in symbol names.
Definition MCAsmInfo.h:187
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:345
int DwarfPersonalitySymbolsAbsOff
Non-zero if DWARF personality symbol reference relocations should have a constant addend instead of b...
Definition MCAsmInfo.h:393
bool SupportsDebugInformation
True if target supports emission of debugging information.
Definition MCAsmInfo.h:372
unsigned AssemblerDialect
Which dialect of an assembler variant to use. Defaults to 0.
Definition MCAsmInfo.h:183
const char * SeparatorString
This string, if specified, is used to separate instructions from each other when on the same line.
Definition MCAsmInfo.h:140
void initializeAtSpecifiers(EnumStrings< AtSpecifierKind, 1 >)
bool UseDataRegionDirectives
This is true if data region markers should be printed as ".data_region/.end_data_region" directives.
Definition MCAsmInfo.h:217
uint16_t DwarfPersonalitySymbolSpec
The optional specifier to use for the personality symbol references.
Definition MCAsmInfo.h:388
unsigned CodePointerSize
Code pointer size in bytes. Default is 4.
Definition MCAsmInfo.h:88
unsigned CalleeSaveStackSlotSize
Size of the stack slot reserved for callee-saved registers, in bytes.
Definition MCAsmInfo.h:92
StringRef CommentString
This indicates the comment string used by the assembler.
Definition MCAsmInfo.h:144
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
bool isX86_64() const
Tests whether the target is x86 (64-bit).
Definition Triple.h:1211
bool isOSWindowsOrUEFI() const
Tests whether the OS is Windows or UEFI.
Definition Triple.h:786
X86ELFMCAsmInfo(const Triple &Triple, const MCTargetOptions &Options)
X86MCAsmInfoDarwin(const Triple &Triple, const MCTargetOptions &Options)
X86MCAsmInfoGNUCOFF(const Triple &Triple, const MCTargetOptions &Options)
X86MCAsmInfoMicrosoftMASM(const Triple &Triple, const MCTargetOptions &Options)
X86MCAsmInfoMicrosoft(const Triple &Triple, const MCTargetOptions &Options)
@ Itanium
Windows CE ARM, PowerPC, SH3, SH4.
Definition MCAsmInfo.h:52
const X86MCOptions & getCLOpts(const MCTargetOptions &Options)
@ S_GOTPCREL_NORELAX
This is an optimization pass for GlobalISel generic memory operations.
Compile-time data representation of enum entries.
Definition Enum.h:47
X86_64MCAsmInfoDarwin(const Triple &Triple, const MCTargetOptions &Options)