Skip to content

[clang] Fix UEFI Target info #127290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 30, 2025
Merged

[clang] Fix UEFI Target info #127290

merged 16 commits into from
Apr 30, 2025

Conversation

Prabhuk
Copy link
Contributor

@Prabhuk Prabhuk commented Feb 15, 2025

For X64 UEFI targets set appropriate integer type sizes, and relevant ABI information. Handle va_list type emitted for UEFI target in Clang Codegen.

For X64 UEFI targets, making the integer size and va_list kind fixes.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Feb 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 15, 2025

@llvm/pr-subscribers-clang

Author: Prabhuk (Prabhuk)

Changes

For X64 UEFI targets, making the integer size and va_list kind fixes.


Full diff: https://github.com/llvm/llvm-project/pull/127290.diff

2 Files Affected:

  • (modified) clang/include/clang/Basic/TargetOSMacros.def (+3)
  • (modified) clang/lib/Basic/Targets/X86.h (+11-5)
diff --git a/clang/include/clang/Basic/TargetOSMacros.def b/clang/include/clang/Basic/TargetOSMacros.def
index 58dce330f9c8f..f4f3276ad1c25 100644
--- a/clang/include/clang/Basic/TargetOSMacros.def
+++ b/clang/include/clang/Basic/TargetOSMacros.def
@@ -53,4 +53,7 @@ TARGET_OS(TARGET_OS_NANO, Triple.isWatchOS())
 TARGET_OS(TARGET_IPHONE_SIMULATOR, Triple.isSimulatorEnvironment())
 TARGET_OS(TARGET_OS_UIKITFORMAC, Triple.isMacCatalystEnvironment())
 
+// UEFI target.
+TARGET_OS(TARGET_OS_UEFI, Triple.isUEFI())
+
 #undef TARGET_OS
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 205edcab9ccb3..20fcb25defba2 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -835,16 +835,22 @@ class LLVM_LIBRARY_VISIBILITY UEFIX86_64TargetInfo
 public:
   UEFIX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
       : UEFITargetInfo<X86_64TargetInfo>(Triple, Opts) {
+    LongWidth = LongAlign = 32;
+    DoubleAlign = LongLongAlign = 64;
+    IntMaxType = SignedLongLong;
+    Int64Type = SignedLongLong;
+    SizeType = UnsignedLongLong;
+    PtrDiffType = SignedLongLong;
+    IntPtrType = SignedLongLong;
+    LongDoubleWidth = LongDoubleAlign = 64;
+    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
+    WCharType = UnsignedShort;
+    WIntType = UnsignedShort;
     this->TheCXXABI.set(TargetCXXABI::Microsoft);
-    this->MaxTLSAlign = 8192u * this->getCharWidth();
     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");
   }
 
-  BuiltinVaListKind getBuiltinVaListKind() const override {
-    return TargetInfo::CharPtrBuiltinVaList;
-  }
-
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
     switch (CC) {
     case CC_C:

@Prabhuk
Copy link
Contributor Author

Prabhuk commented Feb 15, 2025

More smaller fixes based on @RossComputerGuy's patch: #120632

@RossComputerGuy
Copy link
Member

Would this unblock #131376?

@Prabhuk
Copy link
Contributor Author

Prabhuk commented Mar 16, 2025

Would this unblock #131376?

I believe it will. @petrhosek can you PTAL?

@RossComputerGuy
Copy link
Member

Alright, if it does fix it then we should get this moving so libc pre-commits working with UEFI isn't blocked.

@Prabhuk Prabhuk requested a review from petrhosek March 18, 2025 23:59
@Prabhuk Prabhuk merged commit 6274cdb into llvm:main Apr 30, 2025
11 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
For X64 UEFI targets set appropriate integer type sizes, and relevant
ABI information. 

---------

Co-authored-by: Petr Hosek <phosek@google.com>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
For X64 UEFI targets set appropriate integer type sizes, and relevant
ABI information. 

---------

Co-authored-by: Petr Hosek <phosek@google.com>
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
For X64 UEFI targets set appropriate integer type sizes, and relevant
ABI information. 

---------

Co-authored-by: Petr Hosek <phosek@google.com>
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
For X64 UEFI targets set appropriate integer type sizes, and relevant
ABI information. 

---------

Co-authored-by: Petr Hosek <phosek@google.com>
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 2025
For X64 UEFI targets set appropriate integer type sizes, and relevant
ABI information. 

---------

Co-authored-by: Petr Hosek <phosek@google.com>
@Prabhuk Prabhuk deleted the fix_uefi_driver branch May 14, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants