aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorPrabhu Rajasekaran <prabhukr@google.com>2025-04-30 10:07:57 -0700
committerGitHub <noreply@github.com>2025-04-30 10:07:57 -0700
commit6274cdb9a6714908c8a4e30d2ef0bf22a6949065 (patch)
treee101b295ac7a1d67080987dfa62bf29fb39039b4 /clang/lib
parent8e4dd21e6362ca161b7fda4fe7c5fa20f72ffab2 (diff)
downloadllvm-6274cdb9a6714908c8a4e30d2ef0bf22a6949065.zip
llvm-6274cdb9a6714908c8a4e30d2ef0bf22a6949065.tar.gz
llvm-6274cdb9a6714908c8a4e30d2ef0bf22a6949065.tar.bz2
[clang] Fix UEFI Target info (#127290)
For X64 UEFI targets set appropriate integer type sizes, and relevant ABI information. --------- Co-authored-by: Petr Hosek <phosek@google.com>
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Basic/Targets/X86.h17
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp1
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp3
3 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index bc8d60f..194f3fa 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -837,8 +837,23 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
public:
UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: UEFITargetInfo<X86_64TargetInfo>(Triple, Opts) {
+ // The UEFI spec does not mandate specific C++ ABI, integer widths, or
+ // alignment. We are setting these defaults to match the Windows target as
+ // it is the only way to build EFI applications with Clang/LLVM today. We
+ // intend to offer flexibility by supporting choices that are not default in
+ // Windows target in the future.
this->TheCXXABI.set(TargetCXXABI::Microsoft);
- this->MaxTLSAlign = 8192u * this->getCharWidth();
+ LongWidth = LongAlign = 32;
+ DoubleAlign = LongLongAlign = 64;
+ LongDoubleWidth = LongDoubleAlign = 64;
+ LongDoubleFormat = &llvm::APFloat::IEEEdouble();
+ IntMaxType = SignedLongLong;
+ Int64Type = SignedLongLong;
+ SizeType = UnsignedLongLong;
+ PtrDiffType = SignedLongLong;
+ IntPtrType = SignedLongLong;
+ WCharType = UnsignedShort;
+ WIntType = UnsignedShort;
this->resetDataLayout("e-m:w-p270:32:32-p271:32:32-p272:64:64-"
"i64:64-i128:128-f80:128-n8:16:32:64-S128");
}
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index f0ce462..242eaec 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -267,6 +267,7 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
: X86AVXABILevel::None);
switch (Triple.getOS()) {
+ case llvm::Triple::UEFI:
case llvm::Triple::Win32:
return createWinX86_64TargetCodeGenInfo(CGM, AVXLevel);
default:
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 762f8af..3ff35c1 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5977,7 +5977,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// We turn strict aliasing off by default if we're Windows MSVC since MSVC
// doesn't do any TBAA.
if (!Args.hasFlag(options::OPT_fstrict_aliasing, StrictAliasingAliasOption,
- options::OPT_fno_strict_aliasing, !IsWindowsMSVC))
+ options::OPT_fno_strict_aliasing,
+ !IsWindowsMSVC && !IsUEFI))
CmdArgs.push_back("-relaxed-aliasing");
if (Args.hasFlag(options::OPT_fno_pointer_tbaa, options::OPT_fpointer_tbaa,
false))