Add DXContainer

DXIL is wrapped in a container format defined by the DirectX 11
specification. Codebases differ in calling this format either DXBC or
DXILContainer.

Since eventually we want to add support for DXBC as a target
architecture and the format is used by DXBC and DXIL, I've termed it
DXContainer here.

Most of the changes in this patch are just adding cases to switch
statements to address warnings.

Reviewed By: pete

Differential Revision: https://reviews.llvm.org/D122062
This commit is contained in:
Chris Bieneman 2022-03-19 14:33:39 -05:00 committed by Chris Bieneman
parent d1d3563278
commit 9130e471fe
11 changed files with 36 additions and 2 deletions

View File

@ -261,6 +261,7 @@ public:
UnknownObjectFormat,
COFF,
DXContainer,
ELF,
GOFF,
MachO,

View File

@ -76,7 +76,15 @@ public:
using DiagHandlerTy =
std::function<void(const SMDiagnostic &, bool, const SourceMgr &,
std::vector<const MDNode *> &)>;
enum Environment { IsMachO, IsELF, IsGOFF, IsCOFF, IsWasm, IsXCOFF };
enum Environment {
IsMachO,
IsELF,
IsGOFF,
IsCOFF,
IsWasm,
IsXCOFF,
IsDXContainer
};
private:
Environment Env;

View File

@ -530,6 +530,8 @@ public:
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),

View File

@ -4870,6 +4870,9 @@ static const char *getSectionNameForBitcode(const Triple &T) {
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 @@ static const char *getSectionNameForCommandline(const Triple &T) {
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");
}

View File

@ -107,6 +107,9 @@ MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo *mai,
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 @@ MCSymbol *MCContext::createSymbolImpl(const StringMapEntry<bool> *Name,
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);

View File

@ -1038,6 +1038,8 @@ void MCObjectFileInfo::initMCObjectFileInfo(MCContext &MCCtx, bool PIC,
case MCContext::IsXCOFF:
initXCOFFMCObjectFileInfo(TheTriple);
break;
case MCContext::IsDXContainer:
break;
}
}
@ -1054,6 +1056,7 @@ MCSection *MCObjectFileInfo::getDwarfComdatSection(const char *Name,
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.");

View File

@ -798,6 +798,9 @@ AsmParser::AsmParser(SourceMgr &SM, MCContext &Ctx, MCStreamer &Out,
case MCContext::IsXCOFF:
PlatformParser.reset(createXCOFFAsmParser());
break;
case MCContext::IsDXContainer:
llvm_unreachable("DXContainer is not supported yet");
break;
}
PlatformParser->Initialize(*this);

View File

@ -743,6 +743,7 @@ static StringRef getObjectFormatTypeName(Triple::ObjectFormatType Kind) {
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 @@ static Triple::ObjectFormatType getDefaultFormat(const Triple &T) {
return Triple::UnknownObjectFormat;
case Triple::dxil:
return Triple::UnknownObjectFormat;
return Triple::DXContainer;
}
llvm_unreachable("unknown architecture");
}

View File

@ -6380,6 +6380,7 @@ bool ARMAsmParser::parsePrefix(ARMMCExpr::VariantKind &RefKind) {
break;
case MCContext::IsGOFF:
case MCContext::IsXCOFF:
case MCContext::IsDXContainer:
llvm_unreachable("unexpected object format");
break;
}

View File

@ -2106,6 +2106,7 @@ StringRef ModuleAddressSanitizer::getGlobalMetadataSection() const {
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:

View File

@ -1682,6 +1682,9 @@ TEST(TripleTest, FileFormat) {
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());