Refactor AddInst-family functions to their own file (#4941)

This in particular uses free functions because it's likely to end up
more consistent with types (versus a wrapper object for InstStore).
Note, this is unlikely to have a performance impact, but if it does, we
can look into related approaches (and we've already discussed using
LTO).

Renames `PendingBlock::AddInst` to `PendingBlock::Add` because
`MakeElementAccessInst` expects the matching name to exist.
This commit is contained in:
Jon Ross-Perkins
2025-02-14 19:44:36 +00:00
committed by GitHub
parent dd7c64bad0
commit 311b4ff03d
44 changed files with 875 additions and 695 deletions
+3 -2
View File
@@ -7,6 +7,7 @@
#include "llvm/ADT/STLFunctionalExtras.h"
#include "toolchain/check/context.h"
#include "toolchain/check/convert.h"
#include "toolchain/check/inst.h"
#include "toolchain/parse/node_ids.h"
#include "toolchain/sem_ir/ids.h"
@@ -32,8 +33,8 @@ auto PerformPointerDereference(
} else if (type_id != SemIR::ErrorInst::SingletonTypeId) {
diagnose_not_pointer(type_id);
}
return context.AddInst<SemIR::Deref>(
node_id, {.type_id = result_type_id, .pointer_id = base_id});
return AddInst<SemIR::Deref>(
context, node_id, {.type_id = result_type_id, .pointer_id = base_id});
}
} // namespace Carbon::Check