Files
carbon-lang/toolchain/sem_ir/node_kind.cpp
T
josh11b 6d4d05f68a SEMANTICS->SEM_IR in macro names. Update comments in sem_ir/node.h. (#3309)
* Shift to "sem_ir" continued from #3176.
* Comments in `node.h` changed to reflect #3280.
2023-10-18 15:54:06 +00:00

41 lines
1.3 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/sem_ir/node_kind.h"
namespace Carbon::SemIR {
CARBON_DEFINE_ENUM_CLASS_NAMES(NodeKind) = {
#define CARBON_SEM_IR_NODE_KIND(Name) CARBON_ENUM_CLASS_NAME_STRING(Name)
#include "toolchain/sem_ir/node_kind.def"
};
// Returns the name to use for this node kind in Semantics IR.
[[nodiscard]] auto NodeKind::ir_name() const -> llvm::StringRef {
static constexpr llvm::StringRef Table[] = {
#define CARBON_SEM_IR_NODE_KIND_WITH_IR_NAME(Name, IR_Name) IR_Name,
#include "toolchain/sem_ir/node_kind.def"
};
return Table[AsInt()];
}
auto NodeKind::value_kind() const -> NodeValueKind {
static constexpr NodeValueKind Table[] = {
#define CARBON_SEM_IR_NODE_KIND_WITH_VALUE_KIND(Name, Kind) NodeValueKind::Kind,
#include "toolchain/sem_ir/node_kind.def"
};
return Table[AsInt()];
}
auto NodeKind::terminator_kind() const -> TerminatorKind {
static constexpr TerminatorKind Table[] = {
#define CARBON_SEM_IR_NODE_KIND_WITH_TERMINATOR_KIND(Name, Kind) \
TerminatorKind::Kind,
#include "toolchain/sem_ir/node_kind.def"
};
return Table[AsInt()];
}
} // namespace Carbon::SemIR