@@ -445,42 +445,30 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
445
445
LongWidth = LongAlign = PointerWidth = PointerAlign = 64 ;
446
446
IntMaxType = SignedLong;
447
447
Int64Type = SignedLong;
448
- std::string DataLayout;
449
448
450
449
if (Triple.isOSAIX ()) {
451
450
// TODO: Set appropriate ABI for AIX platform.
452
- DataLayout = " E-m:a-Fi64-i64:64-i128:128-n32:64" ;
453
451
LongDoubleWidth = 64 ;
454
452
LongDoubleAlign = DoubleAlign = 32 ;
455
453
LongDoubleFormat = &llvm::APFloat::IEEEdouble ();
456
- } else if ((Triple.getArch () == llvm::Triple::ppc64le)) {
457
- DataLayout = " e-m:e-Fn32-i64:64-i128:128-n32:64 " ;
454
+ } else if ((Triple.getArch () == llvm::Triple::ppc64le) ||
455
+ Triple. isPPC64ELFv2ABI ()) {
458
456
ABI = " elfv2" ;
459
457
} else {
460
- DataLayout = " E-m:e" ;
461
- if (Triple.isPPC64ELFv2ABI ()) {
462
- ABI = " elfv2" ;
463
- DataLayout += " -Fn32" ;
464
- } else {
465
- ABI = " elfv1" ;
466
- DataLayout += " -Fi64" ;
467
- }
468
- DataLayout += " -i64:64-i128:128-n32:64" ;
458
+ ABI = " elfv1" ;
469
459
}
470
460
471
461
if (Triple.isOSFreeBSD () || Triple.isOSOpenBSD () || Triple.isMusl ()) {
472
462
LongDoubleWidth = LongDoubleAlign = 64 ;
473
463
LongDoubleFormat = &llvm::APFloat::IEEEdouble ();
474
464
}
475
465
476
- if (Triple.isOSAIX () || Triple.isOSLinux ())
477
- DataLayout += " -S128-v256:256:256-v512:512:512" ;
478
- resetDataLayout (DataLayout);
479
-
480
466
// Newer PPC64 instruction sets support atomics up to 16 bytes.
481
467
MaxAtomicPromoteWidth = 128 ;
482
468
// Baseline PPC64 supports inlining atomics up to 8 bytes.
483
469
MaxAtomicInlineWidth = 64 ;
470
+
471
+ calculateDataLayout ();
484
472
}
485
473
486
474
void setMaxAtomicWidth () override {
@@ -495,10 +483,33 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public PPCTargetInfo {
495
483
return TargetInfo::CharPtrBuiltinVaList;
496
484
}
497
485
486
+ void calculateDataLayout () {
487
+ std::string DataLayout;
488
+
489
+ if (getTriple ().isOSAIX ()) {
490
+ DataLayout = " E-m:a-Fi64-i64:64-i128:128-n32:64" ;
491
+ } else if ((getTriple ().getArch () == llvm::Triple::ppc64le)) {
492
+ DataLayout = " e-m:e-Fn32-i64:64-i128:128-n32:64" ;
493
+ } else {
494
+ DataLayout = " E-m:e" ;
495
+ if (ABI == " elfv2" ) {
496
+ DataLayout += " -Fn32" ;
497
+ } else {
498
+ DataLayout += " -Fi64" ;
499
+ }
500
+ DataLayout += " -i64:64-i128:128-n32:64" ;
501
+ }
502
+
503
+ if (getTriple ().isOSAIX () || getTriple ().isOSLinux ())
504
+ DataLayout += " -S128-v256:256:256-v512:512:512" ;
505
+ resetDataLayout (DataLayout);
506
+ }
507
+
498
508
// PPC64 Linux-specific ABI options.
499
509
bool setABI (const std::string &Name) override {
500
510
if (Name == " elfv1" || Name == " elfv2" ) {
501
511
ABI = Name;
512
+ calculateDataLayout ();
502
513
return true ;
503
514
}
504
515
return false ;
0 commit comments