Skip to content

Commit 4b9d0c4

Browse files
author
git apple-llvm automerger
committed
Merge commit '6274cdb9a671' from llvm.org/main into next
2 parents bcd210d + 6274cdb commit 4b9d0c4

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

clang/include/clang/Basic/TargetOSMacros.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@ TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS())
5353
TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment())
5454
TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment())
5555

56+
// UEFI target.
57+
TARGET_OS(TARGET_OS_UEFI, Triple.isUEFI())
58+
5659
#undef TARGET_OS

clang/lib/Basic/Targets/X86.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,23 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
836836
public:
837837
UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
838838
: UEFITargetInfo<X86_64TargetInfo>(Triple, Opts) {
839+
// The UEFI spec does not mandate specific C++ ABI, integer widths, or
840+
// alignment. We are setting these defaults to match the Windows target as
841+
// it is the only way to build EFI applications with Clang/LLVM today. We
842+
// intend to offer flexibility by supporting choices that are not default in
843+
// Windows target in the future.
839844
this->TheCXXABI.set(TargetCXXABI::Microsoft);
840-
this->MaxTLSAlign = 8192u * this->getCharWidth();
845+
LongWidth = LongAlign = 32;
846+
DoubleAlign = LongLongAlign = 64;
847+
LongDoubleWidth = LongDoubleAlign = 64;
848+
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
849+
IntMaxType = SignedLongLong;
850+
Int64Type = SignedLongLong;
851+
SizeType = UnsignedLongLong;
852+
PtrDiffType = SignedLongLong;
853+
IntPtrType = SignedLongLong;
854+
WCharType = UnsignedShort;
855+
WIntType = UnsignedShort;
841856
this->resetDataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-"
842857
"i64:64-i128:128-f80:128-n8:16:32:64-S128");
843858
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
267267
: X86AVXABILevel::None);
268268

269269
switch (Triple.getOS()) {
270+
case llvm::Triple::UEFI:
270271
case llvm::Triple::Win32:
271272
return createWinX86_64TargetCodeGenInfo(CGM, AVXLevel);
272273
default:

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6137,7 +6137,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &Job,
61376137
// We turn strict aliasing off by default if we're Windows MSVC since MSVC
61386138
// doesn't do any TBAA.
61396139
if (!Args.hasFlag(options::OPT_fstrict_aliasing, StrictAliasingAliasOption,
6140-
options::OPT_fno_strict_aliasing, !IsWindowsMSVC))
6140+
options::OPT_fno_strict_aliasing,
6141+
!IsWindowsMSVC && !IsUEFI))
61416142
CmdArgs.push_back("-relaxed-aliasing");
61426143
if (Args.hasFlag(options::OPT_fno_pointer_tbaa, options::OPT_fpointer_tbaa,
61436144
false))

clang/test/Preprocessor/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,6 +2835,7 @@
28352835
// RISCV64-LINUX: #define unix 1
28362836

28372837
// RUN: %clang_cc1 -dM -triple=x86_64-uefi -E /dev/null | FileCheck -match-full-lines -check-prefix UEFI %s
2838+
// RUN: %clang_cc1 -dM -triple=x86_64-unknown-uefi -E /dev/null | FileCheck -match-full-lines -check-prefix UEFI %s
28382839

28392840
// UEFI: #define __UEFI__ 1
28402841

0 commit comments

Comments
 (0)