llvm.org GIT mirror llvm / 7b82808
Replace Triple with a new TargetTuple in MCTargetDesc/* and related. NFC. Summary: This is the first patch in the series to migrate Triple's (which are ambiguous) to TargetTuple's (which aren't). For the moment, TargetTuple simply passes all requests to the Triple object it holds. Once it has replaced Triple, it will start to implement the interface in a more suitable way. This change makes some changes to the public C++ API. In particular, InitMCSubtargetInfo(), createMCRelocationInfo(), and createMCSymbolizer() now take TargetTuples instead of Triples. The other public C++ API's have been left as-is for the moment to reduce patch size. This commit also contains a trivial patch to clang to account for the C++ API change. Reviewers: rengolin Subscribers: jyknight, dschuff, arsenm, rampitec, danalbert, srhines, javed.absar, dsanders, echristo, emaste, jholewinski, tberghammer, ted, jfb, llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D10969 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247683 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 5 years ago
112 changed file(s) with 1291 addition(s) and 501 deletion(s). Raw diff Collapse all Expand all
0 //===-- llvm/ADT/TargetTuple.h - Target tuple class -------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// @file
10 /// This file contains the definitions for TargetTuples which describe the
11 /// target in a unique unambiguous way. This is in contrast to the GNU triples
12 /// handled by the Triple class which are more of a guideline than a
13 /// description and whose meaning can be overridden by vendors and distributors.
14 //
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_ADT_TARGETTUPLE_H
18 #define LLVM_ADT_TARGETTUPLE_H
19
20 #include "llvm/ADT/Twine.h"
21 #include "llvm/ADT/Triple.h"
22
23 // Some system headers or GCC predefined macros conflict with identifiers in
24 // this file. Undefine them here.
25 #undef NetBSD
26 #undef mips
27 #undef sparc
28
29 namespace llvm {
30
31 /// TargetTuple is currently a proxy for Triple but will become an unambiguous,
32 /// authoratitive, and mutable counterpart to the GNU triples handled by Triple.
33 class TargetTuple {
34 public:
35 // FIXME: Don't duplicate Triple::ArchType. It's worth mentioning that these
36 // these values don't have to match Triple::ArchType. For example, it
37 // would be fairly sensible to have a single 'mips' architecture and
38 // distinguish endianness and ABI elsewhere.
39 enum ArchType {
40 UnknownArch,
41
42 arm, // ARM (little endian): arm, armv.*, xscale
43 armeb, // ARM (big endian): armeb
44 aarch64, // AArch64 (little endian): aarch64
45 aarch64_be, // AArch64 (big endian): aarch64_be
46 bpfel, // eBPF or extended BPF or 64-bit BPF (little endian)
47 bpfeb, // eBPF or extended BPF or 64-bit BPF (big endian)
48 hexagon, // Hexagon: hexagon
49 mips, // MIPS: mips, mipsallegrex
50 mipsel, // MIPSEL: mipsel, mipsallegrexel
51 mips64, // MIPS64: mips64
52 mips64el, // MIPS64EL: mips64el
53 msp430, // MSP430: msp430
54 ppc, // PPC: powerpc
55 ppc64, // PPC64: powerpc64, ppu
56 ppc64le, // PPC64LE: powerpc64le
57 r600, // R600: AMD GPUs HD2XXX - HD6XXX
58 amdgcn, // AMDGCN: AMD GCN GPUs
59 sparc, // Sparc: sparc
60 sparcv9, // Sparcv9: Sparcv9
61 sparcel, // Sparc: (endianness = little). NB: 'Sparcle' is a CPU variant
62 systemz, // SystemZ: s390x
63 tce, // TCE (http://tce.cs.tut.fi/): tce
64 // FIXME: thumb/thumbeb will be merged into arm/armeb soon.
65 thumb, // Thumb (little endian): thumb, thumbv.*
66 thumbeb, // Thumb (big endian): thumbeb
67 x86, // X86: i[3-9]86
68 x86_64, // X86-64: amd64, x86_64
69 xcore, // XCore: xcore
70 nvptx, // NVPTX: 32-bit
71 nvptx64, // NVPTX: 64-bit
72 le32, // le32: generic little-endian 32-bit CPU (PNaCl / Emscripten)
73 le64, // le64: generic little-endian 64-bit CPU (PNaCl / Emscripten)
74 amdil, // AMDIL
75 amdil64, // AMDIL with 64-bit pointers
76 hsail, // AMD HSAIL
77 hsail64, // AMD HSAIL with 64-bit pointers
78 spir, // SPIR: standard portable IR for OpenCL 32-bit version
79 spir64, // SPIR: standard portable IR for OpenCL 64-bit version
80 kalimba, // Kalimba: generic kalimba
81 shave, // SHAVE: Movidius vector VLIW processors
82 wasm32, // WebAssembly with 32-bit pointers
83 wasm64, // WebAssembly with 64-bit pointers
84 LastArchType = wasm64
85 };
86
87 enum SubArchType {
88 NoSubArch,
89
90 ARMSubArch_v8_1a,
91 ARMSubArch_v8,
92 ARMSubArch_v7,
93 ARMSubArch_v7em,
94 ARMSubArch_v7m,
95 ARMSubArch_v7s,
96 ARMSubArch_v6,
97 ARMSubArch_v6m,
98 ARMSubArch_v6k,
99 ARMSubArch_v6t2,
100 ARMSubArch_v5,
101 ARMSubArch_v5te,
102 ARMSubArch_v4t,
103
104 KalimbaSubArch_v3,
105 KalimbaSubArch_v4,
106 KalimbaSubArch_v5
107 };
108
109 enum VendorType {
110 UnknownVendor,
111
112 Apple,
113 PC,
114 SCEI,
115 BGP,
116 BGQ,
117 Freescale,
118 IBM,
119 ImaginationTechnologies,
120 MipsTechnologies,
121 NVIDIA,
122 CSR,
123 Myriad,
124 LastVendorType = Myriad
125 };
126
127 enum OSType {
128 UnknownOS,
129
130 CloudABI,
131 Darwin,
132 DragonFly,
133 FreeBSD,
134 IOS,
135 KFreeBSD,
136 Linux,
137 Lv2, // PS3
138 MacOSX,
139 NetBSD,
140 OpenBSD,
141 Solaris,
142 Win32,
143 Haiku,
144 Minix,
145 RTEMS,
146 NaCl, // Native Client
147 CNK, // BG/P Compute-Node Kernel
148 Bitrig,
149 AIX,
150 CUDA, // NVIDIA CUDA
151 NVCL, // NVIDIA OpenCL
152 AMDHSA, // AMD HSA Runtime
153 PS4,
154 LastOSType = PS4
155 };
156
157 enum EnvironmentType {
158 UnknownEnvironment,
159
160 GNU,
161 GNUEABI,
162 GNUEABIHF,
163 GNUX32,
164 CODE16,
165 EABI,
166 EABIHF,
167 Android,
168
169 MSVC,
170 Itanium,
171 Cygnus,
172 AMDOpenCL,
173 CoreCLR,
174 LastEnvironmentType = CoreCLR
175 };
176
177 enum ObjectFormatType {
178 UnknownObjectFormat,
179
180 COFF,
181 ELF,
182 MachO,
183 };
184
185 public:
186 /// @name Constructors
187 /// @{
188
189 /// Default constructor leaves all fields unknown.
190 TargetTuple() : GnuTT() {}
191
192 /// Convert a GNU Triple to a TargetTuple.
193 ///
194 /// This conversion assumes that GNU Triple's have a specific defined meaning
195 /// which isn't strictly true. A single Triple can potentially have multiple
196 /// contradictory meanings depending on compiler options and configure-time
197 /// options. Despite this, Triple's do tend to have a 'usual' meaning, or
198 /// rather a default behaviour and this function selects it.
199 ///
200 /// When tool options affect the desired TargetTuple, the tool should obtain
201 /// the usual meaning of the GNU Triple using this constructor and then use
202 /// the mutator methods to apply the tool options.
203 explicit TargetTuple(const Triple &GnuTT) : GnuTT(GnuTT) {}
204
205 /// @}
206 /// @name Typed Component Access
207 /// @{
208
209 /// Get the parsed architecture type of this triple.
210 ArchType getArch() const;
211
212 /// get the parsed subarchitecture type for this triple.
213 SubArchType getSubArch() const;
214
215 /// Get the parsed vendor type of this triple.
216 VendorType getVendor() const;
217
218 /// Get the parsed operating system type of this triple.
219 OSType getOS() const;
220
221 /// Does this triple have the optional environment
222 /// (fourth) component?
223 bool hasEnvironment() const { return GnuTT.hasEnvironment(); }
224
225 /// Get the parsed environment type of this triple.
226 EnvironmentType getEnvironment() const;
227
228 /// Parse the version number from the OS name component of the
229 /// triple, if present.
230 ///
231 /// For example, "fooos1.2.3" would return (1, 2, 3).
232 ///
233 /// If an entry is not defined, it will be returned as 0.
234 void getEnvironmentVersion(unsigned &Major, unsigned &Minor,
235 unsigned &Micro) const;
236
237 /// Get the object format for this triple.
238 ObjectFormatType getObjectFormat() const;
239
240 /// Parse the version number from the OS name component of the
241 /// triple, if present.
242 ///
243 /// For example, "fooos1.2.3" would return (1, 2, 3).
244 ///
245 /// If an entry is not defined, it will be returned as 0.
246 void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const {
247 return GnuTT.getOSVersion(Major, Minor, Micro);
248 }
249
250 /// Return just the major version number, this is
251 /// specialized because it is a common query.
252 unsigned getOSMajorVersion() const { return GnuTT.getOSMajorVersion(); }
253
254 /// Parse the version number as with getOSVersion and then
255 /// translate generic "darwin" versions to the corresponding OS X versions.
256 /// This may also be called with IOS triples but the OS X version number is
257 /// just set to a constant 10.4.0 in that case. Returns true if successful.
258 bool getMacOSXVersion(unsigned &Major, unsigned &Minor,
259 unsigned &Micro) const {
260 return GnuTT.getMacOSXVersion(Major, Minor, Micro);
261 }
262
263 /// Parse the version number as with getOSVersion. This
264 /// should
265 /// only be called with IOS triples.
266 void getiOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const {
267 return GnuTT.getiOSVersion(Major, Minor, Micro);
268 }
269
270 /// @}
271 /// @name Direct Component Access
272 /// @{
273
274 const std::string &str() const { return GnuTT.str(); }
275
276 const std::string &getTriple() const { return GnuTT.str(); }
277
278 /// Get the architecture (first) component of the
279 /// triple.
280 StringRef getArchName() const { return GnuTT.getArchName(); }
281
282 /// Get the vendor (second) component of the triple.
283 StringRef getVendorName() const { return GnuTT.getVendorName(); }
284
285 /// Get the operating system (third) component of the
286 /// triple.
287 StringRef getOSName() const { return GnuTT.getOSName(); }
288
289 /// Get the optional environment (fourth)
290 /// component of the triple, or "" if empty.
291 StringRef getEnvironmentName() const { return GnuTT.getEnvironmentName(); }
292
293 /// Get the operating system and optional
294 /// environment components as a single string (separated by a '-'
295 /// if the environment component is present).
296 StringRef getOSAndEnvironmentName() const {
297 return GnuTT.getOSAndEnvironmentName();
298 }
299
300 /// @}
301 /// @name Convenience Predicates
302 /// @{
303
304 /// Test whether the architecture is 64-bit
305 ///
306 /// Note that this tests for 64-bit pointer width, and nothing else. Note
307 /// that we intentionally expose only three predicates, 64-bit, 32-bit, and
308 /// 16-bit. The inner details of pointer width for particular architectures
309 /// is not summed up in the triple, and so only a coarse grained predicate
310 /// system is provided.
311 bool isArch64Bit() const { return GnuTT.isArch64Bit(); }
312
313 /// Test whether the architecture is 32-bit
314 ///
315 /// Note that this tests for 32-bit pointer width, and nothing else.
316 bool isArch32Bit() const { return GnuTT.isArch32Bit(); }
317
318 /// Test whether the architecture is 16-bit
319 ///
320 /// Note that this tests for 16-bit pointer width, and nothing else.
321 bool isArch16Bit() const { return GnuTT.isArch16Bit(); }
322
323 /// Helper function for doing comparisons against version
324 /// numbers included in the target triple.
325 bool isOSVersionLT(unsigned Major, unsigned Minor = 0,
326 unsigned Micro = 0) const {
327 return GnuTT.isOSVersionLT(Major, Minor, Micro);
328 }
329
330 bool isOSVersionLT(const Triple &Other) const {
331 return GnuTT.isOSVersionLT(Other);
332 }
333
334 /// Comparison function for checking OS X version
335 /// compatibility, which handles supporting skewed version numbering schemes
336 /// used by the "darwin" triples.
337 unsigned isMacOSXVersionLT(unsigned Major, unsigned Minor = 0,
338 unsigned Micro = 0) const {
339 return GnuTT.isMacOSXVersionLT(Major, Minor, Micro);
340 }
341
342 /// Is this a Mac OS X triple. For legacy reasons, we support both
343 /// "darwin" and "osx" as OS X triples.
344 bool isMacOSX() const { return GnuTT.isMacOSX(); }
345
346 /// Is this an iOS triple.
347 bool isiOS() const { return GnuTT.isiOS(); }
348
349 /// Is this a "Darwin" OS (OS X or iOS).
350 bool isOSDarwin() const { return GnuTT.isOSDarwin(); }
351
352 bool isOSNetBSD() const { return GnuTT.isOSNetBSD(); }
353
354 bool isOSOpenBSD() const { return GnuTT.isOSOpenBSD(); }
355
356 bool isOSFreeBSD() const { return GnuTT.isOSFreeBSD(); }
357
358 bool isOSDragonFly() const { return GnuTT.isOSDragonFly(); }
359
360 bool isOSSolaris() const { return GnuTT.isOSSolaris(); }
361
362 bool isOSBitrig() const { return GnuTT.isOSBitrig(); }
363
364 bool isWindowsMSVCEnvironment() const {
365 return GnuTT.isWindowsMSVCEnvironment();
366 }
367
368 bool isKnownWindowsMSVCEnvironment() const {
369 return GnuTT.isKnownWindowsMSVCEnvironment();
370 }
371
372 bool isWindowsCoreCLREnvironment() const {
373 return GnuTT.isWindowsCoreCLREnvironment();
374 }
375
376 bool isWindowsItaniumEnvironment() const {
377 return GnuTT.isWindowsItaniumEnvironment();
378 }
379
380 bool isWindowsCygwinEnvironment() const {
381 return GnuTT.isWindowsCygwinEnvironment();
382 }
383
384 bool isWindowsGNUEnvironment() const {
385 return GnuTT.isWindowsGNUEnvironment();
386 }
387
388 /// Tests for either Cygwin or MinGW OS
389 bool isOSCygMing() const { return GnuTT.isOSCygMing(); }
390
391 /// Is this a "Windows" OS targeting a "MSVCRT.dll" environment.
392 bool isOSMSVCRT() const { return GnuTT.isOSMSVCRT(); }
393
394 /// Tests whether the OS is Windows.
395 bool isOSWindows() const { return GnuTT.isOSWindows(); }
396
397 /// Tests whether the OS is NaCl (Native Client)
398 bool isOSNaCl() const { return GnuTT.isOSNaCl(); }
399
400 /// Tests whether the OS is Linux.
401 bool isOSLinux() const { return GnuTT.isOSLinux(); }
402
403 /// Tests whether the OS uses the ELF binary format.
404 bool isOSBinFormatELF() const { return GnuTT.isOSBinFormatELF(); }
405
406 /// Tests whether the OS uses the COFF binary format.
407 bool isOSBinFormatCOFF() const { return GnuTT.isOSBinFormatCOFF(); }
408
409 /// Tests whether the environment is MachO.
410 bool isOSBinFormatMachO() const { return GnuTT.isOSBinFormatMachO(); }
411
412 /// Tests whether the target is the PS4 CPU
413 bool isPS4CPU() const { return GnuTT.isPS4CPU(); }
414
415 /// Tests whether the target is the PS4 platform
416 bool isPS4() const { return GnuTT.isPS4(); }
417
418 /// @}
419
420 // FIXME: Remove. This function exists to avoid having to migrate everything
421 // at once.
422 const Triple &getTargetTriple() const { return GnuTT; }
423
424 private:
425 Triple GnuTT;
426 };
427
428 } // End llvm namespace
429
430 #endif
99 #ifndef LLVM_MC_MCELFOBJECTWRITER_H
1010 #define LLVM_MC_MCELFOBJECTWRITER_H
1111
12 #include "llvm/ADT/Triple.h"
12 #include "llvm/ADT/TargetTuple.h"
1313 #include "llvm/Support/DataTypes.h"
1414 #include "llvm/Support/ELF.h"
1515 #include
4949 bool IsN64=false);
5050
5151 public:
52 static uint8_t getOSABI(Triple::OSType OSType) {
52 static uint8_t getOSABI(TargetTuple::OSType OSType) {
5353 switch (OSType) {
54 case Triple::CloudABI:
55 return ELF::ELFOSABI_CLOUDABI;
56 case Triple::PS4:
57 case Triple::FreeBSD:
58 return ELF::ELFOSABI_FREEBSD;
59 case Triple::Linux:
60 return ELF::ELFOSABI_LINUX;
61 default:
62 return ELF::ELFOSABI_NONE;
54 case TargetTuple::CloudABI:
55 return ELF::ELFOSABI_CLOUDABI;
56 case TargetTuple::PS4:
57 case TargetTuple::FreeBSD:
58 return ELF::ELFOSABI_FREEBSD;
59 case TargetTuple::Linux:
60 return ELF::ELFOSABI_LINUX;
61 default:
62 return ELF::ELFOSABI_NONE;
6363 }
6464 }
6565
1313 #ifndef LLVM_MC_MCSUBTARGETINFO_H
1414 #define LLVM_MC_MCSUBTARGETINFO_H
1515
16 #include "llvm/ADT/TargetTuple.h"
1617 #include "llvm/MC/MCInstrItineraries.h"
1718 #include "llvm/MC/SubtargetFeature.h"
1819 #include
2627 /// MCSubtargetInfo - Generic base class for all target subtargets.
2728 ///
2829 class MCSubtargetInfo {
29 Triple TargetTriple; // Target triple
30 std::string CPU; // CPU being targeted.
30 TargetTuple TheTargetTuple; // Target triple
31 std::string CPU; // CPU being targeted.
3132 ArrayRef ProcFeatures; // Processor feature list
32 ArrayRef ProcDesc; // Processor descriptions
33 ArrayRef ProcDesc; // Processor descriptions
3334
3435 // Scheduler machine model
3536 const SubtargetInfoKV *ProcSchedModels;
4950
5051 public:
5152 MCSubtargetInfo(const MCSubtargetInfo &) = default;
52 MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
53 MCSubtargetInfo(const TargetTuple &TT, StringRef CPU, StringRef FS,
5354 ArrayRef PF,
5455 ArrayRef PD,
5556 const SubtargetInfoKV *ProcSched,
5758 const MCReadAdvanceEntry *RA, const InstrStage *IS,
5859 const unsigned *OC, const unsigned *FP);
5960
60 /// getTargetTriple - Return the target triple string.
61 const Triple &getTargetTriple() const { return TargetTriple; }
61 /// getTargetTuple - Return the target triple string.
62 const TargetTuple &getTargetTuple() const { return TheTargetTuple; }
6263
6364 /// getCPU - Return the CPU string.
6465 StringRef getCPU() const {
2020
2121 #include "llvm-c/Disassembler.h"
2222 #include "llvm/ADT/Triple.h"
23 #include "llvm/ADT/TargetTuple.h"
2324 #include "llvm/Support/CodeGen.h"
2425 #include "llvm/Support/FormattedStream.h"
2526 #include
6869 bool RelaxAll, bool DWARFMustBeAtTheEnd,
6970 bool LabelSections = false);
7071
71 MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
72
73 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
72 MCRelocationInfo *createMCRelocationInfo(const TargetTuple &TT, MCContext &Ctx);
73
74 MCSymbolizer *createMCSymbolizer(const TargetTuple &TT,
75 LLVMOpInfoCallback GetOpInfo,
7476 LLVMSymbolLookupCallback SymbolLookUp,
7577 void *DisInfo, MCContext *Ctx,
7678 std::unique_ptr &&RelInfo);
9092 typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
9193
9294 typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
93 const Triple &TT);
94 typedef MCCodeGenInfo *(*MCCodeGenInfoCtorFnTy)(const Triple &TT,
95 const TargetTuple &TT);
96 typedef MCCodeGenInfo *(*MCCodeGenInfoCtorFnTy)(const TargetTuple &TT,
9597 Reloc::Model RM,
9698 CodeModel::Model CM,
9799 CodeGenOpt::Level OL);
98100 typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
99101 typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
100 typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
101 typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
102 typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const TargetTuple &TT);
103 // FIXME: CPU and Features should be merged into TargetTuple when possible.
104 typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const TargetTuple &TT,
102105 StringRef CPU,
103106 StringRef Features);
107 // FIXME: CPU and Features should be merged into TargetTuple when possible.
104108 typedef TargetMachine *(*TargetMachineCtorTy)(
105 const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
109 const Target &T, const TargetTuple &TT, StringRef CPU, StringRef Features,
106110 const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM,
107111 CodeGenOpt::Level OL);
108112 // If it weren't for layering issues (this header is in llvm/Support, but
110114 // reference.
111115 typedef AsmPrinter *(*AsmPrinterCtorTy)(
112116 TargetMachine &TM, std::unique_ptr &&Streamer);
117 // FIXME: CPU and Features should be merged into TargetTuple when possible.
113118 typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
114119 const MCRegisterInfo &MRI,
115 const Triple &TT, StringRef CPU);
120 const TargetTuple &TT,
121 StringRef CPU);
116122 typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
117123 MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
118124 const MCTargetOptions &Options);
119125 typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
120126 const MCSubtargetInfo &STI,
121127 MCContext &Ctx);
122 typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
128 typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const TargetTuple &T,
123129 unsigned SyntaxVariant,
124130 const MCAsmInfo &MAI,
125131 const MCInstrInfo &MII,
127133 typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
128134 const MCRegisterInfo &MRI,
129135 MCContext &Ctx);
130 typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
136 typedef MCStreamer *(*ELFStreamerCtorTy)(const TargetTuple &T, MCContext &Ctx,
131137 MCAsmBackend &TAB,
132138 raw_pwrite_stream &OS,
133139 MCCodeEmitter *Emitter,
147153 bool IsVerboseAsm);
148154 typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
149155 MCStreamer &S, const MCSubtargetInfo &STI);
150 typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
156 typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const TargetTuple &TT,
151157 MCContext &Ctx);
152158 typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
153 const Triple &TT, LLVMOpInfoCallback GetOpInfo,
159 const TargetTuple &TT, LLVMOpInfoCallback GetOpInfo,
154160 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
155161 std::unique_ptr &&RelInfo);
156162
287293 /// createMCAsmInfo - Create a MCAsmInfo implementation for the specified
288294 /// target triple.
289295 ///
290 /// \param TheTriple This argument is used to determine the target machine
296 /// \param TT This argument is used to determine the target machine
291297 /// feature set; it should always be provided. Generally this should be
292298 /// either the target triple from the module, or the target triple of the
293299 /// host if that does not exist.
294 MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI,
295 StringRef TheTriple) const {
300 MCAsmInfo *createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TT) const {
296301 if (!MCAsmInfoCtorFn)
297302 return nullptr;
298 return MCAsmInfoCtorFn(MRI, Triple(TheTriple));
303 return MCAsmInfoCtorFn(MRI, TargetTuple(Triple(TT)));
299304 }
300305
301306 /// createMCCodeGenInfo - Create a MCCodeGenInfo implementation.
305310 CodeGenOpt::Level OL) const {
306311 if (!MCCodeGenInfoCtorFn)
307312 return nullptr;
308 return MCCodeGenInfoCtorFn(Triple(TT), RM, CM, OL);
313 return MCCodeGenInfoCtorFn(TargetTuple(Triple(TT)), RM, CM, OL);
309314 }
310315
311316 /// createMCInstrInfo - Create a MCInstrInfo implementation.
329334 MCRegisterInfo *createMCRegInfo(StringRef TT) const {
330335 if (!MCRegInfoCtorFn)
331336 return nullptr;
332 return MCRegInfoCtorFn(Triple(TT));
337 return MCRegInfoCtorFn(TargetTuple(Triple(TT)));
333338 }
334339
335340 /// createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
336341 ///
337 /// \param TheTriple This argument is used to determine the target machine
342 /// \param TT This argument is used to determine the target machine
338343 /// feature set; it should always be provided. Generally this should be
339344 /// either the target triple from the module, or the target triple of the
340345 /// host if that does not exist.
341346 /// \param CPU This specifies the name of the target CPU.
342347 /// \param Features This specifies the string representation of the
343348 /// additional target features.
344 MCSubtargetInfo *createMCSubtargetInfo(StringRef TheTriple, StringRef CPU,
349 MCSubtargetInfo *createMCSubtargetInfo(StringRef TT, StringRef CPU,
345350 StringRef Features) const {
346351 if (!MCSubtargetInfoCtorFn)
347352 return nullptr;
348 return MCSubtargetInfoCtorFn(Triple(TheTriple), CPU, Features);
353 return MCSubtargetInfoCtorFn(TargetTuple(Triple(TT)), CPU, Features);
349354 }
350355
351356 /// createTargetMachine - Create a target specific machine implementation
352 /// for the specified \p Triple.
357 /// for the specified \p TT.
353358 ///
354359 /// \param TT This argument is used to determine the target machine
355360 /// feature set; it should always be provided. Generally this should be
363368 CodeGenOpt::Level OL = CodeGenOpt::Default) const {
364369 if (!TargetMachineCtorFn)
365370 return nullptr;
366 return TargetMachineCtorFn(*this, Triple(TT), CPU, Features, Options, RM,
367 CM, OL);
371 return TargetMachineCtorFn(*this, TargetTuple(Triple(TT)), CPU, Features,
372 Options, RM, CM, OL);
368373 }
369374
370375 /// createMCAsmBackend - Create a target specific assembly parser.
371376 ///
372 /// \param TheTriple The target triple string.
373 MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI,
374 StringRef TheTriple, StringRef CPU) const {
377 /// \param TT The target triple string.
378 MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI, StringRef TT,
379 StringRef CPU) const {
375380 if (!MCAsmBackendCtorFn)
376381 return nullptr;
377 return MCAsmBackendCtorFn(*this, MRI, Triple(TheTriple), CPU);
382 return MCAsmBackendCtorFn(*this, MRI, TargetTuple(Triple(TT)), CPU);
378383 }
379384
380385 /// createMCAsmParser - Create a target specific assembly parser.
406411 return MCDisassemblerCtorFn(*this, STI, Ctx);
407412 }
408413
409 MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
414 MCInstPrinter *createMCInstPrinter(const TargetTuple &TT,
415 unsigned SyntaxVariant,
410416 const MCAsmInfo &MAI,
411417 const MCInstrInfo &MII,
412418 const MCRegisterInfo &MRI) const {
413419 if (!MCInstPrinterCtorFn)
414420 return nullptr;
415 return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
421 return MCInstPrinterCtorFn(TT, SyntaxVariant, MAI, MII, MRI);
416422 }
417423
418424 /// createMCCodeEmitter - Create a target specific code emitter.
426432
427433 /// Create a target specific MCStreamer.
428434 ///
429 /// \param T The target triple.
435 /// \param TT The target triple.
430436 /// \param Ctx The target context.
431437 /// \param TAB The target assembler backend object. Takes ownership.
432438 /// \param OS The stream object.
433439 /// \param Emitter The target independent assembler object.Takes ownership.
434440 /// \param RelaxAll Relax all fixups?
435 MCStreamer *createMCObjectStreamer(const Triple &T, MCContext &Ctx,
441 MCStreamer *createMCObjectStreamer(const TargetTuple &TT, MCContext &Ctx,
436442 MCAsmBackend &TAB, raw_pwrite_stream &OS,
437443 MCCodeEmitter *Emitter,
438444 const MCSubtargetInfo &STI, bool RelaxAll,
439445 bool DWARFMustBeAtTheEnd) const {
440446 MCStreamer *S;
441 switch (T.getObjectFormat()) {
447 switch (TT.getObjectFormat()) {
442448 default:
443449 llvm_unreachable("Unknown object format");
444 case Triple::COFF:
445 assert(T.isOSWindows() && "only Windows COFF is supported");
450 case TargetTuple::COFF:
451 assert(TT.isOSWindows() && "only Windows COFF is supported");
446452 S = COFFStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll);
447453 break;
448 case Triple::MachO:
454 case TargetTuple::MachO:
449455 if (MachOStreamerCtorFn)
450456 S = MachOStreamerCtorFn(Ctx, TAB, OS, Emitter, RelaxAll,
451457 DWARFMustBeAtTheEnd);
453459 S = createMachOStreamer(Ctx, TAB, OS, Emitter, RelaxAll,
454460 DWARFMustBeAtTheEnd);
455461 break;
456 case Triple::ELF:
462 case TargetTuple::ELF:
457463 if (ELFStreamerCtorFn)
458 S = ELFStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
464 S = ELFStreamerCtorFn(TT, Ctx, TAB, OS, Emitter, RelaxAll);
459465 else
460466 S = createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
461467 break;
507513 MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn
508514 ? MCRelocationInfoCtorFn
509515 : llvm::createMCRelocationInfo;
510 return Fn(Triple(TT), Ctx);
516 return Fn(TargetTuple(Triple(TT)), Ctx);
511517 }
512518
513519 /// createMCSymbolizer - Create a target specific MCSymbolizer.
529535 std::unique_ptr &&RelInfo) const {
530536 MCSymbolizerCtorTy Fn =
531537 MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer;
532 return Fn(Triple(TT), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
538 return Fn(TargetTuple(Triple(TT)), GetOpInfo, SymbolLookUp, DisInfo, Ctx,
533539 std::move(RelInfo));
534540 }
535541
587593
588594 /// lookupTarget - Lookup a target based on a target triple.
589595 ///
590 /// \param Triple - The triple to use for finding a target.
596 /// \param TT - The triple to use for finding a target.
591597 /// \param Error - On failure, an error string describing why no target was
592598 /// found.
593 static const Target *lookupTarget(const std::string &Triple,
594 std::string &Error);
599 static const Target *lookupTarget(const std::string &TT, std::string &Error);
595600
596601 /// lookupTarget - Lookup a target based on an architecture name
597602 /// and a target triple. If the architecture name is non-empty,
599604 /// triple is used.
600605 ///
601606 /// \param ArchName - The architecture to use for finding a target.
602 /// \param TheTriple - The triple to use for finding a target. The
607 /// \param TT - The triple to use for finding a target. The
603608 /// triple is updated with canonical architecture name if a lookup
604609 /// by architecture is done.
605610 /// \param Error - On failure, an error string describing why no target was
606611 /// found.
607 static const Target *lookupTarget(const std::string &ArchName,
608 Triple &TheTriple, std::string &Error);
612 static const Target *lookupTarget(const std::string &ArchName, Triple &TT,
613 std::string &Error);
609614
610615 /// @}
611616 /// @name Target Registration
891896
892897 private:
893898 static MCAsmInfo *Allocator(const MCRegisterInfo & /*MRI*/,
894 const Triple &TT) {
895 return new MCAsmInfoImpl(TT);
899 const TargetTuple &TT) {
900 return new MCAsmInfoImpl(TargetTuple(TT));
896901 }
897902 };
898903
925930 }
926931
927932 private:
928 static MCCodeGenInfo *Allocator(const Triple & /*TT*/, Reloc::Model /*RM*/,
929 CodeModel::Model /*CM*/,
933 static MCCodeGenInfo *Allocator(const TargetTuple & /*TT*/,
934 Reloc::Model /*RM*/, CodeModel::Model /*CM*/,
930935 CodeGenOpt::Level /*OL*/) {
931936 return new MCCodeGenInfoImpl();
932937 }
10241029 }
10251030
10261031 private:
1027 static MCRegisterInfo *Allocator(const Triple & /*TT*/) {
1032 static MCRegisterInfo *Allocator(const TargetTuple & /*TT*/) {
10281033 return new MCRegisterInfoImpl();
10291034 }
10301035 };
10571062 }
10581063
10591064 private:
1060 static MCSubtargetInfo *Allocator(const Triple & /*TT*/, StringRef /*CPU*/,
1061 StringRef /*FS*/) {
1065 static MCSubtargetInfo *Allocator(const TargetTuple & /*TT*/,
1066 StringRef /*CPU*/, StringRef /*FS*/) {
10621067 return new MCSubtargetInfoImpl();
10631068 }
10641069 };
10911096 }
10921097
10931098 private:
1094 static TargetMachine *Allocator(const Target &T, const Triple &TT,
1099 static TargetMachine *Allocator(const Target &T, const TargetTuple &TT,
10951100 StringRef CPU, StringRef FS,
10961101 const TargetOptions &Options, Reloc::Model RM,
10971102 CodeModel::Model CM, CodeGenOpt::Level OL) {
1098 return new TargetMachineImpl(T, TT, CPU, FS, Options, RM, CM, OL);
1103 return new TargetMachineImpl(T, TT.getTargetTriple(), CPU, FS, Options, RM,
1104 CM, OL);
10991105 }
11001106 };
11011107
11131119
11141120 private:
11151121 static MCAsmBackend *Allocator(const Target &T, const MCRegisterInfo &MRI,
1116 const Triple &TheTriple, StringRef CPU) {
1117 return new MCAsmBackendImpl(T, MRI, TheTriple, CPU);
1122 const TargetTuple &TT, StringRef CPU) {
1123 return new MCAsmBackendImpl(T, MRI, TT, CPU);
11181124 }
11191125 };
11201126
1414 #define LLVM_TARGET_TARGETMACHINE_H
1515
1616 #include "llvm/ADT/StringRef.h"
17 #include "llvm/ADT/TargetTuple.h"
1718 #include "llvm/ADT/Triple.h"
1819 #include "llvm/IR/DataLayout.h"
1920 #include "llvm/Pass.h"
115116 const Target &getTarget() const { return TheTarget; }
116117
117118 const Triple &getTargetTriple() const { return TargetTriple; }
119 // FIXME: Return a reference once we store a TargetTuple
120 const TargetTuple getTargetTuple() const { return TargetTuple(TargetTriple); }
118121 StringRef getTargetCPU() const { return TargetCPU; }
119122 StringRef getTargetFeatureString() const { return TargetFS; }
120123
4747 TargetSubtargetInfo() = delete;
4848
4949 protected: // Can only create subclasses...
50 TargetSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
50 TargetSubtargetInfo(const TargetTuple &TT, StringRef CPU, StringRef FS,
5151 ArrayRef PF,
5252 ArrayRef PD,
5353 const SubtargetInfoKV *ProcSched,
169169 switch (FileType) {
170170 case CGFT_AssemblyFile: {
171171 MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter(
172 getTargetTriple(), MAI.getAssemblerDialect(), MAI, MII, MRI);
172 getTargetTuple(), MAI.getAssemblerDialect(), MAI, MII, MRI);
173173
174174 // Create a code emitter if asked to show the encoding.
175175 MCCodeEmitter *MCE = nullptr;
198198 // Don't waste memory on names of temp labels.
199199 Context->setUseNamesOnTempLabels(false);
200200
201 Triple T(getTargetTriple().str());
201 TargetTuple T(Triple(getTargetTriple().str()));
202202 AsmStreamer.reset(getTarget().createMCObjectStreamer(
203203 T, *Context, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
204204 /*DWARFMustBeAtTheEnd*/ true));
249249 if (!MCE || !MAB)
250250 return true;
251251
252 const Triple &T = getTargetTriple();
252 const TargetTuple &TT = getTargetTuple();
253253 const MCSubtargetInfo &STI = *getMCSubtargetInfo();
254254 std::unique_ptr AsmStreamer(getTarget().createMCObjectStreamer(
255 T, *Ctx, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
255 TT, *Ctx, *MAB, Out, MCE, STI, Options.MCOptions.MCRelaxAll,
256256 /*DWARFMustBeAtTheEnd*/ true));
257257
258258 // Create the AsmPrinter, which takes ownership of AsmStreamer if successful.
8282 // Set up the instruction printer.
8383 int AsmPrinterVariant = MAI->getAssemblerDialect();
8484 MCInstPrinter *IP = TheTarget->createMCInstPrinter(
85 Triple(TT), AsmPrinterVariant, *MAI, *MII, *MRI);
85 TargetTuple(Triple(TT)), AsmPrinterVariant, *MAI, *MII, *MRI);
8686 if (!IP)
8787 return nullptr;
8888
309309 int AsmPrinterVariant = MAI->getAssemblerDialect();
310310 AsmPrinterVariant = AsmPrinterVariant == 0 ? 1 : 0;
311311 MCInstPrinter *IP = DC->getTarget()->createMCInstPrinter(
312 Triple(DC->getTripleName()), AsmPrinterVariant, *MAI, *MII, *MRI);
312 TargetTuple(Triple(DC->getTripleName())), AsmPrinterVariant, *MAI,
313 *MII, *MRI);
313314 if (IP) {
314315 DC->setIP(IP);
315316 DC->addOptions(LLVMDisassembler_Option_AsmPrinterVariant);
1616 using namespace llvm;
1717
1818 namespace llvm {
19 class Triple;
19 class TargetTuple;
2020 }
2121
2222 // This function tries to add a symbolic operand in place of the immediate
187187 }
188188
189189 namespace llvm {
190 MCSymbolizer *createMCSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
190 MCSymbolizer *createMCSymbolizer(const TargetTuple &TT,
191 LLVMOpInfoCallback GetOpInfo,
191192 LLVMSymbolLookupCallback SymbolLookUp,
192193 void *DisInfo, MCContext *Ctx,
193194 std::unique_ptr &&RelInfo) {
3333 return SubExpr;
3434 }
3535
36 MCRelocationInfo *llvm::createMCRelocationInfo(const Triple &TT,
36 MCRelocationInfo *llvm::createMCRelocationInfo(const TargetTuple &TT,
3737 MCContext &Ctx) {
3838 return new MCRelocationInfo(Ctx);
3939 }
88
99 #include "llvm/MC/MCSubtargetInfo.h"
1010 #include "llvm/ADT/StringRef.h"
11 #include "llvm/ADT/Triple.h"
11 #include "llvm/ADT/TargetTuple.h"
1212 #include "llvm/MC/MCInstrItineraries.h"
1313 #include "llvm/MC/SubtargetFeature.h"
1414 #include "llvm/Support/raw_ostream.h"
3636 }
3737
3838 MCSubtargetInfo::MCSubtargetInfo(
39 const Triple &TT, StringRef C, StringRef FS,
39 const TargetTuple &TT, StringRef C, StringRef FS,
4040 ArrayRef PF, ArrayRef PD,
4141 const SubtargetInfoKV *ProcSched, const MCWriteProcResEntry *WPR,
4242 const MCWriteLatencyEntry *WL, const MCReadAdvanceEntry *RA,
4343 const InstrStage *IS, const unsigned *OC, const unsigned *FP)
44 : TargetTriple(TT), CPU(C), ProcFeatures(PF), ProcDesc(PD),
44 : TheTargetTuple(TT), CPU(C), ProcFeatures(PF), ProcDesc(PD),
4545 ProcSchedModels(ProcSched), WriteProcResTable(WPR), WriteLatencyTable(WL),
4646 ReadAdvanceTable(RA), Stages(IS), OperandCycles(OC), ForwardingPaths(FP) {
4747 InitMCProcessorInfo(CPU, FS);
8787 StringRef.cpp
8888 SystemUtils.cpp
8989 TargetParser.cpp
90 TargetTuple.cpp
9091 Timer.cpp
9192 ToolOutputFile.cpp
9293 Triple.cpp
0 //===--- TargetTuple.cpp - Target tuple class -----------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/ADT/StringSwitch.h"
10 #include "llvm/ADT/TargetTuple.h"
11 #include "llvm/Support/TargetParser.h"
12
13 using namespace llvm;
14
15 // FIXME: These should be removed as soon as the Triple member is replaced.
16 static TargetTuple::ArchType
17 convertTripleArchToTupleArch(Triple::ArchType Arch) {
18 switch (Arch) {
19 case Triple::UnknownArch:
20 return TargetTuple::UnknownArch;
21 case Triple::arm:
22 return TargetTuple::arm;
23 case Triple::armeb:
24 return TargetTuple::armeb;
25 case Triple::aarch64:
26 return TargetTuple::aarch64;
27 case Triple::aarch64_be:
28 return TargetTuple::aarch64_be;
29 case Triple::bpfel:
30 return TargetTuple::bpfel;
31 case Triple::bpfeb:
32 return TargetTuple::bpfeb;
33 case Triple::hexagon:
34 return TargetTuple::hexagon;
35 case Triple::mips:
36 return TargetTuple::mips;
37 case Triple::mipsel:
38 return TargetTuple::mipsel;
39 case Triple::mips64:
40 return TargetTuple::mips64;
41 case Triple::mips64el:
42 return TargetTuple::mips64el;
43 case Triple::msp430:
44 return TargetTuple::msp430;
45 case Triple::ppc:
46 return TargetTuple::ppc;
47 case Triple::ppc64:
48 return TargetTuple::ppc64;
49 case Triple::ppc64le:
50 return TargetTuple::ppc64le;
51 case Triple::r600:
52 return TargetTuple::r600;
53 case Triple::amdgcn:
54 return TargetTuple::amdgcn;
55 case Triple::sparc:
56 return TargetTuple::sparc;
57 case Triple::sparcv9:
58 return TargetTuple::sparcv9;
59 case Triple::sparcel:
60 return TargetTuple::sparcel;
61 case Triple::systemz:
62 return TargetTuple::systemz;
63 case Triple::tce:
64 return TargetTuple::tce;
65 case Triple::thumb:
66 return TargetTuple::thumb;
67 case Triple::thumbeb:
68 return TargetTuple::thumbeb;
69 case Triple::x86:
70 return TargetTuple::x86;
71 case Triple::x86_64:
72 return TargetTuple::x86_64;
73 case Triple::xcore:
74 return TargetTuple::xcore;
75 case Triple::nvptx:
76 return TargetTuple::nvptx;
77 case Triple::nvptx64:
78 return TargetTuple::nvptx64;
79 case Triple::le32:
80 return TargetTuple::le32;
81 case Triple::le64:
82 return TargetTuple::le64;
83 case Triple::amdil:
84 return TargetTuple::amdil;
85 case Triple::amdil64:
86 return TargetTuple::amdil64;
87 case Triple::hsail:
88 return TargetTuple::hsail;
89 case Triple::hsail64:
90 return TargetTuple::hsail64;
91 case Triple::spir:
92 return TargetTuple::spir;
93 case Triple::spir64:
94 return TargetTuple::spir64;
95 case Triple::kalimba:
96 return TargetTuple::kalimba;
97 case Triple::shave:
98 return TargetTuple::shave;
99 case Triple::wasm32:
100 return TargetTuple::wasm32;
101 case Triple::wasm64:
102 return TargetTuple::wasm64;
103 }
104 llvm_unreachable("Unmapped architecture.");
105 }
106
107 // FIXME: These should be removed as soon as the Triple member is replaced.
108 static TargetTuple::SubArchType
109 convertTripleSubArchToTupleSubArch(Triple::SubArchType SubArch) {
110 switch (SubArch) {
111 case Triple::NoSubArch:
112 return TargetTuple::NoSubArch;
113 case Triple::ARMSubArch_v8_1a:
114 return TargetTuple::ARMSubArch_v8_1a;
115 case Triple::ARMSubArch_v8:
116 return TargetTuple::ARMSubArch_v8;
117 case Triple::ARMSubArch_v7:
118 return TargetTuple::ARMSubArch_v7;
119 case Triple::ARMSubArch_v7em:
120 return TargetTuple::ARMSubArch_v7em;
121 case Triple::ARMSubArch_v7m:
122 return TargetTuple::ARMSubArch_v7m;
123 case Triple::ARMSubArch_v7s:
124 return TargetTuple::ARMSubArch_v7s;
125 case Triple::ARMSubArch_v6:
126 return TargetTuple::ARMSubArch_v6;
127 case Triple::ARMSubArch_v6m:
128 return TargetTuple::ARMSubArch_v6m;
129 case Triple::ARMSubArch_v6k:
130 return TargetTuple::ARMSubArch_v6k;
131 case Triple::ARMSubArch_v6t2:
132 return TargetTuple::ARMSubArch_v6t2;
133 case Triple::ARMSubArch_v5:
134 return TargetTuple::ARMSubArch_v5;
135 case Triple::ARMSubArch_v5te:
136 return TargetTuple::ARMSubArch_v5te;
137 case Triple::ARMSubArch_v4t:
138 return TargetTuple::ARMSubArch_v4t;
139 case Triple::KalimbaSubArch_v3:
140 return TargetTuple::KalimbaSubArch_v3;
141 case Triple::KalimbaSubArch_v4:
142 return TargetTuple::KalimbaSubArch_v4;
143 case Triple::KalimbaSubArch_v5:
144 return TargetTuple::KalimbaSubArch_v5;
145 }
146 llvm_unreachable("Unmapped subarchitecture.");
147 }
148
149 // FIXME: These should be removed as soon as the Triple member is replaced.
150 static TargetTuple::VendorType
151 convertTripleVendorToTupleVendor(Triple::VendorType Vendor) {
152 switch (Vendor) {
153 case Triple::UnknownVendor:
154 return TargetTuple::UnknownVendor;
155 case Triple::Apple:
156 return TargetTuple::Apple;
157 case Triple::PC:
158 return TargetTuple::PC;
159 case Triple::SCEI:
160 return TargetTuple::SCEI;
161 case Triple::BGP:
162 return TargetTuple::BGP;
163 case Triple::BGQ:
164 return TargetTuple::BGQ;
165 case Triple::Freescale:
166 return TargetTuple::Freescale;
167 case Triple::IBM:
168 return TargetTuple::IBM;
169 case Triple::ImaginationTechnologies:
170 return TargetTuple::ImaginationTechnologies;
171 case Triple::MipsTechnologies:
172 return TargetTuple::MipsTechnologies;
173 case Triple::NVIDIA:
174 return TargetTuple::NVIDIA;
175 case Triple::CSR:
176 return TargetTuple::CSR;
177 case Triple::Myriad:
178 return TargetTuple::Myriad;
179 }
180 llvm_unreachable("Unmapped vendor.");
181 }
182
183 // FIXME: These should be removed as soon as the Triple member is replaced.
184 static TargetTuple::OSType convertTripleOSToTupleOS(Triple::OSType OS) {
185 switch (OS) {
186 case Triple::UnknownOS:
187 return TargetTuple::UnknownOS;
188 case Triple::CloudABI:
189 return TargetTuple::CloudABI;
190 case Triple::Darwin:
191 return TargetTuple::Darwin;
192 case Triple::DragonFly:
193 return TargetTuple::DragonFly;
194 case Triple::FreeBSD:
195 return TargetTuple::FreeBSD;
196 case Triple::IOS:
197 return TargetTuple::IOS;
198 case Triple::KFreeBSD:
199 return TargetTuple::KFreeBSD;
200 case Triple::Linux:
201 return TargetTuple::Linux;
202 case Triple::Lv2:
203 return TargetTuple::Lv2;
204 case Triple::MacOSX:
205 return TargetTuple::MacOSX;
206 case Triple::NetBSD:
207 return TargetTuple::NetBSD;
208 case Triple::OpenBSD:
209 return TargetTuple::OpenBSD;
210 case Triple::Solaris:
211 return TargetTuple::Solaris;
212 case Triple::Win32:
213 return TargetTuple::Win32;
214 case Triple::Haiku:
215 return TargetTuple::Haiku;
216 case Triple::Minix:
217 return TargetTuple::Minix;
218 case Triple::RTEMS:
219 return TargetTuple::RTEMS;
220 case Triple::NaCl:
221 return TargetTuple::NaCl;
222 case Triple::CNK:
223 return TargetTuple::CNK;
224 case Triple::Bitrig:
225 return TargetTuple::Bitrig;
226 case Triple::AIX:
227 return TargetTuple::AIX;
228 case Triple::CUDA:
229 return TargetTuple::CUDA;
230 case Triple::NVCL:
231 return TargetTuple::NVCL;
232 case Triple::AMDHSA:
233 return TargetTuple::AMDHSA;
234 case Triple::PS4:
235 return TargetTuple::PS4;
236 }
237 llvm_unreachable("Unmapped OS.");
238 }
239
240 // FIXME: These should be removed as soon as the Triple member is replaced.
241 static TargetTuple::EnvironmentType
242 convertTripleEnvToTupleEnv(Triple::EnvironmentType Env) {
243 switch (Env) {
244 case Triple::UnknownEnvironment:
245 return TargetTuple::UnknownEnvironment;
246 case Triple::GNU:
247 return TargetTuple::GNU;
248 case Triple::GNUEABI:
249 return TargetTuple::GNUEABI;
250 case Triple::GNUEABIHF:
251 return TargetTuple::GNUEABIHF;
252 case Triple::GNUX32:
253 return TargetTuple::GNUX32;
254 case Triple::CODE16:
255 return TargetTuple::CODE16;
256 case Triple::EABI:
257 return TargetTuple::EABI;
258 case Triple::EABIHF:
259 return TargetTuple::EABIHF;
260 case Triple::Android:
261 return TargetTuple::Android;
262 case Triple::MSVC:
263 return TargetTuple::MSVC;
264 case Triple::Itanium:
265 return TargetTuple::Itanium;
266 case Triple::Cygnus:
267 return TargetTuple::Cygnus;
268 case Triple::AMDOpenCL:
269 return TargetTuple::AMDOpenCL;
270 case Triple::CoreCLR:
271 return TargetTuple::CoreCLR;
272 }
273 llvm_unreachable("Unmapped Environment.");
274 }
275
276 // FIXME: These should be removed as soon as the Triple member is replaced.
277 static TargetTuple::ObjectFormatType
278 convertTripleObjFmtToTupleObjFmt(Triple::ObjectFormatType ObjFmt) {
279 switch (ObjFmt) {
280 case Triple::UnknownObjectFormat:
281 return TargetTuple::UnknownObjectFormat;
282 case Triple::COFF:
283 return TargetTuple::COFF;
284 case Triple::ELF:
285 return TargetTuple::ELF;
286 case Triple::MachO:
287 return TargetTuple::MachO;
288 }
289 llvm_unreachable("Unmapped Object Format.");
290 }
291
292 TargetTuple::ArchType TargetTuple::getArch() const {
293 return convertTripleArchToTupleArch(GnuTT.getArch());
294 }
295
296 TargetTuple::SubArchType TargetTuple::getSubArch() const {
297 return convertTripleSubArchToTupleSubArch(GnuTT.getSubArch());
298 }
299
300 TargetTuple::VendorType TargetTuple::getVendor() const {
301 return convertTripleVendorToTupleVendor(GnuTT.getVendor());
302 }
303
304 TargetTuple::OSType TargetTuple::getOS() const {
305 return convertTripleOSToTupleOS(GnuTT.getOS());
306 }
307
308 TargetTuple::EnvironmentType TargetTuple::getEnvironment() const {
309 return convertTripleEnvToTupleEnv(GnuTT.getEnvironment());
310 }
311
312 TargetTuple::ObjectFormatType TargetTuple::getObjectFormat() const {
313 return convertTripleObjFmtToTupleObjFmt(GnuTT.getObjectFormat());
314 }
4444 AArch64Subtarget::AArch64Subtarget(const Triple &TT, const std::string &CPU,
4545 const std::string &FS,
4646 const TargetMachine &TM, bool LittleEndian)
47 : AArch64GenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
47 : AArch64GenSubtargetInfo(TargetTuple(TT), CPU, FS), ARMProcFamily(Others),
4848 HasV8_1aOps(false), HasFPARMv8(false), HasNEON(false), HasCrypto(false),
4949 HasCRC(false), HasPerfMon(false), HasZeroCycleRegMove(false),
5050 HasZeroCycleZeroing(false), StrictAlign(false), ReserveX18(false),
1818 #include "AArch64InstrInfo.h"
1919 #include "AArch64RegisterInfo.h"
2020 #include "AArch64SelectionDAGInfo.h"
21 #include "llvm/ADT/TargetTuple.h"
2122 #include "llvm/IR/DataLayout.h"
2223 #include "llvm/Target/TargetSubtargetInfo.h"
2324 #include
9697 return &getInstrInfo()->getRegisterInfo();
9798 }
9899 const Triple &getTargetTriple() const { return TargetTriple; }
100 // FIXME: Return a references once our member is a TargetTuple.
101 const TargetTuple getTargetTuple() const { return TargetTuple(TargetTriple); }
99102 bool enableMachineScheduler() const override { return true; }
100103 bool enablePostRAScheduler() const override {
101104 return isCortexA53() || isCortexA57();
226226 return decodeInstruction(DecoderTable32, MI, Insn, Address, this, STI);
227227 }
228228
229 static MCSymbolizer *
230 createAArch64ExternalSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo,
231 LLVMSymbolLookupCallback SymbolLookUp,
232 void *DisInfo, MCContext *Ctx,
233 std::unique_ptr &&RelInfo) {
229 static MCSymbolizer *createAArch64ExternalSymbolizer(
230 const TargetTuple &TT, LLVMOpInfoCallback GetOpInfo,
231 LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
232 std::unique_ptr &&RelInfo) {
234233 return new llvm::AArch64ExternalSymbolizer(*Ctx, move(RelInfo), GetOpInfo,
235234 SymbolLookUp, DisInfo);
236235 }
99 #include "AArch64.h"
1010 #include "AArch64RegisterInfo.h"
1111 #include "MCTargetDesc/AArch64FixupKinds.h"
12 #include "llvm/ADT/Triple.h"
12 #include "llvm/ADT/TargetTuple.h"
1313 #include "llvm/MC/MCAsmBackend.h"
1414 #include "llvm/MC/MCDirectives.h"
1515 #include "llvm/MC/MCELFObjectWriter.h"
520520
521521 MCAsmBackend *llvm::createAArch64leAsmBackend(const Target &T,
522522 const MCRegisterInfo &MRI,
523 const Triple &TheTriple,
523 const TargetTuple &TT,
524524 StringRef CPU) {
525 if (TheTriple.isOSBinFormatMachO())
525 if (TT.isOSBinFormatMachO())
526526 return new DarwinAArch64AsmBackend(T, MRI);
527527
528 assert(TheTriple.isOSBinFormatELF() && "Expect either MachO or ELF target");
529 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
528 assert(TT.isOSBinFormatELF() && "Expect either MachO or ELF target");
529 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
530530 return new ELFAArch64AsmBackend(T, OSABI, /*IsLittleEndian=*/true);
531531 }
532532
533533 MCAsmBackend *llvm::createAArch64beAsmBackend(const Target &T,
534534 const MCRegisterInfo &MRI,
535 const Triple &TheTriple,
535 const TargetTuple &TT,
536536 StringRef CPU) {
537 assert(TheTriple.isOSBinFormatELF() &&
537 assert(TT.isOSBinFormatELF() &&
538538 "Big endian is only supported for ELF targets!");
539 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
539 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
540540 return new ELFAArch64AsmBackend(T, OSABI,
541541 /*IsLittleEndian=*/false);
542542 }
1616 #include "llvm/MC/MCELFStreamer.h"
1717 #include "llvm/ADT/SmallPtrSet.h"
1818 #include "llvm/ADT/StringExtras.h"
19 #include "llvm/ADT/TargetTuple.h"
1920 #include "llvm/ADT/Twine.h"
2021 #include "llvm/MC/MCAsmBackend.h"
2122 #include "llvm/MC/MCAsmInfo.h"
197198
198199 MCTargetStreamer *
199200 createAArch64ObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
200 const Triple &TT = STI.getTargetTriple();
201 const TargetTuple &TT = STI.getTargetTuple();
201202 if (TT.isOSBinFormatELF())
202203 return new AArch64TargetELFStreamer(S);
203204 return nullptr;
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "AArch64MCAsmInfo.h"
14 #include "llvm/ADT/Triple.h"
14 #include "llvm/ADT/TargetTuple.h"
1515 #include "llvm/MC/MCContext.h"
1616 #include "llvm/MC/MCExpr.h"
1717 #include "llvm/MC/MCStreamer.h"
6868 return MCBinaryExpr::createSub(Res, PC, Context);
6969 }
7070
71 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
72 if (T.getArch() == Triple::aarch64_be)
71 AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const TargetTuple &T) {
72 if (T.getArch() == TargetTuple::aarch64_be)
7373 IsLittleEndian = false;
7474
7575 // We prefer NEON instructions to be printed in the short form.
1919 namespace llvm {
2020 class MCStreamer;
2121 class Target;
22 class Triple;
22 class TargetTuple;
2323
2424 struct AArch64MCAsmInfoDarwin : public MCAsmInfoDarwin {
2525 explicit AArch64MCAsmInfoDarwin();
2929 };
3030
3131 struct AArch64MCAsmInfoELF : public MCAsmInfoELF {
32 explicit AArch64MCAsmInfoELF(const Triple &T);
32 explicit AArch64MCAsmInfoELF(const TargetTuple &TT);
3333 };
3434
3535 } // namespace llvm
3939 return X;
4040 }
4141
42 static MCSubtargetInfo *
43 createAArch64MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
42 static MCSubtargetInfo *createAArch64MCSubtargetInfo(const TargetTuple &TT,
43 StringRef CPU,
44 StringRef FS) {
4445 if (CPU.empty())
4546 CPU = "generic";
4647
4748 return createAArch64MCSubtargetInfoImpl(TT, CPU, FS);
4849 }
4950
50 static MCRegisterInfo *createAArch64MCRegisterInfo(const Triple &Triple) {
51 static MCRegisterInfo *createAArch64MCRegisterInfo(const TargetTuple &TT) {
5152 MCRegisterInfo *X = new MCRegisterInfo();
5253 InitAArch64MCRegisterInfo(X, AArch64::LR);
5354 return X;
5455 }
5556
5657 static MCAsmInfo *createAArch64MCAsmInfo(const MCRegisterInfo &MRI,
57 const Triple &TheTriple) {
58 const TargetTuple &TT) {
5859 MCAsmInfo *MAI;
59 if (TheTriple.isOSBinFormatMachO())
60 if (TT.isOSBinFormatMachO())
6061 MAI = new AArch64MCAsmInfoDarwin();
6162 else {
62 assert(TheTriple.isOSBinFormatELF() && "Only expect Darwin or ELF");
63 MAI = new AArch64MCAsmInfoELF(TheTriple);
63 assert(TT.isOSBinFormatELF() && "Only expect Darwin or ELF");
64 MAI = new AArch64MCAsmInfoELF(TT);
6465 }
6566
6667 // Initial state of the frame pointer is SP.
7172 return MAI;
7273 }
7374
74 static MCCodeGenInfo *createAArch64MCCodeGenInfo(const Triple &TT,
75 static MCCodeGenInfo *createAArch64MCCodeGenInfo(const TargetTuple &TT,
7576 Reloc::Model RM,
7677 CodeModel::Model CM,
7778 CodeGenOpt::Level OL) {
103104 return X;
104105 }
105106
106 static MCInstPrinter *createAArch64MCInstPrinter(const Triple &T,
107 static MCInstPrinter *createAArch64MCInstPrinter(const TargetTuple &TT,
107108 unsigned SyntaxVariant,
108109 const MCAsmInfo &MAI,
109110 const MCInstrInfo &MII,
116117 return nullptr;
117118 }
118119
119 static MCStreamer *createELFStreamer(const Triple &T, MCContext &Ctx,
120 static MCStreamer *createELFStreamer(const TargetTuple &TT, MCContext &Ctx,
120121 MCAsmBackend &TAB, raw_pwrite_stream &OS,
121122 MCCodeEmitter *Emitter, bool RelaxAll) {
122123 return createAArch64ELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
3030 class MCTargetStreamer;
3131 class StringRef;
3232 class Target;
33 class Triple;
33 class TargetTuple;
3434 class raw_ostream;
3535 class raw_pwrite_stream;
3636
4343 MCContext &Ctx);
4444 MCAsmBackend *createAArch64leAsmBackend(const Target &T,
4545 const MCRegisterInfo &MRI,
46 const Triple &TT, StringRef CPU);
46 const TargetTuple &TT, StringRef CPU);
4747 MCAsmBackend *createAArch64beAsmBackend(const Target &T,
4848 const MCRegisterInfo &MRI,
49 const Triple &TT, StringRef CPU);
49 const TargetTuple &TT, StringRef CPU);
5050
5151 MCObjectWriter *createAArch64ELFObjectWriter(raw_pwrite_stream &OS,
5252 uint8_t OSABI,
6262
6363 AMDGPUSubtarget::AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
6464 TargetMachine &TM)
65 : AMDGPUGenSubtargetInfo(TT, GPU, FS), DevName(GPU), Is64bit(false),
66 DumpCode(false), R600ALUInst(false), HasVertexCache(false),
67 TexVTXClauseSize(0), Gen(AMDGPUSubtarget::R600), FP64(false),
68 FP64Denormals(false), FP32Denormals(false), FastFMAF32(false),
69 CaymanISA(false), FlatAddressSpace(false), EnableIRStructurizer(true),
70 EnablePromoteAlloca(false), EnableIfCvt(true), EnableLoadStoreOpt(false),
71 EnableUnsafeDSOffsetFolding(false),
65 : AMDGPUGenSubtargetInfo(TargetTuple(TT), GPU, FS), DevName(GPU),
66 Is64bit(false), DumpCode(false), R600ALUInst(false),
67 HasVertexCache(false), TexVTXClauseSize(0), Gen(AMDGPUSubtarget::R600),
68 FP64(false), FP64Denormals(false), FP32Denormals(false),
69 FastFMAF32(false), CaymanISA(false), FlatAddressSpace(false),
70 EnableIRStructurizer(true), EnablePromoteAlloca(false), EnableIfCvt(true),
71 EnableLoadStoreOpt(false), EnableUnsafeDSOffsetFolding(false),
7272 WavefrontSize(0), CFALUBug(false), LocalMemorySize(0),
7373 EnableVGPRSpilling(false), SGPRInitBug(false), IsGCN(false),
7474 GCN1Encoding(false), GCN3Encoding(false), CIInsts(false), LDSBankCount(0),
173173
174174 MCAsmBackend *llvm::createAMDGPUAsmBackend(const Target &T,
175175 const MCRegisterInfo &MRI,
176 const Triple &TT, StringRef CPU) {
177 Triple TargetTriple(TT);
178
176 const TargetTuple &TT,
177 StringRef CPU) {
179178 // Use 64-bit ELF for amdgcn
180 return new ELFAMDGPUAsmBackend(T, TargetTriple.getArch() == Triple::amdgcn);
179 return new ELFAMDGPUAsmBackend(T, TT.getArch() == TargetTuple::amdgcn);
181180 }
1010 #include "AMDGPUMCAsmInfo.h"
1111
1212 using namespace llvm;
13 AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT) : MCAsmInfoELF() {
13 AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const TargetTuple &TT) : MCAsmInfoELF() {
1414 HasSingleParameterDotFile = false;
1515 //===------------------------------------------------------------------===//
1616 MaxInstLength = 16;
1616 #include "llvm/MC/MCAsmInfoELF.h"
1717 namespace llvm {
1818
19 class Triple;
19 class TargetTuple;
2020
2121 // If you need to create another MCAsmInfo class, which inherits from MCAsmInfo,
2222 // you will need to make sure your new class sets PrivateGlobalPrefix to
2525 // with 'L' as a local symbol.
2626 class AMDGPUMCAsmInfo : public MCAsmInfoELF {
2727 public:
28 explicit AMDGPUMCAsmInfo(const Triple &TT);
28 explicit AMDGPUMCAsmInfo(const TargetTuple &TT);
2929 };
3030 } // namespace llvm
3131 #endif
4343 return X;
4444 }
4545
46 static MCRegisterInfo *createAMDGPUMCRegisterInfo(const Triple &TT) {
46 static MCRegisterInfo *createAMDGPUMCRegisterInfo(const TargetTuple &TT) {
4747 MCRegisterInfo *X = new MCRegisterInfo();
4848 InitAMDGPUMCRegisterInfo(X, 0);
4949 return X;
5050 }
5151
52 static MCSubtargetInfo *
53 createAMDGPUMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
52 static MCSubtargetInfo *createAMDGPUMCSubtargetInfo(const TargetTuple &TT,
53 StringRef CPU,
54 StringRef FS) {
5455 return createAMDGPUMCSubtargetInfoImpl(TT, CPU, FS);
5556 }
5657
57 static MCCodeGenInfo *createAMDGPUMCCodeGenInfo(const Triple &TT,
58 static MCCodeGenInfo *createAMDGPUMCCodeGenInfo(const TargetTuple &TT,
5859 Reloc::Model RM,
5960 CodeModel::Model CM,
6061 CodeGenOpt::Level OL) {
6364 return X;
6465 }
6566
66 static MCInstPrinter *createAMDGPUMCInstPrinter(const Triple &T,
67 static MCInstPrinter *createAMDGPUMCInstPrinter(const TargetTuple &T,
6768 unsigned SyntaxVariant,
6869 const MCAsmInfo &MAI,
6970 const MCInstrInfo &MII,
2727 class MCRegisterInfo;
2828 class MCSubtargetInfo;
2929 class Target;
30 class Triple;
30 class TargetTuple;
3131 class raw_pwrite_stream;
3232 class raw_ostream;
3333
4343 MCContext &Ctx);
4444
4545 MCAsmBackend *createAMDGPUAsmBackend(const Target &T, const MCRegisterInfo &MRI,
46 const Triple &TT, StringRef CPU);
46 const TargetTuple &TT, StringRef CPU);
4747
4848 MCObjectWriter *createAMDGPUELFObjectWriter(bool Is64Bit,
4949 raw_pwrite_stream &OS);
557557 const Triple &TT = TM.getTargetTriple();
558558 StringRef CPU = TM.getTargetCPU();
559559 StringRef FS = TM.getTargetFeatureString();
560 std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPU);
560 std::string ArchFS = ARM_MC::ParseARMTargetTuple(TargetTuple(TT), CPU);
561561 if (!FS.empty()) {
562562 if (!ArchFS.empty())
563563 ArchFS = (Twine(ArchFS) + "," + FS).str();
8080 ARMSubtarget::ARMSubtarget(const Triple &TT, const std::string &CPU,
8181 const std::string &FS,
8282 const ARMBaseTargetMachine &TM, bool IsLittle)
83 : ARMGenSubtargetInfo(TT, CPU, FS), ARMProcFamily(Others),
83 : ARMGenSubtargetInfo(TargetTuple(TT), CPU, FS), ARMProcFamily(Others),
8484 ARMProcClass(None), stackAlignment(4), CPUString(CPU), IsLittle(IsLittle),
8585 TargetTriple(TT), Options(TM.Options), TM(TM),
8686 FrameLowering(initializeFrameLowering(CPU, FS)),
158158 // Insert the architecture feature derived from the target triple into the
159159 // feature string. This is important for setting features that are implied
160160 // based on the architecture version.
161 std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple, CPUString);
161 std::string ArchFS =
162 ARM_MC::ParseARMTargetTuple(TargetTuple(TargetTriple), CPUString);
162163 if (!FS.empty()) {
163164 if (!ArchFS.empty())
164165 ArchFS = (Twine(ArchFS) + "," + FS).str();
778778
779779 MCAsmBackend *llvm::createARMAsmBackend(const Target &T,
780780 const MCRegisterInfo &MRI,
781 const Triple &TheTriple, StringRef CPU,
781 const TargetTuple &TT, StringRef CPU,
782782 bool isLittle) {
783 switch (TheTriple.getObjectFormat()) {
783 switch (TT.getObjectFormat()) {
784784 default:
785785 llvm_unreachable("unsupported object format");
786 case Triple::MachO: {
787 MachO::CPUSubTypeARM CS = getMachOSubTypeFromArch(TheTriple.getArchName());
788 return new ARMAsmBackendDarwin(T, TheTriple, CS);
789 }
790 case Triple::COFF:
791 assert(TheTriple.isOSWindows() && "non-Windows ARM COFF is not supported");
792 return new ARMAsmBackendWinCOFF(T, TheTriple);
793 case Triple::ELF:
794 assert(TheTriple.isOSBinFormatELF() && "using ELF for non-ELF target");
795 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
796 return new ARMAsmBackendELF(T, TheTriple, OSABI, isLittle);
786 case TargetTuple::MachO: {
787 MachO::CPUSubTypeARM CS = getMachOSubTypeFromArch(TT.getArchName());
788 return new ARMAsmBackendDarwin(T, TT, CS);
789 }
790 case TargetTuple::COFF:
791 assert(TT.isOSWindows() && "non-Windows ARM COFF is not supported");
792 return new ARMAsmBackendWinCOFF(T, TT);
793 case TargetTuple::ELF:
794 assert(TT.isOSBinFormatELF() && "using ELF for non-ELF target");
795 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
796 return new ARMAsmBackendELF(T, TT, OSABI, isLittle);
797797 }
798798 }
799799
800800 MCAsmBackend *llvm::createARMLEAsmBackend(const Target &T,
801801 const MCRegisterInfo &MRI,
802 const Triple &TT, StringRef CPU) {
802 const TargetTuple &TT,
803 StringRef CPU) {
803804 return createARMAsmBackend(T, MRI, TT, CPU, true);
804805 }
805806
806807 MCAsmBackend *llvm::createARMBEAsmBackend(const Target &T,
807808 const MCRegisterInfo &MRI,
808 const Triple &TT, StringRef CPU) {
809 const TargetTuple &TT,
810 StringRef CPU) {
809811 return createARMAsmBackend(T, MRI, TT, CPU, false);
810812 }
811813
812814 MCAsmBackend *llvm::createThumbLEAsmBackend(const Target &T,
813815 const MCRegisterInfo &MRI,
814 const Triple &TT, StringRef CPU) {
816 const TargetTuple &TT,
817 StringRef CPU) {
815818 return createARMAsmBackend(T, MRI, TT, CPU, true);
816819 }
817820
818821 MCAsmBackend *llvm::createThumbBEAsmBackend(const Target &T,
819822 const MCRegisterInfo &MRI,
820 const Triple &TT, StringRef CPU) {
823 const TargetTuple &TT,
824 StringRef CPU) {
821825 return createARMAsmBackend(T, MRI, TT, CPU, false);
822826 }
2222 bool isThumbMode; // Currently emitting Thumb code.
2323 bool IsLittleEndian; // Big or little endian.
2424 public:
25 ARMAsmBackend(const Target &T, const Triple &TT, bool IsLittle)
25 ARMAsmBackend(const Target &T, const TargetTuple &TT, bool IsLittle)
2626 : MCAsmBackend(), STI(ARM_MC::createARMMCSubtargetInfo(TT, "", "")),
2727 isThumbMode(TT.getArchName().startswith("thumb")),
2828 IsLittleEndian(IsLittle) {}
1717 class ARMAsmBackendDarwin : public ARMAsmBackend {
1818 public:
1919 const MachO::CPUSubTypeARM Subtype;
20 ARMAsmBackendDarwin(const Target &T, const Triple &TT,
20 ARMAsmBackendDarwin(const Target &T, const TargetTuple &TT,
2121 MachO::CPUSubTypeARM st)
2222 : ARMAsmBackend(T, TT, /* IsLittleEndian */ true), Subtype(st) {
2323 HasDataInCodeSupport = true;
1414 class ARMAsmBackendELF : public ARMAsmBackend {
1515 public:
1616 uint8_t OSABI;
17 ARMAsmBackendELF(const Target &T, const Triple &TT, uint8_t OSABI,
17 ARMAsmBackendELF(const Target &T, const TargetTuple &TT, uint8_t OSABI,
1818 bool IsLittle)
1919 : ARMAsmBackend(T, TT, IsLittle), OSABI(OSABI) {}
2020
1414 namespace {
1515 class ARMAsmBackendWinCOFF : public ARMAsmBackend {
1616 public:
17 ARMAsmBackendWinCOFF(const Target &T, const Triple &TheTriple)
18 : ARMAsmBackend(T, TheTriple, true) {}
17 ARMAsmBackendWinCOFF(const Target &T, const TargetTuple &TT)
18 : ARMAsmBackend(T, TT, true) {}
1919 MCObjectWriter *createObjectWriter(raw_pwrite_stream &OS) const override {
2020 return createARMWinCOFFObjectWriter(OS, /*Is64Bit=*/false);
2121 }
13601360
13611361 MCTargetStreamer *createARMObjectTargetStreamer(MCStreamer &S,
13621362 const MCSubtargetInfo &STI) {
1363 const Triple &TT = STI.getTargetTriple();
1363 const TargetTuple &TT = STI.getTargetTuple();
13641364 if (TT.isOSBinFormatELF())
13651365 return new ARMTargetELFStreamer(S);
13661366 return new ARMTargetStreamer(S);
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "ARMMCAsmInfo.h"
14 #include "llvm/ADT/Triple.h"
14 #include "llvm/ADT/TargetTuple.h"
1515 #include "llvm/Support/CommandLine.h"
1616
1717 using namespace llvm;
1818
1919 void ARMMCAsmInfoDarwin::anchor() { }
2020
21 ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin(const Triple &TheTriple) {
22 if ((TheTriple.getArch() == Triple::armeb) ||
23 (TheTriple.getArch() == Triple::thumbeb))
21 ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin(const TargetTuple &TT) {
22 if ((TT.getArch() == TargetTuple::armeb) ||
23 (TT.getArch() == TargetTuple::thumbeb))
2424 IsLittleEndian = false;
2525
2626 Data64bitsDirective = nullptr;
3939
4040 void ARMELFMCAsmInfo::anchor() { }
4141
42 ARMELFMCAsmInfo::ARMELFMCAsmInfo(const Triple &TheTriple) {
43 if ((TheTriple.getArch() == Triple::armeb) ||
44 (TheTriple.getArch() == Triple::thumbeb))
42 ARMELFMCAsmInfo::ARMELFMCAsmInfo(const TargetTuple &TT) {
43 if ((TT.getArch() == TargetTuple::armeb) ||
44 (TT.getArch() == TargetTuple::thumbeb))
4545 IsLittleEndian = false;
4646
4747 // ".comm align is in bytes but .align is pow-2."
5555 SupportsDebugInformation = true;
5656
5757 // Exceptions handling
58 switch (TheTriple.getOS()) {
59 case Triple::Bitrig:
60 case Triple::NetBSD:
58 switch (TT.getOS()) {
59 case TargetTuple::Bitrig:
60 case TargetTuple::NetBSD:
6161 ExceptionsType = ExceptionHandling::DwarfCFI;
6262 break;
6363 default:
1818 #include "llvm/MC/MCAsmInfoELF.h"
1919
2020 namespace llvm {
21 class Triple;
21 class TargetTuple;
2222
2323 class ARMMCAsmInfoDarwin : public MCAsmInfoDarwin {
2424 virtual void anchor();
2525
2626 public:
27 explicit ARMMCAsmInfoDarwin(const Triple &TheTriple);
27 explicit ARMMCAsmInfoDarwin(const TargetTuple &TT);
2828 };
2929
3030 class ARMELFMCAsmInfo : public MCAsmInfoELF {
3131 void anchor() override;
3232
3333 public:
34 explicit ARMELFMCAsmInfo(const Triple &TT);
34 explicit ARMELFMCAsmInfo(const TargetTuple &TT);
3535
3636 void setUseIntegratedAssembler(bool Value) override;
3737 };
5656 return isThumb(STI) && STI.getFeatureBits()[ARM::FeatureThumb2];
5757 }
5858 bool isTargetMachO(const MCSubtargetInfo &STI) const {
59 const Triple &TT = STI.getTargetTriple();
59 const TargetTuple &TT = STI.getTargetTuple();
6060 return TT.isOSBinFormatMachO();
6161 }
6262
1414 #include "ARMMCAsmInfo.h"
1515 #include "ARMMCTargetDesc.h"
1616 #include "InstPrinter/ARMInstPrinter.h"
17 #include "llvm/ADT/Triple.h"
17 #include "llvm/ADT/TargetTuple.h"
1818 #include "llvm/MC/MCCodeGenInfo.h"
1919 #include "llvm/MC/MCELFStreamer.h"
2020 #include "llvm/MC/MCInstrAnalysis.h"
129129 #define GET_SUBTARGETINFO_MC_DESC
130130 #include "ARMGenSubtargetInfo.inc"
131131
132 std::string ARM_MC::ParseARMTriple(const Triple &TT, StringRef CPU) {
133 bool isThumb =
134 TT.getArch() == Triple::thumb || TT.getArch() == Triple::thumbeb;
132 std::string ARM_MC::ParseARMTargetTuple(const TargetTuple &TT, StringRef CPU) {
133 bool isThumb = TT.getArch() == TargetTuple::thumb ||
134 TT.getArch() == TargetTuple::thumbeb;
135135
136136 bool NoCPU = CPU == "generic" || CPU.empty();
137137 std::string ARMArchFeature;
138138 switch (TT.getSubArch()) {
139139 default:
140140 llvm_unreachable("invalid sub-architecture for ARM");
141 case Triple::ARMSubArch_v8:
141 case TargetTuple::ARMSubArch_v8:
142142 if (NoCPU)
143143 // v8a: FeatureDB, FeatureFPARMv8, FeatureNEON, FeatureDSPThumb2,
144144 // FeatureMP, FeatureHWDiv, FeatureHWDivARM, FeatureTrustZone,
149149 // Use CPU to figure out the exact features
150150 ARMArchFeature = "+v8";
151151 break;
152 case Triple::ARMSubArch_v8_1a:
152 case TargetTuple::ARMSubArch_v8_1a:
153153 if (NoCPU)
154154 // v8.1a: FeatureDB, FeatureFPARMv8, FeatureNEON, FeatureDSPThumb2,
155155 // FeatureMP, FeatureHWDiv, FeatureHWDivARM, FeatureTrustZone,
160160 // Use CPU to figure out the exact features
161161 ARMArchFeature = "+v8.1a";
162162 break;
163 case Triple::ARMSubArch_v7m:
163 case TargetTuple::ARMSubArch_v7m:
164164 isThumb = true;
165165 if (NoCPU)
166166 // v7m: FeatureNoARM, FeatureDB, FeatureHWDiv, FeatureMClass
169169 // Use CPU to figure out the exact features.
170170 ARMArchFeature = "+v7";
171171 break;
172 case Triple::ARMSubArch_v7em:
172 case TargetTuple::ARMSubArch_v7em:
173173 if (NoCPU)
174174 // v7em: FeatureNoARM, FeatureDB, FeatureHWDiv, FeatureDSPThumb2,
175175 // FeatureT2XtPk, FeatureMClass
178178 // Use CPU to figure out the exact features.
179179 ARMArchFeature = "+v7";
180180 break;
181 case Triple::ARMSubArch_v7s:
181 case TargetTuple::ARMSubArch_v7s:
182182 if (NoCPU)
183183 // v7s: FeatureNEON, FeatureDB, FeatureDSPThumb2, FeatureHasRAS
184184 // Swift
187187 // Use CPU to figure out the exact features.
188188 ARMArchFeature = "+v7";
189189 break;
190 case Triple::ARMSubArch_v7:
190 case TargetTuple::ARMSubArch_v7:
191191 // v7 CPUs have lots of different feature sets. If no CPU is specified,
192192 // then assume v7a (e.g. cortex-a8) feature set. Otherwise, return
193193 // the "minimum" feature set and use CPU string to figure out the exact
199199 // Use CPU to figure out the exact features.
200200 ARMArchFeature = "+v7";
201201 break;
202 case Triple::ARMSubArch_v6t2:
202 case TargetTuple::ARMSubArch_v6t2:
203203 ARMArchFeature = "+v6t2";
204204 break;
205 case Triple::ARMSubArch_v6k:
205 case TargetTuple::ARMSubArch_v6k:
206206 ARMArchFeature = "+v6k";
207207 break;
208 case Triple::ARMSubArch_v6m:
208 case TargetTuple::ARMSubArch_v6m:
209209 isThumb = true;
210210 if (NoCPU)
211211 // v6m: FeatureNoARM, FeatureMClass
213213 else
214214 ARMArchFeature = "+v6";
215215 break;
216 case Triple::ARMSubArch_v6:
216 case TargetTuple::ARMSubArch_v6:
217217 ARMArchFeature = "+v6";
218218 break;
219 case Triple::ARMSubArch_v5te:
219 case TargetTuple::ARMSubArch_v5te:
220220 ARMArchFeature = "+v5te";
221221 break;
222 case Triple::ARMSubArch_v5:
222 case TargetTuple::ARMSubArch_v5:
223223 ARMArchFeature = "+v5t";
224224 break;
225 case Triple::ARMSubArch_v4t:
225 case TargetTuple::ARMSubArch_v4t:
226226 ARMArchFeature = "+v4t";
227227 break;
228 case Triple::NoSubArch:
228 case TargetTuple::NoSubArch:
229229 break;
230230 }
231231
246246 return ARMArchFeature;
247247 }
248248
249 MCSubtargetInfo *ARM_MC::createARMMCSubtargetInfo(const Triple &TT,
249 MCSubtargetInfo *ARM_MC::createARMMCSubtargetInfo(const TargetTuple &TT,
250250 StringRef CPU, StringRef FS) {
251 std::string ArchFS = ARM_MC::ParseARMTriple(TT, CPU);
251 std::string ArchFS = ARM_MC::ParseARMTargetTuple(TT, CPU);
252252 if (!FS.empty()) {
253253 if (!ArchFS.empty())
254254 ArchFS = (Twine(ArchFS) + "," + FS).str();
265265 return X;
266266 }
267267
268 static MCRegisterInfo *createARMMCRegisterInfo(const Triple &Triple) {
268 static MCRegisterInfo *createARMMCRegisterInfo(const TargetTuple &TT) {
269269 MCRegisterInfo *X = new MCRegisterInfo();
270270 InitARMMCRegisterInfo(X, ARM::LR, 0, 0, ARM::PC);
271271 return X;
272272 }
273273
274274 static MCAsmInfo *createARMMCAsmInfo(const MCRegisterInfo &MRI,
275 const Triple &TheTriple) {
275 const TargetTuple &TT) {
276276 MCAsmInfo *MAI;
277 if (TheTriple.isOSDarwin() || TheTriple.isOSBinFormatMachO())
278 MAI = new ARMMCAsmInfoDarwin(TheTriple);
279 else if (TheTriple.isWindowsMSVCEnvironment())
277 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
278 MAI = new ARMMCAsmInfoDarwin(TT);
279 else if (TT.isWindowsMSVCEnvironment())
280280 MAI = new ARMCOFFMCAsmInfoMicrosoft();
281 else if (TheTriple.isOSWindows())
281 else if (TT.isOSWindows())
282282 MAI = new ARMCOFFMCAsmInfoGNU();
283283 else
284 MAI = new ARMELFMCAsmInfo(TheTriple);
284 MAI = new ARMELFMCAsmInfo(TT);
285285
286286 unsigned Reg = MRI.getDwarfRegNum(ARM::SP, true);
287287 MAI->addInitialFrameState(MCCFIInstruction::createDefCfa(nullptr, Reg, 0));
289289 return MAI;
290290 }
291291
292 static MCCodeGenInfo *createARMMCCodeGenInfo(const Triple &TT, Reloc::Model RM,
292 static MCCodeGenInfo *createARMMCCodeGenInfo(const TargetTuple &TT,
293 Reloc::Model RM,
293294 CodeModel::Model CM,
294295 CodeGenOpt::Level OL) {
295296 MCCodeGenInfo *X = new MCCodeGenInfo();
301302 return X;
302303 }
303304
304 static MCStreamer *createELFStreamer(const Triple &T, MCContext &Ctx,
305 static MCStreamer *createELFStreamer(const TargetTuple &TT, MCContext &Ctx,
305306 MCAsmBackend &MAB, raw_pwrite_stream &OS,
306307 MCCodeEmitter *Emitter, bool RelaxAll) {
307308 return createARMELFStreamer(Ctx, MAB, OS, Emitter, false,
308 T.getArch() == Triple::thumb);
309 TT.getArch() == TargetTuple::thumb);
309310 }
310311
311312 static MCStreamer *createARMMachOStreamer(MCContext &Ctx, MCAsmBackend &MAB,
315316 return createMachOStreamer(Ctx, MAB, OS, Emitter, false, DWARFMustBeAtTheEnd);
316317 }
317318
318 static MCInstPrinter *createARMMCInstPrinter(const Triple &T,
319 static MCInstPrinter *createARMMCInstPrinter(const TargetTuple &TT,
319320 unsigned SyntaxVariant,
320321 const MCAsmInfo &MAI,
321322 const MCInstrInfo &MII,
325326 return nullptr;
326327 }
327328
328 static MCRelocationInfo *createARMMCRelocationInfo(const Triple &TT,
329 static MCRelocationInfo *createARMMCRelocationInfo(const TargetTuple &TT,
329330 MCContext &Ctx) {
330331 if (TT.isOSBinFormatMachO())
331332 return createARMMachORelocationInfo(Ctx);
3131 class MCTargetStreamer;
3232 class StringRef;
3333 class Target;
34 class Triple;
34 class TargetTuple;
3535 class raw_ostream;
3636 class raw_pwrite_stream;
3737
3939 extern Target TheARMBETarget, TheThumbBETarget;
4040
4141 namespace ARM_MC {
42 std::string ParseARMTriple(const Triple &TT, StringRef CPU);
42 std::string ParseARMTargetTuple(const TargetTuple &TT, StringRef CPU);
4343
4444 /// Create a ARM MCSubtargetInfo instance. This is exposed so Asm parser, etc.
4545 /// do not need to go through TargetRegistry.
46 MCSubtargetInfo *createARMMCSubtargetInfo(const Triple &TT, StringRef CPU,
46 MCSubtargetInfo *createARMMCSubtargetInfo(const TargetTuple &TT, StringRef CPU,
4747 StringRef FS);
4848 }
4949
6464 MCContext &Ctx);
6565
6666 MCAsmBackend *createARMAsmBackend(const Target &T, const MCRegisterInfo &MRI,
67 const Triple &TT, StringRef CPU,
67 const TargetTuple &TT, StringRef CPU,
6868 bool IsLittleEndian);
6969
7070 MCAsmBackend *createARMLEAsmBackend(const Target &T, const MCRegisterInfo &MRI,
71 const Triple &TT, StringRef CPU);
71 const TargetTuple &TT, StringRef CPU);
7272
7373 MCAsmBackend *createARMBEAsmBackend(const Target &T, const MCRegisterInfo &MRI,
74 const Triple &TT, StringRef CPU);
74 const TargetTuple &TT, StringRef CPU);
7575
7676 MCAsmBackend *createThumbLEAsmBackend(const Target &T,
7777 const MCRegisterInfo &MRI,
78 const Triple &TT, StringRef CPU);
78 const TargetTuple &TT, StringRef CPU);
7979
8080 MCAsmBackend *createThumbBEAsmBackend(const Target &T,
8181 const MCRegisterInfo &MRI,
82 const Triple &TT, StringRef CPU);
82 const TargetTuple &TT, StringRef CPU);
8383
8484 // Construct a PE/COFF machine code streamer which will generate a PE/COFF
8585 // object file.
2626
2727 BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU,
2828 const std::string &FS, const TargetMachine &TM)
29 : BPFGenSubtargetInfo(TT, CPU, FS), InstrInfo(), FrameLowering(*this),
30 TLInfo(TM, *this) {}
29 : BPFGenSubtargetInfo(TargetTuple(TT), CPU, FS), InstrInfo(),
30 FrameLowering(*this), TLInfo(TM, *this) {}
9494
9595 MCAsmBackend *llvm::createBPFAsmBackend(const Target &T,
9696 const MCRegisterInfo &MRI,
97 const Triple &TT, StringRef CPU) {
97 const TargetTuple &TT, StringRef CPU) {
9898 return new BPFAsmBackend(/*IsLittleEndian=*/true);
9999 }
100100
101101 MCAsmBackend *llvm::createBPFbeAsmBackend(const Target &T,
102102 const MCRegisterInfo &MRI,
103 const Triple &TT, StringRef CPU) {
103 const TargetTuple &TT,
104 StringRef CPU) {
104105 return new BPFAsmBackend(/*IsLittleEndian=*/false);
105106 }
1515
1616 #include "llvm/ADT/StringRef.h"
1717 #include "llvm/MC/MCAsmInfo.h"
18 #include "llvm/ADT/Triple.h"
18 #include "llvm/ADT/TargetTuple.h"
1919
2020 namespace llvm {
2121 class Target;
22 class Triple;
2322
2423 class BPFMCAsmInfo : public MCAsmInfo {
2524 public:
26 explicit BPFMCAsmInfo(const Triple &TT) {
27 if (TT.getArch() == Triple::bpfeb)
25 explicit BPFMCAsmInfo(const TargetTuple &TT) {
26 if (TT.getArch() == TargetTuple::bpfeb)
2827 IsLittleEndian = false;
2928
3029 PrivateGlobalPrefix = ".L";
3939 return X;
4040 }
4141
42 static MCRegisterInfo *createBPFMCRegisterInfo(const Triple &TT) {
42 static MCRegisterInfo *createBPFMCRegisterInfo(const TargetTuple &TT) {
4343 MCRegisterInfo *X = new MCRegisterInfo();
4444 InitBPFMCRegisterInfo(X, BPF::R11 /* RAReg doesn't exist */);
4545 return X;
4646 }
4747
48 static MCSubtargetInfo *createBPFMCSubtargetInfo(const Triple &TT,
48 static MCSubtargetInfo *createBPFMCSubtargetInfo(const TargetTuple &TT,
4949 StringRef CPU, StringRef FS) {
5050 return createBPFMCSubtargetInfoImpl(TT, CPU, FS);
5151 }
5252
53 static MCCodeGenInfo *createBPFMCCodeGenInfo(const Triple &TT, Reloc::Model RM,
53 static MCCodeGenInfo *createBPFMCCodeGenInfo(const TargetTuple &TT,
54 Reloc::Model RM,
5455 CodeModel::Model CM,
5556 CodeGenOpt::Level OL) {
5657 MCCodeGenInfo *X = new MCCodeGenInfo();
5859 return X;
5960 }
6061
61 static MCStreamer *createBPFMCStreamer(const Triple &T,
62 MCContext &Ctx, MCAsmBackend &MAB,
63 raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
64 bool RelaxAll) {
62 static MCStreamer *createBPFMCStreamer(const TargetTuple &TT, MCContext &Ctx,
63 MCAsmBackend &MAB, raw_pwrite_stream &OS,
64 MCCodeEmitter *Emitter, bool RelaxAll) {
6565 return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
6666 }
6767
68 static MCInstPrinter *createBPFMCInstPrinter(const Triple &T,
68 static MCInstPrinter *createBPFMCInstPrinter(const TargetTuple &TT,
6969 unsigned SyntaxVariant,
7070 const MCAsmInfo &MAI,
7171 const MCInstrInfo &MII,
2626 class MCSubtargetInfo;
2727 class StringRef;
2828 class Target;
29 class Triple;
29 class TargetTuple;
3030 class raw_ostream;
3131 class raw_pwrite_stream;
3232
4242 MCContext &Ctx);
4343
4444 MCAsmBackend *createBPFAsmBackend(const Target &T, const MCRegisterInfo &MRI,
45 const Triple &TT, StringRef CPU);
45 const TargetTuple &TT, StringRef CPU);
4646 MCAsmBackend *createBPFbeAsmBackend(const Target &T, const MCRegisterInfo &MRI,
47 const Triple &TT, StringRef CPU);
47 const TargetTuple &TT, StringRef CPU);
4848
4949 MCObjectWriter *createBPFELFObjectWriter(raw_pwrite_stream &OS,
5050 uint8_t OSABI, bool IsLittleEndian);
7171
7272 HexagonSubtarget::HexagonSubtarget(const Triple &TT, StringRef CPU,
7373 StringRef FS, const TargetMachine &TM)
74 : HexagonGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
74 : HexagonGenSubtargetInfo(TargetTuple(TT), CPU, FS), CPUString(CPU),
7575 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
7676 FrameLowering() {
7777
308308 namespace llvm {
309309 MCAsmBackend *createHexagonAsmBackend(Target const &T,
310310 MCRegisterInfo const & /*MRI*/,
311 const Triple &TT, StringRef CPU) {
311 const TargetTuple &TT, StringRef CPU) {
312312 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
313313 return new HexagonAsmBackend(T, OSABI, CPU);
314314 }
1717 // Pin the vtable to this file.
1818 void HexagonMCAsmInfo::anchor() {}
1919
20 HexagonMCAsmInfo::HexagonMCAsmInfo(const Triple &TT) {
20 HexagonMCAsmInfo::HexagonMCAsmInfo(const TargetTuple &TT) {
2121 Data16bitsDirective = "\t.half\t";
2222 Data32bitsDirective = "\t.word\t";
2323 Data64bitsDirective = nullptr; // .xword is only supported by V9.
1717 #include "llvm/MC/MCAsmInfoELF.h"
1818
1919 namespace llvm {
20 class Triple;
20 class TargetTuple;
2121
2222 class HexagonMCAsmInfo : public MCAsmInfoELF {
2323 void anchor() override;
2424
2525 public:
26 explicit HexagonMCAsmInfo(const Triple &TT);
26 explicit HexagonMCAsmInfo(const TargetTuple &TT);
2727 };
2828
2929 } // namespace llvm
4545 return X;
4646 }
4747
48 static MCRegisterInfo *createHexagonMCRegisterInfo(const Triple &TT) {
48 static MCRegisterInfo *createHexagonMCRegisterInfo(const TargetTuple &TT) {
4949 MCRegisterInfo *X = new MCRegisterInfo();
5050 InitHexagonMCRegisterInfo(X, Hexagon::R0);
5151 return X;
5252 }
5353
54 static MCSubtargetInfo *
55 createHexagonMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
54 static MCSubtargetInfo *createHexagonMCSubtargetInfo(const TargetTuple &TT,
55 StringRef CPU,
56 StringRef FS) {
5657 return createHexagonMCSubtargetInfoImpl(TT, CPU, FS);
5758 }
5859
137138 }
138139
139140 static MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI,
140 const Triple &TT) {
141 const TargetTuple &TT) {
141142 MCAsmInfo *MAI = new HexagonMCAsmInfo(TT);
142143
143144 // VirtualFP = (R30 + #0).
148149 return MAI;
149150 }
150151
151 static MCCodeGenInfo *createHexagonMCCodeGenInfo(const Triple &TT,
152 static MCCodeGenInfo *createHexagonMCCodeGenInfo(const TargetTuple &TT,
152153 Reloc::Model RM,
153154 CodeModel::Model CM,
154155 CodeGenOpt::Level OL) {
159160 return X;
160161 }
161162
162 static MCInstPrinter *createHexagonMCInstPrinter(const Triple &T,
163 static MCInstPrinter *createHexagonMCInstPrinter(const TargetTuple &TT,
163164 unsigned SyntaxVariant,
164165 const MCAsmInfo &MAI,
165166 const MCInstrInfo &MII,
177178 return new HexagonTargetAsmStreamer(S, OS, IsVerboseAsm, *InstPrint);
178179 }
179180
180 static MCStreamer *createMCStreamer(Triple const &T, MCContext &Context,
181 static MCStreamer *createMCStreamer(const TargetTuple &TT, MCContext &Context,
181182 MCAsmBackend &MAB, raw_pwrite_stream &OS,
182183 MCCodeEmitter *Emitter, bool RelaxAll) {
183184 return createHexagonELFStreamer(Context, MAB, OS, Emitter);
2626 class MCRegisterInfo;
2727 class MCSubtargetInfo;
2828 class Target;
29 class Triple;
29 class TargetTuple;
3030 class StringRef;
3131 class raw_ostream;
3232 class raw_pwrite_stream;
4343
4444 MCAsmBackend *createHexagonAsmBackend(Target const &T,
4545 MCRegisterInfo const &MRI,
46 const Triple &TT, StringRef CPU);
46 const TargetTuple &TT, StringRef CPU);
4747
4848 MCObjectWriter *createHexagonELFObjectWriter(raw_pwrite_stream &OS,
4949 uint8_t OSABI, StringRef CPU);
1515
1616 void MSP430MCAsmInfo::anchor() { }
1717
18 MSP430MCAsmInfo::MSP430MCAsmInfo(const Triple &TT) {
18 MSP430MCAsmInfo::MSP430MCAsmInfo(const TargetTuple &TT) {
1919 PointerSize = CalleeSaveStackSlotSize = 2;
2020
2121 CommentString = ";";
1616 #include "llvm/MC/MCAsmInfoELF.h"
1717
1818 namespace llvm {
19 class Triple;
19 class TargetTuple;
2020
2121 class MSP430MCAsmInfo : public MCAsmInfoELF {
2222 void anchor() override;
2323
2424 public:
25 explicit MSP430MCAsmInfo(const Triple &TT);
25 explicit MSP430MCAsmInfo(const TargetTuple &TT);
2626 };
2727
2828 } // namespace llvm
3636 return X;
3737 }
3838
39 static MCRegisterInfo *createMSP430MCRegisterInfo(const Triple &TT) {
39 static MCRegisterInfo *createMSP430MCRegisterInfo(const TargetTuple &TT) {
4040 MCRegisterInfo *X = new MCRegisterInfo();
4141 InitMSP430MCRegisterInfo(X, MSP430::PC);
4242 return X;
4343 }
4444
45 static MCSubtargetInfo *
46 createMSP430MCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
45 static MCSubtargetInfo *createMSP430MCSubtargetInfo(const TargetTuple &TT,
46 StringRef CPU,
47 StringRef FS) {
4748 return createMSP430MCSubtargetInfoImpl(TT, CPU, FS);
4849 }
4950
50 static MCCodeGenInfo *createMSP430MCCodeGenInfo(const Triple &TT,
51 static MCCodeGenInfo *createMSP430MCCodeGenInfo(const TargetTuple &TT,
5152 Reloc::Model RM,
5253 CodeModel::Model CM,
5354 CodeGenOpt::Level OL) {
5657 return X;
5758 }
5859
59 static MCInstPrinter *createMSP430MCInstPrinter(const Triple &T,
60 static MCInstPrinter *createMSP430MCInstPrinter(const TargetTuple &T,
6061 unsigned SyntaxVariant,
6162 const MCAsmInfo &MAI,
6263 const MCInstrInfo &MII,
3232
3333 MSP430Subtarget::MSP430Subtarget(const Triple &TT, const std::string &CPU,
3434 const std::string &FS, const TargetMachine &TM)
35 : MSP430GenSubtargetInfo(TT, CPU, FS), FrameLowering(),
35 : MSP430GenSubtargetInfo(TargetTuple(TT), CPU, FS), FrameLowering(),
3636 InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this) {}
374374 MipsAsmParser(MCSubtargetInfo &sti, MCAsmParser &parser,
375375 const MCInstrInfo &MII, const MCTargetOptions &Options)
376376 : MCTargetAsmParser(Options), STI(sti),
377 ABI(MipsABIInfo::computeTargetABI(Triple(sti.getTargetTriple()),
378 sti.getCPU(), Options)) {
377 ABI(MipsABIInfo::computeTargetABI(sti.getTargetTuple(), sti.getCPU(),
378 Options)) {
379379 MCAsmParserExtension::Initialize(parser);
380380
381381 parser.addAliasForDirective(".asciiz", ".asciz");
401401 IsPicEnabled =
402402 (getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_);
403403
404 Triple TheTriple(sti.getTargetTriple());
405 if ((TheTriple.getArch() == Triple::mips) ||
406 (TheTriple.getArch() == Triple::mips64))
404 const TargetTuple &TT = sti.getTargetTuple();
405 if ((TT.getArch() == TargetTuple::mips) ||
406 (TT.getArch() == TargetTuple::mips64))
407407 IsLittleEndian = false;
408408 else
409409 IsLittleEndian = true;
4646 llvm_unreachable("Unhandled ABI");
4747 }
4848
49 MipsABIInfo MipsABIInfo::computeTargetABI(const Triple &TT, StringRef CPU,
49 MipsABIInfo MipsABIInfo::computeTargetABI(const TargetTuple &TT, StringRef CPU,
5050 const MCTargetOptions &Options) {
5151 if (Options.getABIName().startswith("o32"))
5252 return MipsABIInfo::O32();
6363 // used and not shared in a couple of other places. This needs unifying
6464 // at some level.
6565 if (CPU.empty() || CPU == "generic") {
66 if (TT.getArch() == Triple::mips || TT.getArch() == Triple::mipsel)
66 if (TT.getArch() == TargetTuple::mips ||
67 TT.getArch() == TargetTuple::mipsel)
6768 CPU = "mips32";
6869 else
6970 CPU = "mips64";
1010 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSABIINFO_H
1111
1212 #include "llvm/ADT/ArrayRef.h"
13 #include "llvm/ADT/Triple.h"
13 #include "llvm/ADT/TargetTuple.h"
1414 #include "llvm/IR/CallingConv.h"
1515 #include "llvm/MC/MCRegisterInfo.h"
1616
3535 static MipsABIInfo N32() { return MipsABIInfo(ABI::N32); }
3636 static MipsABIInfo N64() { return MipsABIInfo(ABI::N64); }
3737 static MipsABIInfo EABI() { return MipsABIInfo(ABI::EABI); }
38 static MipsABIInfo computeTargetABI(const Triple &TT, StringRef CPU,
38 static MipsABIInfo computeTargetABI(const TargetTuple &TT, StringRef CPU,
3939 const MCTargetOptions &Options);
4040
4141 bool IsKnown() const { return ThisABI != ABI::Unknown; }
410410 // MCAsmBackend
411411 MCAsmBackend *llvm::createMipsAsmBackendEL32(const Target &T,
412412 const MCRegisterInfo &MRI,
413 const Triple &TT, StringRef CPU) {
413 const TargetTuple &TT,
414 StringRef CPU) {
414415 return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ true,
415416 /*Is64Bit*/ false);
416417 }
417418
418419 MCAsmBackend *llvm::createMipsAsmBackendEB32(const Target &T,
419420 const MCRegisterInfo &MRI,
420 const Triple &TT, StringRef CPU) {
421 const TargetTuple &TT,
422 StringRef CPU) {
421423 return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ false,
422424 /*Is64Bit*/ false);
423425 }
424426
425427 MCAsmBackend *llvm::createMipsAsmBackendEL64(const Target &T,
426428 const MCRegisterInfo &MRI,
427 const Triple &TT, StringRef CPU) {
429 const TargetTuple &TT,
430 StringRef CPU) {
428431 return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ true, /*Is64Bit*/ true);
429432 }
430433
431434 MCAsmBackend *llvm::createMipsAsmBackendEB64(const Target &T,
432435 const MCRegisterInfo &MRI,
433 const Triple &TT, StringRef CPU) {
436 const TargetTuple &TT,
437 StringRef CPU) {
434438 return new MipsAsmBackend(T, TT.getOS(), /*IsLittle*/ false,
435439 /*Is64Bit*/ true);
436440 }
1515 #define LLVM_LIB_TARGET_MIPS_MCTARGETDESC_MIPSASMBACKEND_H
1616
1717 #include "MCTargetDesc/MipsFixupKinds.h"
18 #include "llvm/ADT/Triple.h"
18 #include "llvm/ADT/TargetTuple.h"
1919 #include "llvm/MC/MCAsmBackend.h"
2020
2121 namespace llvm {
2626 class MCObjectWriter;
2727
2828 class MipsAsmBackend : public MCAsmBackend {
29 Triple::OSType OSType;
29 TargetTuple::OSType OSType;
3030 bool IsLittle; // Big or little endian
3131 bool Is64Bit; // 32 or 64 bit words
3232
3333 public:
34 MipsAsmBackend(const Target &T, Triple::OSType OSType, bool IsLittle,
34 MipsAsmBackend(const Target &T, TargetTuple::OSType OSType, bool IsLittle,
3535 bool Is64Bit)
3636 : MCAsmBackend(), OSType(OSType), IsLittle(IsLittle), Is64Bit(Is64Bit) {}
3737
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "MipsMCAsmInfo.h"
14 #include "llvm/ADT/Triple.h"
14 #include "llvm/ADT/TargetTuple.h"
1515
1616 using namespace llvm;
1717
1818 void MipsMCAsmInfo::anchor() { }
1919
20 MipsMCAsmInfo::MipsMCAsmInfo(const Triple &TheTriple) {
21 if ((TheTriple.getArch() == Triple::mips) ||
22 (TheTriple.getArch() == Triple::mips64))
20 MipsMCAsmInfo::MipsMCAsmInfo(const TargetTuple &TT) {
21 if ((TT.getArch() == TargetTuple::mips) ||
22 (TT.getArch() == TargetTuple::mips64))
2323 IsLittleEndian = false;
2424
25 if ((TheTriple.getArch() == Triple::mips64el) ||
26 (TheTriple.getArch() == Triple::mips64)) {
25 if ((TT.getArch() == TargetTuple::mips64el) ||
26 (TT.getArch() == TargetTuple::mips64)) {
2727 PointerSize = CalleeSaveStackSlotSize = 8;
2828 }
2929
1616 #include "llvm/MC/MCAsmInfoELF.h"
1717
1818 namespace llvm {
19 class Triple;
19 class TargetTuple;
2020
2121 class MipsMCAsmInfo : public MCAsmInfoELF {
2222 void anchor() override;
2323
2424 public:
25 explicit MipsMCAsmInfo(const Triple &TheTriple);
25 explicit MipsMCAsmInfo(const TargetTuple &TT);
2626 };
2727
2828 } // namespace llvm
1616 #include "MipsMCNaCl.h"
1717 #include "MipsMCTargetDesc.h"
1818 #include "MipsTargetStreamer.h"
19 #include "llvm/ADT/Triple.h"
19 #include "llvm/ADT/TargetTuple.h"
2020 #include "llvm/MC/MCCodeGenInfo.h"
2121 #include "llvm/MC/MCELFStreamer.h"
2222 #include "llvm/MC/MCInstrInfo.h"
4242
4343 /// Select the Mips CPU for the given triple and cpu name.
4444 /// FIXME: Merge with the copy in MipsSubtarget.cpp
45 StringRef MIPS_MC::selectMipsCPU(const Triple &TT, StringRef CPU) {
45 StringRef MIPS_MC::selectMipsCPU(const TargetTuple &TT, StringRef CPU) {
4646 if (CPU.empty() || CPU == "generic") {
47 if (TT.getArch() == Triple::mips || TT.getArch() == Triple::mipsel)
47 if (TT.getArch() == TargetTuple::mips ||
48 TT.getArch() == TargetTuple::mipsel)
4849 CPU = "mips32";
4950 else
5051 CPU = "mips64";
5859 return X;
5960 }
6061
61 static MCRegisterInfo *createMipsMCRegisterInfo(const Triple &TT) {
62 static MCRegisterInfo *createMipsMCRegisterInfo(const TargetTuple &TT) {
6263 MCRegisterInfo *X = new MCRegisterInfo();
6364 InitMipsMCRegisterInfo(X, Mips::RA);
6465 return X;
6566 }
6667
67 static MCSubtargetInfo *createMipsMCSubtargetInfo(const Triple &TT,
68 static MCSubtargetInfo *createMipsMCSubtargetInfo(const TargetTuple &TT,
6869 StringRef CPU, StringRef FS) {
6970 CPU = MIPS_MC::selectMipsCPU(TT, CPU);
7071 return createMipsMCSubtargetInfoImpl(TT, CPU, FS);
7172 }
7273
7374 static MCAsmInfo *createMipsMCAsmInfo(const MCRegisterInfo &MRI,
74 const Triple &TT) {
75 const TargetTuple &TT) {
7576 MCAsmInfo *MAI = new MipsMCAsmInfo(TT);
7677
7778 unsigned SP = MRI.getDwarfRegNum(Mips::SP, true);
8182 return MAI;
8283 }
8384
84 static MCCodeGenInfo *createMipsMCCodeGenInfo(const Triple &TT, Reloc::Model RM,
85 static MCCodeGenInfo *createMipsMCCodeGenInfo(const TargetTuple &TT,
86 Reloc::Model RM,
8587 CodeModel::Model CM,
8688 CodeGenOpt::Level OL) {
8789 MCCodeGenInfo *X = new MCCodeGenInfo();
9395 return X;
9496 }
9597
96 static MCInstPrinter *createMipsMCInstPrinter(const Triple &T,
98 static MCInstPrinter *createMipsMCInstPrinter(const TargetTuple &T,
9799 unsigned SyntaxVariant,
98100 const MCAsmInfo &MAI,
99101 const MCInstrInfo &MII,
101103 return new MipsInstPrinter(MAI, MII, MRI);
102104 }
103105
104 static MCStreamer *createMCStreamer(const Triple &T, MCContext &Context,
106 static MCStreamer *createMCStreamer(const TargetTuple &T, MCContext &Context,
105107 MCAsmBackend &MAB, raw_pwrite_stream &OS,
106108 MCCodeEmitter *Emitter, bool RelaxAll) {
107109 MCStreamer *S;
2525 class MCSubtargetInfo;
2626 class StringRef;
2727 class Target;
28 class Triple;
28 class TargetTuple;
2929 class raw_ostream;
3030 class raw_pwrite_stream;
3131
4343
4444 MCAsmBackend *createMipsAsmBackendEB32(const Target &T,
4545 const MCRegisterInfo &MRI,
46 const Triple &TT, StringRef CPU);
46 const TargetTuple &TT, StringRef CPU);
4747 MCAsmBackend *createMipsAsmBackendEL32(const Target &T,
4848 const MCRegisterInfo &MRI,
49 const Triple &TT, StringRef CPU);
49 const TargetTuple &TT, StringRef CPU);
5050 MCAsmBackend *createMipsAsmBackendEB64(const Target &T,
5151 const MCRegisterInfo &MRI,
52 const Triple &TT, StringRef CPU);
52 const TargetTuple &TT, StringRef CPU);
5353 MCAsmBackend *createMipsAsmBackendEL64(const Target &T,
5454 const MCRegisterInfo &MRI,
55 const Triple &TT, StringRef CPU);
55 const TargetTuple &TT, StringRef CPU);
5656
5757 MCObjectWriter *createMipsELFObjectWriter(raw_pwrite_stream &OS, uint8_t OSABI,
5858 bool IsLittleEndian, bool Is64Bit);
5959
6060 namespace MIPS_MC {
61 StringRef selectMipsCPU(const Triple &TT, StringRef CPU);
61 StringRef selectMipsCPU(const TargetTuple &TT, StringRef CPU);
6262 }
6363
6464 } // End llvm namespace
692692 // clean anyhow.
693693 // FIXME: For ifunc related functions we could iterate over and look
694694 // for a feature string that doesn't match the default one.
695 const Triple &TT = TM.getTargetTriple();
695 TargetTuple TT(TargetTuple(TM.getTargetTriple()));
696696 StringRef CPU = MIPS_MC::selectMipsCPU(TT, TM.getTargetCPU());
697697 StringRef FS = TM.getTargetFeatureString();
698698 const MipsTargetMachine &MTM = static_cast(TM);
699 const MipsSubtarget STI(TT, CPU, FS, MTM.isLittleEndian(), MTM);
699 const MipsSubtarget STI(TM.getTargetTriple(), CPU, FS, MTM.isLittleEndian(),
700 MTM);
700701
701702 bool IsABICalls = STI.isABICalls();
702703 const MipsABIInfo &ABI = MTM.getABI();
6161 MipsSubtarget::MipsSubtarget(const Triple &TT, const std::string &CPU,
6262 const std::string &FS, bool little,
6363 const MipsTargetMachine &TM)
64 : MipsGenSubtargetInfo(TT, CPU, FS), MipsArchVersion(MipsDefault),
65 IsLittle(little), IsSoftFloat(false), IsSingleFloat(false), IsFPXX(false),
66 NoABICalls(false), IsFP64bit(false), UseOddSPReg(true),
67 IsNaN2008bit(false), IsGP64bit(false), HasVFPU(false), HasCnMips(false),
68 HasMips3_32(false), HasMips3_32r2(false), HasMips4_32(false),
69 HasMips4_32r2(false), HasMips5_32r2(false), InMips16Mode(false),
70 InMips16HardFloat(Mips16HardFloat), InMicroMipsMode(false), HasDSP(false),
71 HasDSPR2(false), AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16),
72 HasMSA(false), UseTCCInDIV(false), HasEVA(false), TM(TM),
73 TargetTriple(TT), TSInfo(),
64 : MipsGenSubtargetInfo(TargetTuple(TT), CPU, FS),
65 MipsArchVersion(MipsDefault), IsLittle(little), IsSoftFloat(false),
66 IsSingleFloat(false), IsFPXX(false), NoABICalls(false), IsFP64bit(false),
67 UseOddSPReg(true), IsNaN2008bit(false), IsGP64bit(false), HasVFPU(false),
68 HasCnMips(false), HasMips3_32(false), HasMips3_32r2(false),
69 HasMips4_32(false), HasMips4_32r2(false), HasMips5_32r2(false),
70 InMips16Mode(false), InMips16HardFloat(Mips16HardFloat),
71 InMicroMipsMode(false), HasDSP(false), HasDSPR2(false),
72 AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16), HasMSA(false),
73 UseTCCInDIV(false), HasEVA(false), TM(TM), TargetTriple(TT), TSInfo(),
7474 InstrInfo(
7575 MipsInstrInfo::create(initializeSubtargetDependencies(CPU, FS, TM))),
7676 FrameLowering(MipsFrameLowering::create(*this)),
141141 MipsSubtarget &
142142 MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS,
143143 const TargetMachine &TM) {
144 std::string CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU);
144 std::string CPUName =
145 MIPS_MC::selectMipsCPU(TargetTuple(TM.getTargetTriple()), CPU);
145146
146147 // Parse features string.
147148 ParseSubtargetFeatures(CPUName, FS);
4747 const TargetOptions &Options,
4848 bool isLittle) {
4949 std::string Ret = "";
50 MipsABIInfo ABI = MipsABIInfo::computeTargetABI(TT, CPU, Options.MCOptions);
50 MipsABIInfo ABI =
51 MipsABIInfo::computeTargetABI(TargetTuple(TT), CPU, Options.MCOptions);
5152
5253 // There are both little and big endian mips.
5354 if (isLittle)
8990 : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options, isLittle), TT,
9091 CPU, FS, Options, RM, CM, OL),
9192 isLittle(isLittle), TLOF(make_unique()),
92 ABI(MipsABIInfo::computeTargetABI(TT, CPU, Options.MCOptions)),
93 ABI(MipsABIInfo::computeTargetABI(TargetTuple(TT), CPU,
94 Options.MCOptions)),
9395 Subtarget(nullptr), DefaultSubtarget(TT, CPU, FS, isLittle, *this),
9496 NoMips16Subtarget(TT, CPU, FS.empty() ? "-mips16" : FS.str() + ",-mips16",
9597 isLittle, *this),
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "NVPTXMCAsmInfo.h"
14 #include "llvm/ADT/Triple.h"
14 #include "llvm/ADT/TargetTuple.h"
1515 #include "llvm/Support/CommandLine.h"
1616
1717 using namespace llvm;
2424
2525 void NVPTXMCAsmInfo::anchor() {}
2626
27 NVPTXMCAsmInfo::NVPTXMCAsmInfo(const Triple &TheTriple) {
28 if (TheTriple.getArch() == Triple::nvptx64) {
27 NVPTXMCAsmInfo::NVPTXMCAsmInfo(const TargetTuple &TT) {
28 if (TT.getArch() == TargetTuple::nvptx64) {
2929 PointerSize = CalleeSaveStackSlotSize = 8;
3030 }
3131
1717
1818 namespace llvm {
1919 class Target;
20 class Triple;
20 class TargetTuple;
2121
2222 class NVPTXMCAsmInfo : public MCAsmInfo {
2323 virtual void anchor();
2424
2525 public:
26 explicit NVPTXMCAsmInfo(const Triple &TheTriple);
26 explicit NVPTXMCAsmInfo(const TargetTuple &TT);
2727 };
2828 } // namespace llvm
2929
3636 return X;
3737 }
3838
39 static MCRegisterInfo *createNVPTXMCRegisterInfo(const Triple &TT) {
39 static MCRegisterInfo *createNVPTXMCRegisterInfo(const TargetTuple &TT) {
4040 MCRegisterInfo *X = new MCRegisterInfo();
4141 // PTX does not have a return address register.
4242 InitNVPTXMCRegisterInfo(X, 0);
4444 }
4545
4646 static MCSubtargetInfo *
47 createNVPTXMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
47 createNVPTXMCSubtargetInfo(const TargetTuple &TT, StringRef CPU, StringRef FS) {
4848 return createNVPTXMCSubtargetInfoImpl(TT, CPU, FS);
4949 }
5050
51 static MCCodeGenInfo *createNVPTXMCCodeGenInfo(const Triple &TT,
51 static MCCodeGenInfo *createNVPTXMCCodeGenInfo(const TargetTuple &TT,
5252 Reloc::Model RM,
5353 CodeModel::Model CM,
5454 CodeGenOpt::Level OL) {
6060 return X;
6161 }
6262
63 static MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T,
63 static MCInstPrinter *createNVPTXMCInstPrinter(const TargetTuple &T,
6464 unsigned SyntaxVariant,
6565 const MCAsmInfo &MAI,
6666 const MCInstrInfo &MII,
4545 NVPTXSubtarget::NVPTXSubtarget(const Triple &TT, const std::string &CPU,
4646 const std::string &FS,
4747 const NVPTXTargetMachine &TM)
48 : NVPTXGenSubtargetInfo(TT, CPU, FS), PTXVersion(0), SmVersion(20), TM(TM),
49 InstrInfo(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS)),
48 : NVPTXGenSubtargetInfo(TargetTuple(TT), CPU, FS), PTXVersion(0),
49 SmVersion(20), TM(TM), InstrInfo(),
50 TLInfo(TM, initializeSubtargetDependencies(CPU, FS)), TSInfo(),
5051 FrameLowering() {}
5152
5253 bool NVPTXSubtarget::hasImageHandles() const {
294294 const MCTargetOptions &Options)
295295 : MCTargetAsmParser(Options), STI(STI), MII(MII) {
296296 // Check for 64-bit vs. 32-bit pointer mode.
297 Triple TheTriple(STI.getTargetTriple());
298 IsPPC64 = (TheTriple.getArch() == Triple::ppc64 ||
299 TheTriple.getArch() == Triple::ppc64le);
300 IsDarwin = TheTriple.isMacOSX();
297 const TargetTuple &TT = STI.getTargetTuple();
298 IsPPC64 = (TT.getArch() == TargetTuple::ppc64 ||
299 TT.getArch() == TargetTuple::ppc64le);
300 IsDarwin = TT.isMacOSX();
301301 // Initialize the set of available features.
302302 setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
303303 }
229229
230230 MCAsmBackend *llvm::createPPCAsmBackend(const Target &T,
231231 const MCRegisterInfo &MRI,
232 const Triple &TT, StringRef CPU) {
232 const TargetTuple &TT, StringRef CPU) {
233233 if (TT.isOSDarwin())
234234 return new DarwinPPCAsmBackend(T);
235235
236236 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TT.getOS());
237 bool IsLittleEndian = TT.getArch() == Triple::ppc64le;
237 bool IsLittleEndian = TT.getArch() == TargetTuple::ppc64le;
238238 return new ELFPPCAsmBackend(T, IsLittleEndian, OSABI);
239239 }
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "PPCMCAsmInfo.h"
14 #include "llvm/ADT/Triple.h"
14 #include "llvm/ADT/TargetTuple.h"
1515
1616 using namespace llvm;
1717
1818 void PPCMCAsmInfoDarwin::anchor() { }
1919
20 PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit, const Triple& T) {
20 PPCMCAsmInfoDarwin::PPCMCAsmInfoDarwin(bool is64Bit, const TargetTuple &TT) {
2121 if (is64Bit) {
2222 PointerSize = CalleeSaveStackSlotSize = 8;
2323 }
3535 // The installed assembler for OSX < 10.6 lacks some directives.
3636 // FIXME: this should really be a check on the assembler characteristics
3737 // rather than OS version
38 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 6))
38 if (TT.isMacOSX() && TT.isMacOSXVersionLT(10, 6))
3939 HasWeakDefCanBeHiddenDirective = false;
4040
4141 UseIntegratedAssembler = true;
4343
4444 void PPCELFMCAsmInfo::anchor() { }
4545
46 PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const Triple& T) {
46 PPCELFMCAsmInfo::PPCELFMCAsmInfo(bool is64Bit, const TargetTuple &TT) {
4747 // FIXME: This is not always needed. For example, it is not needed in the
4848 // v2 abi.
4949 NeedsLocalForSize = true;
5151 if (is64Bit) {
5252 PointerSize = CalleeSaveStackSlotSize = 8;
5353 }
54 IsLittleEndian = T.getArch() == Triple::ppc64le;
54 IsLittleEndian = TT.getArch() == TargetTuple::ppc64le;
5555
5656 // ".comm align is in bytes but .align is pow-2."
5757 AlignmentIsInBytes = false;
1717 #include "llvm/MC/MCAsmInfoELF.h"
1818
1919 namespace llvm {
20 class Triple;
20 class TargetTuple;
2121
2222 class PPCMCAsmInfoDarwin : public MCAsmInfoDarwin {
2323 virtual void anchor();
2424
2525 public:
26 explicit PPCMCAsmInfoDarwin(bool is64Bit, const Triple &);
26 explicit PPCMCAsmInfoDarwin(bool is64Bit, const TargetTuple &);
2727 };
2828
2929 class PPCELFMCAsmInfo : public MCAsmInfoELF {
3030 void anchor() override;
3131
3232 public:
33 explicit PPCELFMCAsmInfo(bool is64Bit, const Triple &);
33 explicit PPCELFMCAsmInfo(bool is64Bit, const TargetTuple &);
3434 };
3535
3636 } // namespace llvm
308308 // Return the thread-pointer register's encoding.
309309 Fixups.push_back(MCFixup::create(0, MO.getExpr(),
310310 (MCFixupKind)PPC::fixup_ppc_nofixup));
311 const Triple &TT = STI.getTargetTriple();
312 bool isPPC64 = TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le;
311 const TargetTuple &TT = STI.getTargetTuple();
312 bool isPPC64 = TT.getArch() == TargetTuple::ppc64 ||
313 TT.getArch() == TargetTuple::ppc64le;
313314 return CTX.getRegisterInfo()->getEncodingValue(isPPC64 ? PPC::X13 : PPC::R2);
314315 }
315316
5050 return X;
5151 }
5252
53 static MCRegisterInfo *createPPCMCRegisterInfo(const Triple &TT) {
54 bool isPPC64 =
55 (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le);
53 static MCRegisterInfo *createPPCMCRegisterInfo(const TargetTuple &TT) {
54 bool isPPC64 = (TT.getArch() == TargetTuple::ppc64 ||
55 TT.getArch() == TargetTuple::ppc64le);
5656 unsigned Flavour = isPPC64 ? 0 : 1;
5757 unsigned RA = isPPC64 ? PPC::LR8 : PPC::LR;
5858
6161 return X;
6262 }
6363
64 static MCSubtargetInfo *createPPCMCSubtargetInfo(const Triple &TT,
64 static MCSubtargetInfo *createPPCMCSubtargetInfo(const TargetTuple &TT,
6565 StringRef CPU, StringRef FS) {
6666 return createPPCMCSubtargetInfoImpl(TT, CPU, FS);
6767 }
6868
6969 static MCAsmInfo *createPPCMCAsmInfo(const MCRegisterInfo &MRI,
70 const Triple &TheTriple) {
71 bool isPPC64 = (TheTriple.getArch() == Triple::ppc64 ||
72 TheTriple.getArch() == Triple::ppc64le);
70 const TargetTuple &TT) {
71 bool isPPC64 = (TT.getArch() == TargetTuple::ppc64 ||
72 TT.getArch() == TargetTuple::ppc64le);
7373
7474 MCAsmInfo *MAI;
75 if (TheTriple.isOSDarwin())
76 MAI = new PPCMCAsmInfoDarwin(isPPC64, TheTriple);
75 if (TT.isOSDarwin())
76 MAI = new PPCMCAsmInfoDarwin(isPPC64, TT);
7777 else
78 MAI = new PPCELFMCAsmInfo(isPPC64, TheTriple);
78 MAI = new PPCELFMCAsmInfo(isPPC64, TT);
7979
8080 // Initial state of the frame pointer is R1.
8181 unsigned Reg = isPPC64 ? PPC::X1 : PPC::R1;
8686 return MAI;
8787 }
8888
89 static MCCodeGenInfo *createPPCMCCodeGenInfo(const Triple &TT, Reloc::Model RM,
89 static MCCodeGenInfo *createPPCMCCodeGenInfo(const TargetTuple &TT,
90 Reloc::Model RM,
9091 CodeModel::Model CM,
9192 CodeGenOpt::Level OL) {
9293 MCCodeGenInfo *X = new MCCodeGenInfo();
9899 RM = Reloc::Static;
99100 }
100101 if (CM == CodeModel::Default) {
101 if (!TT.isOSDarwin() &&
102 (TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le))
102 if (!TT.isOSDarwin() && (TT.getArch() == TargetTuple::ppc64 ||
103 TT.getArch() == TargetTuple::ppc64le))
103104 CM = CodeModel::Medium;
104105 }
105106 X->initMCCodeGenInfo(RM, CM, OL);
224225
225226 static MCTargetStreamer *
226227 createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
227 const Triple &TT = STI.getTargetTriple();
228 const TargetTuple &TT = STI.getTargetTuple();
228229 if (TT.isOSBinFormatELF())
229230 return new PPCTargetELFStreamer(S);
230231 return new PPCTargetMachOStreamer(S);
231232 }
232233
233 static MCInstPrinter *createPPCMCInstPrinter(const Triple &T,
234 static MCInstPrinter *createPPCMCInstPrinter(const TargetTuple &TT,
234235 unsigned SyntaxVariant,
235236 const MCAsmInfo &MAI,
236237 const MCInstrInfo &MII,
237238 const MCRegisterInfo &MRI) {
238 return new PPCInstPrinter(MAI, MII, MRI, T.isOSDarwin());
239 return new PPCInstPrinter(MAI, MII, MRI, TT.isOSDarwin());
239240 }
240241
241242 extern "C" void LLVMInitializePowerPCTargetMC() {
2828 class MCRegisterInfo;
2929 class MCSubtargetInfo;
3030 class Target;
31 class Triple;
31 class TargetTuple;
3232 class StringRef;
3333 class raw_pwrite_stream;
3434 class raw_ostream;
4242 MCContext &Ctx);
4343
4444 MCAsmBackend *createPPCAsmBackend(const Target &T, const MCRegisterInfo &MRI,
45 const Triple &TT, StringRef CPU);
45 const TargetTuple &TT, StringRef CPU);
4646
4747 /// Construct an PPC ELF object writer.
4848 MCObjectWriter *createPPCELFObjectWriter(raw_pwrite_stream &OS, bool Is64Bit,
4848
4949 PPCSubtarget::PPCSubtarget(const Triple &TT, const std::string &CPU,
5050 const std::string &FS, const PPCTargetMachine &TM)
51 : PPCGenSubtargetInfo(TT, CPU, FS), TargetTriple(TT),
51 : PPCGenSubtargetInfo(TargetTuple(TT), CPU, FS), TargetTriple(TT),
5252 IsPPC64(TargetTriple.getArch() == Triple::ppc64 ||
5353 TargetTriple.getArch() == Triple::ppc64le),
5454 TM(TM), FrameLowering(initializeSubtargetDependencies(CPU, FS)),
7676 bool parseDirectiveWord(unsigned Size, SMLoc L);
7777
7878 bool is64Bit() const {
79 return STI.getTargetTriple().getArch() == Triple::sparcv9;
79 return STI.getTargetTuple().getArch() == TargetTuple::sparcv9;
8080 }
8181
8282 void expandSET(MCInst &Inst, SMLoc IDLoc,
266266 };
267267
268268 class ELFSparcAsmBackend : public SparcAsmBackend {
269 Triple::OSType OSType;
269 TargetTuple::OSType OSType;
270
270271 public:
271 ELFSparcAsmBackend(const Target &T, Triple::OSType OSType) :
272 SparcAsmBackend(T), OSType(OSType) { }
272 ELFSparcAsmBackend(const Target &T, TargetTuple::OSType OSType)
273 : SparcAsmBackend(T), OSType(OSType) {}
273274
274275 void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
275276 uint64_t Value, bool IsPCRel) const override {
298299
299300 MCAsmBackend *llvm::createSparcAsmBackend(const Target &T,
300301 const MCRegisterInfo &MRI,
301 const Triple &TT, StringRef CPU) {
302 const TargetTuple &TT,
303 StringRef CPU) {
302304 return new ELFSparcAsmBackend(T, TT.getOS());
303305 }
1212
1313 #include "SparcMCAsmInfo.h"
1414 #include "SparcMCExpr.h"
15 #include "llvm/ADT/Triple.h"
15 #include "llvm/ADT/TargetTuple.h"
1616 #include "llvm/MC/MCStreamer.h"
1717
1818 using namespace llvm;
1919
2020 void SparcELFMCAsmInfo::anchor() {}
2121
22 SparcELFMCAsmInfo::SparcELFMCAsmInfo(const Triple &TheTriple) {
23 bool isV9 = (TheTriple.getArch() == Triple::sparcv9);
24 IsLittleEndian = (TheTriple.getArch() == Triple::sparcel);
22 SparcELFMCAsmInfo::SparcELFMCAsmInfo(const TargetTuple &TT) {
23 bool isV9 = (TT.getArch() == TargetTuple::sparcv9);
24 IsLittleEndian = (TT.getArch() == TargetTuple::sparcel);
2525
2626 if (isV9) {
2727 PointerSize = CalleeSaveStackSlotSize = 8;
1616 #include "llvm/MC/MCAsmInfoELF.h"
1717
1818 namespace llvm {
19 class Triple;
19 class TargetTuple;
2020
2121 class SparcELFMCAsmInfo : public MCAsmInfoELF {
2222 void anchor() override;
2323
2424 public:
25 explicit SparcELFMCAsmInfo(const Triple &TheTriple);
25 explicit SparcELFMCAsmInfo(const TargetTuple &TT);
2626 const MCExpr*
2727 getExprForPersonalitySymbol(const MCSymbol *Sym, unsigned Encoding,
2828 MCStreamer &Streamer) const override;
3333 #include "SparcGenRegisterInfo.inc"
3434
3535 static MCAsmInfo *createSparcMCAsmInfo(const MCRegisterInfo &MRI,
36 const Triple &TT) {
36 const TargetTuple &TT) {
3737 MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
3838 unsigned Reg = MRI.getDwarfRegNum(SP::O6, true);
3939 MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0);
4242 }
4343
4444 static MCAsmInfo *createSparcV9MCAsmInfo(const MCRegisterInfo &MRI,
45 const Triple &TT) {
45 const TargetTuple &TT) {
4646 MCAsmInfo *MAI = new SparcELFMCAsmInfo(TT);
47