aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/include/llvm/Support/DXILOperationCommon.h
blob: 09365411b3e7292484098a8d0ded8ed31f9219d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//===-- DXILOperationCommon.h - DXIL Operation ------------------*- 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 is created to share common definitions used by both the
// DXILOpBuilder and the table
//  generator.
// Documentation for DXIL can be found in
// https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_SUPPORT_DXILOPERATIONCOMMON_H
#define LLVM_SUPPORT_DXILOPERATIONCOMMON_H

#include "llvm/ADT/StringSwitch.h"

namespace llvm {
namespace DXIL {

enum class ParameterKind : uint8_t {
  INVALID = 0,
  VOID,
  HALF,
  FLOAT,
  DOUBLE,
  I1,
  I8,
  I16,
  I32,
  I64,
  OVERLOAD,
  CBUFFER_RET,
  RESOURCE_RET,
  DXIL_HANDLE,
};

inline ParameterKind parameterTypeNameToKind(StringRef Name) {
  return StringSwitch<ParameterKind>(Name)
      .Case("void", ParameterKind::VOID)
      .Case("half", ParameterKind::HALF)
      .Case("float", ParameterKind::FLOAT)
      .Case("double", ParameterKind::DOUBLE)
      .Case("i1", ParameterKind::I1)
      .Case("i8", ParameterKind::I8)
      .Case("i16", ParameterKind::I16)
      .Case("i32", ParameterKind::I32)
      .Case("i64", ParameterKind::I64)
      .Case("$o", ParameterKind::OVERLOAD)
      .Case("dx.types.Handle", ParameterKind::DXIL_HANDLE)
      .Case("dx.types.CBufRet", ParameterKind::CBUFFER_RET)
      .Case("dx.types.ResRet", ParameterKind::RESOURCE_RET)
      .Default(ParameterKind::INVALID);
}

} // namespace DXIL
} // namespace llvm

#endif