/src/keystone/llvm/lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp
Line | Count | Source (jump to first uncovered line) |
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" |
20 | | #include "llvm/Support/ELF.h" |
21 | | using namespace llvm_ks; |
22 | | |
23 | | //#include <iostream> |
24 | | enum AsmWriterFlavorTy { |
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 | | |
30 | | static AsmWriterFlavorTy AsmWriterFlavor = Intel; // ATT |
31 | | |
32 | | static bool MarkedJTDataRegions = false; |
33 | | |
34 | 0 | X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) { |
35 | 0 | bool is64Bit = T.getArch() == Triple::x86_64; |
36 | 0 | if (is64Bit) |
37 | 0 | PointerSize = CalleeSaveStackSlotSize = 8; |
38 | |
|
39 | 0 | AssemblerDialect = AsmWriterFlavor; |
40 | |
|
41 | 0 | TextAlignFillValue = 0x90; |
42 | |
|
43 | 0 | if (!is64Bit) |
44 | 0 | Data64bitsDirective = nullptr; // we can't emit a 64-bit unit |
45 | | |
46 | | // Use ## as a comment string so that .s files generated by llvm can go |
47 | | // through the GCC preprocessor without causing an error. This is needed |
48 | | // because "clang foo.s" runs the C preprocessor, which is usually reserved |
49 | | // for .S files on other systems. Perhaps this is because the file system |
50 | | // wasn't always case preserving or something. |
51 | 0 | CommentString = "##"; |
52 | |
|
53 | 0 | SupportsDebugInformation = true; |
54 | 0 | UseDataRegionDirectives = MarkedJTDataRegions; |
55 | | |
56 | | // Exceptions handling |
57 | 0 | ExceptionsType = ExceptionHandling::DwarfCFI; |
58 | | |
59 | | // old assembler lacks some directives |
60 | | // FIXME: this should really be a check on the assembler characteristics |
61 | | // rather than OS version |
62 | 0 | if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6)) |
63 | 0 | HasWeakDefCanBeHiddenDirective = false; |
64 | | |
65 | | // Assume ld64 is new enough that the abs-ified FDE relocs may be used |
66 | | // (actually, must, since otherwise the non-extern relocations we produce |
67 | | // overwhelm ld64's tiny little mind and it fails). |
68 | 0 | DwarfFDESymbolsUseAbsDiff = true; |
69 | |
|
70 | 0 | UseIntegratedAssembler = true; |
71 | 0 | } |
72 | | |
73 | | X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple) |
74 | 0 | : X86MCAsmInfoDarwin(Triple) { |
75 | 0 | } |
76 | | |
77 | 16.2k | X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) { |
78 | 16.2k | bool is64Bit = T.getArch() == Triple::x86_64; |
79 | 16.2k | bool isX32 = T.getEnvironment() == Triple::GNUX32; |
80 | | |
81 | | // For ELF, x86-64 pointer size depends on the ABI. |
82 | | // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64 |
83 | | // with the x32 ABI, pointer size remains the default 4. |
84 | 16.2k | PointerSize = (is64Bit && !isX32) ? 8 : 4; |
85 | | |
86 | | // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI. |
87 | 16.2k | CalleeSaveStackSlotSize = is64Bit ? 8 : 4; |
88 | | |
89 | 16.2k | AssemblerDialect = AsmWriterFlavor; |
90 | | |
91 | 16.2k | TextAlignFillValue = 0x90; |
92 | | |
93 | | // Debug Information |
94 | 16.2k | SupportsDebugInformation = true; |
95 | | |
96 | | // Exceptions handling |
97 | 16.2k | ExceptionsType = ExceptionHandling::DwarfCFI; |
98 | | |
99 | | // Always enable the integrated assembler by default. |
100 | | // Clang also enabled it when the OS is Solaris but that is redundant here. |
101 | 16.2k | UseIntegratedAssembler = true; |
102 | 16.2k | } |
103 | | |
104 | | const MCExpr * |
105 | | X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym, |
106 | | unsigned Encoding, |
107 | 0 | MCStreamer &Streamer) const { |
108 | 0 | MCContext &Context = Streamer.getContext(); |
109 | 0 | const MCExpr *Res = |
110 | 0 | MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context); |
111 | 0 | const MCExpr *Four = MCConstantExpr::create(4, Context); |
112 | 0 | return MCBinaryExpr::createAdd(Res, Four, Context); |
113 | 0 | } |
114 | | |
115 | 0 | X86MCAsmInfoMicrosoft::X86MCAsmInfoMicrosoft(const Triple &Triple) { |
116 | 0 | if (Triple.getArch() == Triple::x86_64) { |
117 | 0 | PrivateGlobalPrefix = ".L"; |
118 | 0 | PrivateLabelPrefix = ".L"; |
119 | 0 | PointerSize = 8; |
120 | 0 | WinEHEncodingType = WinEH::EncodingType::Itanium; |
121 | 0 | } else { |
122 | | // 32-bit X86 doesn't use CFI, so this isn't a real encoding type. It's just |
123 | | // a place holder that the Windows EHStreamer looks for to suppress CFI |
124 | | // output. In particular, usesWindowsCFI() returns false. |
125 | 0 | WinEHEncodingType = WinEH::EncodingType::X86; |
126 | 0 | } |
127 | |
|
128 | 0 | ExceptionsType = ExceptionHandling::WinEH; |
129 | |
|
130 | 0 | AssemblerDialect = AsmWriterFlavor; |
131 | |
|
132 | 0 | TextAlignFillValue = 0x90; |
133 | |
|
134 | 0 | AllowAtInName = true; |
135 | |
|
136 | 0 | UseIntegratedAssembler = true; |
137 | 0 | } |
138 | | |
139 | 0 | X86MCAsmInfoGNUCOFF::X86MCAsmInfoGNUCOFF(const Triple &Triple) { |
140 | 0 | assert(Triple.isOSWindows() && "Windows is the only supported COFF target"); |
141 | 0 | if (Triple.getArch() == Triple::x86_64) { |
142 | 0 | PrivateGlobalPrefix = ".L"; |
143 | 0 | PrivateLabelPrefix = ".L"; |
144 | 0 | PointerSize = 8; |
145 | 0 | WinEHEncodingType = WinEH::EncodingType::Itanium; |
146 | 0 | ExceptionsType = ExceptionHandling::WinEH; |
147 | 0 | } else { |
148 | 0 | ExceptionsType = ExceptionHandling::DwarfCFI; |
149 | 0 | } |
150 | |
|
151 | 0 | AssemblerDialect = AsmWriterFlavor; |
152 | |
|
153 | 0 | TextAlignFillValue = 0x90; |
154 | |
|
155 | 0 | UseIntegratedAssembler = true; |
156 | 0 | } |