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 @@ -5107,6 +5107,7 @@ return ("." + Section.substr(2) + "$B").str(); case llvm::Triple::Wasm: case llvm::Triple::XCOFF: + case llvm::Triple::GOFF: llvm::report_fatal_error( "Objective-C support is unimplemented for object file format."); } Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4903,6 +4903,8 @@ llvm_unreachable("unknown file format"); case llvm::Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); + case llvm::Triple::GOFF: + llvm_unreachable("GOFF is not yet implemented"); case llvm::Triple::COFF: case llvm::Triple::ELF: case llvm::Triple::Wasm: 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,10 @@ 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 +637,11 @@ 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 @@ -514,6 +514,8 @@ S = createXCOFFStreamer(Ctx, std::move(TAB), std::move(OW), std::move(Emitter), RelaxAll); break; + case Triple::GOFF: + report_fatal_error("GOFF MCObjectStreamer not implemented yet."); } if (ObjectTargetStreamerCtorFn) ObjectTargetStreamerCtorFn(*S, STI); 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 @@ -908,6 +908,8 @@ Env = IsXCOFF; initXCOFFMCObjectFileInfo(TT); break; + case Triple::GOFF: + report_fatal_error("Cannot initialize MC for GOFF object file format."); case Triple::UnknownObjectFormat: report_fatal_error("Cannot initialize MC for unknown object file format."); break; @@ -924,6 +926,7 @@ case Triple::COFF: case Triple::Wasm: case Triple::XCOFF: + case Triple::GOFF: case Triple::UnknownObjectFormat: report_fatal_error("Cannot get DWARF comdat section for this object file " "format: not implemented."); Index: llvm/lib/Support/Triple.cpp =================================================================== --- llvm/lib/Support/Triple.cpp +++ llvm/lib/Support/Triple.cpp @@ -217,6 +217,7 @@ case WASI: return "wasi"; case WatchOS: return "watchos"; case Win32: return "windows"; + case ZOS: return "zos"; } llvm_unreachable("Invalid OSType"); @@ -503,6 +504,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 +559,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); @@ -651,6 +654,7 @@ case Triple::MachO: return "macho"; case Triple::Wasm: return "wasm"; case Triple::XCOFF: return "xcoff"; + case Triple::GOFF: return "goff"; } llvm_unreachable("unknown object format type"); } @@ -705,7 +709,6 @@ case Triple::sparcv9: case Triple::spir64: case Triple::spir: - case Triple::systemz: case Triple::tce: case Triple::tcele: case Triple::thumbeb: @@ -719,6 +722,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 @@ -1961,6 +1961,7 @@ case Triple::MachO: return "__DATA,__asan_globals,regular"; case Triple::Wasm: case Triple::XCOFF: + case Triple::GOFF: report_fatal_error( "ModuleAddressSanitizer not implemented for object file format."); case Triple::UnknownObjectFormat: 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) {