Avoid emplace.

This commit is contained in:
Merry 2024-01-30 17:22:43 +00:00
parent 3131d6c2db
commit 30f1a3c628
10 changed files with 25 additions and 25 deletions

View file

@ -30,7 +30,7 @@ static std::vector<int> ListToIndexes(u32 list) {
std::vector<int> indexes; std::vector<int> indexes;
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
if (mcl::bit::get_bit(i, list)) { if (mcl::bit::get_bit(i, list)) {
indexes.emplace_back(i); indexes.push_back(i);
} }
} }
return indexes; return indexes;

View file

@ -105,9 +105,9 @@ EmittedBlockInfo AddressSpace::Emit(IR::Block block) {
EmittedBlockInfo block_info = EmitArm64(code, std::move(block), GetEmitConfig(), fastmem_manager); EmittedBlockInfo block_info = EmitArm64(code, std::move(block), GetEmitConfig(), fastmem_manager);
ASSERT(block_entries.emplace(block.Location(), block_info.entry_point).second); ASSERT(block_entries.insert({block.Location(), block_info.entry_point}).second);
ASSERT(reverse_block_entries.emplace(block_info.entry_point, block.Location()).second); ASSERT(reverse_block_entries.insert({block_info.entry_point, block.Location()}).second);
ASSERT(block_infos.emplace(block_info.entry_point, block_info).second); ASSERT(block_infos.insert({block_info.entry_point, block_info}).second);
Link(block_info); Link(block_info);
RelinkForDescriptor(block.Location(), block_info.entry_point); RelinkForDescriptor(block.Location(), block_info.entry_point);
@ -255,7 +255,7 @@ void AddressSpace::Link(EmittedBlockInfo& block_info) {
} }
for (auto [target_descriptor, list] : block_info.block_relocations) { for (auto [target_descriptor, list] : block_info.block_relocations) {
block_references[target_descriptor].emplace(block_info.entry_point); block_references[target_descriptor].insert(block_info.entry_point);
LinkBlockLinks(block_info.entry_point, Get(target_descriptor), list); LinkBlockLinks(block_info.entry_point, Get(target_descriptor), list);
} }
} }

View file

@ -45,7 +45,7 @@ public:
} }
void MarkDoNotFastmem(DoNotFastmemMarker marker) { void MarkDoNotFastmem(DoNotFastmemMarker marker) {
do_not_fastmem.emplace(marker); do_not_fastmem.insert(marker);
} }
private: private:

View file

@ -97,7 +97,7 @@ void HostLocInfo::SetupScratchLocation() {
void HostLocInfo::SetupLocation(const IR::Inst* value) { void HostLocInfo::SetupLocation(const IR::Inst* value) {
ASSERT(IsCompletelyEmpty()); ASSERT(IsCompletelyEmpty());
values.clear(); values.clear();
values.emplace_back(value); values.push_back(value);
realized = true; realized = true;
uses_this_inst = 0; uses_this_inst = 0;
accumulated_uses = 0; accumulated_uses = 0;
@ -189,7 +189,7 @@ void RegAlloc::PrepareForCall(std::optional<Argument::copyable_reference> arg0,
} }
void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) { void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) {
defined_insts.emplace(inst); defined_insts.insert(inst);
ASSERT(!ValueLocation(inst)); ASSERT(!ValueLocation(inst));
@ -199,17 +199,17 @@ void RegAlloc::DefineAsExisting(IR::Inst* inst, Argument& arg) {
} }
auto& info = ValueInfo(arg.value.GetInst()); auto& info = ValueInfo(arg.value.GetInst());
info.values.emplace_back(inst); info.values.push_back(inst);
info.expected_uses += inst->UseCount(); info.expected_uses += inst->UseCount();
} }
void RegAlloc::DefineAsRegister(IR::Inst* inst, oaknut::Reg reg) { void RegAlloc::DefineAsRegister(IR::Inst* inst, oaknut::Reg reg) {
defined_insts.emplace(inst); defined_insts.insert(inst);
ASSERT(!ValueLocation(inst)); ASSERT(!ValueLocation(inst));
auto& info = reg.is_vector() ? fprs[reg.index()] : gprs[reg.index()]; auto& info = reg.is_vector() ? fprs[reg.index()] : gprs[reg.index()];
ASSERT(info.IsCompletelyEmpty()); ASSERT(info.IsCompletelyEmpty());
info.values.emplace_back(inst); info.values.push_back(inst);
info.expected_uses += inst->UseCount(); info.expected_uses += inst->UseCount();
} }
@ -373,7 +373,7 @@ int RegAlloc::RealizeReadImpl(const IR::Value& value) {
template<HostLoc::Kind kind> template<HostLoc::Kind kind>
int RegAlloc::RealizeWriteImpl(const IR::Inst* value) { int RegAlloc::RealizeWriteImpl(const IR::Inst* value) {
defined_insts.emplace(value); defined_insts.insert(value);
ASSERT(!ValueLocation(value)); ASSERT(!ValueLocation(value));
@ -398,7 +398,7 @@ int RegAlloc::RealizeWriteImpl(const IR::Inst* value) {
template<HostLoc::Kind kind> template<HostLoc::Kind kind>
int RegAlloc::RealizeReadWriteImpl(const IR::Value& read_value, const IR::Inst* write_value) { int RegAlloc::RealizeReadWriteImpl(const IR::Value& read_value, const IR::Inst* write_value) {
defined_insts.emplace(write_value); defined_insts.insert(write_value);
// TODO: Move elimination // TODO: Move elimination
@ -462,7 +462,7 @@ void RegAlloc::SpillFpr(int index) {
} }
void RegAlloc::ReadWriteFlags(Argument& read, IR::Inst* write) { void RegAlloc::ReadWriteFlags(Argument& read, IR::Inst* write) {
defined_insts.emplace(write); defined_insts.insert(write);
const auto current_location = ValueLocation(read.value.GetInst()); const auto current_location = ValueLocation(read.value.GetInst());
ASSERT(current_location); ASSERT(current_location);

View file

@ -1166,7 +1166,7 @@ void A32EmitX64::EmitTerminalImpl(IR::Term::LinkBlock terminal, IR::LocationDesc
if (conf.enable_cycle_counting) { if (conf.enable_cycle_counting) {
code.cmp(qword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, cycles_remaining)], 0); code.cmp(qword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, cycles_remaining)], 0);
patch_information[terminal.next].jg.emplace_back(code.getCurr()); patch_information[terminal.next].jg.push_back(code.getCurr());
if (const auto next_bb = GetBasicBlock(terminal.next)) { if (const auto next_bb = GetBasicBlock(terminal.next)) {
EmitPatchJg(terminal.next, next_bb->entrypoint); EmitPatchJg(terminal.next, next_bb->entrypoint);
} else { } else {
@ -1175,7 +1175,7 @@ void A32EmitX64::EmitTerminalImpl(IR::Term::LinkBlock terminal, IR::LocationDesc
} else { } else {
code.cmp(dword[r15 + offsetof(A32JitState, halt_reason)], 0); code.cmp(dword[r15 + offsetof(A32JitState, halt_reason)], 0);
patch_information[terminal.next].jz.emplace_back(code.getCurr()); patch_information[terminal.next].jz.push_back(code.getCurr());
if (const auto next_bb = GetBasicBlock(terminal.next)) { if (const auto next_bb = GetBasicBlock(terminal.next)) {
EmitPatchJz(terminal.next, next_bb->entrypoint); EmitPatchJz(terminal.next, next_bb->entrypoint);
} else { } else {
@ -1197,7 +1197,7 @@ void A32EmitX64::EmitTerminalImpl(IR::Term::LinkBlockFast terminal, IR::Location
return; return;
} }
patch_information[terminal.next].jmp.emplace_back(code.getCurr()); patch_information[terminal.next].jmp.push_back(code.getCurr());
if (const auto next_bb = GetBasicBlock(terminal.next)) { if (const auto next_bb = GetBasicBlock(terminal.next)) {
EmitPatchJmp(terminal.next, next_bb->entrypoint); EmitPatchJmp(terminal.next, next_bb->entrypoint);
} else { } else {

View file

@ -620,7 +620,7 @@ void A64EmitX64::EmitTerminalImpl(IR::Term::LinkBlock terminal, IR::LocationDesc
if (conf.enable_cycle_counting) { if (conf.enable_cycle_counting) {
code.cmp(qword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, cycles_remaining)], 0); code.cmp(qword[rsp + ABI_SHADOW_SPACE + offsetof(StackLayout, cycles_remaining)], 0);
patch_information[terminal.next].jg.emplace_back(code.getCurr()); patch_information[terminal.next].jg.push_back(code.getCurr());
if (const auto next_bb = GetBasicBlock(terminal.next)) { if (const auto next_bb = GetBasicBlock(terminal.next)) {
EmitPatchJg(terminal.next, next_bb->entrypoint); EmitPatchJg(terminal.next, next_bb->entrypoint);
} else { } else {
@ -629,7 +629,7 @@ void A64EmitX64::EmitTerminalImpl(IR::Term::LinkBlock terminal, IR::LocationDesc
} else { } else {
code.cmp(dword[r15 + offsetof(A64JitState, halt_reason)], 0); code.cmp(dword[r15 + offsetof(A64JitState, halt_reason)], 0);
patch_information[terminal.next].jz.emplace_back(code.getCurr()); patch_information[terminal.next].jz.push_back(code.getCurr());
if (const auto next_bb = GetBasicBlock(terminal.next)) { if (const auto next_bb = GetBasicBlock(terminal.next)) {
EmitPatchJz(terminal.next, next_bb->entrypoint); EmitPatchJz(terminal.next, next_bb->entrypoint);
} else { } else {
@ -650,7 +650,7 @@ void A64EmitX64::EmitTerminalImpl(IR::Term::LinkBlockFast terminal, IR::Location
return; return;
} }
patch_information[terminal.next].jmp.emplace_back(code.getCurr()); patch_information[terminal.next].jmp.push_back(code.getCurr());
if (auto next_bb = GetBasicBlock(terminal.next)) { if (auto next_bb = GetBasicBlock(terminal.next)) {
EmitPatchJmp(terminal.next, next_bb->entrypoint); EmitPatchJmp(terminal.next, next_bb->entrypoint);
} else { } else {

View file

@ -29,7 +29,7 @@ Xbyak::Address ConstantPool::GetConstant(const Xbyak::AddressFrame& frame, u64 l
ASSERT(insertion_point < pool.size()); ASSERT(insertion_point < pool.size());
ConstantT& target_constant = pool[insertion_point]; ConstantT& target_constant = pool[insertion_point];
target_constant = constant; target_constant = constant;
iter = constant_info.emplace(constant, &target_constant).first; iter = constant_info.insert({constant, &target_constant}).first;
++insertion_point; ++insertion_point;
} }
return frame[code.rip + iter->second]; return frame[code.rip + iter->second];

View file

@ -88,7 +88,7 @@ void EmitX64::PushRSBHelper(Xbyak::Reg64 loc_desc_reg, Xbyak::Reg64 index_reg, I
code.mov(loc_desc_reg, target.Value()); code.mov(loc_desc_reg, target.Value());
patch_information[target].mov_rcx.emplace_back(code.getCurr()); patch_information[target].mov_rcx.push_back(code.getCurr());
EmitPatchMovRcx(target_code_ptr); EmitPatchMovRcx(target_code_ptr);
code.mov(qword[r15 + index_reg * 8 + code.GetJitStateInfo().offsetof_rsb_location_descriptors], loc_desc_reg); code.mov(qword[r15 + index_reg * 8 + code.GetJitStateInfo().offsetof_rsb_location_descriptors], loc_desc_reg);
@ -339,7 +339,7 @@ EmitX64::BlockDescriptor EmitX64::RegisterBlock(const IR::LocationDescriptor& de
Patch(descriptor, entrypoint); Patch(descriptor, entrypoint);
BlockDescriptor block_desc{entrypoint, size}; BlockDescriptor block_desc{entrypoint, size};
block_descriptors.emplace(descriptor.Value(), block_desc); block_descriptors.insert({IR::LocationDescriptor{descriptor.Value()}, block_desc});
return block_desc; return block_desc;
} }

View file

@ -44,7 +44,7 @@ FakeCall AxxEmitX64::FastmemCallback(u64 rip_) {
if (iter->second.recompile) { if (iter->second.recompile) {
const auto marker = iter->second.marker; const auto marker = iter->second.marker;
do_not_fastmem.emplace(marker); do_not_fastmem.insert(marker);
InvalidateBasicBlocks({std::get<0>(marker)}); InvalidateBasicBlocks({std::get<0>(marker)});
} }

View file

@ -24,7 +24,7 @@ Pool::~Pool() {
void* Pool::Alloc() { void* Pool::Alloc() {
if (remaining == 0) { if (remaining == 0) {
slabs.emplace_back(current_slab); slabs.push_back(current_slab);
AllocateNewSlab(); AllocateNewSlab();
} }