inst_kind.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/sem_ir/inst_kind.h"
  5. #include "toolchain/sem_ir/typed_insts.h"
  6. namespace Carbon::SemIR {
  7. CARBON_DEFINE_ENUM_CLASS_NAMES(InstKind) = {
  8. #define CARBON_SEM_IR_INST_KIND(Name) CARBON_ENUM_CLASS_NAME_STRING(Name)
  9. #include "toolchain/sem_ir/inst_kind.def"
  10. };
  11. auto InstKind::definition_info(InstKind inst_kind) -> const DefinitionInfo& {
  12. static constexpr InstKind::DefinitionInfo DefinitionInfos[] = {
  13. #define CARBON_SEM_IR_INST_KIND(Name) SemIR::Name::Kind.info_,
  14. #include "toolchain/sem_ir/inst_kind.def"
  15. };
  16. return DefinitionInfos[inst_kind.AsInt()];
  17. }
  18. auto InstKind::value_kind() const -> InstValueKind {
  19. static constexpr InstValueKind Table[] = {
  20. #define CARBON_SEM_IR_INST_KIND(Name) \
  21. Internal::HasTypeIdMember<SemIR::Name> ? InstValueKind::Typed \
  22. : InstValueKind::None,
  23. #include "toolchain/sem_ir/inst_kind.def"
  24. };
  25. return Table[AsInt()];
  26. }
  27. } // namespace Carbon::SemIR