jasonliu updated this revision to Diff 189387. jasonliu added a comment. Address some review comments
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D58930/new/ https://reviews.llvm.org/D58930 Files: clang/lib/CodeGen/BackendUtil.cpp clang/lib/CodeGen/CodeGenModule.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp llvm/include/llvm/ADT/Triple.h llvm/include/llvm/MC/MCObjectFileInfo.h llvm/lib/MC/MCContext.cpp llvm/lib/MC/MCObjectFileInfo.cpp llvm/lib/MC/MCParser/AsmParser.cpp llvm/lib/Support/Triple.cpp llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/unittests/ADT/TripleTest.cpp
Index: llvm/unittests/ADT/TripleTest.cpp =================================================================== --- llvm/unittests/ADT/TripleTest.cpp +++ llvm/unittests/ADT/TripleTest.cpp @@ -1258,6 +1258,11 @@ EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-wasi-musl-wasm").getObjectFormat()); + EXPECT_EQ(Triple::XCOFF, Triple("powerpc-ibm-aix").getObjectFormat()); + EXPECT_EQ(Triple::XCOFF, Triple("powerpc64-ibm-aix").getObjectFormat()); + EXPECT_EQ(Triple::XCOFF, Triple("powerpc---xcoff").getObjectFormat()); + EXPECT_EQ(Triple::XCOFF, Triple("powerpc64---xcoff").getObjectFormat()); + Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf")); EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat()); @@ -1276,6 +1281,9 @@ T.setObjectFormat(Triple::MachO); EXPECT_EQ(Triple::MachO, T.getObjectFormat()); + + T.setObjectFormat(Triple::XCOFF); + EXPECT_EQ(Triple::XCOFF, T.getObjectFormat()); } TEST(TripleTest, NormalizeWindows) { Index: llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -5594,6 +5594,9 @@ case MCObjectFileInfo::IsWasm: CurrentFormat = WASM; break; + case MCObjectFileInfo::IsXCOFF: + llvm_unreachable("unexpected object format"); + break; } if (~Prefix->SupportedFormats & CurrentFormat) { Index: llvm/lib/Support/Triple.cpp =================================================================== --- llvm/lib/Support/Triple.cpp +++ llvm/lib/Support/Triple.cpp @@ -534,6 +534,9 @@ static Triple::ObjectFormatType parseFormat(StringRef EnvironmentName) { return StringSwitch<Triple::ObjectFormatType>(EnvironmentName) + // "xcoff" must come before "coff" because of the order-dependendent + // pattern matching. + .EndsWith("xcoff", Triple::XCOFF) .EndsWith("coff", Triple::COFF) .EndsWith("elf", Triple::ELF) .EndsWith("macho", Triple::MachO) @@ -622,6 +625,7 @@ case Triple::ELF: return "elf"; case Triple::MachO: return "macho"; case Triple::Wasm: return "wasm"; + case Triple::XCOFF: return "xcoff"; } llvm_unreachable("unknown object format type"); } @@ -686,6 +690,8 @@ case Triple::ppc64: if (T.isOSDarwin()) return Triple::MachO; + else if (T.isOSAIX()) + return Triple::XCOFF; return Triple::ELF; case Triple::wasm32: Index: llvm/lib/MC/MCParser/AsmParser.cpp =================================================================== --- llvm/lib/MC/MCParser/AsmParser.cpp +++ llvm/lib/MC/MCParser/AsmParser.cpp @@ -710,6 +710,9 @@ case MCObjectFileInfo::IsWasm: PlatformParser.reset(createWasmAsmParser()); break; + case MCObjectFileInfo::IsXCOFF: + // TODO: Need to implement createXCOFFAsmParser for XCOFF format. + break; } PlatformParser->Initialize(*this); Index: llvm/lib/MC/MCObjectFileInfo.cpp =================================================================== --- llvm/lib/MC/MCObjectFileInfo.cpp +++ llvm/lib/MC/MCObjectFileInfo.cpp @@ -801,6 +801,10 @@ Env = IsWasm; initWasmMCObjectFileInfo(TT); break; + case Triple::XCOFF: + Env = IsXCOFF; + // TODO: Initialize MCObjectFileInfo for XCOFF format when MCSectionXCOFF is ready. + break; case Triple::UnknownObjectFormat: report_fatal_error("Cannot initialize MC for unknown object file format."); break; @@ -816,6 +820,7 @@ case Triple::MachO: case Triple::COFF: case Triple::Wasm: + case Triple::XCOFF: case Triple::UnknownObjectFormat: report_fatal_error("Cannot get DWARF comdat section for this object file " "format: not implemented."); Index: llvm/lib/MC/MCContext.cpp =================================================================== --- llvm/lib/MC/MCContext.cpp +++ llvm/lib/MC/MCContext.cpp @@ -161,6 +161,9 @@ return new (Name, *this) MCSymbolMachO(Name, IsTemporary); case MCObjectFileInfo::IsWasm: return new (Name, *this) MCSymbolWasm(Name, IsTemporary); + case MCObjectFileInfo::IsXCOFF: + // TODO: Need to implement class MCSymbolXCOFF. + break; } } return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name, Index: llvm/include/llvm/MC/MCObjectFileInfo.h =================================================================== --- llvm/include/llvm/MC/MCObjectFileInfo.h +++ llvm/include/llvm/MC/MCObjectFileInfo.h @@ -380,7 +380,7 @@ return EHFrameSection; } - enum Environment { IsMachO, IsELF, IsCOFF, IsWasm }; + enum Environment { IsMachO, IsELF, IsCOFF, IsWasm, IsXCOFF }; Environment getObjectFileType() const { return Env; } bool isPositionIndependent() const { return PositionIndependent; } Index: llvm/include/llvm/ADT/Triple.h =================================================================== --- llvm/include/llvm/ADT/Triple.h +++ llvm/include/llvm/ADT/Triple.h @@ -219,6 +219,7 @@ ELF, MachO, Wasm, + XCOFF, }; private: @@ -598,6 +599,11 @@ !isAndroid(); } + /// Tests whether the OS is AIX. + bool isOSAIX() const { + return getOS() == Triple::AIX; + } + /// Tests whether the OS uses the ELF binary format. bool isOSBinFormatELF() const { return getObjectFormat() == Triple::ELF; @@ -617,6 +623,11 @@ bool isOSBinFormatWasm() const { return getObjectFormat() == Triple::Wasm; } + + /// Tests whether the OS uses the XCOFF binary format. + bool isOSBinFormatXCOFF() const { + return getObjectFormat() == Triple::XCOFF; + } /// Tests whether the target is the PS4 CPU bool isPS4CPU() const { Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp =================================================================== --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -2059,6 +2059,7 @@ assert(triple.getObjectFormat() != llvm::Triple::UnknownObjectFormat); assert(triple.getObjectFormat() != llvm::Triple::Wasm); + assert(triple.getObjectFormat() != llvm::Triple::XCOFF); switch (triple.getObjectFormat()) { case llvm::Triple::MachO: m_process_arch.SetArchitecture(eArchTypeMachO, cpu, sub); @@ -2073,6 +2074,10 @@ if (log) log->Printf("error: not supported target architecture"); return false; + case llvm::Triple::XCOFF: + if (log) + log->Printf("error: XCOFF is unimplemented"); + return false; case llvm::Triple::UnknownObjectFormat: if (log) log->Printf("error: failed to determine target architecture"); Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -4406,6 +4406,8 @@ switch (Triple.getObjectFormat()) { case llvm::Triple::UnknownObjectFormat: llvm_unreachable("unknown file format"); + case llvm::Triple::XCOFF: + llvm_unreachable("to be determined for XCOFF format"); case llvm::Triple::COFF: case llvm::Triple::ELF: case llvm::Triple::Wasm: Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -1466,6 +1466,9 @@ case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmbc"; + case Triple::XCOFF: + // TODO: Falling through for XCOFF format for now. + break; } llvm_unreachable("Unimplemented ObjectFormatType"); } @@ -1479,6 +1482,9 @@ case Triple::Wasm: case Triple::UnknownObjectFormat: return ".llvmcmd"; + case Triple::XCOFF: + // TODO: Falling through for XCOFF format for now. + break; } llvm_unreachable("Unimplemented ObjectFormatType"); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits