DXILOperationCommon.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- DXILOperationCommon.h - DXIL Operation ------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file is created to share common definitions used by both the
  15. // DXILOpBuilder and the table
  16. // generator.
  17. // Documentation for DXIL can be found in
  18. // https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst.
  19. //
  20. //===----------------------------------------------------------------------===//
  21. #ifndef LLVM_SUPPORT_DXILOPERATIONCOMMON_H
  22. #define LLVM_SUPPORT_DXILOPERATIONCOMMON_H
  23. #include "llvm/ADT/StringSwitch.h"
  24. namespace llvm {
  25. namespace dxil {
  26. enum class ParameterKind : uint8_t {
  27. INVALID = 0,
  28. VOID,
  29. HALF,
  30. FLOAT,
  31. DOUBLE,
  32. I1,
  33. I8,
  34. I16,
  35. I32,
  36. I64,
  37. OVERLOAD,
  38. CBUFFER_RET,
  39. RESOURCE_RET,
  40. DXIL_HANDLE,
  41. };
  42. inline ParameterKind parameterTypeNameToKind(StringRef Name) {
  43. return StringSwitch<ParameterKind>(Name)
  44. .Case("void", ParameterKind::VOID)
  45. .Case("half", ParameterKind::HALF)
  46. .Case("float", ParameterKind::FLOAT)
  47. .Case("double", ParameterKind::DOUBLE)
  48. .Case("i1", ParameterKind::I1)
  49. .Case("i8", ParameterKind::I8)
  50. .Case("i16", ParameterKind::I16)
  51. .Case("i32", ParameterKind::I32)
  52. .Case("i64", ParameterKind::I64)
  53. .Case("$o", ParameterKind::OVERLOAD)
  54. .Case("dx.types.Handle", ParameterKind::DXIL_HANDLE)
  55. .Case("dx.types.CBufRet", ParameterKind::CBUFFER_RET)
  56. .Case("dx.types.ResRet", ParameterKind::RESOURCE_RET)
  57. .Default(ParameterKind::INVALID);
  58. }
  59. } // namespace dxil
  60. } // namespace llvm
  61. #endif
  62. #ifdef __GNUC__
  63. #pragma GCC diagnostic pop
  64. #endif