Add builtins for compound assignment operators. (#5335)

Provide builtins for compound assignments instead of defining them in
the prelude as a use of a binary operator and an assignment. This allows
us to lower compound assignment directly to LLVM operations instead of
producing a function call. In the short term this also allows us to
define a type-generic compound assignment in the prelude.
This commit is contained in:
Richard Smith
2025-04-21 20:38:11 +00:00
committed by GitHub
parent 2bdea71c25
commit b5ae988a08
39 changed files with 1373 additions and 312 deletions
+5
View File
@@ -7,6 +7,7 @@
#include "common/vlog.h"
#include "toolchain/base/kind_switch.h"
#include "toolchain/sem_ir/file.h"
#include "toolchain/sem_ir/generic.h"
namespace Carbon::Lower {
@@ -171,6 +172,10 @@ auto FunctionContext::FinishInit(SemIR::TypeId type_id, SemIR::InstId dest_id,
}
}
auto FunctionContext::GetTypeOfInst(SemIR::InstId inst_id) -> SemIR::TypeId {
return SemIR::GetTypeOfInstInSpecific(sem_ir(), specific_id(), inst_id);
}
auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::InstId source_id,
SemIR::InstId dest_id) -> void {
switch (auto rep = SemIR::ValueRepr::ForType(sem_ir(), type_id); rep.kind) {