mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 12:11:04 +01:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user