a32_get_set_elimination_pass: Convert NZ to NZC
This commit is contained in:
parent
6f106602ba
commit
da2b1c5724
4 changed files with 10 additions and 2 deletions
|
@ -174,7 +174,7 @@ private:
|
|||
IR::Block ir_block = A32::Translate(A32::LocationDescriptor{descriptor}, conf.callbacks, {conf.arch_version, conf.define_unpredictable_behaviour, conf.hook_hint_instructions});
|
||||
Optimization::PolyfillPass(ir_block, polyfill_options);
|
||||
if (conf.HasOptimization(OptimizationFlag::GetSetElimination) && !conf.check_halt_on_memory_access) {
|
||||
Optimization::A32GetSetElimination(ir_block, {});
|
||||
Optimization::A32GetSetElimination(ir_block, {.convert_nz_to_nzc = true});
|
||||
Optimization::DeadCodeElimination(ir_block);
|
||||
}
|
||||
if (conf.HasOptimization(OptimizationFlag::ConstProp)) {
|
||||
|
|
|
@ -208,6 +208,13 @@ void A32GetSetElimination(IR::Block& block, A32GetSetEliminationOptions opt) {
|
|||
cpsr_info.nzc.last_set_instruction->SetArg(0, IR::Value::EmptyNZCVImmediateMarker());
|
||||
}
|
||||
|
||||
if (opt.convert_nz_to_nzc && !cpsr_info.c.register_value.IsEmpty()) {
|
||||
ir.SetInsertionPoint(inst);
|
||||
ir.SetCpsrNZC(IR::NZCV{inst->GetArg(0)}, ir.GetCFlag());
|
||||
inst->Invalidate();
|
||||
break;
|
||||
}
|
||||
|
||||
// cpsr_info.c remains valid
|
||||
cpsr_info.nzc = {};
|
||||
cpsr_info.nzcv = {};
|
||||
|
|
|
@ -28,6 +28,7 @@ struct PolyfillOptions {
|
|||
|
||||
struct A32GetSetEliminationOptions {
|
||||
bool convert_nzc_to_nz = false;
|
||||
bool convert_nz_to_nzc = false;
|
||||
};
|
||||
|
||||
void PolyfillPass(IR::Block& block, const PolyfillOptions& opt);
|
||||
|
|
|
@ -176,7 +176,7 @@ static void RunInstance(size_t run_number, ThumbTestEnv& test_env, A32Unicorn<Th
|
|||
while (num_insts < instructions_to_execute_count) {
|
||||
A32::LocationDescriptor descriptor = {u32(num_insts * 4), cpsr, A32::FPSCR{}};
|
||||
IR::Block ir_block = A32::Translate(descriptor, &test_env, {});
|
||||
Optimization::A32GetSetElimination(ir_block, {});
|
||||
Optimization::A32GetSetElimination(ir_block, {.convert_nz_to_nzc = true});
|
||||
Optimization::DeadCodeElimination(ir_block);
|
||||
Optimization::A32ConstantMemoryReads(ir_block, &test_env);
|
||||
Optimization::ConstantPropagation(ir_block);
|
||||
|
|
Loading…
Reference in a new issue