LLVM 24.0.0git
TargetDataLayout.cpp
Go to the documentation of this file.
1//===--- TargetDataLayout.cpp - Map Triple to LLVM data layout string -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
12using namespace llvm;
13
15 if (T.isOSBinFormatGOFF())
16 return "-m:l";
17 if (T.isOSBinFormatMachO())
18 return "-m:o";
19 if (T.isOSWindowsOrUEFI() && T.isOSBinFormatCOFF())
20 return T.getArch() == Triple::x86 ? "-m:x" : "-m:w";
21 if (T.isOSBinFormatXCOFF())
22 return "-m:a";
23 return "-m:e";
24}
25
26static std::string computeARMDataLayout(const Triple &TT, StringRef ABIName) {
27 auto ABI = ARM::computeTargetABI(TT, ABIName);
28 std::string Ret;
29
30 if (TT.isLittleEndian())
31 // Little endian.
32 Ret += "e";
33 else
34 // Big endian.
35 Ret += "E";
36
37 Ret += getManglingComponent(TT);
38
39 // Pointers are 32 bits and aligned to 32 bits.
40 Ret += "-p:32:32";
41
42 // Function pointers are aligned to 8 bits (because the LSB stores the
43 // ARM/Thumb state).
44 Ret += "-Fi8";
45
46 // ABIs other than APCS have 64 bit integers with natural alignment.
47 if (ABI != ARM::ARM_ABI_APCS)
48 Ret += "-i64:64";
49
50 // We have 64 bits floats. The APCS ABI requires them to be aligned to 32
51 // bits, others to 64 bits. We always try to align to 64 bits.
52 if (ABI == ARM::ARM_ABI_APCS)
53 Ret += "-f64:32:64";
54
55 // We have 128 and 64 bit vectors. The APCS ABI aligns them to 32 bits, others
56 // to 64. We always ty to give them natural alignment.
57 if (ABI == ARM::ARM_ABI_APCS)
58 Ret += "-v64:32:64-v128:32:128";
59 else if (ABI != ARM::ARM_ABI_AAPCS16)
60 Ret += "-v128:64:128";
61
62 // Try to align aggregates to 32 bits (the default is 64 bits, which has no
63 // particular hardware support on 32-bit ARM).
64 Ret += "-a:0:32";
65
66 // Integer registers are 32 bits.
67 Ret += "-n32";
68
69 // The stack is 64 bit aligned on AAPCS and 32 bit aligned everywhere else.
70 if (ABI == ARM::ARM_ABI_AAPCS16)
71 Ret += "-S128";
72 else if (ABI == ARM::ARM_ABI_AAPCS)
73 Ret += "-S64";
74 else
75 Ret += "-S32";
76
77 return Ret;
78}
79
80// Helper function to build a DataLayout string
81static std::string computeAArch64DataLayout(const Triple &TT) {
82 if (TT.isOSBinFormatMachO()) {
83 if (TT.getArch() == Triple::aarch64_32)
84 return "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-"
85 "n32:64-S128-Fn32";
86 return "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-"
87 "Fn32";
88 }
89 if (TT.isOSBinFormatCOFF())
90 return "e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-i64:64-i128:"
91 "128-n32:64-S128-Fn32";
92 std::string Endian = TT.isLittleEndian() ? "e" : "E";
93 std::string Ptr32 = TT.getEnvironment() == Triple::GNUILP32 ? "-p:32:32" : "";
94 return Endian + "-m:e" + Ptr32 +
95 "-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-"
96 "n32:64-S128-Fn32";
97}
98
99// DataLayout: little or big endian
100static std::string computeBPFDataLayout(const Triple &TT) {
101 if (TT.getArch() == Triple::bpfeb)
102 return "E-m:e-p:64:64-i64:64-i128:128-n32:64-S128";
103 else
104 return "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128";
105}
106
107static std::string computeCSKYDataLayout(const Triple &TT) {
108 // CSKY is always 32-bit target with the CSKYv2 ABI as prefer now.
109 // It's a 4-byte aligned stack with ELF mangling only.
110 // Only support little endian for now.
111 // TODO: Add support for big endian.
112 return "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32"
113 "-v128:32:32-a:0:32-Fi32-n32";
114}
115
116static std::string computeLoongArchDataLayout(const Triple &TT) {
117 if (TT.isLoongArch64())
118 return "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128";
119 assert(TT.isLoongArch32() && "only LA32 and LA64 are currently supported");
120 return "e-m:e-p:32:32-i64:64-n32-S128";
121}
122
123static std::string computeM68kDataLayout(const Triple &TT) {
124 std::string Ret = "";
125 // M68k is Big Endian
126 Ret += "E";
127
128 // FIXME how to wire it with the used object format?
129 Ret += "-m:e";
130
131 // M68k pointers are always 32 bit wide even for 16-bit CPUs.
132 // The ABI only specifies 16-bit alignment.
133 // On at least the 68020+ with a 32-bit bus, there is a performance benefit
134 // to having 32-bit alignment.
135 Ret += "-p:32:16:32";
136
137 // Bytes do not require special alignment, words are word aligned and
138 // long words are word aligned at minimum.
139 Ret += "-i8:8:8-i16:16:16-i32:16:32";
140
141 // FIXME no floats at the moment
142
143 // The registers can hold 8, 16, 32 bits
144 Ret += "-n8:16:32";
145
146 Ret += "-a:0:16-S16";
147
148 return Ret;
149}
150
151namespace {
152enum class MipsABI { Unknown, O32, N32, N64 };
153}
154
155// FIXME: This duplicates MipsABIInfo::computeTargetABI, but duplicating this is
156// preferable to violating layering rules. Ideally that information should live
157// in LLVM TargetParser, but for now we just duplicate some ABI name string
158// logic for simplicity.
159static MipsABI getMipsABI(const Triple &TT, StringRef ABIName) {
160 if (ABIName.starts_with("o32"))
161 return MipsABI::O32;
162 if (ABIName.starts_with("n32"))
163 return MipsABI::N32;
164 if (ABIName.starts_with("n64"))
165 return MipsABI::N64;
166 if (TT.isABIN32())
167 return MipsABI::N32;
168 assert(ABIName.empty() && "Unknown ABI option for MIPS");
169
170 if (TT.isMIPS64())
171 return MipsABI::N64;
172 return MipsABI::O32;
173}
174
175static std::string computeMipsDataLayout(const Triple &TT, StringRef ABIName) {
176 std::string Ret;
177 MipsABI ABI = getMipsABI(TT, ABIName);
178
179 // There are both little and big endian mips.
180 if (TT.isLittleEndian())
181 Ret += "e";
182 else
183 Ret += "E";
184
185 if (ABI == MipsABI::O32)
186 Ret += "-m:m";
187 else
188 Ret += "-m:e";
189
190 // Pointers are 32 bit on some ABIs.
191 if (ABI != MipsABI::N64)
192 Ret += "-p:32:32";
193
194 // 8 and 16 bit integers only need to have natural alignment, but try to
195 // align them to 32 bits. 64 bit integers have natural alignment.
196 Ret += "-i8:8:32-i16:16:32-i64:64";
197
198 // 32 bit registers are always available and the stack is at least 64 bit
199 // aligned. On N64 64 bit registers are also available and the stack is
200 // 128 bit aligned.
201 if (ABI == MipsABI::N64 || ABI == MipsABI::N32)
202 Ret += "-i128:128-n32:64-S128";
203 else
204 Ret += "-n32-S64";
205
206 return Ret;
207}
208
209static std::string computePowerDataLayout(const Triple &T, StringRef ABIName) {
210 bool is64Bit = T.isPPC64();
211 std::string Ret;
212
213 // Most PPC* platforms are big endian, PPC(64)LE is little endian.
214 if (T.isLittleEndian())
215 Ret = "e";
216 else
217 Ret = "E";
218
219 Ret += getManglingComponent(T);
220
221 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
222 // pointers.
223 if (!is64Bit || T.getOS() == Triple::Lv2)
224 Ret += "-p:32:32";
225
226 // If the target ABI uses function descriptors, then the alignment of function
227 // pointers depends on the alignment used to emit the descriptor. Otherwise,
228 // function pointers are aligned to 32 bits because the instructions must be.
229 if ((T.getArch() == Triple::ppc64 &&
230 (!T.isPPC64ELFv2ABI() && ABIName != "elfv2"))) {
231 Ret += "-Fi64";
232 } else if (T.isOSAIX()) {
233 Ret += is64Bit ? "-Fi64" : "-Fi32";
234 } else {
235 Ret += "-Fn32";
236 }
237
238 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
239 // documentation are wrong; these are correct (i.e. "what gcc does").
240 Ret += "-i64:64";
241
242 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
243 if (is64Bit)
244 Ret += "-i128:128-n32:64";
245 else
246 Ret += "-n32";
247
248 // The ABI alignment for doubles on AIX is 4 bytes.
249 if (T.isOSAIX())
250 Ret += "-f64:32:64";
251
252 // Specify the vector alignment explicitly. For v256i1 and v512i1, the
253 // calculated alignment would be 256*alignment(i1) and 512*alignment(i1),
254 // which is 256 and 512 bytes - way over aligned.
255 if (is64Bit && (T.isOSAIX() || T.isOSLinux()))
256 Ret += "-S128-v256:256:256-v512:512:512";
257
258 return Ret;
259}
260
261static std::string computeAMDDataLayout(const Triple &TT) {
262 if (TT.getArch() == Triple::r600) {
263 // 32-bit pointers.
264 return "e-m:e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
265 "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1";
266 }
267
268 // 32-bit private, local, and region pointers. 64-bit global, constant and
269 // flat. 160-bit non-integral fat buffer pointers that include a 128-bit
270 // buffer descriptor and a 32-bit offset, which are indexed by 32-bit values
271 // (address space 7), and 128-bit non-integral buffer resourcees (address
272 // space 8) which cannot be non-trivilally accessed by LLVM memory operations
273 // like getelementptr.
274 return "e-m:e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
275 "-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-"
276 "v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-"
277 "v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9";
278}
279
280static std::string computeRISCVDataLayout(const Triple &TT, StringRef ABIName) {
281 if (TT.isOSBinFormatMachO()) {
282 assert(TT.isLittleEndian() && "Invalid endianness");
283 assert(TT.isArch32Bit() && "Invalid triple");
284 assert((ABIName != "ilp32e") && "Invalid ABI.");
285 return "e-m:o-p:32:32-i64:64-n32-S128";
286 }
287
288 std::string Ret;
289
290 if (TT.isLittleEndian())
291 Ret += "e";
292 else
293 Ret += "E";
294
295 Ret += "-m:e";
296
297 // TODO: Maybe we should move RISCVABI to TargetParser, so we can reuse that
298 // logic here instead of duplicating the string handling?
299 bool IsPureCapABI = ABIName.starts_with("il32pc64") ||
300 ABIName.starts_with("l64pc128") ||
301 ABIName.starts_with("cheriot");
302
303 if (TT.isRISCV64()) {
304 Ret += "-p:64:64";
305 if (IsPureCapABI)
306 Ret += "-pe200:128:128:128:64";
307 Ret += "-i64:64-i128:128-n32:64";
308 } else {
309 assert(TT.isRISCV32() && "only RV32 and RV64 are currently supported");
310 Ret += "-p:32:32";
311 if (IsPureCapABI)
312 Ret += "-pe200:64:64:64:32";
313 Ret += "-i64:64-n32";
314 }
315
316 // Stack alignment based on ABI.
317 if (ABIName == "ilp32e")
318 Ret += "-S32";
319 else if (ABIName == "lp64e")
320 Ret += "-S64";
321 else
322 Ret += "-S128";
323
324 // TODO: Support non-purecap CHERI ABIs.
325 if (IsPureCapABI)
326 Ret += "-A200-P200-G200";
327
328 return Ret;
329}
330
331static std::string computeSparcDataLayout(const Triple &T) {
332 const bool Is64Bit = T.isSPARC64();
333
334 // Sparc is typically big endian, but some are little.
335 std::string Ret = T.getArch() == Triple::sparcel ? "e" : "E";
336 Ret += "-m:e";
337
338 // Some ABIs have 32bit pointers.
339 if (!Is64Bit)
340 Ret += "-p:32:32";
341
342 // Alignments for 64 bit integers.
343 Ret += "-i64:64";
344
345 // Alignments for 128 bit integers.
346 // This is not specified in the ABI document but is the de facto standard.
347 Ret += "-i128:128";
348
349 // On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
350 // On SparcV9 registers can hold 64 or 32 bits, on others only 32.
351 if (Is64Bit)
352 Ret += "-n32:64";
353 else
354 Ret += "-f128:64-n32";
355
356 if (Is64Bit)
357 Ret += "-S128";
358 else
359 Ret += "-S64";
360
361 return Ret;
362}
363
364static std::string computeSystemZDataLayout(const Triple &TT) {
365 std::string Ret;
366
367 // Big endian.
368 Ret += "E";
369
370 // The natural stack alignment is 64 bits.
371 Ret += "-S64";
372
373 // Data mangling.
374 Ret += getManglingComponent(TT);
375
376 // Special features for z/OS.
377 if (TT.isOSzOS()) {
378 // Custom address space for ptr32.
379 Ret += "-p1:32:32";
380 }
381
382 // Make sure that global data has at least 16 bits of alignment by
383 // default, so that we can refer to it using LARL. We don't have any
384 // special requirements for stack variables though.
385 Ret += "-i1:8:16-i8:8:16";
386
387 // 64-bit integers are naturally aligned.
388 Ret += "-i64:64";
389
390 // 128-bit floats are aligned only to 64 bits.
391 Ret += "-f128:64";
392
393 // The DataLayout string always holds a vector alignment of 64 bits, see
394 // comment in clang/lib/Basic/Targets/SystemZ.h.
395 Ret += "-v128:64";
396
397 // We prefer 16 bits of aligned for all globals; see above.
398 Ret += "-a:8:16";
399
400 // Integer registers are 32 or 64 bits.
401 Ret += "-n32:64";
402
403 return Ret;
404}
405
406static std::string computeX86DataLayout(const Triple &TT) {
407 bool Is64Bit = TT.isX86_64();
408
409 // X86 is little endian
410 std::string Ret = "e";
411
412 Ret += getManglingComponent(TT);
413 // X86 and x32 have 32 bit pointers.
414 if (!Is64Bit || TT.isX32())
415 Ret += "-p:32:32";
416
417 // Address spaces for 32 bit signed, 32 bit unsigned, and 64 bit pointers.
418 Ret += "-p270:32:32-p271:32:32-p272:64:64";
419
420 // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
421 // 128 bit integers are not specified in the 32-bit ABIs but are used
422 // internally for lowering f128, so we match the alignment to that.
423 if (Is64Bit || TT.isOSWindows())
424 Ret += "-i64:64-i128:128";
425 else if (TT.isOSIAMCU())
426 Ret += "-i64:32-f64:32";
427 else
428 Ret += "-i128:128-f64:32:64";
429
430 // Some ABIs align long double to 128 bits, others to 32.
431 if (TT.isOSIAMCU())
432 ; // No f80
433 else if (Is64Bit || TT.isOSDarwin() || TT.isWindowsMSVCEnvironment())
434 Ret += "-f80:128";
435 else
436 Ret += "-f80:32";
437
438 if (TT.isOSIAMCU())
439 Ret += "-f128:32";
440
441 // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
442 if (Is64Bit)
443 Ret += "-n8:16:32:64";
444 else
445 Ret += "-n8:16:32";
446
447 // The stack is aligned to 32 bits on some ABIs and 128 bits on others.
448 if ((!Is64Bit && TT.isOSWindows()) || TT.isOSIAMCU())
449 Ret += "-a:0:32-S32";
450 else
451 Ret += "-S128";
452
453 return Ret;
454}
455
456static std::string computeNVPTXDataLayout(const Triple &T, StringRef ABIName) {
457 const bool Is32Bit = T.getArch() == Triple::nvptx;
458 const bool IsShortPtr = ABIName == "shortptr";
459 std::string Ret = "e";
460
461 if (Is32Bit) {
462 Ret += "-p:32:32";
463 } else {
464 // Keep the pointer specifications sorted by address space.
465 //
466 // In shortptr mode, specify the following address spaces as 32-bits:
467 // - shared (addrspace:3)
468 // - constant (addrspace:4)
469 // - local (addrspace:5)
470 // - shared cluster (addrspace:7)
471 // - entry parameter (addrspace:101)
472 if (IsShortPtr)
473 Ret += "-p3:32:32-p4:32:32-p5:32:32";
474
475 // Tensor Memory (addrspace:6) is always 32-bits.
476 Ret += "-p6:32:32";
477
478 if (IsShortPtr)
479 Ret += "-p7:32:32-p101:32:32";
480 }
481
482 Ret += "-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64";
483
484 return Ret;
485}
486
487static std::string computeSPIRVDataLayout(const Triple &TT) {
488 const auto Arch = TT.getArch();
489 // TODO: this probably needs to be revisited:
490 // Logical SPIR-V has no pointer size, so any fixed pointer size would be
491 // wrong. The choice to default to 32 or 64 is just motivated by another
492 // memory model used for graphics: PhysicalStorageBuffer64. But it shouldn't
493 // mean anything.
494 if (Arch == Triple::spirv32)
495 return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
496 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1";
497 if (Arch == Triple::spirv)
498 return "e-ve-i64:64-n8:16:32:64-G10";
499 if (TT.getVendor() == Triple::VendorType::AMD &&
500 TT.getOS() == Triple::OSType::AMDHSA)
501 return "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
502 "v512:512-v1024:1024-n32:64-S32-G1-P4-A0";
503 if (TT.getVendor() == Triple::VendorType::Intel)
504 return "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
505 "v512:512-v1024:1024-n8:16:32:64-G1-P9-A0";
506 return "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
507 "v512:512-v1024:1024-n8:16:32:64-G1";
508}
509
510static std::string computeLanaiDataLayout() {
511 // Data layout (keep in sync with clang/lib/Basic/Targets.cpp)
512 return "E" // Big endian
513 "-m:e" // ELF name manging
514 "-p:32:32" // 32-bit pointers, 32 bit aligned
515 "-i64:64" // 64 bit integers, 64 bit aligned
516 "-a:0:32" // 32 bit alignment of objects of aggregate type
517 "-n32" // 32 bit native integer width
518 "-S64"; // 64 bit natural stack alignment
519}
520
521static std::string computeWebAssemblyDataLayout(const Triple &TT) {
522 return TT.getArch() == Triple::wasm64
523 ? (TT.isOSEmscripten() ? "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
524 "i128:128-f128:64-n32:64-S128-ni:1:10:20"
525 : "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
526 "i128:128-n32:64-S128-ni:1:10:20")
527 : (TT.isOSEmscripten() ? "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-"
528 "i128:128-f128:64-n32:64-S128-ni:1:10:20"
529 : "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-"
530 "i128:128-n32:64-S128-ni:1:10:20");
531}
532
533static std::string computeVEDataLayout(const Triple &T) {
534 // Aurora VE is little endian
535 std::string Ret = "e";
536
537 // Use ELF mangling
538 Ret += "-m:e";
539
540 // Alignments for 64 bit integers.
541 Ret += "-i64:64";
542
543 // VE supports 32 bit and 64 bits integer on registers
544 Ret += "-n32:64";
545
546 // Stack alignment is 128 bits
547 Ret += "-S128";
548
549 // Vector alignments are 64 bits
550 // Need to define all of them. Otherwise, each alignment becomes
551 // the size of each data by default.
552 Ret += "-v64:64:64"; // for v2f32
553 Ret += "-v128:64:64";
554 Ret += "-v256:64:64";
555 Ret += "-v512:64:64";
556 Ret += "-v1024:64:64";
557 Ret += "-v2048:64:64";
558 Ret += "-v4096:64:64";
559 Ret += "-v8192:64:64";
560 Ret += "-v16384:64:64"; // for v256f64
561
562 return Ret;
563}
564
565std::string Triple::computeDataLayout(StringRef ABIName) const {
566 switch (getArch()) {
567 case Triple::arm:
568 case Triple::armeb:
569 case Triple::thumb:
570 case Triple::thumbeb:
571 return computeARMDataLayout(*this, ABIName);
572 case Triple::aarch64:
575 return computeAArch64DataLayout(*this);
576 case Triple::arc:
577 return "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-"
578 "f32:32:32-i64:32-f64:32-a:0:32-n32";
579 case Triple::avr:
580 return "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8:16-a:8";
581 case Triple::bpfel:
582 case Triple::bpfeb:
583 return computeBPFDataLayout(*this);
584 case Triple::csky:
585 return computeCSKYDataLayout(*this);
586 case Triple::dxil:
587 return "e-m:e-ve-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-"
588 "f32:32-f64:64-n8:16:32:64";
589 case Triple::hexagon:
590 return "e-m:e-p:32:32:32-a:0-n16:32-"
591 "i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
592 "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048";
595 return computeLoongArchDataLayout(*this);
596 case Triple::m68k:
597 return computeM68kDataLayout(*this);
598 case Triple::mips:
599 case Triple::mipsel:
600 case Triple::mips64:
601 case Triple::mips64el:
602 return computeMipsDataLayout(*this, ABIName);
603 case Triple::msp430:
604 return "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16";
605 case Triple::ppc:
606 case Triple::ppcle:
607 case Triple::ppc64:
608 case Triple::ppc64le:
609 return computePowerDataLayout(*this, ABIName);
610 case Triple::amdgpu:
611 case Triple::r600:
612 return computeAMDDataLayout(*this);
613 case Triple::riscv32:
614 case Triple::riscv64:
617 return computeRISCVDataLayout(*this, ABIName);
618 case Triple::sparc:
619 case Triple::sparcv9:
620 case Triple::sparcel:
621 return computeSparcDataLayout(*this);
622 case Triple::systemz:
623 return computeSystemZDataLayout(*this);
624 case Triple::tce:
625 return "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:32:32-"
626 "f16:16:16-f32:32:32-f64:32:32-v64:64:64-i128:128-v128:128:128-"
627 "v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-"
628 "v4096:4096:4096-a0:0:32-n32";
629 case Triple::tcele:
630 return "e-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:32:32-"
631 "f16:16:16-f32:32:32-f64:32:32-v64:64:64-i128:128-v128:128:128-"
632 "v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-"
633 "v4096:4096:4096-a0:0:32-n32";
634 case Triple::tcele64:
635 return "e-p:64:64:64-i1:8:64-i8:8:64-i16:16:64-i32:32:64-i64:64:64-"
636 "f16:16:64-f32:32:64-f64:64:64-v64:64:64-i128:128-v128:128:128-"
637 "v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-"
638 "v4096:4096:4096-a0:0:64-n64";
639 case Triple::x86:
640 case Triple::x86_64:
641 return computeX86DataLayout(*this);
642 case Triple::xcore:
643 return "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32";
644 case Triple::xtensa:
645 return "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32";
646 case Triple::nvptx:
647 case Triple::nvptx64:
648 return computeNVPTXDataLayout(*this, ABIName);
649 case Triple::spir:
650 case Triple::spir64:
651 case Triple::spirv:
652 case Triple::spirv32:
653 case Triple::spirv64:
654 return computeSPIRVDataLayout(*this);
655 case Triple::lanai:
656 return computeLanaiDataLayout();
657 case Triple::wasm32:
658 case Triple::wasm64:
659 return computeWebAssemblyDataLayout(*this);
660 case Triple::ve:
661 return computeVEDataLayout(*this);
662
663 case Triple::amdil:
664 case Triple::amdil64:
665 case Triple::hsail:
666 case Triple::hsail64:
667 case Triple::kalimba:
668 case Triple::shave:
671 // These are all virtual ISAs with no LLVM backend, and therefore no fixed
672 // LLVM data layout.
673 return "";
674
676 return "";
677 }
678 llvm_unreachable("Invalid arch");
679}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define T
static std::string computeX86DataLayout(const Triple &TT)
static std::string computeNVPTXDataLayout(const Triple &T, StringRef ABIName)
static std::string computePowerDataLayout(const Triple &T, StringRef ABIName)
static std::string computeSystemZDataLayout(const Triple &TT)
static std::string computeAMDDataLayout(const Triple &TT)
static std::string computeMipsDataLayout(const Triple &TT, StringRef ABIName)
static std::string computeBPFDataLayout(const Triple &TT)
static std::string computeSPIRVDataLayout(const Triple &TT)
static std::string computeWebAssemblyDataLayout(const Triple &TT)
static StringRef getManglingComponent(const Triple &T)
static std::string computeCSKYDataLayout(const Triple &TT)
static std::string computeLanaiDataLayout()
static std::string computeM68kDataLayout(const Triple &TT)
static std::string computeARMDataLayout(const Triple &TT, StringRef ABIName)
static MipsABI getMipsABI(const Triple &TT, StringRef ABIName)
static std::string computeLoongArchDataLayout(const Triple &TT)
static std::string computeVEDataLayout(const Triple &T)
static std::string computeSparcDataLayout(const Triple &T)
static std::string computeRISCVDataLayout(const Triple &TT, StringRef ABIName)
static std::string computeAArch64DataLayout(const Triple &TT)
static bool is64Bit(const char *name)
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition StringRef.h:258
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
LLVM_ABI std::string computeDataLayout(StringRef ABIName="") const
Compute the LLVM IR data layout string based on the triple.
@ loongarch32
Definition Triple.h:65
@ renderscript64
Definition Triple.h:116
@ UnknownArch
Definition Triple.h:51
@ loongarch64
Definition Triple.h:66
@ renderscript32
Definition Triple.h:115
ArchType getArch() const
Get the parsed architecture type of this triple.
Definition Triple.h:513
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI LLVM_READONLY ARMABI computeTargetABI(const Triple &TT, StringRef ABIName="")
This is an optimization pass for GlobalISel generic memory operations.