diff --git a/toolchain/lower/constant.cpp b/toolchain/lower/constant.cpp index eaaa2945e9cc..005a5d5ffde1 100644 --- a/toolchain/lower/constant.cpp +++ b/toolchain/lower/constant.cpp @@ -6,6 +6,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Value.h" +#include "toolchain/base/kind_switch.h" #include "toolchain/lower/file_context.h" #include "toolchain/sem_ir/inst.h" @@ -250,12 +251,12 @@ auto LowerConstants(FileContext& file_context, auto inst = file_context.sem_ir().insts().Get(const_id.inst_id()); llvm::Constant* value = nullptr; - switch (inst.kind()) { + CARBON_KIND_SWITCH(inst) { #define CARBON_SEM_IR_INST_KIND_CONSTANT_NEVER(...) #define CARBON_SEM_IR_INST_KIND_CONSTANT_SYMBOLIC_ONLY(...) -#define CARBON_SEM_IR_INST_KIND(Name) \ - case SemIR::Name::Kind: \ - value = Emit##Name##AsConstant(context, inst.As()); \ +#define CARBON_SEM_IR_INST_KIND(Name) \ + case CARBON_KIND(SemIR::Name const_inst): \ + value = Emit##Name##AsConstant(context, const_inst); \ break; #include "toolchain/sem_ir/inst_kind.def" diff --git a/toolchain/lower/function_context.cpp b/toolchain/lower/function_context.cpp index fcb3a721be20..94dffad7a889 100644 --- a/toolchain/lower/function_context.cpp +++ b/toolchain/lower/function_context.cpp @@ -5,6 +5,7 @@ #include "toolchain/lower/function_context.h" #include "common/vlog.h" +#include "toolchain/base/kind_switch.h" #include "toolchain/sem_ir/file.h" namespace Carbon::Lower { @@ -60,11 +61,11 @@ auto FunctionContext::LowerInst(SemIR::InstId inst_id) -> void { auto inst = sem_ir().insts().Get(inst_id); CARBON_VLOG() << "Lowering " << inst_id << ": " << inst << "\n"; builder_.getInserter().SetCurrentInstId(inst_id); - switch (inst.kind()) { + CARBON_KIND_SWITCH(inst) { #define CARBON_SEM_IR_INST_KIND_CONSTANT_ALWAYS(Name) -#define CARBON_SEM_IR_INST_KIND(Name) \ - case SemIR::Name::Kind: \ - Handle##Name(*this, inst_id, inst.As()); \ +#define CARBON_SEM_IR_INST_KIND(Name) \ + case CARBON_KIND(SemIR::Name typed_inst): \ + Handle##Name(*this, inst_id, typed_inst); \ break; #include "toolchain/sem_ir/inst_kind.def"