opcode.cpp 702 B

1234567891011121314151617181920212223242526
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <array>
  5. #include "shader_recompiler/exception.h"
  6. #include "shader_recompiler/frontend/maxwell/opcode.h"
  7. namespace Shader::Maxwell {
  8. namespace {
  9. constexpr std::array NAME_TABLE{
  10. #define INST(name, cute, encode) #cute,
  11. #include "maxwell.inc"
  12. #undef INST
  13. };
  14. } // Anonymous namespace
  15. const char* NameOf(Opcode opcode) {
  16. if (static_cast<size_t>(opcode) >= NAME_TABLE.size()) {
  17. throw InvalidArgument("Invalid opcode with raw value {}", static_cast<int>(opcode));
  18. }
  19. return NAME_TABLE[static_cast<size_t>(opcode)];
  20. }
  21. } // namespace Shader::Maxwell