Author: Kai Nacke Date: 2020-08-11T05:26:26-04:00 New Revision: b3aece05313e740d26e517a9f32af90818ee4390
URL: https://github.com/llvm/llvm-project/commit/b3aece05313e740d26e517a9f32af90818ee4390 DIFF: https://github.com/llvm/llvm-project/commit/b3aece05313e740d26e517a9f32af90818ee4390.diff LOG: [SystemZ/ZOS] Add binary format goff and operating system zos to the triple Adds the binary format goff and the operating system zos to the triple class. goff is selected as default binary format if zos is choosen as operating system. No further functionality is added. Reviewers: efriedma, tahonermann, hubert.reinterpertcast, MaskRay Reviewed By: efriedma, tahonermann, hubert.reinterpertcast Differential Revision: https://reviews.llvm.org/D82081 Added: Modified: clang/lib/CodeGen/BackendUtil.cpp clang/lib/CodeGen/CGObjCMac.cpp clang/lib/CodeGen/CodeGenModule.cpp llvm/include/llvm/ADT/Triple.h llvm/include/llvm/Support/TargetRegistry.h llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/Support/Triple.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/unittests/ADT/TripleTest.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index f0058690e43d..566affa91b76 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -256,6 +256,8 @@ static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) { return true; case Triple::ELF: return CGOpts.DataSections && !CGOpts.DisableIntegratedAS; + case Triple::GOFF: + llvm::report_fatal_error("ASan not implemented for GOFF"); case Triple::XCOFF: llvm::report_fatal_error("ASan not implemented for XCOFF."); case Triple::Wasm: diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 1d0379afb4b5..5922c63e0116 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -5106,9 +5106,10 @@ std::string CGObjCCommonMac::GetSectionName(StringRef Section, "expected the name to begin with __"); return ("." + Section.substr(2) + "$B").str(); case llvm::Triple::Wasm: + case llvm::Triple::GOFF: case llvm::Triple::XCOFF: llvm::report_fatal_error( - "Objective-C support is unimplemented for object file format."); + "Objective-C support is unimplemented for object file format"); } llvm_unreachable("Unhandled llvm::Triple::ObjectFormatType enum"); diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 67f06ac1c07c..ff35d94626d1 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4915,6 +4915,8 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) { switch (Triple.getObjectFormat()) { case llvm::Triple::UnknownObjectFormat: llvm_unreachable("unknown file format"); + case llvm::Triple::GOFF: + llvm_unreachable("GOFF is not yet implemented"); case llvm::Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); case llvm::Triple::COFF: diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index c578c097c6f6..7c3a4b2b699a 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -173,6 +173,7 @@ class Triple { OpenBSD, Solaris, Win32, + ZOS, Haiku, Minix, RTEMS, @@ -224,6 +225,7 @@ class Triple { COFF, ELF, + GOFF, MachO, Wasm, XCOFF, @@ -468,6 +470,8 @@ class Triple { return getSubArch() == Triple::ARMSubArch_v7k; } + bool isOSzOS() const { return getOS() == Triple::ZOS; } + /// isOSDarwin - Is this a "Darwin" OS (macOS, iOS, tvOS or watchOS). bool isOSDarwin() const { return isMacOSX() || isiOS() || isWatchOS(); @@ -620,6 +624,9 @@ class Triple { return getObjectFormat() == Triple::COFF; } + /// Tests whether the OS uses the GOFF binary format. + bool isOSBinFormatGOFF() const { return getObjectFormat() == Triple::GOFF; } + /// Tests whether the environment is MachO. bool isOSBinFormatMachO() const { return getObjectFormat() == Triple::MachO; diff --git a/llvm/include/llvm/Support/TargetRegistry.h b/llvm/include/llvm/Support/TargetRegistry.h index d91eabae8235..2c65eb60f910 100644 --- a/llvm/include/llvm/Support/TargetRegistry.h +++ b/llvm/include/llvm/Support/TargetRegistry.h @@ -510,6 +510,8 @@ class Target { S = createWasmStreamer(Ctx, std::move(TAB), std::move(OW), std::move(Emitter), RelaxAll); break; + case Triple::GOFF: + report_fatal_error("GOFF MCObjectStreamer not implemented yet"); case Triple::XCOFF: S = createXCOFFStreamer(Ctx, std::move(TAB), std::move(OW), std::move(Emitter), RelaxAll); diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 7afef397e05e..b6b2eb3b0dbe 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4740,6 +4740,9 @@ static const char *getSectionNameForBitcode(const Triple &T) { case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmbc"; + case Triple::GOFF: + llvm_unreachable("GOFF is not yet implemented"); + break; case Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); break; @@ -4756,6 +4759,9 @@ static const char *getSectionNameForCommandline(const Triple &T) { case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmcmd"; + case Triple::GOFF: + llvm_unreachable("GOFF is not yet implemented"); + break; case Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); break; diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index b77a9635f64c..a400cc9de75c 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -904,6 +904,9 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC, Env = IsWasm; initWasmMCObjectFileInfo(TT); break; + case Triple::GOFF: + report_fatal_error("Cannot initialize MC for GOFF object file format"); + break; case Triple::XCOFF: Env = IsXCOFF; initXCOFFMCObjectFileInfo(TT); @@ -923,6 +926,7 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name, case Triple::MachO: case Triple::COFF: case Triple::Wasm: + case Triple::GOFF: case Triple::XCOFF: case Triple::UnknownObjectFormat: report_fatal_error("Cannot get DWARF comdat section for this object file " diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp index 72648273b4cd..7c2c44a53805 100644 --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -215,6 +215,7 @@ StringRef Triple::getOSTypeName(OSType Kind) { case WASI: return "wasi"; case WatchOS: return "watchos"; case Win32: return "windows"; + case ZOS: return "zos"; } llvm_unreachable("Invalid OSType"); @@ -499,6 +500,7 @@ static Triple::OSType parseOS(StringRef OSName) { .StartsWith("solaris", Triple::Solaris) .StartsWith("win32", Triple::Win32) .StartsWith("windows", Triple::Win32) + .StartsWith("zos", Triple::ZOS) .StartsWith("haiku", Triple::Haiku) .StartsWith("minix", Triple::Minix) .StartsWith("rtems", Triple::RTEMS) @@ -552,6 +554,7 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) { .EndsWith("xcoff", Triple::XCOFF) .EndsWith("coff", Triple::COFF) .EndsWith("elf", Triple::ELF) + .EndsWith("goff", Triple::GOFF) .EndsWith("macho", Triple::MachO) .EndsWith("wasm", Triple::Wasm) .Default(Triple::UnknownObjectFormat); @@ -643,6 +646,7 @@ static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) { case Triple::UnknownObjectFormat: return ""; case Triple::COFF: return "coff"; case Triple::ELF: return "elf"; + case Triple::GOFF: return "goff"; case Triple::MachO: return "macho"; case Triple::Wasm: return "wasm"; case Triple::XCOFF: return "xcoff"; @@ -700,7 +704,6 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) { case Triple::sparcv9: case Triple::spir64: case Triple::spir: - case Triple::systemz: case Triple::tce: case Triple::tcele: case Triple::thumbeb: @@ -714,6 +717,11 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) { return Triple::XCOFF; return Triple::ELF; + case Triple::systemz: + if (T.isOSzOS()) + return Triple::GOFF; + return Triple::ELF; + case Triple::wasm32: case Triple::wasm64: return Triple::Wasm; diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 85ab19c20e84..5d52a4b0fc18 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1950,9 +1950,10 @@ StringRef ModuleAddressSanitizer::getGlobalMetadataSection() const { case Triple::ELF: return "asan_globals"; case Triple::MachO: return "__DATA,__asan_globals,regular"; case Triple::Wasm: + case Triple::GOFF: case Triple::XCOFF: report_fatal_error( - "ModuleAddressSanitizer not implemented for object file format."); + "ModuleAddressSanitizer not implemented for object file format"); case Triple::UnknownObjectFormat: break; } diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp index 1852d7b6a1b0..1a6b0557bf50 100644 --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -136,6 +136,18 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::FreeBSD, T.getOS()); EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("s390x-ibm-zos"); + EXPECT_EQ(Triple::systemz, T.getArch()); + EXPECT_EQ(Triple::IBM, T.getVendor()); + EXPECT_EQ(Triple::ZOS, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + + T = Triple("systemz-ibm-zos"); + EXPECT_EQ(Triple::systemz, T.getArch()); + EXPECT_EQ(Triple::IBM, T.getVendor()); + EXPECT_EQ(Triple::ZOS, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("arm-none-none-eabi"); EXPECT_EQ(Triple::arm, T.getArch()); EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); @@ -1314,6 +1326,15 @@ TEST(TripleTest, FileFormat) { EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat()); EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat()); + EXPECT_EQ(Triple::ELF, Triple("systemz-ibm-linux").getObjectFormat()); + EXPECT_EQ(Triple::ELF, Triple("systemz-ibm-unknown").getObjectFormat()); + + EXPECT_EQ(Triple::GOFF, Triple("s390x-ibm-zos").getObjectFormat()); + EXPECT_EQ(Triple::GOFF, Triple("systemz-ibm-zos").getObjectFormat()); + EXPECT_EQ(Triple::GOFF, Triple("s390x-ibm-zos-goff").getObjectFormat()); + EXPECT_EQ(Triple::GOFF, Triple("s390x-unknown-zos-goff").getObjectFormat()); + EXPECT_EQ(Triple::GOFF, Triple("s390x---goff").getObjectFormat()); + EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown").getObjectFormat()); EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown").getObjectFormat()); EXPECT_EQ(Triple::Wasm, Triple("wasm32-wasi").getObjectFormat()); @@ -1360,6 +1381,9 @@ TEST(TripleTest, FileFormat) { T.setObjectFormat(Triple::XCOFF); EXPECT_EQ(Triple::XCOFF, T.getObjectFormat()); + + T.setObjectFormat(Triple::GOFF); + EXPECT_EQ(Triple::GOFF, T.getObjectFormat()); } TEST(TripleTest, NormalizeWindows) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits