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