From 25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 14 Dec 2022 00:16:59 +0000 Subject: haha it's been a while since i last committed, hasn't it --- compiler_and_linker/unsorted/LoadDeletion.c | 46 +++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'compiler_and_linker/unsorted/LoadDeletion.c') diff --git a/compiler_and_linker/unsorted/LoadDeletion.c b/compiler_and_linker/unsorted/LoadDeletion.c index e69de29..316e8c2 100644 --- a/compiler_and_linker/unsorted/LoadDeletion.c +++ b/compiler_and_linker/unsorted/LoadDeletion.c @@ -0,0 +1,46 @@ +#include "compiler/LoadDeletion.h" +#include "compiler/CopyPropagation.h" +#include "compiler/CParser.h" +#include "compiler/PCode.h" +#include "compiler/PCodeInfo.h" + +int deletedloads; + +static int is_load(PCode *instr) { + return + (instr->op == PC_LI || instr->op == PC_VSPLTISB || instr->op == PC_VSPLTISH || instr->op == PC_VSPLTISW) + && + instr->args[0].data.reg.reg >= n_real_registers[(char) instr->args[0].arg]; +} + +static int loadpropagatestouse(int candidateID, int useID) { + return 0; +} + +static void deleteload(int id) { + Candidate *candidate; + + candidate = Candidates + id; + if (candidate->list || (candidate->pcode->flags & fSideEffects)) + return; + if (candidate->pcode->args[0].data.reg.reg < n_real_registers[(char) candidate->pcode->args[0].arg]) + return; + + deletepcode(candidate->pcode); + deletedloads = 1; +} + +static Propagation load_immediate_prop = { + &is_load, + &loadpropagatestouse, + &deleteload, + "LOAD IMMEDIATE", + "LOAD_IMMEDIATES", + "l%ld", + 0 +}; + +void deletedeadloads(Object *proc) { + propagateinstructions(proc, &load_immediate_prop, (copts.optimizationlevel >= 4) ? 4 : 1, 0); + deletedloads = propagated_instructions; +} -- cgit v1.2.3