Skip to content

Commit 388ad04

Browse files
author
git apple-llvm automerger
committed
Merge commit '21ed37e3e725' from llvm.org/release/19.x into stable/20240723
2 parents 2515d25 + 21ed37e commit 388ad04

File tree

16 files changed

+138
-12
lines changed

16 files changed

+138
-12
lines changed

clang/lib/Basic/Targets/ARM.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,9 @@ ARMTargetInfo::ARMTargetInfo(const llvm::Triple &Triple,
311311
switch (Triple.getEnvironment()) {
312312
case llvm::Triple::Android:
313313
case llvm::Triple::GNUEABI:
314+
case llvm::Triple::GNUEABIT64:
314315
case llvm::Triple::GNUEABIHF:
316+
case llvm::Triple::GNUEABIHFT64:
315317
case llvm::Triple::MuslEABI:
316318
case llvm::Triple::MuslEABIHF:
317319
case llvm::Triple::OpenHOS:

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ class LLVM_LIBRARY_VISIBILITY LinuxTargetInfo : public OSTargetInfo<Target> {
340340
Builder.defineMacro("_GNU_SOURCE");
341341
if (this->HasFloat128)
342342
Builder.defineMacro("__FLOAT128__");
343+
if (Triple.isTime64ABI()) {
344+
Builder.defineMacro("_FILE_OFFSET_BITS", "64");
345+
Builder.defineMacro("_TIME_BITS", "64");
346+
}
343347
}
344348

345349
public:

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,7 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
177177
else if (ABIStr == "aapcs16")
178178
Kind = ARMABIKind::AAPCS16_VFP;
179179
else if (CodeGenOpts.FloatABI == "hard" ||
180-
(CodeGenOpts.FloatABI != "soft" &&
181-
(Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
182-
Triple.getEnvironment() == llvm::Triple::MuslEABIHF ||
183-
Triple.getEnvironment() == llvm::Triple::EABIHF)))
180+
(CodeGenOpts.FloatABI != "soft" && Triple.isHardFloatABI()))
184181
Kind = ARMABIKind::AAPCS_VFP;
185182

186183
return createARMTargetCodeGenInfo(CGM, Kind);

clang/lib/CodeGen/Targets/ARM.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class ARMABIInfo : public ABIInfo {
3535
case llvm::Triple::EABI:
3636
case llvm::Triple::EABIHF:
3737
case llvm::Triple::GNUEABI:
38+
case llvm::Triple::GNUEABIT64:
3839
case llvm::Triple::GNUEABIHF:
40+
case llvm::Triple::GNUEABIHFT64:
3941
case llvm::Triple::MuslEABI:
4042
case llvm::Triple::MuslEABIHF:
4143
return true;
@@ -48,6 +50,7 @@ class ARMABIInfo : public ABIInfo {
4850
switch (getTarget().getTriple().getEnvironment()) {
4951
case llvm::Triple::EABIHF:
5052
case llvm::Triple::GNUEABIHF:
53+
case llvm::Triple::GNUEABIHFT64:
5154
case llvm::Triple::MuslEABIHF:
5255
return true;
5356
default:

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ static llvm::Triple computeTargetTriple(const Driver &D,
602602
if (A->getOption().matches(options::OPT_m64) ||
603603
A->getOption().matches(options::OPT_maix64)) {
604604
AT = Target.get64BitArchVariant().getArch();
605-
if (Target.getEnvironment() == llvm::Triple::GNUX32)
605+
if (Target.getEnvironment() == llvm::Triple::GNUX32 ||
606+
Target.getEnvironment() == llvm::Triple::GNUT64)
606607
Target.setEnvironment(llvm::Triple::GNU);
607608
else if (Target.getEnvironment() == llvm::Triple::MuslX32)
608609
Target.setEnvironment(llvm::Triple::Musl);
@@ -665,11 +666,13 @@ static llvm::Triple computeTargetTriple(const Driver &D,
665666
} else if (ABIName == "n32") {
666667
Target = Target.get64BitArchVariant();
667668
if (Target.getEnvironment() == llvm::Triple::GNU ||
669+
Target.getEnvironment() == llvm::Triple::GNUT64 ||
668670
Target.getEnvironment() == llvm::Triple::GNUABI64)
669671
Target.setEnvironment(llvm::Triple::GNUABIN32);
670672
} else if (ABIName == "64") {
671673
Target = Target.get64BitArchVariant();
672674
if (Target.getEnvironment() == llvm::Triple::GNU ||
675+
Target.getEnvironment() == llvm::Triple::GNUT64 ||
673676
Target.getEnvironment() == llvm::Triple::GNUABIN32)
674677
Target.setEnvironment(llvm::Triple::GNUABI64);
675678
}

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,11 @@ void arm::setFloatABIInTriple(const Driver &D, const ArgList &Args,
327327
Triple.setEnvironment(isHardFloat ? llvm::Triple::GNUEABIHF
328328
: llvm::Triple::GNUEABI);
329329
break;
330+
case llvm::Triple::GNUEABIT64:
331+
case llvm::Triple::GNUEABIHFT64:
332+
Triple.setEnvironment(isHardFloat ? llvm::Triple::GNUEABIHFT64
333+
: llvm::Triple::GNUEABIT64);
334+
break;
330335
case llvm::Triple::EABI:
331336
case llvm::Triple::EABIHF:
332337
Triple.setEnvironment(isHardFloat ? llvm::Triple::EABIHF
@@ -414,10 +419,12 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) {
414419
return FloatABI::Soft;
415420
switch (Triple.getEnvironment()) {
416421
case llvm::Triple::GNUEABIHF:
422+
case llvm::Triple::GNUEABIHFT64:
417423
case llvm::Triple::MuslEABIHF:
418424
case llvm::Triple::EABIHF:
419425
return FloatABI::Hard;
420426
case llvm::Triple::GNUEABI:
427+
case llvm::Triple::GNUEABIT64:
421428
case llvm::Triple::MuslEABI:
422429
case llvm::Triple::EABI:
423430
// EABI is always AAPCS, and if it was not marked 'hard', it's softfp

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,6 +2694,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
26942694
case llvm::Triple::thumb:
26952695
LibDirs.append(begin(ARMLibDirs), end(ARMLibDirs));
26962696
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF ||
2697+
TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHFT64 ||
26972698
TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF ||
26982699
TargetTriple.getEnvironment() == llvm::Triple::EABIHF) {
26992700
TripleAliases.append(begin(ARMHFTriples), end(ARMHFTriples));
@@ -2705,6 +2706,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
27052706
case llvm::Triple::thumbeb:
27062707
LibDirs.append(begin(ARMebLibDirs), end(ARMebLibDirs));
27072708
if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF ||
2709+
TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHFT64 ||
27082710
TargetTriple.getEnvironment() == llvm::Triple::MuslEABIHF ||
27092711
TargetTriple.getEnvironment() == llvm::Triple::EABIHF) {
27102712
TripleAliases.append(begin(ARMebHFTriples), end(ARMebHFTriples));

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
508508
case llvm::Triple::thumbeb: {
509509
const bool HF =
510510
Triple.getEnvironment() == llvm::Triple::GNUEABIHF ||
511+
Triple.getEnvironment() == llvm::Triple::GNUEABIHFT64 ||
511512
tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard;
512513

513514
LibDir = "lib";

clang/test/Preprocessor/time64.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %clang_cc1 -E -dM -triple=i686-pc-linux-gnu /dev/null | FileCheck -match-full-lines -check-prefix TIME32 %s
2+
// RUN: %clang_cc1 -E -dM -triple=i686-pc-linux-gnut64 /dev/null | FileCheck -match-full-lines -check-prefix TIME64 %s
3+
// RUN: %clang_cc1 -E -dM -triple=armv5tel-softfloat-linux-gnueabi /dev/null | FileCheck -match-full-lines -check-prefix TIME32 %s
4+
// RUN: %clang_cc1 -E -dM -triple=armv5tel-softfloat-linux-gnueabit64 /dev/null | FileCheck -match-full-lines -check-prefix TIME64 %s
5+
// RUN: %clang_cc1 -E -dM -triple=armv7a-unknown-linux-gnueabihf /dev/null | FileCheck -match-full-lines -check-prefix TIME32 %s
6+
// RUN: %clang_cc1 -E -dM -triple=armv7a-unknown-linux-gnueabihft64 /dev/null | FileCheck -match-full-lines -check-prefix TIME64 %s
7+
//
8+
// TIME32-NOT:#define _FILE_OFFSET_BITS 64
9+
// TIME32-NOT:#define _TIME_BITS 64
10+
//
11+
// TIME64:#define _FILE_OFFSET_BITS 64
12+
// TIME64:#define _TIME_BITS 64

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,11 @@ class Triple {
295295

296296
PAuthTest,
297297

298-
LastEnvironmentType = PAuthTest
298+
GNUT64,
299+
GNUEABIT64,
300+
GNUEABIHFT64,
301+
302+
LastEnvironmentType = GNUEABIHFT64
299303
};
300304
enum ObjectFormatType {
301305
UnknownObjectFormat,
@@ -606,11 +610,12 @@ class Triple {
606610

607611
bool isGNUEnvironment() const {
608612
EnvironmentType Env = getEnvironment();
609-
return Env == Triple::GNU || Env == Triple::GNUABIN32 ||
610-
Env == Triple::GNUABI64 || Env == Triple::GNUEABI ||
611-
Env == Triple::GNUEABIHF || Env == Triple::GNUF32 ||
612-
Env == Triple::GNUF64 || Env == Triple::GNUSF ||
613-
Env == Triple::GNUX32;
613+
return Env == Triple::GNU || Env == Triple::GNUT64 ||
614+
Env == Triple::GNUABIN32 || Env == Triple::GNUABI64 ||
615+
Env == Triple::GNUEABI || Env == Triple::GNUEABIT64 ||
616+
Env == Triple::GNUEABIHF || Env == Triple::GNUEABIHFT64 ||
617+
Env == Triple::GNUF32 || Env == Triple::GNUF64 ||
618+
Env == Triple::GNUSF || Env == Triple::GNUX32;
614619
}
615620

616621
/// Tests whether the OS is Haiku.
@@ -867,9 +872,11 @@ class Triple {
867872
return (isARM() || isThumb()) &&
868873
(getEnvironment() == Triple::EABI ||
869874
getEnvironment() == Triple::GNUEABI ||
875+
getEnvironment() == Triple::GNUEABIT64 ||
870876
getEnvironment() == Triple::MuslEABI ||
871877
getEnvironment() == Triple::EABIHF ||
872878
getEnvironment() == Triple::GNUEABIHF ||
879+
getEnvironment() == Triple::GNUEABIHFT64 ||
873880
getEnvironment() == Triple::OpenHOS ||
874881
getEnvironment() == Triple::MuslEABIHF || isAndroid()) &&
875882
isOSBinFormatELF();
@@ -1047,6 +1054,22 @@ class Triple {
10471054
return getArch() == Triple::bpfel || getArch() == Triple::bpfeb;
10481055
}
10491056

1057+
/// Tests if the target forces 64-bit time_t on a 32-bit architecture.
1058+
bool isTime64ABI() const {
1059+
EnvironmentType Env = getEnvironment();
1060+
return Env == Triple::GNUT64 || Env == Triple::GNUEABIT64 ||
1061+
Env == Triple::GNUEABIHFT64;
1062+
}
1063+
1064+
/// Tests if the target forces hardfloat.
1065+
bool isHardFloatABI() const {
1066+
EnvironmentType Env = getEnvironment();
1067+
return Env == llvm::Triple::GNUEABIHF ||
1068+
Env == llvm::Triple::GNUEABIHFT64 ||
1069+
Env == llvm::Triple::MuslEABIHF ||
1070+
Env == llvm::Triple::EABIHF;
1071+
}
1072+
10501073
/// Tests whether the target supports comdat
10511074
bool supportsCOMDAT() const {
10521075
return !(isOSBinFormatMachO() || isOSBinFormatXCOFF() ||

0 commit comments

Comments
 (0)