Skip to content

Commit

Permalink
[Basic] Support 64-bit x86 target for UEFI
Browse files Browse the repository at this point in the history
Adding support for X86_64 UEFI target to begin with.

Reviewed By: phosek, MaskRay

Differential Revision: https://reviews.llvm.org/D152206
  • Loading branch information
Prabhuk committed Sep 28, 2023
1 parent 0ea3d88 commit 720e3ba
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/IR/DataLayout.cpp
Expand Up @@ -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";
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/TargetParser/Triple.cpp
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions llvm/unittests/IR/DataLayoutTest.cpp
Expand Up @@ -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"

Expand Down Expand Up @@ -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
1 change: 1 addition & 0 deletions llvm/unittests/TargetParser/TripleTest.cpp
Expand Up @@ -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());
Expand Down

0 comments on commit 720e3ba

Please sign in to comment.