2022-12-14 00:16:59 +00:00
|
|
|
#include "compiler/LoadDeletion.h"
|
|
|
|
#include "compiler/CopyPropagation.h"
|
|
|
|
#include "compiler/CParser.h"
|
|
|
|
#include "compiler/PCode.h"
|
|
|
|
#include "compiler/PCodeInfo.h"
|
2022-12-14 01:00:56 +00:00
|
|
|
#include "compiler/Registers.h"
|
2022-12-14 00:16:59 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
&&
|
2022-12-14 01:00:56 +00:00
|
|
|
instr->args[0].data.reg.reg >= n_real_registers[instr->args[0].arg];
|
2022-12-14 00:16:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2022-12-14 01:00:56 +00:00
|
|
|
if (candidate->pcode->args[0].data.reg.reg < n_real_registers[candidate->pcode->args[0].arg])
|
2022-12-14 00:16:59 +00:00
|
|
|
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;
|
|
|
|
}
|