diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -261,6 +261,7 @@ UnknownObjectFormat, COFF, + DXContainer, ELF, GOFF, MachO, diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h --- a/llvm/include/llvm/MC/MCContext.h +++ b/llvm/include/llvm/MC/MCContext.h @@ -76,7 +76,15 @@ using DiagHandlerTy = std::function &)>; - enum Environment { IsMachO, IsELF, IsGOFF, IsCOFF, IsWasm, IsXCOFF }; + enum Environment { + IsMachO, + IsELF, + IsGOFF, + IsCOFF, + IsWasm, + IsXCOFF, + IsDXContainer + }; private: Environment Env; diff --git a/llvm/include/llvm/MC/TargetRegistry.h b/llvm/include/llvm/MC/TargetRegistry.h --- a/llvm/include/llvm/MC/TargetRegistry.h +++ b/llvm/include/llvm/MC/TargetRegistry.h @@ -530,6 +530,8 @@ switch (T.getObjectFormat()) { case Triple::UnknownObjectFormat: llvm_unreachable("Unknown object format"); + case Triple::DXContainer: + llvm_unreachable("DXContainer is unsupported through MC"); case Triple::COFF: assert(T.isOSWindows() && "only Windows COFF is supported"); S = COFFStreamerCtorFn(Ctx, std::move(TAB), std::move(OW), diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4870,6 +4870,9 @@ case Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); break; + case Triple::DXContainer: + llvm_unreachable("DXContainer is not yet implemented"); + break; } llvm_unreachable("Unimplemented ObjectFormatType"); } @@ -4889,6 +4892,9 @@ case Triple::XCOFF: llvm_unreachable("XCOFF is not yet implemented"); break; + case Triple::DXContainer: + llvm_unreachable("DXC is not yet implemented"); + break; } llvm_unreachable("Unimplemented ObjectFormatType"); } diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp --- a/llvm/lib/MC/MCContext.cpp +++ b/llvm/lib/MC/MCContext.cpp @@ -107,6 +107,9 @@ case Triple::GOFF: Env = IsGOFF; break; + case Triple::DXContainer: + Env = IsDXContainer; + break; case Triple::UnknownObjectFormat: report_fatal_error("Cannot initialize MC for unknown object file format."); break; @@ -248,6 +251,8 @@ return new (Name, *this) MCSymbolWasm(Name, IsTemporary); case MCContext::IsXCOFF: return createXCOFFSymbolImpl(Name, IsTemporary); + case MCContext::IsDXContainer: + break; } return new (Name, *this) MCSymbol(MCSymbol::SymbolKindUnset, Name, IsTemporary); diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -1038,6 +1038,8 @@ case MCContext::IsXCOFF: initXCOFFMCObjectFileInfo(TheTriple); break; + case MCContext::IsDXContainer: + break; } } @@ -1054,6 +1056,7 @@ case Triple::COFF: case Triple::GOFF: case Triple::XCOFF: + case Triple::DXContainer: case Triple::UnknownObjectFormat: report_fatal_error("Cannot get DWARF comdat section for this object file " "format: not implemented."); diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -798,6 +798,9 @@ case MCContext::IsXCOFF: PlatformParser.reset(createXCOFFAsmParser()); break; + case MCContext::IsDXContainer: + llvm_unreachable("DXContainer is not supported yet"); + break; } PlatformParser->Initialize(*this); diff --git a/llvm/lib/Support/Triple.cpp b/llvm/lib/Support/Triple.cpp --- a/llvm/lib/Support/Triple.cpp +++ b/llvm/lib/Support/Triple.cpp @@ -743,6 +743,7 @@ case Triple::MachO: return "macho"; case Triple::Wasm: return "wasm"; case Triple::XCOFF: return "xcoff"; + case Triple::DXContainer: return "dxcontainer"; } llvm_unreachable("unknown object format type"); } @@ -830,7 +831,7 @@ return Triple::UnknownObjectFormat; case Triple::dxil: - return Triple::UnknownObjectFormat; + return Triple::DXContainer; } llvm_unreachable("unknown architecture"); } diff --git a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -6380,6 +6380,7 @@ break; case MCContext::IsGOFF: case MCContext::IsXCOFF: + case MCContext::IsDXContainer: llvm_unreachable("unexpected object format"); break; } diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -2106,6 +2106,7 @@ case Triple::Wasm: case Triple::GOFF: case Triple::XCOFF: + case Triple::DXContainer: report_fatal_error( "ModuleAddressSanitizer not implemented for object file format"); case Triple::UnknownObjectFormat: diff --git a/llvm/unittests/ADT/TripleTest.cpp b/llvm/unittests/ADT/TripleTest.cpp --- a/llvm/unittests/ADT/TripleTest.cpp +++ b/llvm/unittests/ADT/TripleTest.cpp @@ -1682,6 +1682,9 @@ Triple CygwinNormalized(Triple::normalize("i686-pc-cygwin-elf")); EXPECT_EQ(Triple::ELF, CygwinNormalized.getObjectFormat()); + EXPECT_EQ(Triple::DXContainer, + Triple("dxil-unknown-shadermodel").getObjectFormat()); + Triple T = Triple(""); T.setObjectFormat(Triple::ELF); EXPECT_EQ(Triple::ELF, T.getObjectFormat());