Prabhuk updated this revision to Diff 557456. Prabhuk added a comment. Relanding the change.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152206/new/ https://reviews.llvm.org/D152206 Files: llvm/lib/IR/DataLayout.cpp llvm/lib/TargetParser/Triple.cpp llvm/unittests/IR/DataLayoutTest.cpp llvm/unittests/TargetParser/TripleTest.cpp Index: llvm/unittests/TargetParser/TripleTest.cpp =================================================================== --- llvm/unittests/TargetParser/TripleTest.cpp +++ llvm/unittests/TargetParser/TripleTest.cpp @@ -462,6 +462,7 @@ 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()); Index: llvm/unittests/IR/DataLayoutTest.cpp =================================================================== --- llvm/unittests/IR/DataLayoutTest.cpp +++ 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 @@ 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 Index: llvm/lib/TargetParser/Triple.cpp =================================================================== --- llvm/lib/TargetParser/Triple.cpp +++ llvm/lib/TargetParser/Triple.cpp @@ -799,6 +799,8 @@ case Triple::x86_64: if (T.isOSWindows()) return Triple::COFF; + else if (T.isUEFI()) + return Triple::COFF; return Triple::ELF; case Triple::aarch64_be: Index: llvm/lib/IR/DataLayout.cpp =================================================================== --- llvm/lib/IR/DataLayout.cpp +++ llvm/lib/IR/DataLayout.cpp @@ -171,7 +171,7 @@ 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";
Index: llvm/unittests/TargetParser/TripleTest.cpp =================================================================== --- llvm/unittests/TargetParser/TripleTest.cpp +++ llvm/unittests/TargetParser/TripleTest.cpp @@ -462,6 +462,7 @@ 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()); Index: llvm/unittests/IR/DataLayoutTest.cpp =================================================================== --- llvm/unittests/IR/DataLayoutTest.cpp +++ 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 @@ 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 Index: llvm/lib/TargetParser/Triple.cpp =================================================================== --- llvm/lib/TargetParser/Triple.cpp +++ llvm/lib/TargetParser/Triple.cpp @@ -799,6 +799,8 @@ case Triple::x86_64: if (T.isOSWindows()) return Triple::COFF; + else if (T.isUEFI()) + return Triple::COFF; return Triple::ELF; case Triple::aarch64_be: Index: llvm/lib/IR/DataLayout.cpp =================================================================== --- llvm/lib/IR/DataLayout.cpp +++ llvm/lib/IR/DataLayout.cpp @@ -171,7 +171,7 @@ 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";
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits