llvm.org GIT mirror llvm / bd5fac5
Support: generalise object type handling for Windows This generalises the object file type parsing to all Windows environments. This is used by cygwin as well as MSVC environments for MCJIT. This also makes the triple more similar to Chandler's suggestion of a separate field for the object file format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205219 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
2 changed file(s) with 35 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
546546 Components.resize(4);
547547 Components[2] = "windows";
548548 if (Environment == UnknownEnvironment) {
549 if (ObjectFormat == UnknownObjectFormat)
549 if (ObjectFormat == UnknownObjectFormat || ObjectFormat == Triple::COFF)
550550 Components[3] = "msvc";
551551 else
552552 Components[3] = getObjectFormatTypeName(ObjectFormat);
553 } else if (ObjectFormat != UnknownObjectFormat &&
554 ObjectFormat != Triple::COFF) {
555 Components.resize(5);
556 Components[4] = getObjectFormatTypeName(ObjectFormat);
557553 }
558554 } else if (OS == Triple::MinGW32) {
559555 Components.resize(4);
560556 Components[2] = "windows";
561 Components[3] = (ObjectFormat == Triple::ELF) ? "gnuelf" : "gnu";
557 Components[3] = "gnu";
562558 } else if (OS == Triple::Cygwin) {
563559 Components.resize(4);
564560 Components[2] = "windows";
565561 Components[3] = "cygnus";
562 }
563 if (OS == Triple::MinGW32 || OS == Triple::Cygwin ||
564 (OS == Triple::Win32 && Environment != UnknownEnvironment)) {
565 if (ObjectFormat != UnknownObjectFormat && ObjectFormat != Triple::COFF) {
566 Components.resize(5);
567 Components[4] = getObjectFormatTypeName(ObjectFormat);
568 }
566569 }
567570
568571 // Stick the corrected components back together to form the normalized string.
725728 }
726729
727730 void Triple::setObjectFormat(ObjectFormatType Kind) {
728 setEnvironmentName(getObjectFormatTypeName(Kind));
731 if (Environment == UnknownEnvironment)
732 return setEnvironmentName(getObjectFormatTypeName(Kind));
733
734 Twine Env = getEnvironmentTypeName(Environment) + Twine("-") +
735 getObjectFormatTypeName(Kind);
736 setEnvironmentName(Env.str());
729737 }
730738
731739 void Triple::setArchName(StringRef Str) {
509509 EXPECT_EQ(Triple::COFF, Triple("i686--win32").getObjectFormat());
510510
511511 EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
512
513 {
514 Triple Normalized(Triple::normalize("i686-pc-windows-msvc-elf"));
515 EXPECT_EQ(Triple::ELF, Normalized.getObjectFormat());
516 }
512 EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
513
514 Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
515 EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
516
517 Triple GNUWindowsNormalized(Triple::normalize("i686-pc-windows-gnu-elf"));
518 EXPECT_EQ(Triple::ELF, GNUWindowsNormalized.getObjectFormat());
519
520 Triple CygnusNormalised(Triple::normalize("i686-pc-windows-cygnus-elf"));
521 EXPECT_EQ(Triple::ELF, CygnusNormalised.getObjectFormat());
522
523 Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf"));
524 EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat());
517525
518526 Triple T = Triple("");
519527 T.setObjectFormat(Triple::ELF);
547555 EXPECT_EQ("x86_64-pc-windows-macho", Triple::normalize("x86_64-pc-win32-macho"));
548556 EXPECT_EQ("x86_64--windows-macho", Triple::normalize("x86_64-win32-macho"));
549557
558 EXPECT_EQ("i686-pc-windows-cygnus",
559 Triple::normalize("i686-pc-windows-cygnus"));
560 EXPECT_EQ("i686-pc-windows-gnu", Triple::normalize("i686-pc-windows-gnu"));
550561 EXPECT_EQ("i686-pc-windows-itanium", Triple::normalize("i686-pc-windows-itanium"));
551
552562 EXPECT_EQ("i686-pc-windows-msvc", Triple::normalize("i686-pc-windows-msvc"));
553 }
554 }
563
564 EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-windows-elf-elf"));
565 }
566 }