inst_kind.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132
  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::has_type() const -> bool {
  19. static constexpr bool Table[] = {
  20. #define CARBON_SEM_IR_INST_KIND(Name) Internal::HasTypeIdMember<SemIR::Name>,
  21. #include "toolchain/sem_ir/inst_kind.def"
  22. };
  23. return Table[AsInt()];
  24. }
  25. } // namespace Carbon::SemIR