semantics_node_kind.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/semantics/semantics_node_kind.h"
  5. namespace Carbon::SemIR {
  6. CARBON_DEFINE_ENUM_CLASS_NAMES(NodeKind) = {
  7. #define CARBON_SEMANTICS_NODE_KIND(Name) CARBON_ENUM_CLASS_NAME_STRING(Name)
  8. #include "toolchain/semantics/semantics_node_kind.def"
  9. };
  10. // Returns the name to use for this node kind in Semantics IR.
  11. [[nodiscard]] auto NodeKind::ir_name() const -> llvm::StringRef {
  12. static constexpr llvm::StringRef Table[] = {
  13. #define CARBON_SEMANTICS_NODE_KIND_WITH_IR_NAME(Name, IR_Name) IR_Name,
  14. #include "toolchain/semantics/semantics_node_kind.def"
  15. };
  16. return Table[AsInt()];
  17. }
  18. auto NodeKind::value_kind() const -> NodeValueKind {
  19. static constexpr NodeValueKind Table[] = {
  20. #define CARBON_SEMANTICS_NODE_KIND_WITH_VALUE_KIND(Name, Kind) \
  21. NodeValueKind::Kind,
  22. #include "toolchain/semantics/semantics_node_kind.def"
  23. };
  24. return Table[AsInt()];
  25. }
  26. auto NodeKind::terminator_kind() const -> TerminatorKind {
  27. static constexpr TerminatorKind Table[] = {
  28. #define CARBON_SEMANTICS_NODE_KIND_WITH_TERMINATOR_KIND(Name, Kind) \
  29. TerminatorKind::Kind,
  30. #include "toolchain/semantics/semantics_node_kind.def"
  31. };
  32. return Table[AsInt()];
  33. }
  34. } // namespace Carbon::SemIR