xref: /openbsd-src/gnu/llvm/llvm/lib/BinaryFormat/DXContainer.cpp (revision d415bd752c734aee168c4ee86ff32e8cc249eb16)
1*d415bd75Srobert 
2*d415bd75Srobert //===-- llvm/BinaryFormat/DXContainer.cpp - DXContainer Utils ----*- C++-*-===//
3*d415bd75Srobert //
4*d415bd75Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*d415bd75Srobert // See https://llvm.org/LICENSE.txt for license information.
6*d415bd75Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*d415bd75Srobert //
8*d415bd75Srobert //===----------------------------------------------------------------------===//
9*d415bd75Srobert //
10*d415bd75Srobert // This file contains utility functions for working with DXContainers.
11*d415bd75Srobert //
12*d415bd75Srobert //===----------------------------------------------------------------------===//
13*d415bd75Srobert 
14*d415bd75Srobert #include "llvm/BinaryFormat/DXContainer.h"
15*d415bd75Srobert #include "llvm/ADT/StringSwitch.h"
16*d415bd75Srobert 
17*d415bd75Srobert using namespace llvm;
18*d415bd75Srobert using namespace llvm::dxbc;
19*d415bd75Srobert 
parsePartType(StringRef S)20*d415bd75Srobert dxbc::PartType dxbc::parsePartType(StringRef S) {
21*d415bd75Srobert #define CONTAINER_PART(PartName) .Case(#PartName, PartType::PartName)
22*d415bd75Srobert   return StringSwitch<dxbc::PartType>(S)
23*d415bd75Srobert #include "llvm/BinaryFormat/DXContainerConstants.def"
24*d415bd75Srobert       .Default(dxbc::PartType::Unknown);
25*d415bd75Srobert }
26*d415bd75Srobert 
isPopulated()27*d415bd75Srobert bool ShaderHash::isPopulated() {
28*d415bd75Srobert   static uint8_t Zeros[16] = {0};
29*d415bd75Srobert   return Flags > 0 || 0 != memcmp(&Digest, &Zeros, 16);
30*d415bd75Srobert }
31