Skip to content

Commit 25ab042

Browse files
committed
Remove all uses of isArch64Bit and simplify CSKY implementation
1 parent d45ce60 commit 25ab042

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

llvm/lib/TargetParser/TargetDataLayout.cpp

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,12 @@ static std::string computeBPFDataLayout(const Triple &TT) {
107107
}
108108

109109
static std::string computeCSKYDataLayout(const Triple &TT) {
110-
std::string Ret;
111-
112-
// Only support little endian for now.
113-
// TODO: Add support for big endian.
114-
Ret += "e";
115-
116110
// CSKY is always 32-bit target with the CSKYv2 ABI as prefer now.
117111
// It's a 4-byte aligned stack with ELF mangling only.
118-
Ret += "-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32"
112+
// Only support little endian for now.
113+
// TODO: Add support for big endian.
114+
return "e-m:e-S32-p:32:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:32"
119115
"-v128:32:32-a:0:32-Fi32-n32";
120-
121-
return Ret;
122116
}
123117

124118
static std::string computeLoongArchDataLayout(const Triple &TT) {
@@ -320,7 +314,7 @@ static std::string computeSparcDataLayout(const Triple &T) {
320314
Ret += "-m:e";
321315

322316
// Some ABIs have 32bit pointers.
323-
if (!is64Bit)
317+
if (!Is64Bit)
324318
Ret += "-p:32:32";
325319

326320
// Alignments for 64 bit integers.
@@ -332,12 +326,12 @@ static std::string computeSparcDataLayout(const Triple &T) {
332326

333327
// On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
334328
// On SparcV9 registers can hold 64 or 32 bits, on others only 32.
335-
if (is64Bit)
329+
if (Is64Bit)
336330
Ret += "-n32:64";
337331
else
338332
Ret += "-f128:64-n32";
339333

340-
if (is64Bit)
334+
if (Is64Bit)
341335
Ret += "-S128";
342336
else
343337
Ret += "-S64";
@@ -356,10 +350,8 @@ static std::string computeSystemZDataLayout(const Triple &TT) {
356350

357351
// Special features for z/OS.
358352
if (TT.isOSzOS()) {
359-
if (TT.isArch64Bit()) {
360-
// Custom address space for ptr32.
361-
Ret += "-p1:32:32";
362-
}
353+
// Custom address space for ptr32.
354+
Ret += "-p1:32:32";
363355
}
364356

365357
// Make sure that global data has at least 16 bits of alignment by
@@ -387,12 +379,14 @@ static std::string computeSystemZDataLayout(const Triple &TT) {
387379
}
388380

389381
static std::string computeX86DataLayout(const Triple &TT) {
382+
bool Is64Bit = TT.getArch() == Triple::x86_64;
383+
390384
// X86 is little endian
391385
std::string Ret = "e";
392386

393387
Ret += getManglingComponent(TT);
394388
// X86 and x32 have 32 bit pointers.
395-
if (!TT.isArch64Bit() || TT.isX32())
389+
if (!Is64Bit || TT.isX32())
396390
Ret += "-p:32:32";
397391

398392
// Address spaces for 32 bit signed, 32 bit unsigned, and 64 bit pointers.
@@ -401,7 +395,7 @@ static std::string computeX86DataLayout(const Triple &TT) {
401395
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
402396
// 128 bit integers are not specified in the 32-bit ABIs but are used
403397
// internally for lowering f128, so we match the alignment to that.
404-
if (TT.isArch64Bit() || TT.isOSWindows())
398+
if (Is64Bit || TT.isOSWindows())
405399
Ret += "-i64:64-i128:128";
406400
else if (TT.isOSIAMCU())
407401
Ret += "-i64:32-f64:32";
@@ -411,7 +405,7 @@ static std::string computeX86DataLayout(const Triple &TT) {
411405
// Some ABIs align long double to 128 bits, others to 32.
412406
if (TT.isOSIAMCU())
413407
; // No f80
414-
else if (TT.isArch64Bit() || TT.isOSDarwin() || TT.isWindowsMSVCEnvironment())
408+
else if (Is64Bit || TT.isOSDarwin() || TT.isWindowsMSVCEnvironment())
415409
Ret += "-f80:128";
416410
else
417411
Ret += "-f80:32";
@@ -420,13 +414,13 @@ static std::string computeX86DataLayout(const Triple &TT) {
420414
Ret += "-f128:32";
421415

422416
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
423-
if (TT.isArch64Bit())
417+
if (Is64Bit)
424418
Ret += "-n8:16:32:64";
425419
else
426420
Ret += "-n8:16:32";
427421

428422
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
429-
if ((!TT.isArch64Bit() && TT.isOSWindows()) || TT.isOSIAMCU())
423+
if ((!Is64Bit && TT.isOSWindows()) || TT.isOSIAMCU())
430424
Ret += "-a:0:32-S32";
431425
else
432426
Ret += "-S128";
@@ -435,12 +429,13 @@ static std::string computeX86DataLayout(const Triple &TT) {
435429
}
436430

437431
static std::string computeNVPTXDataLayout(const Triple &T, StringRef ABIName) {
432+
bool Is64Bit = T.getArch() == Triple::nvptx64;
438433
std::string Ret = "e";
439434

440435
// Tensor Memory (addrspace:6) is always 32-bits.
441436
// Distributed Shared Memory (addrspace:7) follows shared memory
442437
// (addrspace:3).
443-
if (!T.isArch64Bit())
438+
if (!Is64Bit)
444439
Ret += "-p:32:32-p6:32:32-p7:32:32";
445440
else if (ABIName == "shortptr")
446441
Ret += "-p3:32:32-p4:32:32-p5:32:32-p6:32:32-p7:32:32";
@@ -485,7 +480,7 @@ static std::string computeLanaiDataLayout() {
485480
}
486481

487482
static std::string computeWebAssemblyDataLayout(const Triple &TT) {
488-
return TT.isArch64Bit()
483+
return TT.getArch() == Triple::wasm64
489484
? (TT.isOSEmscripten() ? "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"
490485
"i128:128-f128:64-n32:64-S128-ni:1:10:20"
491486
: "e-m:e-p:64:64-p10:8:8-p20:8:8-i64:64-"

0 commit comments

Comments
 (0)