diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-12-14 00:16:59 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-12-14 00:16:59 +0000 |
commit | 25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22 (patch) | |
tree | c0ee632aa3752884b996c562622e2ece88216ea4 /compiler_and_linker/unsorted/LoadDeletion.c | |
parent | 9d2728a5605f651934fe67a6fe6986b3e4a2c011 (diff) | |
download | MWCC-25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22.tar.gz MWCC-25bab8b1fb2fc851ea3f1f630b3de65ca6afdc22.zip |
haha it's been a while since i last committed, hasn't it
Diffstat (limited to 'compiler_and_linker/unsorted/LoadDeletion.c')
-rw-r--r-- | compiler_and_linker/unsorted/LoadDeletion.c | 46 |
1 files changed, 46 insertions, 0 deletions
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; +} |