This patch refactors some of the DXContainer Object and YAML code to make it easier to add more part parsing. DXContainer has a whole bunch of constant values, so I've added a DXContainerConstants.def file which will grow with constant definitions, but starts with just part identifiers. I've also added a utility to parse the part magic string into an enum, and converted the code to use that utility and the enum instead of the part literal string. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D133980
26 lines
911 B
C++
26 lines
911 B
C++
|
|
//===-- llvm/BinaryFormat/DXContainer.cpp - DXContainer Utils ----*- C++-*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file contains utility functions for working with DXContainers.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/BinaryFormat/DXContainer.h"
|
|
#include "llvm/ADT/StringSwitch.h"
|
|
|
|
using namespace llvm;
|
|
using namespace llvm;
|
|
|
|
dxbc::PartType dxbc::parsePartType(StringRef S) {
|
|
#define CONTAINER_PART(PartName) .Case(#PartName, PartType::PartName)
|
|
return StringSwitch<dxbc::PartType>(S)
|
|
#include "llvm/BinaryFormat/DXContainerConstants.def"
|
|
.Default(dxbc::PartType::Unknown);
|
|
}
|