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
123// The Linux m68k target uses the ABI used
124// by Sun Microsystems for the old a.out-based binaries: 16-bit
125// alignment of int/long/pointer.
126//
127// NetBSD/m68k on the other hand uses the SVR4 ABI, which
128// aligns int/long/pointer/objects/stack on 32-bit boundaries.
129//
130// For now we just fix this for NetBSD/m68k.
131//
132// Ref. https://github.com/llvm/llvm-project/issues/199826
133
134static std::string computeM68kDataLayout(const Triple &TT) {
135 std::string Ret = "";
136 // M68k is Big Endian
137 Ret += "E";
138
139 // FIXME how to wire it with the used object format?
140 Ret += "-m:e";
141
142 if (!TT.isOSNetBSD()) {
143 // M68k pointers are always 32 bit wide even for 16-bit CPUs.
144 // The ABI only specifies 16-bit alignment.
145 // On at least the 68020+ with a 32-bit bus, there is a performance benefit
146 // to having 32-bit alignment.
147 Ret += "-p:32:16:32";
148
149 // Bytes do not require special alignment, words are word aligned and
150 // long words are word aligned at minimum.
151 Ret += "-i8:8:8-i16:16:16-i32:16:32";
152
153 // The registers can hold 8, 16, 32 bits
154 Ret += "-n8:16:32";
155
156 Ret += "-a:0:16-S16";
157 } else {
158 // NetBSD/m68k aligns long/pointer/stack/objects on 32-bits,
159 // ref. comment above.
160 Ret += "-p:32:32:32";
161 // Bytes do not require special alignment,
162 // 16-bit ints are 16-bit aligned and
163 // 32-bit ints are 32-bit aligned
164 Ret += "-i8:8:8-i16:16:16-i32:32:32";
165 // The registers can hold 8, 16, 32 bits
166 Ret += "-n8:16:32";
167 // object and stack alignment is also 32 bits
168 Ret += "-a:0:32-S32";
169 }
170
171 // FIXME no floats at the moment
172
173 return Ret;
174}
175
176namespace {
177enum class MipsABI { Unknown, O32, N32, N64 };
178}
179
180// FIXME: This duplicates MipsABIInfo::computeTargetABI, but duplicating this is
181// preferable to violating layering rules. Ideally that information should live
182// in LLVM TargetParser, but for now we just duplicate some ABI name string
183// logic for simplicity.
184static MipsABI getMipsABI(const Triple &TT, StringRef ABIName) {
185 if (ABIName.starts_with("o32"))
186 return MipsABI::O32;
187 if (ABIName.starts_with("n32"))
188 return MipsABI::N32;
189 if (ABIName.starts_with("n64"))
190 return MipsABI::N64;
191 if (TT.isABIN32())
192 return MipsABI::N32;
193 assert(ABIName.empty() && "Unknown ABI option for MIPS");
194
195 if (TT.isMIPS64())
196 return MipsABI::N64;
197 return MipsABI::O32;
198}
199
200static std::string computeMipsDataLayout(const Triple &TT, StringRef ABIName) {
201 std::string Ret;
202 MipsABI ABI = getMipsABI(TT, ABIName);
203
204 // There are both little and big endian mips.
205 if (TT.isLittleEndian())
206 Ret += "e";
207 else
208 Ret += "E";
209
210 if (ABI == MipsABI::O32)
211 Ret += "-m:m";
212 else
213 Ret += "-m:e";
214
215 // Pointers are 32 bit on some ABIs.
216 if (ABI != MipsABI::N64)
217 Ret += "-p:32:32";
218
219 // 8 and 16 bit integers only need to have natural alignment, but try to
220 // align them to 32 bits. 64 bit integers have natural alignment.
221 Ret += "-i8:8:32-i16:16:32-i64:64";
222
223 // 32 bit registers are always available and the stack is at least 64 bit
224 // aligned. On N64 64 bit registers are also available and the stack is
225 // 128 bit aligned.
226 if (ABI == MipsABI::N64 || ABI == MipsABI::N32)
227 Ret += "-i128:128-n32:64-S128";
228 else
229 Ret += "-n32-S64";
230
231 return Ret;
232}
233
234static std::string computePowerDataLayout(const Triple &T, StringRef ABIName) {
235 bool is64Bit = T.isPPC64();
236 std::string Ret;
237
238 // Most PPC* platforms are big endian, PPC(64)LE is little endian.
239 if (T.isLittleEndian())
240 Ret = "e";
241 else
242 Ret = "E";
243
244 Ret += getManglingComponent(T);
245
246 // PPC32 has 32 bit pointers. The PS3 (OS Lv2) is a PPC64 machine with 32 bit
247 // pointers.
248 if (!is64Bit || T.getOS() == Triple::Lv2)
249 Ret += "-p:32:32";
250
251 // If the target ABI uses function descriptors, then the alignment of function
252 // pointers depends on the alignment used to emit the descriptor. Otherwise,
253 // function pointers are aligned to 32 bits because the instructions must be.
254 if ((T.getArch() == Triple::ppc64 &&
255 (!T.isPPC64ELFv2ABI() && ABIName != "elfv2"))) {
256 Ret += "-Fi64";
257 } else if (T.isOSAIX()) {
258 Ret += is64Bit ? "-Fi64" : "-Fi32";
259 } else {
260 Ret += "-Fn32";
261 }
262
263 // Note, the alignment values for f64 and i64 on ppc64 in Darwin
264 // documentation are wrong; these are correct (i.e. "what gcc does").
265 Ret += "-i64:64";
266
267 // PPC64 has 32 and 64 bit registers, PPC32 has only 32 bit ones.
268 if (is64Bit)
269 Ret += "-i128:128-n32:64";
270 else
271 Ret += "-n32";
272
273 // The ABI alignment for doubles on AIX is 4 bytes.
274 if (T.isOSAIX())
275 Ret += "-f64:32:64";
276
277 // Specify the vector alignment explicitly. For v256i1 and v512i1, the
278 // calculated alignment would be 256*alignment(i1) and 512*alignment(i1),
279 // which is 256 and 512 bytes - way over aligned.
280 if (is64Bit && (T.isOSAIX() || T.isOSLinux()))
281 Ret += "-S128-v256:256:256-v512:512:512";
282
283 return Ret;
284}
285
286static std::string computeAMDDataLayout(const Triple &TT) {
287 if (TT.getArch() == Triple::r600) {
288 // 32-bit pointers.
289 return "e-m:e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
290 "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1";
291 }
292
293 // 32-bit private, local, and region pointers. 64-bit global, constant and
294 // flat. 160-bit non-integral fat buffer pointers that include a 128-bit
295 // buffer descriptor and a 32-bit offset, which are indexed by 32-bit values
296 // (address space 7), and 128-bit non-integral buffer resourcees (address
297 // space 8) which cannot be non-trivilally accessed by LLVM memory operations
298 // like getelementptr.
299 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"
300 "-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-p10:32:32"
301 "-p11:32:32-p12:32:32-p13:32:32-p14:32:32-p15:32:32"
302 "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:"
303 "512-"
304 "v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9";
305}
306
307static std::string computeRISCVDataLayout(const Triple &TT, StringRef ABIName) {
308 if (TT.isOSBinFormatMachO()) {
309 assert(TT.isLittleEndian() && "Invalid endianness");
310 assert(TT.isArch32Bit() && "Invalid triple");
311 assert((ABIName != "ilp32e") && "Invalid ABI.");
312 return "e-m:o-p:32:32-i64:64-n32-S128";
313 }
314
315 std::string Ret;
316
317 if (TT.isLittleEndian())
318 Ret += "e";
319 else
320 Ret += "E";
321
322 Ret += "-m:e";
323
324 // TODO: Maybe we should move RISCVABI to TargetParser, so we can reuse that
325 // logic here instead of duplicating the string handling?
326 bool IsPureCapABI = ABIName.starts_with("il32pc64") ||
327 ABIName.starts_with("l64pc128") ||
328 ABIName.starts_with("cheriot");
329
330 if (TT.isRISCV64()) {
331 Ret += "-p:64:64";
332 if (IsPureCapABI)
333 Ret += "-pe200:128:128:128:64";
334 Ret += "-i64:64-i128:128-n32:64";
335 } else {
336 assert(TT.isRISCV32() && "only RV32 and RV64 are currently supported");
337 Ret += "-p:32:32";
338 if (IsPureCapABI)
339 Ret += "-pe200:64:64:64:32";
340 Ret += "-i64:64-n32";
341 }
342
343 // Stack alignment based on ABI.
344 if (ABIName == "ilp32e")
345 Ret += "-S32";
346 else if (ABIName == "lp64e")
347 Ret += "-S64";
348 else
349 Ret += "-S128";
350
351 // TODO: Support non-purecap CHERI ABIs.
352 if (IsPureCapABI)
353 Ret += "-A200-P200-G200";
354
355 return Ret;
356}
357
358static std::string computeSparcDataLayout(const Triple &T) {
359 const bool Is64Bit = T.isSPARC64();
360
361 // Sparc is typically big endian, but some are little.
362 std::string Ret = T.getArch() == Triple::sparcel ? "e" : "E";
363 Ret += "-m:e";
364
365 // Some ABIs have 32bit pointers.
366 if (!Is64Bit)
367 Ret += "-p:32:32";
368
369 // Alignments for 64 bit integers.
370 Ret += "-i64:64";
371
372 // Alignments for 128 bit integers.
373 // This is not specified in the ABI document but is the de facto standard.
374 Ret += "-i128:128";
375
376 // On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
377 // On SparcV9 registers can hold 64 or 32 bits, on others only 32.
378 if (Is64Bit)
379 Ret += "-n32:64";
380 else
381 Ret += "-f128:64-n32";
382
383 if (Is64Bit)
384 Ret += "-S128";
385 else
386 Ret += "-S64";
387
388 return Ret;
389}
390
391static std::string computeSystemZDataLayout(const Triple &TT) {
392 std::string Ret;
393
394 // Big endian.
395 Ret += "E";
396
397 // The natural stack alignment is 64 bits.
398 Ret += "-S64";
399
400 // Data mangling.
401 Ret += getManglingComponent(TT);
402
403 // Special features for z/OS.
404 if (TT.isOSzOS()) {
405 // Custom address space for ptr32.
406 Ret += "-p1:32:32";
407 }
408
409 // Make sure that global data has at least 16 bits of alignment by
410 // default, so that we can refer to it using LARL. We don't have any
411 // special requirements for stack variables though.
412 Ret += "-i1:8:16-i8:8:16";
413
414 // 64-bit integers are naturally aligned.
415 Ret += "-i64:64";
416
417 // 128-bit floats are aligned only to 64 bits.
418 Ret += "-f128:64";
419
420 // The DataLayout string always holds a vector alignment of 64 bits, see
421 // comment in clang/lib/Basic/Targets/SystemZ.h.
422 Ret += "-v128:64";
423
424 // We prefer 16 bits of aligned for all globals; see above.
425 Ret += "-a:8:16";
426
427 // Integer registers are 32 or 64 bits.
428 Ret += "-n32:64";
429
430 return Ret;
431}
432
433static std::string computeX86DataLayout(const Triple &TT) {
434 bool Is64Bit = TT.isX86_64();
435
436 // X86 is little endian
437 std::string Ret = "e";
438
439 Ret += getManglingComponent(TT);
440 // X86 and x32 have 32 bit pointers.
441 if (!Is64Bit || TT.isX32())
442 Ret += "-p:32:32";
443
444 // Address spaces for 32 bit signed, 32 bit unsigned, and 64 bit pointers.
445 Ret += "-p270:32:32-p271:32:32-p272:64:64";
446
447 // Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
448 // 128 bit integers are not specified in the 32-bit ABIs but are used
449 // internally for lowering f128, so we match the alignment to that.
450 if (Is64Bit || TT.isOSWindows())
451 Ret += "-i64:64-i128:128";
452 else if (TT.isOSIAMCU())
453 Ret += "-i64:32-f64:32";
454 else
455 Ret += "-i128:128-f64:32:64";
456
457 // Some ABIs align long double to 128 bits, others to 32.
458 if (TT.isOSIAMCU())
459 ; // No f80
460 else if (Is64Bit || TT.isOSDarwin() || TT.isWindowsMSVCEnvironment())
461 Ret += "-f80:128";
462 else
463 Ret += "-f80:32";
464
465 if (TT.isOSIAMCU())
466 Ret += "-f128:32";
467
468 // The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
469 if (Is64Bit)
470 Ret += "-n8:16:32:64";
471 else
472 Ret += "-n8:16:32";
473
474 // The stack is aligned to 32 bits on some ABIs and 128 bits on others.
475 if ((!Is64Bit && TT.isOSWindows()) || TT.isOSIAMCU())
476 Ret += "-a:0:32-S32";
477 else
478 Ret += "-S128";
479
480 return Ret;
481}
482
483static std::string computeNVPTXDataLayout(const Triple &T, StringRef ABIName) {
484 const bool Is32Bit = T.getArch() == Triple::nvptx;
485 const bool IsShortPtr = ABIName == "shortptr";
486 std::string Ret = "e";
487
488 if (Is32Bit) {
489 Ret += "-p:32:32";
490 } else {
491 // Keep the pointer specifications sorted by address space.
492 //
493 // In shortptr mode, specify the following address spaces as 32-bits:
494 // - shared (addrspace:3)
495 // - constant (addrspace:4)
496 // - local (addrspace:5)
497 // - shared cluster (addrspace:7)
498 // - entry parameter (addrspace:101)
499 if (IsShortPtr)
500 Ret += "-p3:32:32-p4:32:32-p5:32:32";
501
502 // Tensor Memory (addrspace:6) is always 32-bits.
503 Ret += "-p6:32:32";
504
505 if (IsShortPtr)
506 Ret += "-p7:32:32-p101:32:32";
507 }
508
509 Ret += "-i64:64-i128:128-i256:256-v16:16-v32:32-n16:32:64";
510
511 return Ret;
512}
513
514static std::string computeSPIRVDataLayout(const Triple &TT) {
515 const auto Arch = TT.getArch();
516 // TODO: this probably needs to be revisited:
517 // Logical SPIR-V has no pointer size, so any fixed pointer size would be
518 // wrong. The choice to default to 32 or 64 is just motivated by another
519 // memory model used for graphics: PhysicalStorageBuffer64. But it shouldn't
520 // mean anything.
521 if (Arch == Triple::spirv32)
522 return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-"
523 "v256:256-v512:512-v1024:1024-n8:16:32:64-G1";
524 if (Arch == Triple::spirv)
525 return "e-ve-i64:64-n8:16:32:64-G10";
526 if (TT.getVendor() == Triple::VendorType::AMD &&
527 TT.getOS() == Triple::OSType::AMDHSA)
528 return "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
529 "v512:512-v1024:1024-n32:64-S32-G1-P4-A0";
530 if (TT.getVendor() == Triple::VendorType::Intel)
531 return "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
532 "v512:512-v1024:1024-n8:16:32:64-G1-P9-A0";
533 return "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-"
534 "v512:512-v1024:1024-n8:16:32:64-G1";
535}
536
537static std::string computeLanaiDataLayout() {
538 // Data layout (keep in sync with clang/lib/Basic/Targets.cpp)
539 return "E" // Big endian
540 "-m:e" // ELF name manging
541 "-p:32:32" // 32-bit pointers, 32 bit aligned
542 "-i64:64" // 64 bit integers, 64 bit aligned
543 "-a:0:32" // 32 bit alignment of objects of aggregate type
544 "-n32" // 32 bit native integer width
545 "-S64"; // 64 bit natural stack alignment
546}
547
548static std::string computeWebAssemblyDataLayout(const Triple &TT) {
549 return TT.getArch() == Triple::wasm64
550 ? (TT.isOSEmscripten() ? "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
551 "i128:128-f128:64-n32:64-S128-ni:1:10:20"
552 : "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
553 "i128:128-n32:64-S128-ni:1:10:20")
554 : (TT.isOSEmscripten() ? "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-"
555 "i128:128-f128:64-n32:64-S128-ni:1:10:20"
556 : "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-"
557 "i128:128-n32:64-S128-ni:1:10:20");
558}
559
560static std::string computeVEDataLayout(const Triple &T) {
561 // Aurora VE is little endian
562 std::string Ret = "e";
563
564 // Use ELF mangling
565 Ret += "-m:e";
566
567 // Alignments for 64 bit integers.
568 Ret += "-i64:64";
569
570 // VE supports 32 bit and 64 bits integer on registers
571 Ret += "-n32:64";
572
573 // Stack alignment is 128 bits
574 Ret += "-S128";
575
576 // Vector alignments are 64 bits
577 // Need to define all of them. Otherwise, each alignment becomes
578 // the size of each data by default.
579 Ret += "-v64:64:64"; // for v2f32
580 Ret += "-v128:64:64";
581 Ret += "-v256:64:64";
582 Ret += "-v512:64:64";
583 Ret += "-v1024:64:64";
584 Ret += "-v2048:64:64";
585 Ret += "-v4096:64:64";
586 Ret += "-v8192:64:64";
587 Ret += "-v16384:64:64"; // for v256f64
588
589 return Ret;
590}
591
592std::string Triple::computeDataLayout(StringRef ABIName) const {
593 switch (getArch()) {
594 case Triple::arm:
595 case Triple::armeb:
596 case Triple::thumb:
597 case Triple::thumbeb:
598 return computeARMDataLayout(*this, ABIName);
599 case Triple::aarch64:
602 return computeAArch64DataLayout(*this);
603 case Triple::arc:
604 return "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-"
605 "f32:32:32-i64:32-f64:32-a:0:32-n32";
606 case Triple::avr:
607 return "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8:16-a:8";
608 case Triple::bpfel:
609 case Triple::bpfeb:
610 return computeBPFDataLayout(*this);
611 case Triple::csky:
612 return computeCSKYDataLayout(*this);
613 case Triple::dxil:
614 return "e-m:e-ve-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-"
615 "f32:32-f64:64-n8:16:32:64";
616 case Triple::hexagon:
617 return "e-m:e-p:32:32:32-a:0-n16:32-"
618 "i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-"
619 "v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048";
622 return computeLoongArchDataLayout(*this);
623 case Triple::m68k:
624 return computeM68kDataLayout(*this);
625 case Triple::mips:
626 case Triple::mipsel:
627 case Triple::mips64:
628 case Triple::mips64el:
629 return computeMipsDataLayout(*this, ABIName);
630 case Triple::msp430:
631 return "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16";
632 case Triple::ppc:
633 case Triple::ppcle:
634 case Triple::ppc64:
635 case Triple::ppc64le:
636 return computePowerDataLayout(*this, ABIName);
637 case Triple::amdgpu:
638 case Triple::r600:
639 return computeAMDDataLayout(*this);
640 case Triple::riscv32:
641 case Triple::riscv64:
644 return computeRISCVDataLayout(*this, ABIName);
645 case Triple::sparc:
646 case Triple::sparcv9:
647 case Triple::sparcel:
648 return computeSparcDataLayout(*this);
649 case Triple::systemz:
650 return computeSystemZDataLayout(*this);
651 case Triple::tce:
652 return "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:32:32-"
653 "f16:16:16-f32:32:32-f64:32:32-v64:64:64-i128:128-v128:128:128-"
654 "v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-"
655 "v4096:4096:4096-a0:0:32-n32";
656 case Triple::tcele:
657 return "e-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:32:32-"
658 "f16:16:16-f32:32:32-f64:32:32-v64:64:64-i128:128-v128:128:128-"
659 "v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-"
660 "v4096:4096:4096-a0:0:32-n32";
661 case Triple::tcele64:
662 return "e-p:64:64:64-i1:8:64-i8:8:64-i16:16:64-i32:32:64-i64:64:64-"
663 "f16:16:64-f32:32:64-f64:64:64-v64:64:64-i128:128-v128:128:128-"
664 "v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-"
665 "v4096:4096:4096-a0:0:64-n64";
666 case Triple::x86:
667 case Triple::x86_64:
668 return computeX86DataLayout(*this);
669 case Triple::xcore:
670 return "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:32-f64:32-a:0:32-n32";
671 case Triple::xtensa:
672 return "e-m:e-p:32:32-i8:8:32-i16:16:32-i64:64-n32";
673 case Triple::nvptx:
674 case Triple::nvptx64:
675 return computeNVPTXDataLayout(*this, ABIName);
676 case Triple::spir:
677 case Triple::spir64:
678 case Triple::spirv:
679 case Triple::spirv32:
680 case Triple::spirv64:
681 return computeSPIRVDataLayout(*this);
682 case Triple::lanai:
683 return computeLanaiDataLayout();
684 case Triple::wasm32:
685 case Triple::wasm64:
686 return computeWebAssemblyDataLayout(*this);
687 case Triple::ve:
688 return computeVEDataLayout(*this);
689
690 case Triple::amdil:
691 case Triple::amdil64:
692 case Triple::hsail:
693 case Triple::hsail64:
694 case Triple::kalimba:
695 case Triple::shave:
698 // These are all virtual ISAs with no LLVM backend, and therefore no fixed
699 // LLVM data layout.
700 return "";
701
703 return "";
704 }
705 llvm_unreachable("Invalid arch");
706}
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:514
#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.