[llvm] 315a407 - [Basic] Support 64-bit x86 target for UEFI
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 27 20:23:18 PDT 2023
Author: prabhukr
Date: 2023-09-27T20:23:11-07:00
New Revision: 315a407086b0ab302d0293b720d7f9b3e8f6ffa9
URL: https://github.com/llvm/llvm-project/commit/315a407086b0ab302d0293b720d7f9b3e8f6ffa9
DIFF: https://github.com/llvm/llvm-project/commit/315a407086b0ab302d0293b720d7f9b3e8f6ffa9.diff
LOG: [Basic] Support 64-bit x86 target for UEFI
Adding support for X86_64 UEFI target to begin with.
Reviewed By: phosek, MaskRay
Differential Revision: https://reviews.llvm.org/D152206
Added:
Modified:
llvm/lib/IR/DataLayout.cpp
llvm/lib/TargetParser/Triple.cpp
llvm/unittests/IR/DataLayoutTest.cpp
llvm/unittests/TargetParser/TripleTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 53842b184ed6be0..d324c4b488f7294 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -171,7 +171,7 @@ const char *DataLayout::getManglingComponent(const Triple &T) {
return "-m:l";
if (T.isOSBinFormatMachO())
return "-m:o";
- if (T.isOSWindows() && T.isOSBinFormatCOFF())
+ if ((T.isOSWindows() || T.isUEFI()) && T.isOSBinFormatCOFF())
return T.getArch() == Triple::x86 ? "-m:x" : "-m:w";
if (T.isOSBinFormatXCOFF())
return "-m:a";
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 3da145f3b0b8927..b9fab469f747607 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -799,6 +799,8 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
case Triple::x86_64:
if (T.isOSWindows())
return Triple::COFF;
+ else if (T.isUEFI())
+ return Triple::COFF;
return Triple::ELF;
case Triple::aarch64_be:
diff --git a/llvm/unittests/IR/DataLayoutTest.cpp b/llvm/unittests/IR/DataLayoutTest.cpp
index b9fc2172b7bf2eb..4b711e87e1a9d29 100644
--- a/llvm/unittests/IR/DataLayoutTest.cpp
+++ b/llvm/unittests/IR/DataLayoutTest.cpp
@@ -11,6 +11,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
+#include "llvm/TargetParser/Triple.h"
#include "llvm/Testing/Support/Error.h"
#include "gtest/gtest.h"
@@ -104,4 +105,11 @@ TEST(DataLayoutTest, VectorAlign) {
EXPECT_EQ(Align(4 * 8), DL->getPrefTypeAlign(V8F32Ty));
}
+TEST(DataLayoutTest, UEFI) {
+ Triple TT = Triple("x86_64-unknown-uefi");
+
+ // Test UEFI X86_64 Mangling Component.
+ EXPECT_STREQ(DataLayout::getManglingComponent(TT), "-m:w");
+}
+
} // anonymous namespace
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 2b2ec73fcb8a926..0a43b1a8925d1ea 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -462,6 +462,7 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::UnknownVendor, T.getVendor());
EXPECT_EQ(Triple::UEFI, T.getOS());
EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
+ EXPECT_EQ(Triple::COFF, T.getObjectFormat());
T = Triple("wasm32-unknown-unknown");
EXPECT_EQ(Triple::wasm32, T.getArch());
More information about the llvm-commits
mailing list