a32_get_set_elimination_pass: Correct insertion point

This commit is contained in:
Merry 2022-07-20 16:53:48 +01:00
parent da2b1c5724
commit 72c87d11e4
4 changed files with 16 additions and 6 deletions

View file

@ -393,14 +393,24 @@ public:
void SetTerm(const Terminal& terminal); void SetTerm(const Terminal& terminal);
void SetInsertionPoint(IR::Inst* new_insertion_point) { void SetInsertionPointBefore(IR::Inst* new_insertion_point) {
insertion_point = IR::Block::iterator{*new_insertion_point}; insertion_point = IR::Block::iterator{*new_insertion_point};
} }
void SetInsertionPoint(IR::Block::iterator new_insertion_point) { void SetInsertionPointBefore(IR::Block::iterator new_insertion_point) {
insertion_point = new_insertion_point; insertion_point = new_insertion_point;
} }
void SetInsertionPointAfter(IR::Inst* new_insertion_point) {
insertion_point = IR::Block::iterator{*new_insertion_point};
++insertion_point;
}
void SetInsertionPointAfter(IR::Block::iterator new_insertion_point) {
insertion_point = new_insertion_point;
++insertion_point;
}
protected: protected:
IR::Block::iterator insertion_point; IR::Block::iterator insertion_point;

View file

@ -209,7 +209,7 @@ void A32GetSetElimination(IR::Block& block, A32GetSetEliminationOptions opt) {
} }
if (opt.convert_nz_to_nzc && !cpsr_info.c.register_value.IsEmpty()) { if (opt.convert_nz_to_nzc && !cpsr_info.c.register_value.IsEmpty()) {
ir.SetInsertionPoint(inst); ir.SetInsertionPointAfter(inst);
ir.SetCpsrNZC(IR::NZCV{inst->GetArg(0)}, ir.GetCFlag()); ir.SetCpsrNZC(IR::NZCV{inst->GetArg(0)}, ir.GetCFlag());
inst->Invalidate(); inst->Invalidate();
break; break;
@ -223,7 +223,7 @@ void A32GetSetElimination(IR::Block& block, A32GetSetEliminationOptions opt) {
} }
case IR::Opcode::A32SetCpsrNZC: { case IR::Opcode::A32SetCpsrNZC: {
if (opt.convert_nzc_to_nz && !inst->GetArg(1).IsImmediate() && inst->GetArg(1).GetInstRecursive()->GetOpcode() == IR::Opcode::A32GetCFlag) { if (opt.convert_nzc_to_nz && !inst->GetArg(1).IsImmediate() && inst->GetArg(1).GetInstRecursive()->GetOpcode() == IR::Opcode::A32GetCFlag) {
ir.SetInsertionPoint(inst); ir.SetInsertionPointAfter(inst);
ir.SetCpsrNZ(IR::NZCV{inst->GetArg(0)}); ir.SetCpsrNZ(IR::NZCV{inst->GetArg(0)});
inst->Invalidate(); inst->Invalidate();
break; break;

View file

@ -26,7 +26,7 @@ void A64CallbackConfigPass(IR::Block& block, const A64::UserConfig& conf) {
if (op == A64::DataCacheOperation::ZeroByVA) { if (op == A64::DataCacheOperation::ZeroByVA) {
A64::IREmitter ir{block}; A64::IREmitter ir{block};
ir.current_location = A64::LocationDescriptor{IR::LocationDescriptor{inst.GetArg(0).GetU64()}}; ir.current_location = A64::LocationDescriptor{IR::LocationDescriptor{inst.GetArg(0).GetU64()}};
ir.SetInsertionPoint(&inst); ir.SetInsertionPointBefore(&inst);
size_t bytes = 4 << static_cast<size_t>(conf.dczid_el0 & 0b1111); size_t bytes = 4 << static_cast<size_t>(conf.dczid_el0 & 0b1111);
IR::U64 addr{inst.GetArg(2)}; IR::U64 addr{inst.GetArg(2)};

View file

@ -148,7 +148,7 @@ void PolyfillPass(IR::Block& block, const PolyfillOptions& polyfill) {
IR::IREmitter ir{block}; IR::IREmitter ir{block};
for (auto& inst : block) { for (auto& inst : block) {
ir.SetInsertionPoint(&inst); ir.SetInsertionPointBefore(&inst);
switch (inst.GetOpcode()) { switch (inst.GetOpcode()) {
case IR::Opcode::SHA256MessageSchedule0: case IR::Opcode::SHA256MessageSchedule0: