Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -255,6 +255,8 @@ 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: Index: clang/lib/CodeGen/CGObjCMac.cpp =================================================================== --- clang/lib/CodeGen/CGObjCMac.cpp +++ clang/lib/CodeGen/CGObjCMac.cpp @@ -5106,9 +5106,10 @@ "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"); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4901,6 +4901,8 @@ 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: Index: llvm/include/llvm/ADT/Triple.h =================================================================== --- llvm/include/llvm/ADT/Triple.h +++ llvm/include/llvm/ADT/Triple.h @@ -173,6 +173,7 @@ OpenBSD, Solaris, Win32, + ZOS, Haiku, Minix, RTEMS, @@ -225,6 +226,7 @@ COFF, ELF, + GOFF, MachO, Wasm, XCOFF, @@ -479,6 +481,8 @@ 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(); @@ -631,6 +635,9 @@ 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; Index: llvm/include/llvm/Support/TargetRegistry.h =================================================================== --- llvm/include/llvm/Support/TargetRegistry.h +++ llvm/include/llvm/Support/TargetRegistry.h @@ -510,6 +510,8 @@ 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); Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4728,6 +4728,8 @@ case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmbc"; + case Triple::GOFF: + llvm_unreachable("GOFF is not yet implemented"); case Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); break; @@ -4744,6 +4746,8 @@ case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmcmd"; + case Triple::GOFF: + llvm_unreachable("GOFF is not yet implemented"); case Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); break; Index: llvm/lib/MC/MCObjectFileInfo.cpp =================================================================== --- llvm/lib/MC/MCObjectFileInfo.cpp +++ llvm/lib/MC/MCObjectFileInfo.cpp @@ -904,6 +904,8 @@ Env = IsWasm; initWasmMCObjectFileInfo(TT); break; + case Triple::GOFF: + report_fatal_error("Cannot initialize MC for GOFF object file format"); case Triple::XCOFF: Env = IsXCOFF; initXCOFFMCObjectFileInfo(TT); @@ -923,6 +925,7 @@ 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 " Index: llvm/lib/Support/Triple.cpp =================================================================== --- llvm/lib/Support/Triple.cpp +++ llvm/lib/Support/Triple.cpp @@ -217,6 +217,8 @@ case WASI: return "wasi"; case WatchOS: return "watchos"; case Win32: return "windows"; + case ZOS: + return "zos"; } llvm_unreachable("Invalid OSType"); @@ -503,6 +505,7 @@ .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) @@ -557,6 +560,7 @@ .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); @@ -650,6 +654,7 @@ case Triple::ELF: return "elf"; case Triple::MachO: return "macho"; case Triple::Wasm: return "wasm"; + case Triple::GOFF: return "goff"; case Triple::XCOFF: return "xcoff"; } llvm_unreachable("unknown object format type"); @@ -705,7 +710,6 @@ case Triple::sparcv9: case Triple::spir64: case Triple::spir: - case Triple::systemz: case Triple::tce: case Triple::tcele: case Triple::thumbeb: @@ -719,6 +723,11 @@ return Triple::XCOFF; return Triple::ELF; + case Triple::systemz: + if (T.getOS() == Triple::ZOS) + return Triple::GOFF; + return Triple::ELF; + case Triple::wasm32: case Triple::wasm64: return Triple::Wasm; Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1960,9 +1960,10 @@ 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; } Index: llvm/unittests/ADT/TripleTest.cpp =================================================================== --- llvm/unittests/ADT/TripleTest.cpp +++ llvm/unittests/ADT/TripleTest.cpp @@ -170,6 +170,18 @@ 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()); @@ -1289,6 +1301,15 @@ 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()); @@ -1335,6 +1356,9 @@ T.setObjectFormat(Triple::XCOFF); EXPECT_EQ(Triple::XCOFF, T.getObjectFormat()); + + T.setObjectFormat(Triple::GOFF); + EXPECT_EQ(Triple::GOFF, T.getObjectFormat()); } TEST(TripleTest, NormalizeWindows) {